From 9cfaef0960d206a554035000141935cc0fcf39e5 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Wed, 11 Sep 2019 17:53:39 +0300 Subject: client xlator: misc. cleanups - remove dead code - move functions to be static - move some code that only needs to be executed under if branch - remove some dead assignments and redundant checks. No functional change, I hope. Change-Id: I93d952408197ecd2fa91c3f812a73c54242342fa updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/protocol/client/src/client-callback.c | 34 +- xlators/protocol/client/src/client-handshake.c | 21 +- xlators/protocol/client/src/client-rpc-fops.c | 31 +- xlators/protocol/client/src/client-rpc-fops_v2.c | 31 +- xlators/protocol/client/src/client.c | 1001 +++++++++------------- xlators/protocol/client/src/client.h | 18 +- 6 files changed, 474 insertions(+), 662 deletions(-) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c index c401c4fd791..36b69d2f51a 100644 --- a/xlators/protocol/client/src/client-callback.c +++ b/xlators/protocol/client/src/client-callback.c @@ -13,7 +13,7 @@ #include #include "client-messages.h" -int +static int client_cbk_null(struct rpc_clnt *rpc, void *mydata, void *data) { gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, @@ -21,7 +21,7 @@ client_cbk_null(struct rpc_clnt *rpc, void *mydata, void *data) return 0; } -int +static int client_cbk_fetchspec(struct rpc_clnt *rpc, void *mydata, void *data) { gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, @@ -29,7 +29,7 @@ client_cbk_fetchspec(struct rpc_clnt *rpc, void *mydata, void *data) return 0; } -int +static int client_cbk_ino_flush(struct rpc_clnt *rpc, void *mydata, void *data) { gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, @@ -37,7 +37,7 @@ client_cbk_ino_flush(struct rpc_clnt *rpc, void *mydata, void *data) return 0; } -int +static int client_cbk_recall_lease(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -54,8 +54,6 @@ client_cbk_recall_lease(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; @@ -90,7 +88,7 @@ out: return ret; } -int +static int client_cbk_cache_invalidation(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -107,7 +105,7 @@ client_cbk_cache_invalidation(struct rpc_clnt *rpc, void *mydata, void *data) gf_msg_trace(THIS->name, 0, "Upcall callback is called"); - if (!rpc || !mydata || !data) + if (!data) goto out; iov = (struct iovec *)data; @@ -145,15 +143,13 @@ out: return 0; } -int +static int client_cbk_child_up(struct rpc_clnt *rpc, void *mydata, void *data) { clnt_conf_t *conf = NULL; - xlator_t *this = NULL; + xlator_t *this = THIS; - this = THIS; GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, rpc, out); conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, out); @@ -165,15 +161,13 @@ out: return 0; } -int +static int client_cbk_child_down(struct rpc_clnt *rpc, void *mydata, void *data) { clnt_conf_t *conf = NULL; - xlator_t *this = NULL; + xlator_t *this = THIS; - this = THIS; GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, rpc, out); conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, out); @@ -185,7 +179,7 @@ out: return 0; } -int +static int client_cbk_inodelk_contention(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -204,8 +198,6 @@ client_cbk_inodelk_contention(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; @@ -240,7 +232,7 @@ out: return ret; } -int +static int client_cbk_entrylk_contention(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -257,8 +249,6 @@ client_cbk_entrylk_contention(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index d990855ed14..e6a5e84f422 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -27,13 +27,6 @@ extern rpc_clnt_prog_t clnt3_3_fop_prog; extern rpc_clnt_prog_t clnt4_0_fop_prog; extern rpc_clnt_prog_t clnt_pmap_prog; -typedef struct client_fd_lk_local { - gf_atomic_t ref; - gf_boolean_t error; - gf_lock_t lock; - clnt_fd_ctx_t *fdctx; -} clnt_fd_lk_local_t; - int32_t client3_getspec(call_frame_t *frame, xlator_t *this, void *data) { @@ -159,12 +152,9 @@ client3_3_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count, } if (rsp.op_ret == -1) { - ret = -1; goto out; } - ret = 0; - out: fdctx->reopen_done(fdctx, (rsp.op_ret) ? -1 : rsp.fd, this); @@ -218,7 +208,6 @@ client3_3_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count, } if (-1 == rsp.op_ret) { - ret = -1; goto out; } @@ -249,7 +238,6 @@ protocol_client_reopendir(clnt_fd_ctx_t *fdctx, xlator_t *this) local = mem_get0(this->local_pool); if (!local) { - ret = -1; goto out; } local->fdctx = fdctx; @@ -261,7 +249,6 @@ protocol_client_reopendir(clnt_fd_ctx_t *fdctx, xlator_t *this) frame = create_frame(this, this->ctx->pool); if (!frame) { - ret = -1; goto out; } @@ -308,13 +295,11 @@ protocol_client_reopenfile(clnt_fd_ctx_t *fdctx, xlator_t *this) frame = create_frame(this, this->ctx->pool); if (!frame) { - ret = -1; goto out; } local = mem_get0(this->local_pool); if (!local) { - ret = -1; goto out; } @@ -409,12 +394,9 @@ client4_0_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count, } if (rsp.op_ret == -1) { - ret = -1; goto out; } - ret = 0; - out: fdctx->reopen_done(fdctx, (rsp.op_ret) ? -1 : rsp.fd, this); @@ -468,7 +450,6 @@ client4_0_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count, } if (-1 == rsp.op_ret) { - ret = -1; goto out; } @@ -1324,7 +1305,7 @@ client_query_portmap(xlator_t *this, struct rpc_clnt *rpc) req.brick = remote_subvol; - if (!dict_get_str(options, "transport-type", &xprt)) { + if (!dict_get_str_sizen(options, "transport-type", &xprt)) { if (!strcmp(xprt, "rdma")) { snprintf(brick_name, sizeof(brick_name), "%s.rdma", remote_subvol); req.brick = brick_name; diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 247d49728a3..c6f2ca137aa 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -2900,8 +2900,6 @@ client3_3_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, this = THIS; - memset(vector, 0, sizeof(vector)); - frame = myframe; local = frame->local; @@ -2920,6 +2918,8 @@ client3_3_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, goto out; } + memset(vector, 0, sizeof(vector)); + ret = client_post_readv(this, &rsp, &iobref, req->rsp_iobref, &stat, vector, &req->rsp[1], &rspcount, &xdata); out: @@ -3185,9 +3185,6 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(vector, 0, sizeof(vector)); - memset(&cp, 0, sizeof(client_payload_t)); - conf = this->private; args = data; local = mem_get0(this->local_pool); @@ -3204,7 +3201,7 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc, NULL); if (args->xdata) { - content = dict_get(args->xdata, GF_CONTENT_KEY); + content = dict_get_sizen(args->xdata, GF_CONTENT_KEY); if (content != NULL) { rsp_iobref = iobref_new(); if (rsp_iobref == NULL) { @@ -3220,6 +3217,7 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) } iobref_add(rsp_iobref, rsp_iobuf); + memset(vector, 0, sizeof(vector)); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr(rsp_iobuf); rsphdr->iov_len = iobuf_pagesize(rsp_iobuf); @@ -3237,6 +3235,7 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -3460,7 +3459,6 @@ client3_3_readlink(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -3499,6 +3497,7 @@ client3_3_readlink(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -3849,7 +3848,7 @@ client3_3_mkdir(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - if (!args->xdata || !dict_get(args->xdata, "gfid-req")) { + if (!args->xdata || !dict_get_sizen(args->xdata, "gfid-req")) { op_errno = EPERM; gf_msg_callingfn(this->name, GF_LOG_WARNING, op_errno, PC_MSG_GFID_NULL, "mkdir: %s is received " @@ -4038,7 +4037,6 @@ client3_3_readv(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -4086,6 +4084,7 @@ client3_3_readv(call_frame_t *frame, xlator_t *this, void *data) local->iobref = rsp_iobref; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); cp.rsp_payload = &rsp_vec; cp.rsp_payload_cnt = 1; cp.rsp_iobref = local->iobref; @@ -4131,7 +4130,6 @@ client3_3_writev(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -4149,6 +4147,7 @@ client3_3_writev(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.iobref = args->iobref; cp.payload = args->vector; cp.payload_cnt = args->count; @@ -4587,7 +4586,6 @@ client3_3_fgetxattr(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -4628,6 +4626,7 @@ client3_3_fgetxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -4682,7 +4681,6 @@ client3_3_getxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } - memset(&cp, 0, sizeof(client_payload_t)); args = data; local = mem_get0(this->local_pool); @@ -4755,6 +4753,7 @@ client3_3_getxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -4809,7 +4808,6 @@ client3_3_xattrop(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; if (!(args->loc && args->loc->inode)) @@ -4856,6 +4854,7 @@ client3_3_xattrop(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -4910,7 +4909,6 @@ client3_3_fxattrop(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -4951,6 +4949,7 @@ client3_3_fxattrop(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -5434,7 +5433,6 @@ client3_3_readdir(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -5484,6 +5482,7 @@ client3_3_readdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = rsp_iobref; @@ -5539,7 +5538,6 @@ client3_3_readdirp(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -5589,6 +5587,7 @@ client3_3_readdirp(call_frame_t *frame, xlator_t *this, void *data) local->fd = fd_ref(args->fd); + memset(&cp, 0, sizeof(client_payload_t)); cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = rsp_iobref; diff --git a/xlators/protocol/client/src/client-rpc-fops_v2.c b/xlators/protocol/client/src/client-rpc-fops_v2.c index 92461026b68..756722494d0 100644 --- a/xlators/protocol/client/src/client-rpc-fops_v2.c +++ b/xlators/protocol/client/src/client-rpc-fops_v2.c @@ -2605,7 +2605,7 @@ client4_0_lookup_cbk(struct rpc_req *req, struct iovec *iov, int count, rsp.op_ret = -1; op_errno = ESTALE; if (xdata) - ret = dict_set_int32(xdata, "gfid-changed", 1); + ret = dict_set_int32_sizen(xdata, "gfid-changed", 1); goto out; } @@ -2659,8 +2659,6 @@ client4_0_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, this = THIS; - memset(vector, 0, sizeof(vector)); - frame = myframe; local = frame->local; @@ -2679,6 +2677,8 @@ client4_0_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, goto out; } + memset(vector, 0, sizeof(vector)); + ret = client_post_readv_v2(this, &rsp, &iobref, req->rsp_iobref, &stat, vector, &req->rsp[1], &rspcount, &xdata); out: @@ -3000,9 +3000,6 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(vector, 0, sizeof(vector)); - memset(&cp, 0, sizeof(client_payload_t)); - conf = this->private; args = data; local = mem_get0(this->local_pool); @@ -3019,7 +3016,7 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc, NULL); if (args->xdata) { - content = dict_get(args->xdata, GF_CONTENT_KEY); + content = dict_get_sizen(args->xdata, GF_CONTENT_KEY); if (content != NULL) { rsp_iobref = iobref_new(); if (rsp_iobref == NULL) { @@ -3035,6 +3032,7 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) } iobref_add(rsp_iobref, rsp_iobuf); + memset(vector, 0, sizeof(vector)); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr(rsp_iobuf); rsphdr->iov_len = iobuf_pagesize(rsp_iobuf); @@ -3052,6 +3050,8 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = local->iobref; @@ -3633,7 +3633,7 @@ client4_0_mkdir(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - if (!args->xdata || !dict_get(args->xdata, "gfid-req")) { + if (!args->xdata || !dict_get_sizen(args->xdata, "gfid-req")) { op_errno = EPERM; gf_msg_callingfn(this->name, GF_LOG_WARNING, op_errno, PC_MSG_GFID_NULL, "mkdir: %s is received " @@ -3822,7 +3822,6 @@ client4_0_readv(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -3868,6 +3867,8 @@ client4_0_readv(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsp_payload = &rsp_vec; cp.rsp_payload_cnt = 1; cp.rsp_iobref = local->iobref; @@ -3909,7 +3910,6 @@ client4_0_writev(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -3927,6 +3927,8 @@ client4_0_writev(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.iobref = args->iobref; cp.payload = args->vector; cp.payload_cnt = args->count; @@ -5007,7 +5009,6 @@ client4_0_readdir(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -5057,6 +5058,8 @@ client4_0_readdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = rsp_iobref; @@ -5112,7 +5115,6 @@ client4_0_readdirp(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -5162,6 +5164,8 @@ client4_0_readdirp(call_frame_t *frame, xlator_t *this, void *data) local->fd = fd_ref(args->fd); + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; cp.rsphdr_cnt = count; cp.rsp_iobref = rsp_iobref; @@ -5888,7 +5892,6 @@ client4_0_put(call_frame_t *frame, xlator_t *this, void *data) if (!frame || !this || !data) goto unwind; - memset(&cp, 0, sizeof(client_payload_t)); args = data; conf = this->private; @@ -5911,6 +5914,8 @@ client4_0_put(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.iobref = args->iobref; cp.payload = args->vector; cp.payload_cnt = args->count; diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index e8b5cd82e9f..ee5a59962e2 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -26,12 +26,8 @@ extern struct rpcclnt_cb_program gluster_cbk_prog; int client_handshake(xlator_t *this, struct rpc_clnt *rpc); -int -client_init_rpc(xlator_t *this); -int +static int client_destroy_rpc(xlator_t *this); -int -client_mark_fd_bad(xlator_t *this); static void client_filter_o_direct(clnt_conf_t *conf, int32_t *flags) @@ -60,7 +56,7 @@ out: return 0; } -int +static int client_is_last_child_down(xlator_t *this, int32_t event, struct rpc_clnt *rpc) { rpc_clnt_connection_t *conn = NULL; @@ -76,10 +72,14 @@ client_is_last_child_down(xlator_t *this, int32_t event, struct rpc_clnt *rpc) if (!conf->parent_down) goto out; + + if (event != GF_EVENT_CHILD_DOWN) + goto out; + conn = &rpc->conn; pthread_mutex_lock(&conn->lock); { - if (event == GF_EVENT_CHILD_DOWN && !conn->reconnect && rpc->disabled) { + if (!conn->reconnect && rpc->disabled) { ret = 1; } } @@ -169,26 +169,6 @@ client_notify_dispatch(xlator_t *this, int32_t event, void *data, ...) return ret; } -int32_t -client_type_to_gf_type(short l_type) -{ - int32_t gf_type = GF_LK_EOL; - - switch (l_type) { - case F_RDLCK: - gf_type = GF_LK_F_RDLCK; - break; - case F_WRLCK: - gf_type = GF_LK_F_WRLCK; - break; - case F_UNLCK: - gf_type = GF_LK_F_UNLCK; - break; - } - - return gf_type; -} - int client_submit_request(xlator_t *this, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, @@ -321,134 +301,14 @@ out: return ret; } -int -client_submit_compound_request(xlator_t *this, void *req, call_frame_t *frame, - rpc_clnt_prog_t *prog, int procnum, - fop_cbk_fn_t cbkfn, struct iovec *req_payload, - int req_count, struct iobref *iobref, - struct iovec *rsphdr, int rsphdr_count, - struct iovec *rsp_payload, int rsp_payload_count, - struct iobref *rsp_iobref, xdrproc_t xdrproc) -{ - int ret = -1; - clnt_conf_t *conf = NULL; - struct iovec iov = { - 0, - }; - struct iobuf *iobuf = NULL; - int count = 0; - struct iobref *new_iobref = NULL; - ssize_t xdr_size = 0; - struct rpc_req rpcreq = { - 0, - }; - - GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, prog, out); - GF_VALIDATE_OR_GOTO(this->name, frame, out); - - conf = this->private; - - /* If 'setvolume' is not successful, we should not send frames to - * server - */ - - if (!conf->connected) { - gf_msg_debug(this->name, 0, "connection in disconnected state"); - goto out; - } - - if (req && xdrproc) { - xdr_size = xdr_sizeof(xdrproc, req); - iobuf = iobuf_get2(this->ctx->iobuf_pool, xdr_size); - if (!iobuf) { - goto out; - }; - - new_iobref = iobref_new(); - if (!new_iobref) { - goto out; - } - - if (iobref != NULL) { - ret = iobref_merge(new_iobref, iobref); - if (ret != 0) { - goto out; - } - } - - ret = iobref_add(new_iobref, iobuf); - if (ret != 0) { - goto out; - } - - iov.iov_base = iobuf->ptr; - iov.iov_len = iobuf_size(iobuf); - - /* Create the xdr payload */ - ret = xdr_serialize_generic(iov, req, xdrproc); - if (ret == -1) { - /* callingfn so that, we can get to know which xdr - function was called */ - gf_log_callingfn(this->name, GF_LOG_WARNING, - "XDR payload creation failed"); - goto out; - } - iov.iov_len = ret; - count = 1; - } - - /* do not send all groups if they are resolved server-side */ - if (!conf->send_gids) { - if (frame->root->ngrps <= SMALL_GROUP_COUNT) { - frame->root->groups_small[0] = frame->root->gid; - frame->root->groups = frame->root->groups_small; - } - frame->root->ngrps = 1; - } - - /* Send the msg */ - ret = rpc_clnt_submit(conf->rpc, prog, procnum, cbkfn, &iov, count, - req_payload, req_count, new_iobref, frame, rsphdr, - rsphdr_count, rsp_payload, rsp_payload_count, - rsp_iobref); - - if (ret < 0) { - gf_msg_debug(this->name, 0, "rpc_clnt_submit failed"); - } - - ret = 0; - - if (new_iobref) - iobref_unref(new_iobref); - - if (iobuf) - iobuf_unref(iobuf); - - return ret; - -out: - rpcreq.rpc_status = -1; - - cbkfn(&rpcreq, NULL, 0, frame); - - if (new_iobref) - iobref_unref(new_iobref); - - if (iobuf) - iobuf_unref(iobuf); - - return 0; -} - -int32_t +static int32_t client_forget(xlator_t *this, inode_t *inode) { /* Nothing here */ return 0; } -int32_t +static int32_t client_releasedir(xlator_t *this, fd_t *fd) { int ret = -1; @@ -462,10 +322,9 @@ client_releasedir(xlator_t *this, fd_t *fd) if (!conf || !conf->fops) goto out; - args.fd = fd; - proc = &conf->fops->proctable[GF_FOP_RELEASEDIR]; if (proc->fn) { + args.fd = fd; ret = proc->fn(NULL, this, &args); } out: @@ -475,7 +334,7 @@ out: return 0; } -int32_t +static int32_t client_release(xlator_t *this, fd_t *fd) { int ret = -1; @@ -489,9 +348,9 @@ client_release(xlator_t *this, fd_t *fd) if (!conf || !conf->fops) goto out; - args.fd = fd; proc = &conf->fops->proctable[GF_FOP_RELEASE]; if (proc->fn) { + args.fd = fd; ret = proc->fn(NULL, this, &args); } out: @@ -501,7 +360,7 @@ out: return 0; } -int32_t +static int32_t client_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -515,12 +374,12 @@ client_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LOOKUP]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: /* think of avoiding a missing frame */ if (ret) @@ -530,7 +389,7 @@ out: return 0; } -int32_t +static int32_t client_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -544,12 +403,12 @@ client_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_STAT]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(stat, frame, -1, ENOTCONN, NULL, NULL); @@ -557,7 +416,7 @@ out: return 0; } -int32_t +static int32_t client_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata) { @@ -572,13 +431,13 @@ client_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.offset = offset; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_TRUNCATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.offset = offset; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(truncate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -586,7 +445,7 @@ out: return 0; } -int32_t +static int32_t client_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, dict_t *xdata) { @@ -601,13 +460,13 @@ client_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FTRUNCATE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(ftruncate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -615,7 +474,7 @@ out: return 0; } -int32_t +static int32_t client_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, dict_t *xdata) { @@ -630,13 +489,13 @@ client_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mask = mask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ACCESS]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mask = mask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(access, frame, -1, ENOTCONN, NULL); @@ -644,7 +503,7 @@ out: return 0; } -int32_t +static int32_t client_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, dict_t *xdata) { @@ -659,13 +518,13 @@ client_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.size = size; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_READLINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.size = size; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readlink, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -673,7 +532,7 @@ out: return 0; } -int +static int client_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata) { @@ -688,15 +547,15 @@ client_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.rdev = rdev; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_MKNOD]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.rdev = rdev; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(mknod, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -705,7 +564,7 @@ out: return 0; } -int +static int client_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata) { @@ -720,14 +579,14 @@ client_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_MKDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(mkdir, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -736,7 +595,7 @@ out: return 0; } -int32_t +static int32_t client_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, dict_t *xdata) { @@ -751,13 +610,13 @@ client_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - args.flags = xflag; - proc = &conf->fops->proctable[GF_FOP_UNLINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; + args.flags = xflag; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(unlink, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -765,7 +624,7 @@ out: return 0; } -int32_t +static int32_t client_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata) { @@ -780,13 +639,13 @@ client_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RMDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: /* think of avoiding a missing frame */ if (ret) @@ -795,7 +654,7 @@ out: return 0; } -int +static int client_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, loc_t *loc, mode_t umask, dict_t *xdata) { @@ -810,14 +669,14 @@ client_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, if (!conf || !conf->fops) goto out; - args.linkname = linkpath; - args.loc = loc; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SYMLINK]; - if (proc->fn) + if (proc->fn) { + args.linkname = linkpath; + args.loc = loc; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(symlink, frame, -1, ENOTCONN, NULL, NULL, NULL, @@ -826,7 +685,7 @@ out: return 0; } -int32_t +static int32_t client_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { @@ -841,13 +700,13 @@ client_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (!conf || !conf->fops) goto out; - args.oldloc = oldloc; - args.newloc = newloc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RENAME]; - if (proc->fn) + if (proc->fn) { + args.oldloc = oldloc; + args.newloc = newloc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(rename, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -856,7 +715,7 @@ out: return 0; } -int32_t +static int32_t client_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { @@ -871,13 +730,13 @@ client_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (!conf || !conf->fops) goto out; - args.oldloc = oldloc; - args.newloc = newloc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LINK]; - if (proc->fn) + if (proc->fn) { + args.oldloc = oldloc; + args.newloc = newloc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(link, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -886,7 +745,7 @@ out: return 0; } -int32_t +static int32_t client_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) { @@ -901,18 +760,17 @@ client_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.fd = fd; - args.umask = umask; - args.xdata = xdata; - args.flags = flags; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_CREATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.fd = fd; + args.umask = umask; + args.xdata = xdata; + args.flags = flags; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(create, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -921,7 +779,7 @@ out: return 0; } -int32_t +static int32_t client_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, fd_t *fd, dict_t *xdata) { @@ -936,17 +794,15 @@ client_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.fd = fd; - args.xdata = xdata; - args.flags = flags; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_OPEN]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.fd = fd; + args.xdata = xdata; + args.flags = flags; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(open, frame, -1, ENOTCONN, NULL, NULL); @@ -954,7 +810,7 @@ out: return 0; } -int32_t +static int32_t client_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) { @@ -969,18 +825,17 @@ client_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.size = size; - args.offset = offset; - args.flags = flags; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_READ]; - if (proc->fn) - ret = proc->fn(frame, this, &args); + if (proc->fn) { + args.fd = fd; + args.size = size; + args.offset = offset; + args.flags = flags; + args.xdata = xdata; + client_filter_o_direct(conf, &args.flags); + ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readv, frame, -1, ENOTCONN, NULL, 0, NULL, NULL, @@ -989,7 +844,7 @@ out: return 0; } -int32_t +static int32_t client_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, uint32_t flags, struct iobref *iobref, dict_t *xdata) @@ -1005,20 +860,19 @@ client_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.vector = vector; - args.count = count; - args.offset = off; - args.size = iov_length(vector, count); - args.flags = flags; - args.iobref = iobref; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_WRITE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.vector = vector; + args.count = count; + args.offset = off; + args.size = iov_length(vector, count); + args.flags = flags; + args.iobref = iobref; + args.xdata = xdata; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(writev, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1026,7 +880,7 @@ out: return 0; } -int32_t +static int32_t client_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; @@ -1040,12 +894,12 @@ client_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FLUSH]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(flush, frame, -1, ENOTCONN, NULL); @@ -1053,7 +907,7 @@ out: return 0; } -int32_t +static int32_t client_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata) { @@ -1068,13 +922,13 @@ client_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSYNC]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsync, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1082,7 +936,7 @@ out: return 0; } -int32_t +static int32_t client_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; @@ -1096,12 +950,12 @@ client_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSTAT]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fstat, frame, -1, ENOTCONN, NULL, NULL); @@ -1109,7 +963,7 @@ out: return 0; } -int32_t +static int32_t client_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, dict_t *xdata) { @@ -1124,13 +978,13 @@ client_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_OPENDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(opendir, frame, -1, ENOTCONN, NULL, NULL); @@ -1153,13 +1007,13 @@ client_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSYNCDIR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsyncdir, frame, -1, ENOTCONN, NULL); @@ -1167,7 +1021,7 @@ out: return 0; } -int32_t +static int32_t client_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -1181,12 +1035,12 @@ client_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_STATFS]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(statfs, frame, -1, ENOTCONN, NULL, NULL); @@ -1194,7 +1048,7 @@ out: return 0; } -int32_t +static int32_t client_copy_file_range(call_frame_t *frame, xlator_t *this, fd_t *fd_in, off_t off_in, fd_t *fd_out, off_t off_out, size_t len, uint32_t flags, dict_t *xdata) @@ -1210,17 +1064,17 @@ client_copy_file_range(call_frame_t *frame, xlator_t *this, fd_t *fd_in, if (!conf || !conf->fops) goto out; - args.fd = fd_in; - args.fd_out = fd_out; - args.offset = off_in; - args.off_out = off_out; - args.size = len; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_COPY_FILE_RANGE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd_in; + args.fd_out = fd_out; + args.offset = off_in; + args.off_out = off_out; + args.size = len; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(copy_file_range, frame, -1, ENOTCONN, NULL, NULL, @@ -1233,9 +1087,8 @@ static gf_boolean_t is_client_rpc_init_command(dict_t *dict, xlator_t *this, char **value) { gf_boolean_t ret = _gf_false; - int dict_ret = -1; - dict_ret = dict_get_str(dict, CLIENT_CMD_CONNECT, value); + int dict_ret = dict_get_str_sizen(dict, CLIENT_CMD_CONNECT, value); if (dict_ret) { gf_msg_trace(this->name, 0, "key %s not present", CLIENT_CMD_CONNECT); goto out; @@ -1259,7 +1112,7 @@ is_client_rpc_destroy_command(dict_t *dict, xlator_t *this) goto out; } - dict_ret = dict_get_str(dict, CLIENT_CMD_DISCONNECT, &dummy); + dict_ret = dict_get_str_sizen(dict, CLIENT_CMD_DISCONNECT, &dummy); if (dict_ret) { gf_msg_trace(this->name, 0, "key %s not present", CLIENT_CMD_DISCONNECT); @@ -1298,7 +1151,7 @@ client_set_remote_options(char *value, xlator_t *this) if (!host_dup) { goto out; } - ret = dict_set_dynstr(this->options, "remote-host", host_dup); + ret = dict_set_dynstr_sizen(this->options, "remote-host", host_dup); if (ret) { gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, "failed to set remote-host with %s", host); @@ -1313,7 +1166,8 @@ client_set_remote_options(char *value, xlator_t *this) goto out; } - ret = dict_set_dynstr(this->options, "remote-subvolume", subvol_dup); + ret = dict_set_dynstr_sizen(this->options, "remote-subvolume", + subvol_dup); if (ret) { gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, "failed to set remote-host with %s", host); @@ -1325,7 +1179,7 @@ client_set_remote_options(char *value, xlator_t *this) if (remote_port_str) { remote_port = atoi(remote_port_str); - ret = dict_set_int32(this->options, "remote-port", remote_port); + ret = dict_set_int32_sizen(this->options, "remote-port", remote_port); if (ret) { gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED, "failed to set remote-port to %d", remote_port); @@ -1340,7 +1194,7 @@ out: return ret; } -int32_t +static int32_t client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, int32_t flags, dict_t *xdata) { @@ -1387,13 +1241,12 @@ client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, goto out; } - args.loc = loc; - args.xattr = dict; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SETXATTR]; if (proc->fn) { + args.loc = loc; + args.xattr = dict; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); if (ret) { need_unwind = 1; @@ -1406,7 +1259,7 @@ out: return 0; } -int32_t +static int32_t client_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, int32_t flags, dict_t *xdata) { @@ -1421,14 +1274,14 @@ client_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xattr = dict; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSETXATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xattr = dict; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsetxattr, frame, -1, ENOTCONN, NULL); @@ -1436,7 +1289,7 @@ out: return 0; } -int32_t +static int32_t client_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, dict_t *xdata) { @@ -1451,13 +1304,13 @@ client_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.name = name; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FGETXATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.name = name; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fgetxattr, frame, -1, ENOTCONN, NULL, NULL); @@ -1465,7 +1318,7 @@ out: return 0; } -int32_t +static int32_t client_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, dict_t *xdata) { @@ -1480,13 +1333,13 @@ client_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.name = name; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_GETXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(getxattr, frame, -1, ENOTCONN, NULL, NULL); @@ -1494,7 +1347,7 @@ out: return 0; } -int32_t +static int32_t client_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { @@ -1509,14 +1362,14 @@ client_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.flags = flags; - args.xattr = dict; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_XATTROP]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.flags = flags; + args.xattr = dict; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(xattrop, frame, -1, ENOTCONN, NULL, NULL); @@ -1524,7 +1377,7 @@ out: return 0; } -int32_t +static int32_t client_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { @@ -1539,14 +1392,14 @@ client_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xattr = dict; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FXATTROP]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xattr = dict; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fxattrop, frame, -1, ENOTCONN, NULL, NULL); @@ -1554,7 +1407,7 @@ out: return 0; } -int32_t +static int32_t client_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, dict_t *xdata) { @@ -1569,13 +1422,13 @@ client_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.name = name; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_REMOVEXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(removexattr, frame, -1, ENOTCONN, NULL); @@ -1583,7 +1436,7 @@ out: return 0; } -int32_t +static int32_t client_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, dict_t *xdata) { @@ -1598,13 +1451,13 @@ client_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.name = name; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fremovexattr, frame, -1, ENOTCONN, NULL); @@ -1612,7 +1465,7 @@ out: return 0; } -int32_t +static int32_t client_lease(call_frame_t *frame, xlator_t *this, loc_t *loc, struct gf_lease *lease, dict_t *xdata) { @@ -1627,13 +1480,13 @@ client_lease(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.lease = lease; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LEASE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.lease = lease; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(lk, frame, -1, ENOTCONN, NULL, NULL); @@ -1641,7 +1494,7 @@ out: return 0; } -int32_t +static int32_t client_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1656,14 +1509,14 @@ client_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.cmd = cmd; - args.flock = lock; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.cmd = cmd; + args.flock = lock; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(lk, frame, -1, ENOTCONN, NULL, NULL); @@ -1671,7 +1524,7 @@ out: return 0; } -int32_t +static int32_t client_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1686,15 +1539,15 @@ client_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.cmd = cmd; - args.flock = lock; - args.volume = volume; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_INODELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.cmd = cmd; + args.flock = lock; + args.volume = volume; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(inodelk, frame, -1, ENOTCONN, NULL); @@ -1702,7 +1555,7 @@ out: return 0; } -int32_t +static int32_t client_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1717,15 +1570,15 @@ client_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.cmd = cmd; - args.flock = lock; - args.volume = volume; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FINODELK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.cmd = cmd; + args.flock = lock; + args.volume = volume; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(finodelk, frame, -1, ENOTCONN, NULL); @@ -1733,7 +1586,7 @@ out: return 0; } -int32_t +static int32_t client_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) @@ -1749,16 +1602,16 @@ client_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.basename = basename; - args.type = type; - args.volume = volume; - args.cmd_entrylk = cmd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ENTRYLK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.basename = basename; + args.type = type; + args.volume = volume; + args.cmd_entrylk = cmd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(entrylk, frame, -1, ENOTCONN, NULL); @@ -1766,7 +1619,7 @@ out: return 0; } -int32_t +static int32_t client_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) @@ -1782,16 +1635,16 @@ client_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.basename = basename; - args.type = type; - args.volume = volume; - args.cmd_entrylk = cmd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FENTRYLK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.basename = basename; + args.type = type; + args.volume = volume; + args.cmd_entrylk = cmd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fentrylk, frame, -1, ENOTCONN, NULL); @@ -1799,7 +1652,7 @@ out: return 0; } -int32_t +static int32_t client_rchecksum(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, int32_t len, dict_t *xdata) { @@ -1814,14 +1667,14 @@ client_rchecksum(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.len = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RCHECKSUM]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.len = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(rchecksum, frame, -1, ENOTCONN, 0, NULL, NULL); @@ -1844,17 +1697,17 @@ client_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - if (off != 0) - off = gf_dirent_orig_offset(this, off); - - args.fd = fd; - args.size = size; - args.offset = off; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_READDIR]; - if (proc->fn) + if (proc->fn) { + if (off != 0) + off = gf_dirent_orig_offset(this, off); + + args.fd = fd; + args.size = size; + args.offset = off; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readdir, frame, -1, ENOTCONN, NULL, NULL); @@ -1862,7 +1715,7 @@ out: return 0; } -int32_t +static int32_t client_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t off, dict_t *dict) { @@ -1877,17 +1730,17 @@ client_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - if (off != 0) - off = gf_dirent_orig_offset(this, off); - - args.fd = fd; - args.size = size; - args.offset = off; - args.xdata = dict; - proc = &conf->fops->proctable[GF_FOP_READDIRP]; - if (proc->fn) + if (proc->fn) { + if (off != 0) + off = gf_dirent_orig_offset(this, off); + + args.fd = fd; + args.size = size; + args.offset = off; + args.xdata = dict; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readdirp, frame, -1, ENOTCONN, NULL, NULL); @@ -1895,7 +1748,7 @@ out: return 0; } -int32_t +static int32_t client_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, int32_t valid, dict_t *xdata) { @@ -1910,14 +1763,14 @@ client_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.stbuf = stbuf; - args.valid = valid; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SETATTR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.stbuf = stbuf; + args.valid = valid; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(setattr, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1925,7 +1778,7 @@ out: return 0; } -int32_t +static int32_t client_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, int32_t valid, dict_t *xdata) { @@ -1940,14 +1793,14 @@ client_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.stbuf = stbuf; - args.valid = valid; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSETATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.stbuf = stbuf; + args.valid = valid; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsetattr, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1955,7 +1808,7 @@ out: return 0; } -int32_t +static int32_t client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, off_t offset, size_t len, dict_t *xdata) { @@ -1970,15 +1823,15 @@ client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = mode; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FALLOCATE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = mode; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fallocate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1986,7 +1839,7 @@ out: return 0; } -int32_t +static int32_t client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, size_t len, dict_t *xdata) { @@ -2001,14 +1854,14 @@ client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_DISCARD]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(discard, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -2016,7 +1869,7 @@ out: return 0; } -int32_t +static int32_t client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, off_t len, dict_t *xdata) { @@ -2031,14 +1884,14 @@ client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ZEROFILL]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(zerofill, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -2046,7 +1899,7 @@ out: return 0; } -int32_t +static int32_t client_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) { int ret = -1; @@ -2060,12 +1913,12 @@ client_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.cmd = op; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_IPC]; - if (proc->fn) + if (proc->fn) { + args.cmd = op; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(ipc, frame, -1, ENOTCONN, NULL); @@ -2073,7 +1926,7 @@ out: return 0; } -int32_t +static int32_t client_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, gf_seek_what_t what, dict_t *xdata) { @@ -2088,14 +1941,14 @@ client_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.what = what; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SEEK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.what = what; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(seek, frame, -1, ENOTCONN, 0, NULL); @@ -2103,7 +1956,7 @@ out: return 0; } -int32_t +static int32_t client_getactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { @@ -2118,12 +1971,12 @@ client_getactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_GETACTIVELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(getactivelk, frame, -1, ENOTCONN, NULL, NULL); @@ -2131,7 +1984,7 @@ out: return 0; } -int32_t +static int32_t client_setactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, lock_migration_info_t *locklist, dict_t *xdata) { @@ -2146,13 +1999,13 @@ client_setactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - args.locklist = locklist; - proc = &conf->fops->proctable[GF_FOP_SETACTIVELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; + args.locklist = locklist; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(setactivelk, frame, -1, ENOTCONN, NULL); @@ -2160,7 +2013,7 @@ out: return 0; } -int32_t +static int32_t client_getspec(call_frame_t *frame, xlator_t *this, const char *key, int32_t flags) { @@ -2175,12 +2028,11 @@ client_getspec(call_frame_t *frame, xlator_t *this, const char *key, if (!conf || !conf->fops || !conf->handshake) goto out; - args.name = key; - args.flags = flags; - /* For all other xlators, getspec is an fop, hence its in fops table */ proc = &conf->fops->proctable[GF_FOP_GETSPEC]; if (proc->fn) { + args.name = key; + args.flags = flags; /* But at protocol level, this is handshake */ ret = proc->fn(frame, this, &args); } @@ -2191,7 +2043,7 @@ out: return 0; } -int32_t +static int32_t client_compound(call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata) { int ret = -1; @@ -2203,11 +2055,11 @@ client_compound(call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata) if (!conf || !conf->fops) goto out; - args->xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_COMPOUND]; - if (proc->fn) + if (proc->fn) { + args->xdata = xdata; ret = proc->fn(frame, this, args); + } out: if (ret) STACK_UNWIND_STRICT(compound, frame, -1, ENOTCONN, NULL, NULL); @@ -2229,20 +2081,19 @@ client_namelink(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops || !conf->handshake) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_NAMELINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(namelink, frame, -1, EINVAL, NULL, NULL, NULL); return 0; } -int32_t +static int32_t client_icreate(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dict_t *xdata) { @@ -2257,21 +2108,20 @@ client_icreate(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops || !conf->handshake) goto out; - args.loc = loc; - args.mode = mode; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ICREATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.xdata = xdata; ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(icreate, frame, -1, EINVAL, NULL, NULL, NULL); return 0; } -int32_t +static int32_t client_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, mode_t umask, uint32_t flags, struct iovec *vector, int32_t count, off_t off, struct iobref *iobref, dict_t *xattr, dict_t *xdata) @@ -2287,23 +2137,23 @@ client_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.umask = umask; - args.flags = flags; - args.vector = vector; - args.count = count; - args.offset = off; - args.size = iov_length(vector, count); - args.iobref = iobref; - args.xattr = xattr; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_PUT]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.umask = umask; + args.flags = flags; + args.vector = vector; + args.count = count; + args.offset = off; + args.size = iov_length(vector, count); + args.iobref = iobref; + args.xattr = xattr; + args.xdata = xdata; + + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(put, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -2312,14 +2162,12 @@ out: return 0; } -int +static void client_mark_fd_bad(xlator_t *this) { - clnt_conf_t *conf = NULL; + clnt_conf_t *conf = this->private; clnt_fd_ctx_t *tmp = NULL, *fdctx = NULL; - conf = this->private; - pthread_spin_lock(&conf->fd_lock); { list_for_each_entry_safe(fdctx, tmp, &conf->saved_fds, sfd_pos) @@ -2328,8 +2176,6 @@ client_mark_fd_bad(xlator_t *this) } } pthread_spin_unlock(&conf->fd_lock); - - return 0; } static int @@ -2530,13 +2376,13 @@ notify(xlator_t *this, int32_t event, void *data, ...) return 0; } -int +static int client_check_remote_host(xlator_t *this, dict_t *options) { char *remote_host = NULL; int ret = -1; - ret = dict_get_str(options, "remote-host", &remote_host); + ret = dict_get_str_sizen(options, "remote-host", &remote_host); if (ret < 0) { gf_msg(this->name, GF_LOG_INFO, EINVAL, PC_MSG_DICT_GET_FAILED, "Remote host is not set. " @@ -2549,8 +2395,8 @@ client_check_remote_host(xlator_t *this, dict_t *options) goto out; } - ret = dict_set_str(options, "remote-host", - this->ctx->cmd_args.volfile_server); + ret = dict_set_str_sizen(options, "remote-host", + this->ctx->cmd_args.volfile_server); if (ret == -1) { gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_GET_FAILED, "Failed to set the " @@ -2564,14 +2410,11 @@ out: return ret; } -int +static int build_client_config(xlator_t *this, clnt_conf_t *conf) { int ret = -1; - if (!conf) - goto out; - GF_OPTION_INIT("frame-timeout", conf->rpc_conf.rpc_timeout, int32, out); GF_OPTION_INIT("remote-port", conf->rpc_conf.remote_port, int32, out); @@ -2620,7 +2463,7 @@ mem_acct_init(xlator_t *this) return ret; } -int +static int client_destroy_rpc(xlator_t *this) { int ret = -1; @@ -2648,7 +2491,7 @@ out: return ret; } -int +static int client_init_rpc(xlator_t *this) { int ret = -1; @@ -2695,7 +2538,7 @@ out: return ret; } -int +static int client_check_event_threads(xlator_t *this, clnt_conf_t *conf, int32_t old, int32_t new) { @@ -2740,10 +2583,12 @@ reconfigure(xlator_t *this, dict_t *options) if (ret) goto out; - subvol_ret = dict_get_str(this->options, "remote-host", &old_remote_host); + subvol_ret = dict_get_str_sizen(this->options, "remote-host", + &old_remote_host); if (subvol_ret == 0) { - subvol_ret = dict_get_str(options, "remote-host", &new_remote_host); + subvol_ret = dict_get_str_sizen(options, "remote-host", + &new_remote_host); if (subvol_ret == 0) { if (strcmp(old_remote_host, new_remote_host)) { ret = 1; @@ -2752,12 +2597,12 @@ reconfigure(xlator_t *this, dict_t *options) } } - subvol_ret = dict_get_str(this->options, "remote-subvolume", - &old_remote_subvol); + subvol_ret = dict_get_str_sizen(this->options, "remote-subvolume", + &old_remote_subvol); if (subvol_ret == 0) { - subvol_ret = dict_get_str(options, "remote-subvolume", - &new_remote_subvol); + subvol_ret = dict_get_str_sizen(options, "remote-subvolume", + &new_remote_subvol); if (subvol_ret == 0) { if (strcmp(old_remote_subvol, new_remote_subvol)) { ret = 1; @@ -2909,13 +2754,14 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) if (ret != 0) return; + gf_proc_dump_write("------", "------"); + + lock_no = 0; + ret = TRY_LOCK(&lk_ctx_ref->lock); if (ret) return; - gf_proc_dump_write("------", "------"); - - lock_no = 0; list_for_each_entry(plock, &lk_ctx_ref->lk_list, next) { snprintf(key, sizeof(key), "granted-posix-lock[%d]", lock_no++); @@ -2930,13 +2776,14 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) get_lk_type(plock->user_flock.l_type), plock->user_flock.l_start, plock->user_flock.l_len); } + UNLOCK(&lk_ctx_ref->lock); + gf_proc_dump_write("------", "------"); - UNLOCK(&lk_ctx_ref->lock); fd_lk_ctx_unref(lk_ctx_ref); } -int +static int client_priv_dump(xlator_t *this) { clnt_conf_t *conf = NULL; @@ -2954,15 +2801,15 @@ client_priv_dump(xlator_t *this) if (!conf) return -1; - ret = pthread_mutex_trylock(&conf->lock); - if (ret) - return -1; - gf_proc_dump_build_key(key_prefix, "xlator.protocol.client", "%s.priv", this->name); gf_proc_dump_add_section("%s", key_prefix); + ret = pthread_mutex_trylock(&conf->lock); + if (ret) + return -1; + pthread_spin_lock(&conf->fd_lock); list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) { diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 879a7d530d3..1f05fba444e 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -39,22 +39,18 @@ typedef enum { #define CLIENT_POST_FOP(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gf_common_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ + int _op_ret = _this_rsp->op_ret; \ + int _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ } while (0) #define CLIENT_POST_FOP_TYPE(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gfs3_##fop##_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ + int _op_ret = _this_rsp->op_ret; \ + int _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ } while (0) @@ -325,12 +321,6 @@ client_dump_locks(char *name, inode_t *inode, dict_t *dict); int client_fdctx_destroy(xlator_t *this, clnt_fd_ctx_t *fdctx); -int32_t -client_type_to_gf_type(short l_type); - -int -client_mark_fd_bad(xlator_t *this); - int client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock); void -- cgit