a3470f
From 80efc701cb29684355cd133fbf29c14948772ba1 Mon Sep 17 00:00:00 2001
a3470f
From: Susant Palai <spalai@redhat.com>
a3470f
Date: Wed, 11 Apr 2018 23:14:02 +0530
a3470f
Subject: [PATCH 229/236] fuse: do fd_resolve in fuse_getattr if fd is received
a3470f
a3470f
problem: With the current code, post graph switch the old fd is received for
a3470f
fuse_getattr and since it is associated with old inode, it does not
a3470f
have the inode ctx across xlators in new graph. Hence, dht
a3470f
errored out saying "no layout" for fstat call. Hence the EINVAL.
a3470f
a3470f
Solution: if fd is passed, init and resolve fd to carry on getattr
a3470f
a3470f
test case:
a3470f
- Created a single brick distributed volume
a3470f
- Started untar
a3470f
- Added a new-brick
a3470f
a3470f
Without this fix, untar used to abort with ERROR.
a3470f
a3470f
upstream patch: https://review.gluster.org/#/c/19849/
a3470f
a3470f
> Change-Id: I5805c463fb9a04ba5c24829b768127097ff8b9f9
a3470f
> fixes: bz#1566207
a3470f
> Signed-off-by: Susant Palai <spalai@redhat.com>
a3470f
> (cherry picked from commit 87bcdd9465b140e0b9d33dadf3384e28b7b6ed9f)
a3470f
a3470f
Change-Id: I5805c463fb9a04ba5c24829b768127097ff8b9f9
a3470f
BUG: 1563692
a3470f
Signed-off-by: Susant Palai <spalai@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/136232
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
a3470f
---
a3470f
 xlators/cluster/dht/src/dht-inode-read.c |  4 ++--
a3470f
 xlators/mount/fuse/src/fuse-bridge.c     | 13 ++++++++-----
a3470f
 2 files changed, 10 insertions(+), 7 deletions(-)
a3470f
a3470f
diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c
a3470f
index fa63fef..d1895eb 100644
a3470f
--- a/xlators/cluster/dht/src/dht-inode-read.c
a3470f
+++ b/xlators/cluster/dht/src/dht-inode-read.c
a3470f
@@ -400,8 +400,8 @@ dht_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
a3470f
 
a3470f
         layout = local->layout;
a3470f
         if (!layout) {
a3470f
-                gf_msg_debug (this->name, 0,
a3470f
-                              "no layout for fd=%p", fd);
a3470f
+                gf_msg (this->name, GF_LOG_ERROR, 0, 0,
a3470f
+                        "no layout for fd=%p", fd);
a3470f
                 op_errno = EINVAL;
a3470f
                 goto err;
a3470f
         }
a3470f
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
a3470f
index 3e31eca..44697d2 100644
a3470f
--- a/xlators/mount/fuse/src/fuse-bridge.c
a3470f
+++ b/xlators/mount/fuse/src/fuse-bridge.c
a3470f
@@ -893,7 +893,7 @@ fuse_root_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
a3470f
 void
a3470f
 fuse_getattr_resume (fuse_state_t *state)
a3470f
 {
a3470f
-        if (!state->loc.inode) {
a3470f
+        if (!state->loc.inode && !(state->fd && state->fd->inode)) {
a3470f
                 gf_log ("glusterfs-fuse", GF_LOG_ERROR,
a3470f
                         "%"PRIu64": GETATTR %"PRIu64" (%s) resolution failed",
a3470f
                         state->finh->unique, state->finh->nodeid,
a3470f
@@ -904,9 +904,9 @@ fuse_getattr_resume (fuse_state_t *state)
a3470f
                 return;
a3470f
         }
a3470f
 
a3470f
-        if (!IA_ISDIR (state->loc.inode->ia_type)) {
a3470f
-                if (state->fd == NULL)
a3470f
-                        state->fd = fd_lookup (state->loc.inode, state->finh->pid);
a3470f
+        if (state->fd == NULL && !IA_ISDIR (state->loc.inode->ia_type)) {
a3470f
+                state->fd = fd_lookup (state->loc.inode, state->finh->pid);
a3470f
+
a3470f
                 if (state->fd == NULL)
a3470f
                         state->fd = fd_lookup (state->loc.inode, 0);
a3470f
         }
a3470f
@@ -947,7 +947,10 @@ fuse_getattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
a3470f
                 state->fd = fd_ref ((fd_t *)fgi->fh);
a3470f
 #endif
a3470f
 
a3470f
-        fuse_resolve_inode_init (state, &state->resolve, state->finh->nodeid);
a3470f
+        if (state->fd)
a3470f
+                fuse_resolve_fd_init (state, &state->resolve, state->fd);
a3470f
+        else
a3470f
+                fuse_resolve_inode_init (state, &state->resolve, state->finh->nodeid);
a3470f
 
a3470f
         fuse_resolve_and_resume (state, fuse_getattr_resume);
a3470f
 }
a3470f
-- 
a3470f
1.8.3.1
a3470f