d1681e
From 2be2ed1e0da026c4ae932daa263c1215d23342a9 Mon Sep 17 00:00:00 2001
d1681e
From: Csaba Henk <csaba@redhat.com>
d1681e
Date: Mon, 5 Mar 2018 13:02:09 +0100
d1681e
Subject: [PATCH 189/201] fuse: enable proper "fgetattr"-like semantics
d1681e
d1681e
GETATTR FUSE message can carry a file handle
d1681e
reference in which case it serves as a hint
d1681e
for the FUSE server that the stat data is
d1681e
preferably acquired in context of the given
d1681e
filehandle (which we call '"fgetattr"-like
d1681e
semantics').
d1681e
d1681e
So far FUSE ignored the GETTATTR provided
d1681e
filehandle and grabbed a file handle
d1681e
heuristically. This caused confusion in the
d1681e
caching layers, which has been tracked down
d1681e
as one of the reasons of referred BUG.
d1681e
d1681e
As of the BUG, this is just a partial fix.
d1681e
d1681e
> BUG: 1512691
d1681e
> Change-Id: I67eebbf5407ca725ed111fbda4181ead10d03f6d
d1681e
> Reviewed-on: https://review.gluster.org/19673
d1681e
> Signed-off-by: Csaba Henk <csaba@redhat.com>
d1681e
d1681e
BUG: 1518710
d1681e
Change-Id: I67eebbf5407ca725ed111fbda4181ead10d03f6d
d1681e
Signed-off-by: Csaba Henk <csaba@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/133419
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d1681e
---
d1681e
 xlators/mount/fuse/src/fuse-bridge.c | 14 +++++++++++++-
d1681e
 1 file changed, 13 insertions(+), 1 deletion(-)
d1681e
d1681e
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
d1681e
index 03d26eb..3e31eca 100644
d1681e
--- a/xlators/mount/fuse/src/fuse-bridge.c
d1681e
+++ b/xlators/mount/fuse/src/fuse-bridge.c
d1681e
@@ -905,7 +905,10 @@ fuse_getattr_resume (fuse_state_t *state)
d1681e
         }
d1681e
 
d1681e
         if (!IA_ISDIR (state->loc.inode->ia_type)) {
d1681e
-                state->fd = fd_lookup (state->loc.inode, 0);
d1681e
+                if (state->fd == NULL)
d1681e
+                        state->fd = fd_lookup (state->loc.inode, state->finh->pid);
d1681e
+                if (state->fd == NULL)
d1681e
+                        state->fd = fd_lookup (state->loc.inode, 0);
d1681e
         }
d1681e
 
d1681e
         if (!state->fd) {
d1681e
@@ -931,9 +934,18 @@ fuse_getattr_resume (fuse_state_t *state)
d1681e
 static void
d1681e
 fuse_getattr (xlator_t *this, fuse_in_header_t *finh, void *msg)
d1681e
 {
d1681e
+#if FUSE_KERNEL_MINOR_VERSION >= 9
d1681e
+        struct fuse_getattr_in *fgi  = msg;
d1681e
+        fuse_private_t         *priv = NULL;
d1681e
+#endif
d1681e
         fuse_state_t *state;
d1681e
 
d1681e
         GET_STATE (this, finh, state);
d1681e
+#if FUSE_KERNEL_MINOR_VERSION >= 9
d1681e
+        priv = this->private;
d1681e
+        if (priv->proto_minor >= 9 && fgi->getattr_flags & FUSE_GETATTR_FH)
d1681e
+                state->fd = fd_ref ((fd_t *)fgi->fh);
d1681e
+#endif
d1681e
 
d1681e
         fuse_resolve_inode_init (state, &state->resolve, state->finh->nodeid);
d1681e
 
d1681e
-- 
d1681e
1.8.3.1
d1681e