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