summaryrefslogtreecommitdiffstats
path: root/xlators/mount/fuse
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-01-21 20:05:55 +0530
committerAnand Avati <avati@gluster.com>2012-01-25 02:26:51 -0800
commit49c325d949b2df06572df7dd3825735fb9c8cd6f (patch)
treebfd7fd3c21610ac4fc6ab57f36f09259fb0636f2 /xlators/mount/fuse
parentd7ecaaa1ed0f88869812ea17cb64a102a74c8c1c (diff)
complete the implementation of missing 'f**xattr()' fops
in debug/* and cluster/* translators and a syncop_fsetxattr() added a test case for testing the working of 'f-fop()' on fuse mount. Change-Id: I0c2aeeb30a0fb382ef2495cca1e66b00abaffd35 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 766571 Reviewed-on: http://review.gluster.com/802 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/mount/fuse')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c174
1 files changed, 129 insertions, 45 deletions
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);