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/mount/fuse/src/fuse-bridge.c | 43 +++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'xlators/mount/fuse/src/fuse-bridge.c') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 4aee4963..fad62c22 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -2959,12 +2959,21 @@ fuse_listxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) void fuse_removexattr_resume (fuse_state_t *state) { - gf_log ("glusterfs-fuse", GF_LOG_TRACE, - "%"PRIu64": REMOVEXATTR %s/%"PRIu64" (%s)", state->finh->unique, - state->loc.path, state->finh->nodeid, state->name); + if (state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": REMOVEXATTR %p/%"PRIu64" (%s)", state->finh->unique, + state->fd, state->finh->nodeid, state->name); + + FUSE_FOP (state, fuse_err_cbk, GF_FOP_FREMOVEXATTR, + fremovexattr, state->fd, state->name); + } else { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": REMOVEXATTR %s/%"PRIu64" (%s)", state->finh->unique, + state->loc.path, state->finh->nodeid, state->name); - FUSE_FOP (state, fuse_err_cbk, GF_FOP_REMOVEXATTR, - removexattr, &state->loc, state->name); + FUSE_FOP (state, fuse_err_cbk, GF_FOP_REMOVEXATTR, + removexattr, &state->loc, state->name); + } } static void @@ -2982,17 +2991,27 @@ fuse_removexattr (xlator_t *this, fuse_in_header_t *finh, void *msg) GET_STATE (this, finh, state); ret = fuse_loc_fill (&state->loc, state, finh->nodeid, 0, NULL); - if ((state->loc.inode == NULL) || - (ret < 0)) { + if (!state->loc.inode) { gf_log ("glusterfs-fuse", GF_LOG_DEBUG, - "%"PRIu64": REMOVEXATTR %s/%"PRIu64" (%s) (fuse_loc_fill() failed)", - finh->unique, state->loc.path, finh->nodeid, name); + "%"PRIu64": REMOVEXATTR %s/%"PRIu64" (%s) " + "(fuse_loc_fill() failed (%d))", + finh->unique, state->loc.path, finh->nodeid, name, ret); send_fuse_err (this, finh, ENOENT); free_fuse_state (state); return; } + state->fd = fd_lookup (state->loc.inode, state->finh->pid); + if (!state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": REMOVEXATTR %"PRIu64" (fuse_loc_fill() failed)", + state->finh->unique, state->finh->nodeid); + send_fuse_err (state->this, state->finh, ENOENT); + free_fuse_state (state); + return; + } + ret = fuse_flip_xattr_ns (priv, name, &newkey); if (ret) { send_fuse_err (this, finh, ENOMEM); @@ -3001,8 +3020,10 @@ fuse_removexattr (xlator_t *this, fuse_in_header_t *finh, void *msg) } state->name = newkey; - uuid_copy (state->resolve.gfid, state->loc.inode->gfid); - state->resolve.path = gf_strdup (state->loc.path); + if (!state->fd) { + uuid_copy (state->resolve.gfid, state->loc.inode->gfid); + state->resolve.path = gf_strdup (state->loc.path); + } fuse_resolve_and_resume (state, fuse_removexattr_resume); return; -- cgit