glusterfs  8.2
About: GlusterFS is a network/cluster filesystem. The storage server (or each in a cluster) runs glusterfsd and the clients use mount command or glusterfs client to mount the exported filesystem. Release series 8.x (latest version).
  Fossies Dox: glusterfs-8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rpc-transport.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
3  This file is part of GlusterFS.
4 
5  This file is licensed to you under your choice of the GNU Lesser
6  General Public License, version 3 or any later version (LGPLv3 or
7  later), or the GNU General Public License, version 2 (GPLv2), in all
8  cases as published by the Free Software Foundation.
9 */
10 
11 #ifndef __RPC_TRANSPORT_H__
12 #define __RPC_TRANSPORT_H__
13 
14 #include <inttypes.h>
15 #ifdef GF_SOLARIS_HOST_OS
16 #include <rpc/auth.h>
17 #else
18 #include <rpc/rpc.h>
19 #endif
20 
21 #include <rpc/rpc_msg.h>
22 
23 #ifndef MAX_IOVEC
24 #define MAX_IOVEC 16
25 #endif
26 
27 #ifndef AI_ADDRCONFIG
28 #define AI_ADDRCONFIG 0
29 #endif /* AI_ADDRCONFIG */
30 
31 /* Given the 4-byte fragment header, returns non-zero if this fragment
32  * is the last fragment for the RPC record being assembled.
33  * RPC Record marking standard defines a 32 bit value as the fragment
34  * header with the MSB signifying whether the fragment is the last
35  * fragment for the record being assembled.
36  */
37 #define RPC_LASTFRAG(fraghdr) ((uint32_t)(fraghdr & 0x80000000U))
38 
39 /* Given the 4-byte fragment header, extracts the bits that contain
40  * the fragment size.
41  */
42 #define RPC_FRAGSIZE(fraghdr) ((uint32_t)(fraghdr & 0x7fffffffU))
43 
44 #define RPC_FRAGHDR_SIZE 4
45 #define RPC_MSGTYPE_SIZE 8
46 
47 /* size of the msg from the start of call-body till and including credlen */
48 #define RPC_CALL_BODY_SIZE 24
49 
50 #define RPC_REPLY_STATUS_SIZE 4
51 
52 #define RPC_AUTH_FLAVOUR_N_LENGTH_SIZE 8
53 
54 #define RPC_ACCEPT_STATUS_LEN 4
55 
56 struct rpc_transport_ops;
57 typedef struct rpc_transport rpc_transport_t;
58 
59 #include <glusterfs/dict.h>
60 #include <glusterfs/compat.h>
61 #include <glusterfs/async.h>
62 #include "rpcsvc-common.h"
63 
64 struct peer_info {
65  // OP-VERSION of clients
66  uint32_t max_op_version;
67  uint32_t min_op_version;
68  struct sockaddr_storage sockaddr;
69  socklen_t sockaddr_len;
71  // Volume mounted by client
72  char volname[NAME_MAX];
73 };
74 typedef struct peer_info peer_info_t;
75 
76 typedef enum msg_type msg_type_t;
77 
78 typedef enum {
79  RPC_TRANSPORT_ACCEPT, /* New client has been accepted */
80  RPC_TRANSPORT_DISCONNECT, /* Connection is disconnected */
81  RPC_TRANSPORT_CLEANUP, /* connection is about to be freed */
82  /*RPC_TRANSPORT_READ,*/ /* An event used to enable rpcsvc to instruct
83  * transport the number of bytes to read.
84  * This helps in reading large msgs, wherein
85  * the rpc actors might decide to place the
86  * actor's payload in new iobufs separate
87  * from the rpc header, proghdr and
88  * authentication information. glusterfs/nfs
89  * read and write actors are few examples
90  * that might beniefit from this. While
91  * reading a single msg, this event may be
92  * delivered more than once.
93  */
94  RPC_TRANSPORT_MAP_XID_REQUEST, /* receiver of this event should send
95  * the prognum and procnum corresponding
96  * to xid.
97  */
98  RPC_TRANSPORT_MSG_RECEIVED, /* Complete rpc msg has been read */
99  RPC_TRANSPORT_CONNECT, /* client is connected to server */
101  RPC_TRANSPORT_EVENT_THREAD_DIED /* event-thread has died */
103 
105  struct iovec *rpchdr;
106  struct iovec *proghdr;
109  struct iovec *progpayload;
110  struct iobref *iobref;
112 };
114 
116  struct iovec *rsphdr;
117  struct iovec *rsp_payload;
121 };
123 
125  struct rpc_req *rpc_req;
128 };
130 
132  void *private;
134 };
136 
138  union {
141  } data;
143 };
145 
146 /* FIXME: prognum, procnum and progver are already present in
147  * rpc_request, hence these should be removed from request_info
148  */
150  int prognum;
151  int progver;
152  void *rpc_req; /* struct rpc_req */
154  int procnum;
155  uint32_t xid;
156 };
157 typedef struct rpc_request_info rpc_request_info_t;
158 
159 typedef int (*rpc_transport_notify_t)(rpc_transport_t *, void *mydata,
160  rpc_transport_event_t, void *data, ...);
161 
164  rpc_transport_t *listener; /* listener transport to which
165  * request for creation of this
166  * transport came from. valid only
167  * on server process.
168  */
169 
170  void *private;
172  void *xl; /* Used for THIS */
173  void *mydata;
174  pthread_mutex_t lock;
178  char *name;
179  void *dnscache;
180  void *drc_client;
182  int32_t (*init)(rpc_transport_t *this);
183  void (*fini)(rpc_transport_t *this);
186  void *notify_data;
189 
192  uint32_t xid; /* RPC/XID used for callbacks */
194 
195  struct list_head list;
196  void *dl_handle; /* handle of dlopen() */
197  char *ssl_name;
198  dict_t *clnt_options; /* store options received from
199  * client */
202  /* connect_failed: saves the connect() syscall status as socket_t
203  * member holding connect() status can't be accessed by higher gfapi
204  * layer or in client management notification handler functions
205  */
209 };
210 
213  void *private;
214  struct iobref *iobref;
215  struct iovec vector[MAX_IOVEC];
217  int count;
218  char is_reply;
219  char vectored;
220 };
222 
224  /* no need of receive op, msg will be delivered through an event
225  * notification
226  */
228  int32_t (*submit_reply)(rpc_transport_t *this,
229  rpc_transport_reply_t *reply);
230  int32_t (*connect)(rpc_transport_t *this, int port);
231  int32_t (*listen)(rpc_transport_t *this);
232  int32_t (*disconnect)(rpc_transport_t *this, gf_boolean_t wait);
233  int32_t (*get_peername)(rpc_transport_t *this, char *hostname, int hostlen);
234  int32_t (*get_peeraddr)(rpc_transport_t *this, char *peeraddr, int addrlen,
235  struct sockaddr_storage *sa, socklen_t sasize);
236  int32_t (*get_myname)(rpc_transport_t *this, char *hostname, int hostlen);
237  int32_t (*get_myaddr)(rpc_transport_t *this, char *peeraddr, int addrlen,
238  struct sockaddr_storage *sa, socklen_t sasize);
239  int32_t (*throttle)(rpc_transport_t *this, gf_boolean_t onoff);
240 };
241 
242 int32_t
243 rpc_transport_count(const char *transport_type);
244 
245 int32_t
247 
248 int32_t
249 rpc_transport_connect(rpc_transport_t *this, int port);
250 
251 int32_t
253 
254 int32_t
256  void *data, ...);
257 
258 int32_t
260 
261 int32_t
263 
266 
269 
270 int32_t
272 
273 int
275  void *mydata);
276 
277 int32_t
278 rpc_transport_get_peername(rpc_transport_t *this, char *hostname, int hostlen);
279 
280 int32_t
281 rpc_transport_get_peeraddr(rpc_transport_t *this, char *peeraddr, int addrlen,
282  struct sockaddr_storage *sa, size_t salen);
283 
284 int32_t
285 rpc_transport_get_myaddr(rpc_transport_t *this, char *peeraddr, int addrlen,
286  struct sockaddr_storage *sa, size_t salen);
287 
288 int
290 
292 rpc_transport_pollin_alloc(rpc_transport_t *this, struct iovec *vector,
293  int count, struct iobuf *hdr_iobuf,
294  struct iobref *iobref, void *private);
295 void
297 
298 int
300  int32_t time, int32_t timeout);
301 
302 int
304  int frame_timeout);
305 
306 int
307 rpc_transport_inet_options_build(dict_t *options, const char *hostname,
308  int port, char *af);
309 
310 void
312 #endif /* __RPC_TRANSPORT_H__ */
rpc_transport::ops
struct rpc_transport_ops * ops
Definition: rpc-transport.h:163
rpc_transport_req::msg
rpc_transport_msg_t msg
Definition: rpc-transport.h:126
iobref
Definition: iobuf.h:154
rpc_transport_rsp::rsphdr_count
int rsphdr_count
Definition: rpc-transport.h:118
rpc_transport_unref
int32_t rpc_transport_unref(rpc_transport_t *trans)
Definition: rpc-transport.c:490
rpc_transport_pollin_alloc
rpc_transport_pollin_t * rpc_transport_pollin_alloc(rpc_transport_t *this, struct iovec *vector, int count, struct iobuf *hdr_iobuf, struct iobref *iobref, void *private)
Definition: rpc-transport.c:114
rpc_transport_pollin::iobref
struct iobref * iobref
Definition: rpc-transport.h:214
_glusterfs_ctx
Definition: glusterfs.h:618
rpc_transport_get_peername
int32_t rpc_transport_get_peername(rpc_transport_t *this, char *hostname, int hostlen)
Definition: rpc-transport.c:63
rpc_transport_pollin_destroy
void rpc_transport_pollin_destroy(rpc_transport_pollin_t *pollin)
Definition: rpc-transport.c:95
rpc_transport_pollin::vectored
char vectored
Definition: rpc-transport.h:219
rpc_transport::notify
rpc_transport_notify_t notify
Definition: rpc-transport.h:185
_gf_async
Definition: async.h:96
rpc_request_info::xid
uint32_t xid
Definition: rpc-transport.h:155
rpc_transport_msg::rpchdrcount
int rpchdrcount
Definition: rpc-transport.h:107
RPC_TRANSPORT_MAP_XID_REQUEST
@ RPC_TRANSPORT_MAP_XID_REQUEST
Definition: rpc-transport.h:94
RPC_TRANSPORT_EVENT_THREAD_DIED
@ RPC_TRANSPORT_EVENT_THREAD_DIED
Definition: rpc-transport.h:101
rpc_req
Definition: rpc-clnt.h:151
rpc_transport::connect_failed
bool connect_failed
Definition: rpc-transport.h:206
rpc_transport::total_bytes_write
uint64_t total_bytes_write
Definition: rpc-transport.h:191
rpc_transport_rsp::rsp_payload_count
int rsp_payload_count
Definition: rpc-transport.h:119
rpc_transport::outstanding_rpc_count
int32_t outstanding_rpc_count
Definition: rpc-transport.h:193
rpc_transport_pollin
Definition: rpc-transport.h:211
rpc_transport::buf
data_t * buf
Definition: rpc-transport.h:181
rpc_transport_event_t
rpc_transport_event_t
Definition: rpc-transport.h:78
rpc_transport_req::rsp
rpc_transport_rsp_t rsp
Definition: rpc-transport.h:127
rpc_transport_notify
int32_t rpc_transport_notify(rpc_transport_t *this, rpc_transport_event_t event, void *data,...)
Definition: rpc-transport.c:513
peer_info::min_op_version
uint32_t min_op_version
Definition: rpc-transport.h:67
rpc_transport_register_notify
int rpc_transport_register_notify(rpc_transport_t *trans, rpc_transport_notify_t, void *mydata)
Definition: rpc-transport.c:529
async.h
rpc_transport::xl_private
struct _client * xl_private
Definition: rpc-transport.h:171
rpc_transport_rsp::rsp_iobref
struct iobref * rsp_iobref
Definition: rpc-transport.h:120
rpc_transport_pollin::vector
struct iovec vector[16]
Definition: rpc-transport.h:215
rpc_transport_get_myaddr
int32_t rpc_transport_get_myaddr(rpc_transport_t *this, char *peeraddr, int addrlen, struct sockaddr_storage *sa, size_t salen)
Definition: rpc-transport.c:50
rpc_transport_keepalive_options_set
int rpc_transport_keepalive_options_set(dict_t *options, int32_t interval, int32_t time, int32_t timeout)
Definition: rpc-transport.c:547
rpc_transport::ssl_name
char * ssl_name
Definition: rpc-transport.h:197
rpc_transport_reply
Definition: rpc-transport.h:131
rpc_transport::xid
uint32_t xid
Definition: rpc-transport.h:192
rpc_transport_msg::progpayloadcount
int progpayloadcount
Definition: rpc-transport.h:111
rpc_transport::reconfigure
int(* reconfigure)(rpc_transport_t *this, dict_t *options)
Definition: rpc-transport.h:184
rpc_transport_inet_options_build
int rpc_transport_inet_options_build(dict_t *options, const char *hostname, int port, char *af)
Definition: rpc-transport.c:620
rpc_transport_ops::disconnect
int32_t(* disconnect)(rpc_transport_t *this, bool wait)
Definition: rpc-transport.h:232
peer_info::identifier
char identifier[UNIX_PATH_MAX]
Definition: rpc-transport.h:70
RPC_TRANSPORT_DISCONNECT
@ RPC_TRANSPORT_DISCONNECT
Definition: rpc-transport.h:80
rpc_transport_throttle
int rpc_transport_throttle(rpc_transport_t *this, bool onoff)
Definition: rpc-transport.c:74
rpc_request_info::procnum
int procnum
Definition: rpc-transport.h:154
rpc_transport::bind_insecure
int bind_insecure
Definition: rpc-transport.h:201
rpc_request_info::prognum
int prognum
Definition: rpc-transport.h:150
rpc_transport::name
char * name
Definition: rpc-transport.h:178
rpc_transport_ops::get_peeraddr
int32_t(* get_peeraddr)(rpc_transport_t *this, char *peeraddr, int addrlen, struct sockaddr_storage *sa, socklen_t sasize)
Definition: rpc-transport.h:234
rpc_transport_data::req
rpc_transport_req_t req
Definition: rpc-transport.h:139
_data
Definition: dict.h:97
rpc_transport_ops::get_peername
int32_t(* get_peername)(rpc_transport_t *this, char *hostname, int hostlen)
Definition: rpc-transport.h:233
rpc_transport
Definition: rpc-transport.h:162
rpc_transport::clnt_options
dict_t * clnt_options
Definition: rpc-transport.h:198
rpc_request_info::rsp
rpc_transport_rsp_t rsp
Definition: rpc-transport.h:153
gf_boolean_t
#define gf_boolean_t
Definition: glusterfs.h:368
rpc_transport::list
struct list_head list
Definition: rpc-transport.h:195
rpc_transport_ops::listen
int32_t(* listen)(rpc_transport_t *this)
Definition: rpc-transport.h:231
rpc_transport_count
int32_t rpc_transport_count(const char *transport_type)
Definition: rpc-transport.c:24
rpc_transport_notify_t
int(* rpc_transport_notify_t)(rpc_transport_t *, void *mydata, rpc_transport_event_t, void *data,...)
Definition: rpc-transport.h:159
rpc_transport_req
Definition: rpc-transport.h:124
rpc_transport::options
dict_t * options
Definition: rpc-transport.h:177
rpc_request_info::rpc_req
void * rpc_req
Definition: rpc-transport.h:152
rpc_transport_msg::rpchdr
struct iovec * rpchdr
Definition: rpc-transport.h:105
rpc_transport_cleanup
void rpc_transport_cleanup(rpc_transport_t *)
Definition: rpc-transport.c:142
RPC_TRANSPORT_MSG_SENT
@ RPC_TRANSPORT_MSG_SENT
Definition: rpc-transport.h:100
list_head
Definition: list.h:14
compat.h
rpc_transport_reply::msg
rpc_transport_msg_t msg
Definition: rpc-transport.h:133
RPC_TRANSPORT_CONNECT
@ RPC_TRANSPORT_CONNECT
Definition: rpc-transport.h:99
RPC_TRANSPORT_CLEANUP
@ RPC_TRANSPORT_CLEANUP
Definition: rpc-transport.h:81
rpc_transport::notify_data
void * notify_data
Definition: rpc-transport.h:186
peer_info::volname
char volname[NAME_MAX]
Definition: rpc-transport.h:72
peer_info::sockaddr_len
socklen_t sockaddr_len
Definition: rpc-transport.h:69
rpc_transport::xl
void * xl
Definition: rpc-transport.h:172
rpc_transport::disconnect_progress
gf_atomic_int64_t disconnect_progress
Definition: rpc-transport.h:200
rpcsvc-common.h
rpc_transport_unix_options_build
int rpc_transport_unix_options_build(dict_t *options, char *filepath, int frame_timeout)
Definition: rpc-transport.c:573
rpc_transport_pollin::is_reply
char is_reply
Definition: rpc-transport.h:218
rpc_transport_submit_reply
int32_t rpc_transport_submit_reply(rpc_transport_t *this, rpc_transport_reply_t *reply)
Definition: rpc-transport.c:393
rpc_transport_pollin::async
gf_async_t async
Definition: rpc-transport.h:216
rpc_transport::fini
void(* fini)(rpc_transport_t *this)
Definition: rpc-transport.h:183
rpc_transport::mydata
void * mydata
Definition: rpc-transport.h:173
rpc_request_info
Definition: rpc-transport.h:149
rpc_transport_msg::progpayload
struct iovec * progpayload
Definition: rpc-transport.h:109
rpc_transport_rsp::rsp_payload
struct iovec * rsp_payload
Definition: rpc-transport.h:117
peer_info::sockaddr
struct sockaddr_storage sockaddr
Definition: rpc-transport.h:68
rpc_transport::dnscache
void * dnscache
Definition: rpc-transport.h:179
rpc_transport_msg::proghdrcount
int proghdrcount
Definition: rpc-transport.h:108
rpc_transport_load
rpc_transport_t * rpc_transport_load(glusterfs_ctx_t *ctx, dict_t *options, char *name)
Definition: rpc-transport.c:167
rpc_transport::ctx
glusterfs_ctx_t * ctx
Definition: rpc-transport.h:176
name
char * name
Definition: xdr-nfs3.h:948
rpc_transport_connect
int32_t rpc_transport_connect(rpc_transport_t *this, int port)
Definition: rpc-transport.c:406
rpc_transport::dl_handle
void * dl_handle
Definition: rpc-transport.h:196
rpc_transport::drc_client
void * drc_client
Definition: rpc-transport.h:180
rpc_transport::notify_poller_death
char notify_poller_death
Definition: rpc-transport.h:207
rpc_transport_ops
Definition: rpc-transport.h:223
rpc_transport_listen
int32_t rpc_transport_listen(rpc_transport_t *this)
Definition: rpc-transport.c:418
rpc_transport_ops::submit_reply
int32_t(* submit_reply)(rpc_transport_t *this, rpc_transport_reply_t *reply)
Definition: rpc-transport.h:228
rpc_transport::lock
pthread_mutex_t lock
Definition: rpc-transport.h:174
RPC_TRANSPORT_ACCEPT
@ RPC_TRANSPORT_ACCEPT
Definition: rpc-transport.h:79
_client
Definition: client_t.h:34
rpc_transport::refcount
gf_atomic_int64_t refcount
Definition: rpc-transport.h:175
rpc_transport::listener
rpc_transport_t * listener
Definition: rpc-transport.h:164
rpc_transport_data::data
union rpc_transport_data::@49 data
rpc_transport_data::is_request
char is_request
Definition: rpc-transport.h:142
rpc_transport_msg
Definition: rpc-transport.h:104
rpc_transport_msg::proghdr
struct iovec * proghdr
Definition: rpc-transport.h:106
rpc_request_info::progver
int progver
Definition: rpc-transport.h:151
options
static struct argp_option options[]
Definition: glfs-bm.c:322
rpc_transport_data
Definition: rpc-transport.h:137
rpc_transport_get_peeraddr
int32_t rpc_transport_get_peeraddr(rpc_transport_t *this, char *peeraddr, int addrlen, struct sockaddr_storage *sa, size_t salen)
Definition: rpc-transport.c:83
rpc_transport::peerinfo
peer_info_t peerinfo
Definition: rpc-transport.h:187
rpc_transport_pollin::trans
struct rpc_transport * trans
Definition: rpc-transport.h:212
rpc_transport::poller_death_accept
char poller_death_accept
Definition: rpc-transport.h:208
rpc_transport_submit_request
int32_t rpc_transport_submit_request(rpc_transport_t *this, rpc_transport_req_t *req)
Definition: rpc-transport.c:380
dict.h
RPC_TRANSPORT_MSG_RECEIVED
@ RPC_TRANSPORT_MSG_RECEIVED
Definition: rpc-transport.h:98
rpc_transport_msg::iobref
struct iobref * iobref
Definition: rpc-transport.h:110
rpc_transport::myinfo
peer_info_t myinfo
Definition: rpc-transport.h:188
rpc_transport_ops::get_myaddr
int32_t(* get_myaddr)(rpc_transport_t *this, char *peeraddr, int addrlen, struct sockaddr_storage *sa, socklen_t sasize)
Definition: rpc-transport.h:237
peer_info::max_op_version
uint32_t max_op_version
Definition: rpc-transport.h:66
rpc_transport_ops::connect
int32_t(* connect)(rpc_transport_t *this, int port)
Definition: rpc-transport.h:230
rpc_transport_req::rpc_req
struct rpc_req * rpc_req
Definition: rpc-transport.h:125
MAX_IOVEC
#define MAX_IOVEC
Definition: rpc-transport.h:24
rpc_transport_ref
rpc_transport_t * rpc_transport_ref(rpc_transport_t *trans)
Definition: rpc-transport.c:476
rpc_transport_data::reply
rpc_transport_reply_t reply
Definition: rpc-transport.h:140
rpc_transport_pollin::count
int count
Definition: rpc-transport.h:217
rpc_transport_ops::get_myname
int32_t(* get_myname)(rpc_transport_t *this, char *hostname, int hostlen)
Definition: rpc-transport.h:236
rpc_transport_rsp
Definition: rpc-transport.h:115
_dict
Definition: dict.h:114
rpc_transport::init
int32_t(* init)(rpc_transport_t *this)
Definition: rpc-transport.h:182
gf_atomic_t
#define gf_atomic_t
Definition: atomic.h:111
rpc_transport::total_bytes_read
uint64_t total_bytes_read
Definition: rpc-transport.h:190
rpc_transport_ops::submit_request
int32_t(* submit_request)(rpc_transport_t *this, rpc_transport_req_t *req)
Definition: rpc-transport.h:227
rpc_transport_disconnect
int32_t rpc_transport_disconnect(rpc_transport_t *this, bool wait)
Definition: rpc-transport.c:430
rpc_transport_ops::throttle
int32_t(* throttle)(rpc_transport_t *this, bool onoff)
Definition: rpc-transport.h:239
iobuf
Definition: iobuf.h:58
msg_type_t
enum msg_type msg_type_t
Definition: rpc-transport.h:76
rpc_transport_rsp::rsphdr
struct iovec * rsphdr
Definition: rpc-transport.h:116
UNIX_PATH_MAX
#define UNIX_PATH_MAX
Definition: rdd.c:26
peer_info
Definition: rpc-transport.h:64