diff options
author | Amar Tumballi <amarts@redhat.com> | 2018-01-18 10:31:38 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2018-02-01 11:40:24 +0000 |
commit | d663b9a323f34919da3f35bfc221a0aa91d9ab94 (patch) | |
tree | 0753cdaf840826567d65cda6bfcef73510aad8fa /xlators/protocol/client | |
parent | ce9055449477dd59f29de213d140c60b03e465eb (diff) |
protocol: utilize the version 4 xdr
updates #384
Change-Id: Id80bf470988dbecc69779de9eb64088559cb1f6a
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/protocol/client')
-rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 264 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 67 | ||||
-rw-r--r-- | xlators/protocol/client/src/client-rpc-fops_v2.c | 102 |
3 files changed, 360 insertions, 73 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index fe6e923c077..def95c15cf9 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -655,6 +655,257 @@ protocol_client_reopen (clnt_fd_ctx_t *fdctx, xlator_t *this) protocol_client_reopenfile (fdctx, this); } +/* v4.x + */ +int +client4_0_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + int32_t ret = -1; + gfx_open_rsp rsp = {0,}; + clnt_local_t *local = NULL; + clnt_fd_ctx_t *fdctx = NULL; + call_frame_t *frame = NULL; + xlator_t *this = NULL; + + frame = myframe; + this = frame->this; + local = frame->local; + fdctx = local->fdctx; + + if (-1 == req->rpc_status) { + gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, + PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " + "returning ENOTCONN"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfx_open_rsp); + if (ret < 0) { + gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, + PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (rsp.op_ret < 0) { + gf_msg (frame->this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed.", + local->loc.path); + } else { + gf_msg_debug (frame->this->name, 0, + "reopen on %s succeeded (remote-fd = %"PRId64")", + local->loc.path, rsp.fd); + } + + if (rsp.op_ret == -1) { + ret = -1; + goto out; + } + + ret = 0; + +out: + fdctx->reopen_done (fdctx, (rsp.op_ret) ? -1 : rsp.fd, this); + + frame->local = NULL; + STACK_DESTROY (frame->root); + + client_local_wipe (local); + + return 0; +} + +int +client4_0_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + int32_t ret = -1; + gfx_open_rsp rsp = {0,}; + clnt_local_t *local = NULL; + clnt_fd_ctx_t *fdctx = NULL; + call_frame_t *frame = NULL; + + frame = myframe; + local = frame->local; + fdctx = local->fdctx; + + if (-1 == req->rpc_status) { + gf_msg (frame->this->name, GF_LOG_WARNING, ENOTCONN, + PC_MSG_RPC_STATUS_ERROR, "received RPC status error, " + "returning ENOTCONN"); + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfx_open_rsp); + if (ret < 0) { + gf_msg (frame->this->name, GF_LOG_ERROR, EINVAL, + PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (rsp.op_ret < 0) { + gf_msg (frame->this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_DIR_OP_FAILED, "reopendir on %s failed", + local->loc.path); + } else { + gf_msg (frame->this->name, GF_LOG_INFO, 0, + PC_MSG_DIR_OP_SUCCESS, "reopendir on %s succeeded " + "(fd = %"PRId64")", local->loc.path, rsp.fd); + } + + if (-1 == rsp.op_ret) { + ret = -1; + goto out; + } + +out: + fdctx->reopen_done (fdctx, (rsp.op_ret) ? -1 : rsp.fd, frame->this); + + frame->local = NULL; + STACK_DESTROY (frame->root); + client_local_wipe (local); + + return 0; +} + +static int +protocol_client_reopendir_v2 (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + int ret = -1; + gfx_opendir_req req = {{0,},}; + clnt_local_t *local = NULL; + call_frame_t *frame = NULL; + clnt_conf_t *conf = NULL; + + conf = this->private; + + local = mem_get0 (this->local_pool); + if (!local) { + ret = -1; + goto out; + } + local->fdctx = fdctx; + + gf_uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; + + frame = create_frame (this, this->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + + memcpy (req.gfid, fdctx->gfid, 16); + + gf_msg_debug (frame->this->name, 0, + "attempting reopen on %s", local->loc.path); + + frame->local = local; + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_OPENDIR, + client4_0_reopendir_cbk, NULL, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfx_opendir_req); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, + "failed to send the re-opendir request"); + } + + return 0; + +out: + if (local) + client_local_wipe (local); + + fdctx->reopen_done (fdctx, fdctx->remote_fd, this); + + return 0; + +} + +static int +protocol_client_reopenfile_v2 (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + int ret = -1; + gfx_open_req req = {{0,},}; + clnt_local_t *local = NULL; + call_frame_t *frame = NULL; + clnt_conf_t *conf = NULL; + + conf = this->private; + + 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; + } + + local->fdctx = fdctx; + gf_uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; + + frame->local = local; + + memcpy (req.gfid, fdctx->gfid, 16); + req.flags = gf_flags_from_flags (fdctx->flags); + req.flags = req.flags & (~(O_TRUNC|O_CREAT|O_EXCL)); + + gf_msg_debug (frame->this->name, 0, + "attempting reopen on %s", local->loc.path); + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_OPEN, client4_0_reopen_cbk, NULL, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfx_open_req); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, + "failed to send the re-open request"); + } + + return 0; + +out: + if (frame) { + frame->local = NULL; + STACK_DESTROY (frame->root); + } + + if (local) + client_local_wipe (local); + + fdctx->reopen_done (fdctx, fdctx->remote_fd, this); + + return 0; + +} + +static void +protocol_client_reopen_v2 (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + if (fdctx->is_dir) + protocol_client_reopendir_v2 (fdctx, this); + else + protocol_client_reopenfile_v2 (fdctx, this); +} + gf_boolean_t __is_fd_reopen_in_progress (clnt_fd_ctx_t *fdctx) { @@ -695,8 +946,12 @@ client_attempt_reopen (fd_t *fd, xlator_t *this) } unlock: pthread_spin_unlock (&conf->fd_lock); - if (reopen) - protocol_client_reopen (fdctx, this); + if (reopen) { + if (conf->fops->progver == GLUSTER_FOP_VERSION_v2) + protocol_client_reopen_v2 (fdctx, this); + else + protocol_client_reopen (fdctx, this); + } out: return; } @@ -743,7 +998,10 @@ client_post_handshake (call_frame_t *frame, xlator_t *this) list_for_each_entry_safe (fdctx, tmp, &reopen_head, sfd_pos) { list_del_init (&fdctx->sfd_pos); - protocol_client_reopen (fdctx, this); + if (conf->fops->progver == GLUSTER_FOP_VERSION_v2) + protocol_client_reopen_v2 (fdctx, this); + else + protocol_client_reopen (fdctx, this); } } else { gf_msg_debug (this->name, 0, diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 4279a32a054..03ca2172692 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -6356,70 +6356,3 @@ rpc_clnt_prog_t clnt3_3_fop_prog = { .proctable = clnt3_3_fop_actors, .procnames = clnt3_3_fop_names, }; - -rpc_clnt_procedure_t clnt4_0_fop_actors[GF_FOP_MAXVALUE] = { - [GF_FOP_NULL] = { "NULL", NULL}, - [GF_FOP_STAT] = { "STAT", client3_3_stat }, - [GF_FOP_READLINK] = { "READLINK", client3_3_readlink }, - [GF_FOP_MKNOD] = { "MKNOD", client3_3_mknod }, - [GF_FOP_MKDIR] = { "MKDIR", client3_3_mkdir }, - [GF_FOP_UNLINK] = { "UNLINK", client3_3_unlink }, - [GF_FOP_RMDIR] = { "RMDIR", client3_3_rmdir }, - [GF_FOP_SYMLINK] = { "SYMLINK", client3_3_symlink }, - [GF_FOP_RENAME] = { "RENAME", client3_3_rename }, - [GF_FOP_LINK] = { "LINK", client3_3_link }, - [GF_FOP_TRUNCATE] = { "TRUNCATE", client3_3_truncate }, - [GF_FOP_OPEN] = { "OPEN", client3_3_open }, - [GF_FOP_READ] = { "READ", client3_3_readv }, - [GF_FOP_WRITE] = { "WRITE", client3_3_writev }, - [GF_FOP_STATFS] = { "STATFS", client3_3_statfs }, - [GF_FOP_FLUSH] = { "FLUSH", client3_3_flush }, - [GF_FOP_FSYNC] = { "FSYNC", client3_3_fsync }, - [GF_FOP_SETXATTR] = { "SETXATTR", client3_3_setxattr }, - [GF_FOP_GETXATTR] = { "GETXATTR", client3_3_getxattr }, - [GF_FOP_REMOVEXATTR] = { "REMOVEXATTR", client3_3_removexattr }, - [GF_FOP_OPENDIR] = { "OPENDIR", client3_3_opendir }, - [GF_FOP_FSYNCDIR] = { "FSYNCDIR", client3_3_fsyncdir }, - [GF_FOP_ACCESS] = { "ACCESS", client3_3_access }, - [GF_FOP_CREATE] = { "CREATE", client3_3_create }, - [GF_FOP_FTRUNCATE] = { "FTRUNCATE", client3_3_ftruncate }, - [GF_FOP_FSTAT] = { "FSTAT", client3_3_fstat }, - [GF_FOP_LK] = { "LK", client3_3_lk }, - [GF_FOP_LOOKUP] = { "LOOKUP", client3_3_lookup }, - [GF_FOP_READDIR] = { "READDIR", client3_3_readdir }, - [GF_FOP_INODELK] = { "INODELK", client3_3_inodelk }, - [GF_FOP_FINODELK] = { "FINODELK", client3_3_finodelk }, - [GF_FOP_ENTRYLK] = { "ENTRYLK", client3_3_entrylk }, - [GF_FOP_FENTRYLK] = { "FENTRYLK", client3_3_fentrylk }, - [GF_FOP_XATTROP] = { "XATTROP", client3_3_xattrop }, - [GF_FOP_FXATTROP] = { "FXATTROP", client3_3_fxattrop }, - [GF_FOP_FGETXATTR] = { "FGETXATTR", client3_3_fgetxattr }, - [GF_FOP_FSETXATTR] = { "FSETXATTR", client3_3_fsetxattr }, - [GF_FOP_RCHECKSUM] = { "RCHECKSUM", client3_3_rchecksum }, - [GF_FOP_SETATTR] = { "SETATTR", client3_3_setattr }, - [GF_FOP_FSETATTR] = { "FSETATTR", client3_3_fsetattr }, - [GF_FOP_READDIRP] = { "READDIRP", client3_3_readdirp }, - [GF_FOP_FALLOCATE] = { "FALLOCATE", client3_3_fallocate }, - [GF_FOP_DISCARD] = { "DISCARD", client3_3_discard }, - [GF_FOP_ZEROFILL] = { "ZEROFILL", client3_3_zerofill}, - [GF_FOP_RELEASE] = { "RELEASE", client3_3_release }, - [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_3_releasedir }, - [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, - [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client3_3_fremovexattr }, - [GF_FOP_IPC] = { "IPC", client3_3_ipc }, - [GF_FOP_SEEK] = { "SEEK", client3_3_seek }, - [GF_FOP_LEASE] = { "LEASE", client3_3_lease }, - [GF_FOP_GETACTIVELK] = { "GETACTIVELK", client3_3_getactivelk}, - [GF_FOP_SETACTIVELK] = { "SETACTIVELK", client3_3_setactivelk}, - [GF_FOP_COMPOUND] = { "COMPOUND", client3_3_compound }, -}; - - -rpc_clnt_prog_t clnt4_0_fop_prog = { - .progname = "GlusterFS 4.x v1", - .prognum = GLUSTER_FOP_PROGRAM, - .progver = GLUSTER_FOP_VERSION_v2, - .numproc = GLUSTER_FOP_PROCCNT, - .proctable = clnt4_0_fop_actors, - .procnames = clnt3_3_fop_names, -}; diff --git a/xlators/protocol/client/src/client-rpc-fops_v2.c b/xlators/protocol/client/src/client-rpc-fops_v2.c index 4471825c470..aad1666096b 100644 --- a/xlators/protocol/client/src/client-rpc-fops_v2.c +++ b/xlators/protocol/client/src/client-rpc-fops_v2.c @@ -20,6 +20,8 @@ extern int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data); +extern int32_t +client3_3_getxattr (call_frame_t *frame, xlator_t *this, void *data); extern int client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, @@ -891,6 +893,12 @@ out: loc_gfid_utoa (&local->loc), (local->name) ? local->name : "(null)"); } + } else { + /* This is required as many places, `if (ret)` is checked + for syncop_getxattr() */ + gf_msg_debug (this->name, 0, "resetting op_ret to 0 from %d", + rsp.op_ret); + rsp.op_ret = 0; } CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict, xdata); @@ -952,6 +960,12 @@ out: PC_MSG_REMOTE_OP_FAILED, "remote operation " "failed"); } + } else { + /* This is required as many places, `if (ret)` is checked + for syncop_fgetxattr() */ + gf_msg_debug (this->name, 0, "resetting op_ret to 0 from %d", + rsp.op_ret); + rsp.op_ret = 0; } CLIENT_STACK_UNWIND (fgetxattr, frame, rsp.op_ret, op_errno, dict, xdata); @@ -1488,6 +1502,12 @@ out: PC_MSG_REMOTE_OP_FAILED, "remote operation failed. " "Path: %s (%s)", local->loc.path, loc_gfid_utoa (&local->loc)); + } else { + /* This is required as many places, `if (ret)` is checked + for syncop_xattrop() */ + gf_msg_debug (this->name, 0, "resetting op_ret to 0 from %d", + rsp.op_ret); + rsp.op_ret = 0; } CLIENT_STACK_UNWIND (xattrop, frame, rsp.op_ret, @@ -1548,10 +1568,17 @@ out: gf_error_to_errno (rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); - } else if (rsp.op_ret == 0) { + } else { + /* This is required as many places, `if (ret)` is checked + for syncop_fxattrop() */ + gf_msg_debug (this->name, 0, "resetting op_ret to 0 from %d", + rsp.op_ret); + rsp.op_ret = 0; + if (local->attempt_reopen) client_attempt_reopen (local->fd, this); } + CLIENT_STACK_UNWIND (fxattrop, frame, rsp.op_ret, gf_error_to_errno (op_errno), dict, xdata); if (xdata) @@ -5542,7 +5569,7 @@ out: } int32_t -client4_namelink (call_frame_t *frame, xlator_t *this, void *data) +client4_0_namelink (call_frame_t *frame, xlator_t *this, void *data) { int32_t ret = 0; int32_t op_errno = EINVAL; @@ -5588,7 +5615,7 @@ client4_namelink (call_frame_t *frame, xlator_t *this, void *data) } int32_t -client4_icreate (call_frame_t *frame, xlator_t *this, void *data) +client4_0_icreate (call_frame_t *frame, xlator_t *this, void *data) { int32_t ret = 0; int32_t op_errno = EINVAL; @@ -6055,3 +6082,72 @@ char *clnt4_0_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_ICREATE] = "ICREATE", [GFS3_OP_NAMELINK] = "NAMELINK", }; + +rpc_clnt_procedure_t clnt4_0_fop_actors[GF_FOP_MAXVALUE] = { + [GF_FOP_NULL] = { "NULL", NULL}, + [GF_FOP_STAT] = { "STAT", client4_0_stat }, + [GF_FOP_READLINK] = { "READLINK", client4_0_readlink }, + [GF_FOP_MKNOD] = { "MKNOD", client4_0_mknod }, + [GF_FOP_MKDIR] = { "MKDIR", client4_0_mkdir }, + [GF_FOP_UNLINK] = { "UNLINK", client4_0_unlink }, + [GF_FOP_RMDIR] = { "RMDIR", client4_0_rmdir }, + [GF_FOP_SYMLINK] = { "SYMLINK", client4_0_symlink }, + [GF_FOP_RENAME] = { "RENAME", client4_0_rename }, + [GF_FOP_LINK] = { "LINK", client4_0_link }, + [GF_FOP_TRUNCATE] = { "TRUNCATE", client4_0_truncate }, + [GF_FOP_OPEN] = { "OPEN", client4_0_open }, + [GF_FOP_READ] = { "READ", client4_0_readv }, + [GF_FOP_WRITE] = { "WRITE", client4_0_writev }, + [GF_FOP_STATFS] = { "STATFS", client4_0_statfs }, + [GF_FOP_FLUSH] = { "FLUSH", client4_0_flush }, + [GF_FOP_FSYNC] = { "FSYNC", client4_0_fsync }, + [GF_FOP_GETXATTR] = { "GETXATTR", client4_0_getxattr }, + [GF_FOP_SETXATTR] = { "SETXATTR", client4_0_setxattr }, + [GF_FOP_REMOVEXATTR] = { "REMOVEXATTR", client4_0_removexattr }, + [GF_FOP_OPENDIR] = { "OPENDIR", client4_0_opendir }, + [GF_FOP_FSYNCDIR] = { "FSYNCDIR", client4_0_fsyncdir }, + [GF_FOP_ACCESS] = { "ACCESS", client4_0_access }, + [GF_FOP_CREATE] = { "CREATE", client4_0_create }, + [GF_FOP_FTRUNCATE] = { "FTRUNCATE", client4_0_ftruncate }, + [GF_FOP_FSTAT] = { "FSTAT", client4_0_fstat }, + [GF_FOP_LK] = { "LK", client4_0_lk }, + [GF_FOP_LOOKUP] = { "LOOKUP", client4_0_lookup }, + [GF_FOP_READDIR] = { "READDIR", client4_0_readdir }, + [GF_FOP_INODELK] = { "INODELK", client4_0_inodelk }, + [GF_FOP_FINODELK] = { "FINODELK", client4_0_finodelk }, + [GF_FOP_ENTRYLK] = { "ENTRYLK", client4_0_entrylk }, + [GF_FOP_FENTRYLK] = { "FENTRYLK", client4_0_fentrylk }, + [GF_FOP_XATTROP] = { "XATTROP", client4_0_xattrop }, + [GF_FOP_FXATTROP] = { "FXATTROP", client4_0_fxattrop }, + [GF_FOP_FGETXATTR] = { "FGETXATTR", client4_0_fgetxattr }, + [GF_FOP_FSETXATTR] = { "FSETXATTR", client4_0_fsetxattr }, + [GF_FOP_RCHECKSUM] = { "RCHECKSUM", client4_0_rchecksum }, + [GF_FOP_SETATTR] = { "SETATTR", client4_0_setattr }, + [GF_FOP_FSETATTR] = { "FSETATTR", client4_0_fsetattr }, + [GF_FOP_READDIRP] = { "READDIRP", client4_0_readdirp }, + [GF_FOP_FALLOCATE] = { "FALLOCATE", client4_0_fallocate }, + [GF_FOP_DISCARD] = { "DISCARD", client4_0_discard }, + [GF_FOP_ZEROFILL] = { "ZEROFILL", client4_0_zerofill}, + [GF_FOP_RELEASE] = { "RELEASE", client4_0_release }, + [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client4_0_releasedir }, + [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, + [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client4_0_fremovexattr }, + [GF_FOP_IPC] = { "IPC", client4_0_ipc }, + [GF_FOP_SEEK] = { "SEEK", client4_0_seek }, + [GF_FOP_LEASE] = { "LEASE", client4_0_lease }, + [GF_FOP_GETACTIVELK] = { "GETACTIVELK", client4_0_getactivelk }, + [GF_FOP_SETACTIVELK] = { "SETACTIVELK", client4_0_setactivelk }, + [GF_FOP_COMPOUND] = { "COMPOUND", client4_0_compound }, + [GF_FOP_ICREATE] = { "ICREATE", client4_0_icreate }, + [GF_FOP_NAMELINK] = { "NAMELINK", client4_0_namelink }, +}; + + +rpc_clnt_prog_t clnt4_0_fop_prog = { + .progname = "GlusterFS 4.x v1", + .prognum = GLUSTER_FOP_PROGRAM, + .progver = GLUSTER_FOP_VERSION_v2, + .numproc = GLUSTER_FOP_PROCCNT, + .proctable = clnt4_0_fop_actors, + .procnames = clnt4_0_fop_names, +}; |