diff options
Diffstat (limited to 'xlators/protocol')
-rw-r--r-- | xlators/protocol/client/src/client.c | 33 | ||||
-rw-r--r-- | xlators/protocol/client/src/client3_1-fops.c | 84 | ||||
-rw-r--r-- | xlators/protocol/server/src/server3_1-fops.c | 94 |
3 files changed, 211 insertions, 0 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 8e823bec4..5f1198703 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1421,6 +1421,38 @@ out: return 0; } +int32_t +client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name) +{ + int ret = -1; + clnt_conf_t *conf = NULL; + rpc_clnt_procedure_t *proc = NULL; + clnt_args_t args = {0,}; + + conf = this->private; + if (!conf || !conf->fops) + goto out; + + args.name = name; + args.fd = fd; + + proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_FREMOVEXATTR]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT (fremovexattr, frame, -1, ENOTCONN); + + return 0; +} + int32_t client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, @@ -2303,6 +2335,7 @@ struct xlator_fops fops = { .fsetxattr = client_fsetxattr, .fgetxattr = client_fgetxattr, .removexattr = client_removexattr, + .fremovexattr = client_fremovexattr, .opendir = client_opendir, .readdir = client_readdir, .readdirp = client_readdirp, diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index d34ffc200..0a89127b9 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -1040,6 +1040,44 @@ out: } int +client3_1_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gf_common_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + + this = THIS; + + frame = myframe; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + STACK_UNWIND_STRICT (fremovexattr, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno)); + + return 0; +} + +int client3_1_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { @@ -4582,6 +4620,50 @@ unwind: return 0; } +int32_t +client3_1_fremovexattr (call_frame_t *frame, xlator_t *this, + void *data) +{ + clnt_conf_t *conf = NULL; + clnt_args_t *args = NULL; + gfs3_fremovexattr_req req = {{0,},}; + int ret = 0; + int64_t remote_fd = -1; + int op_errno = ESTALE; + + if (!frame || !this || !data) + goto unwind; + + args = data; + + if (!(args->fd && args->fd->inode)) + goto unwind; + + CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, unwind); + + memcpy (req.gfid, args->fd->inode->gfid, 16); + req.name = (char *)args->name; + req.fd = remote_fd; + + conf = this->private; + + ret = client_submit_request (this, &req, frame, conf->fops, + GFS3_OP_FREMOVEXATTR, + client3_1_fremovexattr_cbk, NULL, + NULL, 0, NULL, 0, NULL, + (xdrproc_t)xdr_gfs3_fremovexattr_req); + if (ret) { + op_errno = ENOTCONN; + goto unwind; + } + + return 0; +unwind: + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno)); + STACK_UNWIND_STRICT (fremovexattr, frame, -1, op_errno); + return 0; +} + int32_t client3_1_lk (call_frame_t *frame, xlator_t *this, @@ -5308,6 +5390,7 @@ rpc_clnt_procedure_t clnt3_1_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_RELEASE] = { "RELEASE", client3_1_release }, [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_1_releasedir }, [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, + [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client3_1_fremovexattr }, }; /* Used From RPC-CLNT library to log proper name of procedure based on number */ @@ -5355,6 +5438,7 @@ char *clnt3_1_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_READDIRP] = "READDIRP", [GFS3_OP_RELEASE] = "RELEASE", [GFS3_OP_RELEASEDIR] = "RELEASEDIR", + [GFS3_OP_FREMOVEXATTR] = "FREMOVEXATTR", }; rpc_clnt_prog_t clnt3_1_fop_prog = { diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c index 482c242d5..79aede074 100644 --- a/xlators/protocol/server/src/server3_1-fops.c +++ b/xlators/protocol/server/src/server3_1-fops.c @@ -692,6 +692,33 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } int +server_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + gf_common_rsp rsp = {0,}; + rpcsvc_request_t *req = NULL; + server_state_t *state = NULL; + + req = frame->local; + state = CALL_STATE(frame); + + rsp.op_ret = op_ret; + rsp.op_errno = gf_errno_to_error (op_errno); + if (op_ret == -1) + gf_log (this->name, GF_LOG_INFO, + "%"PRId64": FREMOVEXATTR (%s) ==> %"PRId32" (%s)", + frame->root->unique, ((state->fd->inode) ? + uuid_utoa (state->fd->inode->gfid) : + "--"), + op_ret, strerror (op_errno)); + + server_submit_reply (frame, req, &rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gf_common_rsp); + + return 0; +} + +int server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict) { @@ -2211,6 +2238,26 @@ err: } int +server_fremovexattr_resume (call_frame_t *frame, xlator_t *bound_xl) +{ + server_state_t *state = NULL; + + state = CALL_STATE (frame); + + if (state->resolve.op_ret != 0) + goto err; + + STACK_WIND (frame, server_fremovexattr_cbk, + bound_xl, bound_xl->fops->fremovexattr, + state->fd, state->name); + return 0; +err: + server_fremovexattr_cbk (frame, NULL, frame->this, state->resolve.op_ret, + state->resolve.op_errno); + return 0; +} + +int server_fgetxattr_resume (call_frame_t *frame, xlator_t *bound_xl) { server_state_t *state = NULL; @@ -3932,6 +3979,52 @@ out: return ret; } +int +server_fremovexattr (rpcsvc_request_t *req) +{ + server_state_t *state = NULL; + call_frame_t *frame = NULL; + gfs3_fremovexattr_req args = {{0,},}; + int ret = -1; + + if (!req) + return ret; + + args.name = alloca (4096); + + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_gfs3_fremovexattr_req)) { + //failed to decode msg; + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + frame = get_frame_from_request (req); + if (!frame) { + // something wrong, mostly insufficient memory + req->rpc_err = GARBAGE_ARGS; /* TODO */ + goto out; + } + frame->root->op = GF_FOP_FREMOVEXATTR; + + state = CALL_STATE (frame); + if (!state->conn->bound_xl) { + /* auth failure, request on subvolume without setvolume */ + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + state->resolve.type = RESOLVE_MUST; + state->resolve.fd_no = args.fd; + memcpy (state->resolve.gfid, args.gfid, 16); + state->name = gf_strdup (args.name); + + ret = 0; + resolve_and_resume (frame, server_fremovexattr_resume); +out: + return ret; +} + @@ -5223,6 +5316,7 @@ rpcsvc_actor_t glusterfs3_1_fop_actors[] = { [GFS3_OP_READDIRP] = { "READDIRP", GFS3_OP_READDIRP, server_readdirp, NULL, NULL, 0}, [GFS3_OP_RELEASE] = { "RELEASE", GFS3_OP_RELEASE, server_release, NULL, NULL, 0}, [GFS3_OP_RELEASEDIR] = { "RELEASEDIR", GFS3_OP_RELEASEDIR, server_releasedir, NULL, NULL, 0}, + [GFS3_OP_FREMOVEXATTR] = { "FREMOVEXATTR", GFS3_OP_FREMOVEXATTR, server_fremovexattr, NULL, NULL, 0}, }; |