diff options
-rw-r--r-- | libglusterfs/src/syncop.c | 29 | ||||
-rw-r--r-- | libglusterfs/src/syncop.h | 1 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-inode-read.c | 131 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-inode-read.h | 4 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-inode-write.c | 9 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 1 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr.h | 2 | ||||
-rw-r--r-- | xlators/cluster/afr/src/pump.c | 2 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 61 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht.c | 1 | ||||
-rw-r--r-- | xlators/debug/error-gen/src/error-gen.c | 129 | ||||
-rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 76 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 174 |
13 files changed, 569 insertions, 51 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index cb3b67ce79f..86b4822c59d 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -532,6 +532,35 @@ syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags) } int +syncop_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + __wake (args); + + return 0; +} + + +int +syncop_fsetxattr (xlator_t *subvol, fd_t *fd, dict_t *dict, int32_t flags) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_fsetxattr_cbk, subvol->fops->fsetxattr, + fd, dict, flags); + + errno = args.op_errno; + return args.op_ret; +} + +int syncop_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, dict_t *dict) { diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index 57567426dab..7f696f17723 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -182,6 +182,7 @@ int syncop_fsetattr (xlator_t *subvol, fd_t *fd, struct iatt *iatt, int valid, int syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf); int syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags); +int syncop_fsetxattr (xlator_t *subvol, fd_t *fd, dict_t *dict, int32_t flags); int syncop_listxattr (xlator_t *subvol, loc_t *loc, dict_t **dict); int syncop_getxattr (xlator_t *xl, loc_t *loc, dict_t **dict, const char *key); int syncop_fgetxattr (xlator_t *xl, fd_t *fd, dict_t **dict, const char *key); diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c index 162c7eed47b..5b534cf3742 100644 --- a/xlators/cluster/afr/src/afr-inode-read.c +++ b/xlators/cluster/afr/src/afr-inode-read.c @@ -890,6 +890,137 @@ out: return 0; } +/* {{{ fgetxattr */ + + +int32_t +afr_fgetxattr_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno, + dict_t *dict) +{ + afr_private_t * priv = NULL; + afr_local_t * local = NULL; + xlator_t ** children = NULL; + int unwind = 1; + int32_t *last_index = NULL; + int32_t next_call_child = -1; + int32_t read_child = -1; + int32_t *fresh_children = NULL; + + priv = this->private; + children = priv->children; + + local = frame->local; + + read_child = (long) cookie; + + if (op_ret == -1) { + last_index = &local->cont.getxattr.last_index; + fresh_children = local->fresh_children; + next_call_child = afr_next_call_child (fresh_children, + local->child_up, + priv->child_count, + last_index, read_child); + if (next_call_child < 0) + goto out; + + unwind = 0; + STACK_WIND_COOKIE (frame, afr_fgetxattr_cbk, + (void *) (long) read_child, + children[next_call_child], + children[next_call_child]->fops->fgetxattr, + local->fd, + local->cont.getxattr.name); + } + +out: + if (unwind) { + if (op_ret >= 0 && dict) + __filter_xattrs (dict); + + AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict); + } + + return 0; +} + +int32_t +afr_fgetxattr_unwind (call_frame_t *frame, + int op_ret, int op_errno, dict_t *dict) + +{ + AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, dict); + return 0; +} + +int32_t +afr_fgetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name) +{ + afr_private_t *priv = NULL; + xlator_t **children = NULL; + int call_child = 0; + afr_local_t *local = NULL; + int32_t op_ret = -1; + int32_t op_errno = 0; + int32_t read_child = -1; + + + VALIDATE_OR_GOTO (frame, out); + VALIDATE_OR_GOTO (this, out); + VALIDATE_OR_GOTO (this->private, out); + + priv = this->private; + VALIDATE_OR_GOTO (priv->children, out); + + children = priv->children; + + ALLOC_OR_GOTO (local, afr_local_t, out); + frame->local = local; + + op_ret = afr_local_init (local, priv, &op_errno); + if (op_ret < 0) { + op_errno = -op_ret; + goto out; + } + + local->fd = fd_ref (fd); + if (name) + local->cont.getxattr.name = gf_strdup (name); + + /* pathinfo gets handled only in getxattr() */ + + local->fresh_children = afr_children_create (priv->child_count); + if (!local->fresh_children) { + op_errno = ENOMEM; + goto out; + } + + read_child = afr_inode_get_read_ctx (this, fd->inode, local->fresh_children); + op_ret = afr_get_call_child (this, local->child_up, read_child, + local->fresh_children, + &call_child, + &local->cont.getxattr.last_index); + if (op_ret < 0) { + op_errno = -op_ret; + op_ret = -1; + goto out; + } + + STACK_WIND_COOKIE (frame, afr_fgetxattr_cbk, + (void *) (long) call_child, + children[call_child], + children[call_child]->fops->fgetxattr, + fd, name); + + op_ret = 0; +out: + if (op_ret == -1) { + AFR_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, NULL); + } + return 0; +} + /* }}} */ diff --git a/xlators/cluster/afr/src/afr-inode-read.h b/xlators/cluster/afr/src/afr-inode-read.h index 5479cfbd562..8af3ed1b503 100644 --- a/xlators/cluster/afr/src/afr-inode-read.h +++ b/xlators/cluster/afr/src/afr-inode-read.h @@ -44,4 +44,8 @@ int32_t afr_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name); +int32_t +afr_fgetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name); + #endif /* __INODE_READ_H__ */ diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c index bd7746df347..2a7e0e736a5 100644 --- a/xlators/cluster/afr/src/afr-inode-write.c +++ b/xlators/cluster/afr/src/afr-inode-write.c @@ -1716,6 +1716,7 @@ out: /* }}} */ + /* {{{ removexattr */ @@ -1737,8 +1738,8 @@ afr_removexattr_unwind (call_frame_t *frame, xlator_t *this) if (main_frame) { AFR_STACK_UNWIND (removexattr, main_frame, - local->op_ret, local->op_errno) - } + local->op_ret, local->op_errno); + } return 0; } @@ -1913,8 +1914,8 @@ afr_fremovexattr_unwind (call_frame_t *frame, xlator_t *this) if (main_frame) { AFR_STACK_UNWIND (fremovexattr, main_frame, - local->op_ret, local->op_errno) - } + local->op_ret, local->op_errno); + } return 0; } diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index efb1742ea7e..18cd030f1d4 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -389,6 +389,7 @@ struct xlator_fops fops = { .fstat = afr_fstat, .readlink = afr_readlink, .getxattr = afr_getxattr, + .fgetxattr = afr_fgetxattr, .readv = afr_readv, /* inode write */ diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index 889828a6fa6..de25a2d465d 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -868,7 +868,7 @@ afr_launch_openfd_self_heal (call_frame_t *frame, xlator_t *this, fd_t *fd); STACK_UNWIND_STRICT (fop, frame, params); \ afr_local_cleanup (__local, __this); \ GF_FREE (__local); \ - } while (0); + } while (0) #define AFR_STACK_DESTROY(frame) \ do { \ diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c index 357aa9f295f..8ef30edbaf4 100644 --- a/xlators/cluster/afr/src/pump.c +++ b/xlators/cluster/afr/src/pump.c @@ -1471,7 +1471,7 @@ afr_setxattr_unwind (call_frame_t *frame, xlator_t *this) if (main_frame) { AFR_STACK_UNWIND (setxattr, main_frame, - local->op_ret, local->op_errno) + local->op_ret, local->op_errno); } return 0; } diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index c26ff95974d..29b3dca83e5 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1946,6 +1946,67 @@ err: } int +dht_fgetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *key) +{ + xlator_t *subvol = NULL; + dht_local_t *local = NULL; + dht_layout_t *layout = NULL; + int op_errno = -1; + int i = 0; + int cnt = 0; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (fd, err); + VALIDATE_OR_GOTO (fd->inode, err); + VALIDATE_OR_GOTO (this->private, err); + + local = dht_local_init (frame, NULL, fd, GF_FOP_FGETXATTR); + if (!local) { + op_errno = ENOMEM; + + goto err; + } + + layout = local->layout; + if (!layout) { + gf_log (this->name, GF_LOG_ERROR, + "layout is NULL"); + op_errno = ENOENT; + goto err; + } + + if (key) { + local->key = gf_strdup (key); + if (!local->key) { + op_errno = ENOMEM; + goto err; + } + } + + if (fd->inode->ia_type == IA_IFDIR) { + cnt = local->call_cnt = layout->cnt; + } else { + cnt = local->call_cnt = 1; + } + + for (i = 0; i < cnt; i++) { + subvol = layout->list[i].xlator; + STACK_WIND (frame, dht_getxattr_cbk, + subvol, subvol->fops->fgetxattr, + fd, key); + } + return 0; + +err: + op_errno = (op_errno == -1) ? errno : op_errno; + DHT_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL); + + return 0; +} + +int dht_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xattr, int flags) { diff --git a/xlators/cluster/dht/src/dht.c b/xlators/cluster/dht/src/dht.c index ca79910d30b..18fee7cd3c6 100644 --- a/xlators/cluster/dht/src/dht.c +++ b/xlators/cluster/dht/src/dht.c @@ -478,6 +478,7 @@ struct xlator_fops fops = { .access = dht_access, .readlink = dht_readlink, .getxattr = dht_getxattr, + .fgetxattr = dht_fgetxattr, .readv = dht_readv, .flush = dht_flush, .fsync = dht_fsync, diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index 7e776332f09..ca2ce488fa9 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -113,6 +113,15 @@ sys_error_t error_no_list[] = { [GF_FOP_REMOVEXATTR] = { .error_no_count = 4, .error_no = {EACCES,EBADF,ENAMETOOLONG, EINTR}}, + [GF_FOP_FSETXATTR] = { .error_no_count = 4, + .error_no = {EACCES,EBADF,EINTR, + ENAMETOOLONG}}, + [GF_FOP_FGETXATTR] = { .error_no_count = 4, + .error_no = {EACCES,EBADF,ENAMETOOLONG, + EINTR}}, + [GF_FOP_FREMOVEXATTR] = { .error_no_count = 4, + .error_no = {EACCES,EBADF,ENAMETOOLONG, + EINTR}}, [GF_FOP_OPENDIR] = { .error_no_count = 8, .error_no = {EACCES,EEXIST,EFAULT, EISDIR,EMFILE, @@ -286,6 +295,12 @@ get_fop_int (char **op_no_str) return GF_FOP_GETXATTR; else if (!strcmp ((*op_no_str), "removexattr")) return GF_FOP_REMOVEXATTR; + else if (!strcmp ((*op_no_str), "fsetxattr")) + return GF_FOP_FSETXATTR; + else if (!strcmp ((*op_no_str), "fgetxattr")) + return GF_FOP_FGETXATTR; + else if (!strcmp ((*op_no_str), "fremovexattr")) + return GF_FOP_FREMOVEXATTR; else if (!strcmp ((*op_no_str), "opendir")) return GF_FOP_OPENDIR; else if (!strcmp ((*op_no_str), "readdir")) @@ -1410,6 +1425,80 @@ error_gen_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, return 0; } +int +error_gen_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno); + + return 0; +} + + +int +error_gen_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + dict_t *dict, int32_t flags) +{ + int op_errno = 0; + eg_t *egp = NULL; + int enable = 1; + + egp = this->private; + enable = egp->enable[GF_FOP_FSETXATTR]; + + if (enable) + op_errno = error_gen (this, GF_FOP_FSETXATTR); + + if (op_errno) { + GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno)); + STACK_UNWIND_STRICT (fsetxattr, frame, -1, op_errno); + return 0; + } + + STACK_WIND (frame, error_gen_fsetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetxattr, + fd, dict, flags); + return 0; +} + + +int +error_gen_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict) +{ + STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict); + return 0; +} + + +int +error_gen_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name) +{ + int op_errno = 0; + eg_t *egp = NULL; + int enable = 1; + + egp = this->private; + enable = egp->enable[GF_FOP_FGETXATTR]; + + if (enable) + op_errno = error_gen (this, GF_FOP_FGETXATTR); + + if (op_errno) { + GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno)); + STACK_UNWIND_STRICT (fgetxattr, frame, -1, op_errno, NULL); + return 0; + } + + STACK_WIND (frame, error_gen_fgetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, + fd, name); + return 0; +} + int error_gen_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -1524,6 +1613,43 @@ error_gen_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, return 0; } +int +error_gen_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno); + + return 0; +} + + +int +error_gen_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, + const char *name) +{ + int op_errno = 0; + eg_t *egp = NULL; + int enable = 1; + + egp = this->private; + enable = egp->enable[GF_FOP_FREMOVEXATTR]; + + if (enable) + op_errno = error_gen (this, GF_FOP_FREMOVEXATTR); + + if (op_errno) { + GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno)); + STACK_UNWIND_STRICT (fremovexattr, frame, -1, op_errno); + return 0; + } + + STACK_WIND (frame, error_gen_fremovexattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, + fd, name); + return 0; +} + int error_gen_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -2008,6 +2134,9 @@ struct xlator_fops fops = { .setxattr = error_gen_setxattr, .getxattr = error_gen_getxattr, .removexattr = error_gen_removexattr, + .fsetxattr = error_gen_fsetxattr, + .fgetxattr = error_gen_fgetxattr, + .fremovexattr = error_gen_fremovexattr, .opendir = error_gen_opendir, .readdir = error_gen_readdir, .readdirp = error_gen_readdirp, diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 923470b8757..e47b062eebf 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -1636,6 +1636,35 @@ io_stats_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, return 0; } +int +io_stats_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + UPDATE_PROFILE_STATS (frame, FSETXATTR); + STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno); + return 0; +} + + +int +io_stats_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict) +{ + UPDATE_PROFILE_STATS (frame, FGETXATTR); + STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict); + return 0; +} + + +int +io_stats_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + UPDATE_PROFILE_STATS (frame, FREMOVEXATTR); + STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno); + return 0; +} + int io_stats_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -2205,6 +2234,50 @@ io_stats_removexattr (call_frame_t *frame, xlator_t *this, int +io_stats_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, + int32_t flags) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fsetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetxattr, + fd, dict, flags); + return 0; +} + + +int +io_stats_fgetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fgetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, + fd, name); + return 0; +} + + +int +io_stats_fremovexattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fremovexattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, + fd, name); + + return 0; +} + + +int io_stats_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd) { @@ -2681,6 +2754,9 @@ struct xlator_fops fops = { .setxattr = io_stats_setxattr, .getxattr = io_stats_getxattr, .removexattr = io_stats_removexattr, + .fsetxattr = io_stats_fsetxattr, + .fgetxattr = io_stats_fgetxattr, + .fremovexattr = io_stats_fremovexattr, .opendir = io_stats_opendir, .readdir = io_stats_readdir, .readdirp = io_stats_readdirp, diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index fad62c22969..7ced17831b4 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -915,12 +915,23 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) state->lk_owner = fsi->lock_owner; #endif - if ((state->loc.inode == NULL && ret == 0) || - (ret < 0)) { + state->valid = fsi->valid; + + if (fsi->valid & FATTR_FH) { + state->fd = FH_TO_FD (fsi->fh); + } + +#ifdef GF_TEST_FFOP + /* this is for calls like 'fchmod()' */ + if (!state->fd) + state->fd = fd_lookup (state->loc.inode, state->finh->pid); +#endif /* GF_TEST_FFOP */ + /* It is possible to get ftruncate without proper inode info from fuse */ + if (ret && !state->fd) { gf_log ("glusterfs-fuse", GF_LOG_WARNING, - "%"PRIu64": SETATTR %s (fuse_loc_fill() failed)", - finh->unique, state->loc.path); + "%"PRIu64": SETATTR %s (fuse_loc_fill() failed (%d))", + finh->unique, state->loc.path, ret); send_fuse_err (this, finh, ENOENT); free_fuse_state (state); @@ -928,16 +939,19 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) return; } + if (!state->fd && !state->loc.inode) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": SETATTR %"PRIu64" (fuse_loc_fill() failed)", + state->finh->unique, state->finh->nodeid); + send_fuse_err (state->this, state->finh, ENOENT); + free_fuse_state (state); + return; + } + gf_log ("glusterfs-fuse", GF_LOG_TRACE, "%"PRIu64": SETATTR (%"PRIu64")%s", finh->unique, finh->nodeid, state->loc.path); - state->valid = fsi->valid; - - if (fsi->valid & FATTR_FH) { - state->fd = FH_TO_FD (fsi->fh); - } - if ((fsi->valid & (FATTR_MASK)) != FATTR_SIZE) { if (fsi->valid & FATTR_SIZE) { state->size = fsi->size; @@ -2574,12 +2588,21 @@ fuse_statfs (xlator_t *this, fuse_in_header_t *finh, void *msg) void fuse_setxattr_resume (fuse_state_t *state) { - gf_log ("glusterfs-fuse", GF_LOG_TRACE, - "%"PRIu64": SETXATTR %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": SETXATTR %p/%"PRIu64" (%s)", state->finh->unique, + state->fd, state->finh->nodeid, state->name); + + FUSE_FOP (state, fuse_setxattr_cbk, GF_FOP_FSETXATTR, + fsetxattr, state->fd, state->dict, state->flags); + } else { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": SETXATTR %s/%"PRIu64" (%s)", state->finh->unique, + state->loc.path, state->finh->nodeid, state->name); - FUSE_FOP (state, fuse_setxattr_cbk, GF_FOP_SETXATTR, - setxattr, &state->loc, state->dict, state->flags); + FUSE_FOP (state, fuse_setxattr_cbk, GF_FOP_SETXATTR, + setxattr, &state->loc, state->dict, state->flags); + } } static void @@ -2653,18 +2676,29 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) GET_STATE (this, finh, state); state->size = fsi->size; 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_WARNING, - "%"PRIu64": SETXATTR %s/%"PRIu64" (%s) (fuse_loc_fill() failed)", - finh->unique, - state->loc.path, finh->nodeid, name); + "%"PRIu64": SETXATTR %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; } +#ifdef GF_TEST_FFOP + state->fd = fd_lookup (state->loc.inode, state->finh->pid); +#endif /* GF_TEST_FFOP */ + if (ret && !state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": SETXATTR %"PRIu64" (fuse_loc_fill() failed)", + state->finh->unique, state->finh->nodeid); + send_fuse_err (state->this, state->finh, ENOENT); + free_fuse_state (state); + return; + } + state->dict = get_new_dict (); if (!state->dict) { gf_log ("glusterfs-fuse", GF_LOG_ERROR, @@ -2696,8 +2730,10 @@ fuse_setxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) state->flags = fsi->flags; 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_setxattr_resume); @@ -2823,12 +2859,21 @@ out: void fuse_getxattr_resume (fuse_state_t *state) { - gf_log ("glusterfs-fuse", GF_LOG_TRACE, - "%"PRIu64": GETXATTR %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": GETXATTR %p/%"PRIu64" (%s)", state->finh->unique, + state->fd, state->finh->nodeid, state->name); - FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_GETXATTR, - getxattr, &state->loc, state->name); + FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_FGETXATTR, + fgetxattr, state->fd, state->name); + } else { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": GETXATTR %s/%"PRIu64" (%s)", state->finh->unique, + state->loc.path, state->finh->nodeid, state->name); + + FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_GETXATTR, + getxattr, &state->loc, state->name); + } } static void @@ -2885,17 +2930,29 @@ fuse_getxattr (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_WARNING, - "%"PRIu64": GETXATTR %s/%"PRIu64" (%s) (fuse_loc_fill() failed)", - finh->unique, state->loc.path, finh->nodeid, name); + "%"PRIu64": GETXATTR %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; } +#ifdef GF_TEST_FFOP + state->fd = fd_lookup (state->loc.inode, state->finh->pid); +#endif /* GF_TEST_FFOP */ + if (ret && !state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": GETXATTR %"PRIu64" (fuse_loc_fill() failed)", + state->finh->unique, state->finh->nodeid); + send_fuse_err (state->this, state->finh, ENOENT); + free_fuse_state (state); + return; + } + rv = fuse_flip_xattr_ns (priv, name, &newkey); if (rv) { send_fuse_err (this, finh, ENOMEM); @@ -2906,8 +2963,10 @@ fuse_getxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) state->size = fgxi->size; 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_getxattr_resume); out: @@ -2917,12 +2976,21 @@ fuse_getxattr (xlator_t *this, fuse_in_header_t *finh, void *msg) void fuse_listxattr_resume (fuse_state_t *state) { - gf_log ("glusterfs-fuse", GF_LOG_TRACE, - "%"PRIu64": LISTXATTR %s/%"PRIu64, state->finh->unique, - state->loc.path, state->finh->nodeid); + if (state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": LISTXATTR %p/%"PRIu64, state->finh->unique, + state->fd, state->finh->nodeid); - FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_GETXATTR, - getxattr, &state->loc, NULL); + FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_FGETXATTR, + fgetxattr, state->fd, NULL); + } else { + gf_log ("glusterfs-fuse", GF_LOG_TRACE, + "%"PRIu64": LISTXATTR %s/%"PRIu64, state->finh->unique, + state->loc.path, state->finh->nodeid); + + FUSE_FOP (state, fuse_xattr_cbk, GF_FOP_GETXATTR, + getxattr, &state->loc, NULL); + } } static void @@ -2936,20 +3004,34 @@ fuse_listxattr (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_WARNING, - "%"PRIu64": LISTXATTR %s/%"PRIu64" (fuse_loc_fill() failed)", - finh->unique, state->loc.path, finh->nodeid); + "%"PRIu64": LISTXATTR %s/%"PRIu64 + " (fuse_loc_fill() failed (%d))", + finh->unique, state->loc.path, finh->nodeid, ret); send_fuse_err (this, finh, ENOENT); free_fuse_state (state); return; } +#ifdef GF_TEST_FFOP + state->fd = fd_lookup (state->loc.inode, state->finh->pid); +#endif /* GF_TEST_FFOP */ + if (ret && !state->fd) { + gf_log ("glusterfs-fuse", GF_LOG_WARNING, + "%"PRIu64": LISTXATTR %"PRIu64" (fuse_loc_fill() failed)", + state->finh->unique, state->finh->nodeid); + send_fuse_err (state->this, state->finh, ENOENT); + free_fuse_state (state); + return; + } + state->size = fgxi->size; - 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_listxattr_resume); @@ -3002,8 +3084,10 @@ fuse_removexattr (xlator_t *this, fuse_in_header_t *finh, void *msg) return; } +#ifdef GF_TEST_FFOP state->fd = fd_lookup (state->loc.inode, state->finh->pid); - if (!state->fd) { +#endif /* GF_TEST_FFOP */ + if (ret && !state->fd) { gf_log ("glusterfs-fuse", GF_LOG_WARNING, "%"PRIu64": REMOVEXATTR %"PRIu64" (fuse_loc_fill() failed)", state->finh->unique, state->finh->nodeid); |