From b56bf714c1f22212700db50c057e4e47b99be739 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Fri, 23 Nov 2018 12:14:59 +0200 Subject: rpc *.h fles: align structs Make an effort to slightly better align the structures. Change-Id: I6f80a451f2ffbf15adfb986cedc24c2799787b49 updates: bz#1193929 Signed-off-by: Yaniv Kaul --- rpc/rpc-lib/src/rpc-clnt.h | 2 +- rpc/rpc-lib/src/rpc-drc.h | 16 +++---- rpc/rpc-lib/src/rpc-transport.h | 22 +++++---- rpc/rpc-lib/src/rpcsvc-common.h | 8 ++-- rpc/rpc-lib/src/rpcsvc.c | 4 +- rpc/rpc-lib/src/rpcsvc.h | 62 +++++++++++++------------- rpc/rpc-transport/rdma/src/rdma.c | 8 +--- rpc/rpc-transport/socket/src/socket.h | 84 +++++++++++++++++------------------ 8 files changed, 100 insertions(+), 106 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-lib/src/rpc-clnt.h b/rpc/rpc-lib/src/rpc-clnt.h index d122382e446..d80df7f8b96 100644 --- a/rpc/rpc-lib/src/rpc-clnt.h +++ b/rpc/rpc-lib/src/rpc-clnt.h @@ -52,8 +52,8 @@ struct saved_frame { }; void *capital_this; void *frame; - struct timeval saved_at; struct rpc_req *rpcreq; + struct timeval saved_at; rpc_transport_rsp_t rsp; }; diff --git a/rpc/rpc-lib/src/rpc-drc.h b/rpc/rpc-lib/src/rpc-drc.h index 1fd1e5e24ef..89b7c87e756 100644 --- a/rpc/rpc-lib/src/rpc-drc.h +++ b/rpc/rpc-lib/src/rpc-drc.h @@ -19,18 +19,17 @@ /* per-client cache structure */ struct drc_client { - uint32_t ref; union gf_sock_union sock_union; /* pointers to the cache */ struct rb_table *rbtree; /* no. of ops currently cached */ uint32_t op_count; + uint32_t ref; struct list_head client_list; }; struct drc_cached_op { drc_op_state_t state; - uint32_t xid; int prognum; int progversion; int procnum; @@ -39,6 +38,7 @@ struct drc_cached_op { struct list_head client_list; struct list_head global_list; int32_t ref; + uint32_t xid; }; /* global drc definitions */ @@ -50,19 +50,19 @@ struct drc_globals { * it is used so in gf_libavl_allocator */ struct libavl_allocator allocator; - drc_type_t type; /* configurable size parameter */ - uint32_t global_cache_size; - drc_lru_factor_t lru_factor; gf_lock_t lock; - drc_status_t status; - uint32_t op_count; uint64_t cache_hits; uint64_t intransit_hits; struct mem_pool *mempool; struct list_head cache_head; - uint32_t client_count; struct list_head clients_head; + uint32_t op_count; + uint32_t client_count; + uint32_t global_cache_size; + drc_type_t type; + drc_lru_factor_t lru_factor; + drc_status_t status; }; int diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index fd737d0c764..87ea3a28dfd 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -61,12 +61,12 @@ typedef struct rpc_transport rpc_transport_t; #include "rpcsvc-common.h" struct peer_info { - struct sockaddr_storage sockaddr; - socklen_t sockaddr_len; - char identifier[UNIX_PATH_MAX]; // OP-VERSION of clients uint32_t max_op_version; uint32_t min_op_version; + struct sockaddr_storage sockaddr; + socklen_t sockaddr_len; + char identifier[UNIX_PATH_MAX]; // Volume mounted by client char volname[NAME_MAX]; }; @@ -121,24 +121,24 @@ struct rpc_transport_rsp { typedef struct rpc_transport_rsp rpc_transport_rsp_t; struct rpc_transport_req { + struct rpc_req *rpc_req; rpc_transport_msg_t msg; rpc_transport_rsp_t rsp; - struct rpc_req *rpc_req; }; typedef struct rpc_transport_req rpc_transport_req_t; struct rpc_transport_reply { - rpc_transport_msg_t msg; void *private; + rpc_transport_msg_t msg; }; typedef struct rpc_transport_reply rpc_transport_reply_t; struct rpc_transport_data { - char is_request; union { rpc_transport_req_t req; rpc_transport_reply_t reply; } data; + char is_request; }; typedef struct rpc_transport_data rpc_transport_data_t; @@ -146,22 +146,22 @@ typedef struct rpc_transport_data rpc_transport_data_t; * rpc_request, hence these should be removed from request_info */ struct rpc_request_info { - uint32_t xid; int prognum; int progver; int procnum; void *rpc_req; /* struct rpc_req */ rpc_transport_rsp_t rsp; + uint32_t xid; }; typedef struct rpc_request_info rpc_request_info_t; struct rpc_transport_pollin { - struct iovec vector[MAX_IOVEC]; int count; - char vectored; void *private; struct iobref *iobref; + struct iovec vector[MAX_IOVEC]; char is_reply; + char vectored; }; typedef struct rpc_transport_pollin rpc_transport_pollin_t; @@ -182,9 +182,6 @@ struct rpc_transport { void *mydata; pthread_mutex_t lock; gf_atomic_t refcount; - - int32_t outstanding_rpc_count; - glusterfs_ctx_t *ctx; dict_t *options; char *name; @@ -202,6 +199,7 @@ struct rpc_transport { uint64_t total_bytes_read; uint64_t total_bytes_write; uint32_t xid; /* RPC/XID used for callbacks */ + int32_t outstanding_rpc_count; struct list_head list; int bind_insecure; diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h index 6a36b1f1b9b..56200b38faa 100644 --- a/rpc/rpc-lib/src/rpcsvc-common.h +++ b/rpc/rpc-lib/src/rpcsvc-common.h @@ -50,10 +50,6 @@ typedef struct rpcsvc_state { /* Reference to the options */ dict_t *options; - /* Allow insecure ports. */ - gf_boolean_t allow_insecure; - gf_boolean_t register_portmap; - gf_boolean_t root_squash; uid_t anonuid; gid_t anongid; glusterfs_ctx_t *ctx; @@ -79,6 +75,10 @@ typedef struct rpcsvc_state { gf_boolean_t addr_namelookup; /* determine whether throttling is needed, by default OFF */ gf_boolean_t throttle; + /* Allow insecure ports. */ + gf_boolean_t allow_insecure; + gf_boolean_t register_portmap; + gf_boolean_t root_squash; } rpcsvc_t; /* DRC START */ diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index d678bca43a8..8dcc2947b33 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -1369,9 +1369,9 @@ rpcsvc_transport_submit(rpc_transport_t *trans, struct iovec *rpchdr, int progpayloadcount, struct iobref *iobref, void *priv) { int ret = -1; - rpc_transport_reply_t reply = {{ + rpc_transport_reply_t reply = { 0, - }}; + }; if ((!trans) || (!rpchdr) || (!rpchdr->iov_base)) { goto out; diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h index 8388dd404c5..d6260ca5028 100644 --- a/rpc/rpc-lib/src/rpcsvc.h +++ b/rpc/rpc-lib/src/rpcsvc.h @@ -171,11 +171,6 @@ struct rpcsvc_request { rpcsvc_program_t *prog; - /* The identifier for the call from client. - * Needed to pair the reply with the call. - */ - uint32_t xid; - int prognum; int progver; @@ -247,11 +242,6 @@ struct rpcsvc_request { * sent to the client. */ rpcsvc_auth_data_t verf; - - /* Execute this request's actor function in ownthread of program?*/ - gf_boolean_t ownthread; - - gf_boolean_t synctask; /* Container for a RPC program wanting to store a temp * request-specific item. */ @@ -275,6 +265,16 @@ struct rpcsvc_request { /* ctime: origin of time on the client side, ideally this is the one we should consider for time */ struct timespec ctime; + + /* The identifier for the call from client. + * Needed to pair the reply with the call. + */ + uint32_t xid; + + /* Execute this request's actor function in ownthread of program?*/ + gf_boolean_t ownthread; + + gf_boolean_t synctask; }; #define rpcsvc_request_program(req) ((rpcsvc_program_t *)((req)->prog)) @@ -391,21 +391,20 @@ struct rpcsvc_program { int prognum; int progver; /* FIXME */ - dict_t *options; /* An opaque dictionary - * populated by the program - * (probably from xl->options) - * which contain enough - * information for transport to - * initialize. As a part of - * cleanup, the members of - * options which are of interest - * to transport should be put - * into a structure for better - * readability and structure - * should replace options member - * here. - */ - uint16_t progport; /* Registered with portmap */ + dict_t *options; /* An opaque dictionary + * populated by the program + * (probably from xl->options) + * which contain enough + * information for transport to + * initialize. As a part of + * cleanup, the members of + * options which are of interest + * to transport should be put + * into a structure for better + * readability and structure + * should replace options member + * here. + */ #if 0 int progaddrfamily; /* AF_INET or AF_INET6 */ char *proghost; /* Bind host, can be NULL */ @@ -433,12 +432,6 @@ struct rpcsvc_program { */ int min_auth; - /* Execute actor function in program's own thread? This will reduce */ - /* the workload on poller threads */ - gf_boolean_t ownthread; - gf_boolean_t alive; - - gf_boolean_t synctask; /* list member to link to list of registered services with rpcsvc */ struct list_head program; rpcsvc_request_queue_t request_queue[EVENT_MAX_THREADS]; @@ -454,6 +447,13 @@ struct rpcsvc_program { * It is used to control the scaling of rpcsvc_request_handler threads */ int eventthreadcount; + uint16_t progport; /* Registered with portmap */ + /* Execute actor function in program's own thread? This will reduce */ + /* the workload on poller threads */ + gf_boolean_t ownthread; + gf_boolean_t alive; + + gf_boolean_t synctask; }; typedef struct rpcsvc_cbk_program { diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c index 26cf201a8a3..ebf54885f1a 100644 --- a/rpc/rpc-transport/rdma/src/rdma.c +++ b/rpc/rpc-transport/rdma/src/rdma.c @@ -2880,9 +2880,7 @@ gf_rdma_submit_request(rpc_transport_t *this, rpc_transport_req_t *req) { int32_t ret = 0; gf_rdma_ioq_t *entry = NULL; - rpc_transport_data_t data = { - 0, - }; + rpc_transport_data_t data; gf_rdma_private_t *priv = NULL; gf_rdma_peer_t *peer = NULL; @@ -2940,9 +2938,7 @@ gf_rdma_submit_reply(rpc_transport_t *this, rpc_transport_reply_t *reply) { int32_t ret = 0; gf_rdma_ioq_t *entry = NULL; - rpc_transport_data_t data = { - 0, - }; + rpc_transport_data_t data; if (reply == NULL) { goto out; diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h index 27db0ed427b..f1bfba45076 100644 --- a/rpc/rpc-transport/socket/src/socket.h +++ b/rpc/rpc-transport/socket/src/socket.h @@ -108,12 +108,12 @@ struct ioq { }; }; - uint32_t fraghdr; struct iovec vector[MAX_IOVEC]; int count; struct iovec *pending_vector; int pending_count; struct iobref *iobref; + uint32_t fraghdr; }; typedef struct { @@ -169,27 +169,27 @@ struct gf_sock_incoming_frag { #define GF_SOCKET_RA_MAX 1024 struct gf_sock_incoming { - sp_rpcrecord_state_t record_state; - struct gf_sock_incoming_frag frag; char *proghdr_base_addr; struct iobuf *iobuf; size_t iobuf_size; - struct iovec vector[2]; int count; + struct gf_sock_incoming_frag frag; + struct iovec vector[2]; struct iovec payload_vector; struct iobref *iobref; rpc_request_info_t *request_info; struct iovec *pending_vector; int pending_count; - uint32_t fraghdr; - char complete_record; - msg_type_t msg_type; size_t total_bytes_read; size_t ra_read; size_t ra_max; size_t ra_served; char *ra_buf; + uint32_t fraghdr; + char complete_record; + msg_type_t msg_type; + sp_rpcrecord_state_t record_state; }; typedef enum { @@ -201,17 +201,6 @@ typedef enum { } ot_state_t; typedef struct { - int32_t sock; - int32_t idx; - int32_t gen; - /* -1 = not connected. 0 = in progress. 1 = connected */ - char connected; - /* 1 = connect failed for reasons other than EINPROGRESS/ENOENT - see socket_connect for details */ - char connect_failed; - char bio; - char connect_finish_log; - char submit_log; union { struct list_head ioq; struct { @@ -219,25 +208,36 @@ typedef struct { struct ioq *ioq_prev; }; }; - struct gf_sock_incoming incoming; pthread_mutex_t in_lock; pthread_mutex_t out_lock; pthread_mutex_t cond_lock; pthread_cond_t cond; + pthread_t thread; int windowsize; - char lowlat; - char nodelay; int keepalive; int keepaliveidle; int keepaliveintvl; int keepalivecnt; int timeout; + int log_ctr; + /* ssl_error_required is used only during the SSL connection setup + * phase. + * It holds the error code returned by SSL_get_error() and is used to + * arm the epoll event set for the required event for the specific fd. + */ + int ssl_error_required; + + GF_REF_DECL; /* refcount to keep track of socket_poller + threads */ + struct { + pthread_mutex_t lock; + pthread_cond_t cond; + uint64_t in_progress; + } notify; + int32_t sock; + int32_t idx; + int32_t gen; uint32_t backlog; - gf_boolean_t read_fail_log; - gf_boolean_t ssl_enabled; /* outbound I/O */ - gf_boolean_t mgmt_ssl; /* outbound mgmt */ - mgmt_ssl_t srvr_ssl; - gf_boolean_t use_ssl; SSL_METHOD *ssl_meth; SSL_CTX *ssl_ctx; int ssl_session_id; @@ -246,10 +246,24 @@ typedef struct { char *ssl_own_cert; char *ssl_private_key; char *ssl_ca_list; - pthread_t thread; int pipe[2]; + struct gf_sock_incoming incoming; + /* -1 = not connected. 0 = in progress. 1 = connected */ + char connected; + /* 1 = connect failed for reasons other than EINPROGRESS/ENOENT + see socket_connect for details */ + char connect_failed; + char bio; + char connect_finish_log; + char submit_log; + char lowlat; + char nodelay; + mgmt_ssl_t srvr_ssl; + gf_boolean_t read_fail_log; + gf_boolean_t ssl_enabled; /* outbound I/O */ + gf_boolean_t mgmt_ssl; /* outbound mgmt */ gf_boolean_t is_server; - int log_ctr; + gf_boolean_t use_ssl; gf_boolean_t ssl_accepted; /* To indicate SSL_accept() */ gf_boolean_t ssl_connected; /* or SSL_connect() has been * been completed on this socket. @@ -271,20 +285,6 @@ typedef struct { * newly accepted socket */ - /* ssl_error_required is used only during the SSL connection setup - * phase. - * It holds the error code returned by SSL_get_error() and is used to - * arm the epoll event set for the required event for the specific fd. - */ - int ssl_error_required; - - GF_REF_DECL; /* refcount to keep track of socket_poller - threads */ - struct { - pthread_mutex_t lock; - pthread_cond_t cond; - uint64_t in_progress; - } notify; } socket_private_t; #endif -- cgit