From f737a745b54c2dffe5e3e3203cea1eecf1c7ecf1 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Fri, 13 Sep 2019 21:27:44 +0300 Subject: rpc: align structs squash tens of warnings on padding of structs in afr structures. The warnings were found by manually added '-Wpadded' to the GCC command line. Also made relevant structs and definitions static, where it was applicable. Change-Id: Ib71a7e9c6179378f072d796d11172d086c343e53 updates: bz#1193929 Signed-off-by: Yaniv Kaul --- rpc/rpc-lib/src/rpc-clnt.h | 16 +++++++-------- rpc/rpc-lib/src/rpc-transport.h | 16 +++++++-------- rpc/rpc-lib/src/rpcsvc-common.h | 4 ++-- rpc/rpc-lib/src/rpcsvc.c | 12 ++++++------ rpc/rpc-lib/src/rpcsvc.h | 43 +++++++++++++++++++++-------------------- 5 files changed, 46 insertions(+), 45 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index 1d3274bbddd..0d0b115578c 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -85,8 +85,8 @@ typedef int (*rpcclnt_cb_fn)(struct rpc_clnt *rpc, void *mydata, void *data); */ typedef struct rpcclnt_actor_desc { char procname[32]; - int procnum; rpcclnt_cb_fn actor; + int procnum; } rpcclnt_cb_actor_t; /* Describes a program and its version along with the function pointers @@ -98,8 +98,6 @@ typedef struct rpcclnt_cb_program { int prognum; int progver; rpcclnt_cb_actor_t *actors; /* All procedure handlers */ - int numactors; /* Num actors in actor array */ - /* Program specific state handed to actors */ void *private; @@ -108,6 +106,8 @@ typedef struct rpcclnt_cb_program { /* Needed for passing back in cb_actor */ void *mydata; + int numactors; /* Num actors in actor array */ + } rpcclnt_cb_program_t; typedef struct rpc_auth_data { @@ -151,17 +151,17 @@ typedef struct rpc_clnt_connection rpc_clnt_connection_t; struct rpc_req { rpc_clnt_connection_t *conn; struct iovec req[2]; - int reqcnt; struct iobref *req_iobref; struct iovec rsp[2]; int rspcnt; + int reqcnt; struct iobref *rsp_iobref; - int rpc_status; - rpc_auth_data_t verf; rpc_clnt_prog_t *prog; - int procnum; + rpc_auth_data_t verf; fop_cbk_fn_t cbkfn; void *conn_private; + int procnum; + int rpc_status; uint32_t xid; }; @@ -182,8 +182,8 @@ typedef struct rpc_clnt { glusterfs_ctx_t *ctx; gf_atomic_t refcount; - int auth_value; xlator_t *owner; + int auth_value; char disabled; } rpc_clnt_t; diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index 5b88be5a3de..6ca42a77c44 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -103,19 +103,19 @@ typedef enum { struct rpc_transport_msg { struct iovec *rpchdr; - int rpchdrcount; struct iovec *proghdr; + int rpchdrcount; int proghdrcount; struct iovec *progpayload; - int progpayloadcount; struct iobref *iobref; + int progpayloadcount; }; typedef struct rpc_transport_msg rpc_transport_msg_t; struct rpc_transport_rsp { struct iovec *rsphdr; - int rsphdr_count; struct iovec *rsp_payload; + int rsphdr_count; int rsp_payload_count; struct iobref *rsp_iobref; }; @@ -149,9 +149,9 @@ typedef struct rpc_transport_data rpc_transport_data_t; struct rpc_request_info { int prognum; int progver; - int procnum; void *rpc_req; /* struct rpc_req */ rpc_transport_rsp_t rsp; + int procnum; uint32_t xid; }; typedef struct rpc_request_info rpc_request_info_t; @@ -193,11 +193,12 @@ struct rpc_transport { int32_t outstanding_rpc_count; struct list_head list; - int bind_insecure; void *dl_handle; /* handle of dlopen() */ char *ssl_name; dict_t *clnt_options; /* store options received from * client */ + gf_atomic_t disconnect_progress; + int bind_insecure; /* connect_failed: saves the connect() syscall status as socket_t * member holding connect() status can't be accessed by higher gfapi * layer or in client management notification handler functions @@ -205,18 +206,17 @@ struct rpc_transport { gf_boolean_t connect_failed; char notify_poller_death; char poller_death_accept; - gf_atomic_t disconnect_progress; }; struct rpc_transport_pollin { struct rpc_transport *trans; - int count; void *private; struct iobref *iobref; struct iovec vector[MAX_IOVEC]; + gf_async_t async; + int count; char is_reply; char vectored; - gf_async_t async; }; typedef struct rpc_transport_pollin rpc_transport_pollin_t; diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h index 734601eef0b..6c4ec49a6ef 100644 --- a/rpc/rpc-lib/src/rpcsvc-common.h +++ b/rpc/rpc-lib/src/rpcsvc-common.h @@ -39,8 +39,6 @@ typedef struct rpcsvc_state { pthread_rwlock_t rpclock; - unsigned int memfactor; - /* List of the authentication schemes available. */ struct list_head authschemes; @@ -61,6 +59,8 @@ typedef struct rpcsvc_state { struct list_head notify; int notify_count; + unsigned int memfactor; + xlator_t *xl; /* xlator */ void *mydata; rpcsvc_notify_t notifyfn; diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 5639abbb204..2818f62e619 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -41,7 +41,7 @@ #include "xdr-rpcclnt.h" #include -struct rpcsvc_program gluster_dump_prog; +static struct rpcsvc_program gluster_dump_prog; #define rpcsvc_alloc_request(svc, request) \ do { \ @@ -3227,13 +3227,13 @@ out: return ret; } -rpcsvc_actor_t gluster_dump_actors[GF_DUMP_MAXVALUE] = { - [GF_DUMP_NULL] = {"NULL", GF_DUMP_NULL, NULL, NULL, 0, DRC_NA}, - [GF_DUMP_DUMP] = {"DUMP", GF_DUMP_DUMP, rpcsvc_dump, NULL, 0, DRC_NA}, - [GF_DUMP_PING] = {"PING", GF_DUMP_PING, rpcsvc_ping, NULL, 0, DRC_NA}, +static rpcsvc_actor_t gluster_dump_actors[GF_DUMP_MAXVALUE] = { + [GF_DUMP_NULL] = {"NULL", NULL, NULL, GF_DUMP_NULL, DRC_NA, 0}, + [GF_DUMP_DUMP] = {"DUMP", rpcsvc_dump, NULL, GF_DUMP_DUMP, DRC_NA, 0}, + [GF_DUMP_PING] = {"PING", rpcsvc_ping, NULL, GF_DUMP_PING, DRC_NA, 0}, }; -struct rpcsvc_program gluster_dump_prog = { +static struct rpcsvc_program gluster_dump_prog = { .progname = "GF-DUMP", .prognum = GLUSTER_DUMP_PROGRAM, .progver = GLUSTER_DUMP_VERSION, diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index f6a02d6759f..a88fc841b60 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -190,24 +190,11 @@ struct rpcsvc_request { * by the program actors. This is the buffer that will need to * be de-xdred by the actor. */ - struct iovec msg[MAX_IOVEC]; int count; + struct iovec msg[MAX_IOVEC]; struct iobref *iobref; - /* Status of the RPC call, whether it was accepted or denied. */ - int rpc_status; - - /* In case, the call was denied, the RPC error is stored here - * till the reply is sent. - */ - int rpc_err; - - /* In case the failure happened because of an authentication problem - * , this value needs to be assigned the correct auth error number. - */ - int auth_err; - /* There can be cases of RPC requests where the reply needs to * be built from multiple sources. E.g. where even the NFS reply * can contain a payload, as in the NFSv3 read reply. Here the RPC header @@ -245,6 +232,19 @@ struct rpcsvc_request { /* request queue in rpcsvc */ struct list_head request_list; + /* Status of the RPC call, whether it was accepted or denied. */ + int rpc_status; + + /* In case, the call was denied, the RPC error is stored here + * till the reply is sent. + */ + int rpc_err; + + /* In case the failure happened because of an authentication problem + * , this value needs to be assigned the correct auth error number. + */ + int auth_err; + /* Things passed to rpc layer from client */ /* @flags: Can be used for binary data passed in xdata to be @@ -357,7 +357,6 @@ typedef void (*rpcsvc_deallocate_reply)(void *msg); */ typedef struct rpcsvc_actor_desc { char procname[RPCSVC_NAME_MAX]; - int procnum; rpcsvc_actor actor; /* Handler for cases where the RPC requests fragments are large enough @@ -370,18 +369,20 @@ typedef struct rpcsvc_actor_desc { */ rpcsvc_vector_sizer vector_sizer; + int procnum; + /* Can actor be ran on behalf an unprivileged requestor? */ - gf_boolean_t unprivileged; drc_op_type_t op_type; + gf_boolean_t unprivileged; } rpcsvc_actor_t; typedef struct rpcsvc_request_queue { - int gen; struct list_head request_queue; pthread_mutex_t queue_lock; pthread_cond_t queue_cond; pthread_t thread; struct rpcsvc_program *program; + int gen; gf_boolean_t waiting; } rpcsvc_request_queue_t; @@ -416,8 +417,6 @@ struct rpcsvc_program { int numactors; /* Num actors in actor array */ int proghighvers; /* Highest ver for program supported by the system. */ - int proglowvers; /* Lowest ver */ - /* Program specific state handed to actors */ void *private; @@ -429,6 +428,8 @@ struct rpcsvc_program { */ rpcsvc_notify_t notify; + int proglowvers; /* Lowest ver */ + /* An integer that identifies the min auth strength that is required * by this protocol, for eg. MOUNT3 needs AUTH_UNIX at least. * See RFC 1813, Section 5.2.1. @@ -438,7 +439,6 @@ struct rpcsvc_program { /* list member to link to list of registered services with rpcsvc */ struct list_head program; rpcsvc_request_queue_t request_queue[EVENT_MAX_THREADS]; - char request_queue_status[EVENT_MAX_THREADS / 8 + 1]; pthread_mutex_t thr_lock; pthread_cond_t thr_cond; int threadcount; @@ -457,6 +457,7 @@ struct rpcsvc_program { gf_boolean_t alive; gf_boolean_t synctask; + char request_queue_status[EVENT_MAX_THREADS / 8 + 1]; }; typedef struct rpcsvc_cbk_program { @@ -588,9 +589,9 @@ typedef struct rpcsvc_auth_ops { typedef struct rpcsvc_auth_flavour_desc { char authname[RPCSVC_NAME_MAX]; - int authnum; rpcsvc_auth_ops_t *authops; void *authprivate; + int authnum; } rpcsvc_auth_t; typedef void *(*rpcsvc_auth_initer_t)(rpcsvc_t *svc, dict_t *options); -- cgit