From d7ecaaa1ed0f88869812ea17cb64a102a74c8c1c Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 17 Jan 2012 05:57:24 +0530 Subject: core: add 'fremovexattr()' fop so operations can be done on fd for extended attribute removal Change-Id: Ie026f1b53793aeb4ae33e96ea5408c7a97f34bf6 Signed-off-by: Amar Tumballi BUG: 766571 Reviewed-on: http://review.gluster.com/778 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/protocol/client/src/client.c | 33 +++++++++++ xlators/protocol/client/src/client3_1-fops.c | 84 ++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 8e823bec4e8..5f11987034d 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 d34ffc20031..0a89127b9a7 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -1039,6 +1039,44 @@ out: return 0; } +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 = { -- cgit