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