summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-09-11 17:53:39 +0300
committerAmar Tumballi <amarts@gmail.com>2019-10-11 04:00:19 +0000
commit9cfaef0960d206a554035000141935cc0fcf39e5 (patch)
tree83ddc52b5232791f946cc254e0920ce2d10eed0b /xlators/protocol/client/src/client.c
parent0a9ca8162725b2f6b17a4d2e8cc863d27bb8770e (diff)
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 <ykaul@redhat.com>
Diffstat (limited to 'xlators/protocol/client/src/client.c')
-rw-r--r--xlators/protocol/client/src/client.c1001
1 files changed, 424 insertions, 577 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index e8b5cd8..ee5a599 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)
{