diff options
Diffstat (limited to 'rpc/rpc-lib/src/rpc-transport.h')
| -rw-r--r-- | rpc/rpc-lib/src/rpc-transport.h | 208 |
1 files changed, 117 insertions, 91 deletions
diff --git a/rpc/rpc-lib/src/rpc-transport.h b/rpc/rpc-lib/src/rpc-transport.h index b3c7985e0..2db9072ae 100644 --- a/rpc/rpc-lib/src/rpc-transport.h +++ b/rpc/rpc-lib/src/rpc-transport.h @@ -1,20 +1,11 @@ /* - Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef __RPC_TRANSPORT_H__ @@ -25,16 +16,30 @@ #include "config.h" #endif + #include <inttypes.h> -#include <rpc/rpc.h> +#ifdef GF_SOLARIS_HOST_OS #include <rpc/auth.h> +#else +#include <rpc/rpc.h> +#endif + #include <rpc/rpc_msg.h> + +#ifndef MAX_IOVEC +#define MAX_IOVEC 16 +#endif + +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0 +#endif /* AI_ADDRCONFIG */ + /* Given the 4-byte fragment header, returns non-zero if this fragment - * is the last fragment for the RPC record being assemebled. + * is the last fragment for the RPC record being assembled. * RPC Record marking standard defines a 32 bit value as the fragment * header with the MSB signifying whether the fragment is the last - * fragment for the record being asembled. + * fragment for the record being assembled. */ #define RPC_LASTFRAG(fraghdr) ((uint32_t)(fraghdr & 0x80000000U)) @@ -63,9 +68,14 @@ 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]; + 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; + //Volume mounted by client + char volname[1024]; }; typedef struct peer_info peer_info_t; @@ -87,7 +97,7 @@ typedef enum { * reading a single msg, this event may be * delivered more than once. */ - RPC_TRANSPORT_MAP_XID_REQUEST, /* reciever of this event should send + RPC_TRANSPORT_MAP_XID_REQUEST, /* receiver of this event should send * the prognum and procnum corresponding * to xid. */ @@ -108,18 +118,18 @@ struct rpc_transport_msg { typedef struct rpc_transport_msg rpc_transport_msg_t; struct rpc_transport_rsp { - /* as of now, the entire rsp payload is read into rspbuf and hence - * rspcount is always set to one. - */ - struct iovec *rspvec; - int rspcount; - struct iobuf *rspbuf; + struct iovec *rsphdr; + int rsphdr_count; + struct iovec *rsp_payload; + int rsp_payload_count; + struct iobref *rsp_iobref; }; typedef struct rpc_transport_rsp rpc_transport_rsp_t; struct rpc_transport_req { - rpc_transport_msg_t msg; - rpc_transport_rsp_t rsp; + rpc_transport_msg_t msg; + rpc_transport_rsp_t rsp; + struct rpc_req *rpc_req; }; typedef struct rpc_transport_req rpc_transport_req_t; @@ -129,77 +139,82 @@ struct rpc_transport_reply { }; 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; +}; +typedef struct rpc_transport_data rpc_transport_data_t; + +/* FIXME: prognum, procnum and progver are already present in + * 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; }; typedef struct rpc_request_info rpc_request_info_t; struct rpc_transport_pollin { - union { - struct vectored { - struct iobuf *iobuf1; - size_t size1; - struct iobuf *iobuf2; - size_t size2; - } vector; - struct simple { - struct iobuf *iobuf; - size_t size; - } simple; - } data; + struct iovec vector[2]; + int count; char vectored; void *private; + struct iobref *iobref; + struct iobuf *hdr_iobuf; + char is_reply; }; typedef struct rpc_transport_pollin rpc_transport_pollin_t; typedef int (*rpc_transport_notify_t) (rpc_transport_t *, void *mydata, rpc_transport_event_t, void *data, ...); + + struct rpc_transport { - struct rpc_transport_ops *ops; - void *private; - void *xl_private; - void *mydata; - pthread_mutex_t lock; - int32_t refcount; + struct rpc_transport_ops *ops; + rpc_transport_t *listener; /* listener transport to which + * request for creation of this + * transport came from. valid only + * on server process. + */ + + void *private; + struct _client_t *xl_private; + void *xl; /* Used for THIS */ + void *mydata; + pthread_mutex_t lock; + int32_t refcount; + + int32_t outstanding_rpc_count; glusterfs_ctx_t *ctx; dict_t *options; char *name; - void *dnscache; - data_t *buf; - int32_t (*init) (rpc_transport_t *this); - void (*fini) (rpc_transport_t *this); + void *dnscache; + void *drc_client; + data_t *buf; + int32_t (*init) (rpc_transport_t *this); + void (*fini) (rpc_transport_t *this); + int (*reconfigure) (rpc_transport_t *this, dict_t *options); rpc_transport_notify_t notify; void *notify_data; - peer_info_t peerinfo; - peer_info_t myinfo; - - rpc_transport_t *peer_trans; - struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - pthread_t thread; - struct list_head msgs; - /* any request/reply will be transformed as pollin data on the - * peer, hence we are building up a pollin data even before - * handing it over to peer rpc_transport. In order to decide whether - * the pollin data is vectored or simple, we follow a simple - * algo i.e., if there is a progpayload in request/reply, its - * considered vectored, otherwise its a simple pollin data. - */ - rpc_transport_pollin_t *msg; - } handover; -}; + peer_info_t peerinfo; + peer_info_t myinfo; -typedef struct { - rpc_transport_pollin_t *pollin; - struct list_head list; -} rpc_transport_handover_t; + uint64_t total_bytes_read; + uint64_t total_bytes_write; + + struct list_head list; + int bind_insecure; + void *dl_handle; /* handle of dlopen() */ +}; struct rpc_transport_ops { /* no need of receive op, msg will be delivered through an event @@ -209,19 +224,20 @@ struct rpc_transport_ops { rpc_transport_req_t *req); int32_t (*submit_reply) (rpc_transport_t *this, rpc_transport_reply_t *reply); - int32_t (*connect) (rpc_transport_t *this); - int32_t (*listen) (rpc_transport_t *this); - int32_t (*disconnect) (rpc_transport_t *this); + int32_t (*connect) (rpc_transport_t *this, int port); + int32_t (*listen) (rpc_transport_t *this); + int32_t (*disconnect) (rpc_transport_t *this); int32_t (*get_peername) (rpc_transport_t *this, char *hostname, int hostlen); int32_t (*get_peeraddr) (rpc_transport_t *this, char *peeraddr, - int addrlen, struct sockaddr *sa, + int addrlen, struct sockaddr_storage *sa, socklen_t sasize); int32_t (*get_myname) (rpc_transport_t *this, char *hostname, int hostlen); int32_t (*get_myaddr) (rpc_transport_t *this, char *peeraddr, - int addrlen, struct sockaddr *sa, + int addrlen, struct sockaddr_storage *sa, socklen_t sasize); + int32_t (*throttle) (rpc_transport_t *this, gf_boolean_t onoff); }; @@ -229,12 +245,15 @@ int32_t rpc_transport_listen (rpc_transport_t *this); int32_t -rpc_transport_connect (rpc_transport_t *this); +rpc_transport_connect (rpc_transport_t *this, int port); int32_t rpc_transport_disconnect (rpc_transport_t *this); int32_t +rpc_transport_destroy (rpc_transport_t *this); + +int32_t rpc_transport_notify (rpc_transport_t *this, rpc_transport_event_t event, void *data, ...); @@ -245,9 +264,6 @@ int32_t rpc_transport_submit_reply (rpc_transport_t *this, rpc_transport_reply_t *reply); -int32_t -rpc_transport_destroy (rpc_transport_t *this); - rpc_transport_t * rpc_transport_load (glusterfs_ctx_t *ctx, dict_t *options, char *name); @@ -258,9 +274,6 @@ int32_t rpc_transport_unref (rpc_transport_t *trans); int -rpc_transport_setpeer (rpc_transport_t *trans, rpc_transport_t *trans_peer); - -int rpc_transport_register_notify (rpc_transport_t *trans, rpc_transport_notify_t, void *mydata); @@ -269,20 +282,33 @@ rpc_transport_get_peername (rpc_transport_t *this, char *hostname, int hostlen); int32_t rpc_transport_get_peeraddr (rpc_transport_t *this, char *peeraddr, int addrlen, - struct sockaddr *sa, size_t salen); + struct sockaddr_storage *sa, size_t salen); int32_t rpc_transport_get_myname (rpc_transport_t *this, char *hostname, int hostlen); int32_t rpc_transport_get_myaddr (rpc_transport_t *this, char *peeraddr, int addrlen, - struct sockaddr *sa, size_t salen); + struct sockaddr_storage *sa, size_t salen); + +int +rpc_transport_throttle (rpc_transport_t *this, gf_boolean_t onoff); rpc_transport_pollin_t * -rpc_transport_pollin_alloc (rpc_transport_t *this, struct iobuf *iobuf, - size_t iobuf_size, struct iobuf *vectoriob, - size_t vectoriob_size, void *private); +rpc_transport_pollin_alloc (rpc_transport_t *this, struct iovec *vector, + int count, struct iobuf *hdr_iobuf, + struct iobref *iobref, void *private); void rpc_transport_pollin_destroy (rpc_transport_pollin_t *pollin); +int +rpc_transport_keepalive_options_set (dict_t *options, int32_t interval, + int32_t time); + +int +rpc_transport_unix_options_build (dict_t **options, char *filepath, + int frame_timeout); + +int +rpc_transport_inet_options_build (dict_t **options, const char *hostname, int port); #endif /* __RPC_TRANSPORT_H__ */ |
