Blob Blame History Raw
From 3eff3dcb1b0a0a4ce67214ce238fdd2082f26593 Mon Sep 17 00:00:00 2001
From: Amar Tumballi <amarts@redhat.com>
Date: Mon, 23 Oct 2017 21:17:52 +0200
Subject: [PATCH 627/631] protocol/server: fix the comparision logic in case of
 subdir mount

without the fix, the stat entry on a file would return inode==1 for
many files, in case of subdir mount

This happened with the confusion of return value of 'gf_uuid_compare()',
it is more like strcmp, instead of a gf_boolean return value, and hence
resulted in the bug.

> Upstream:
> URL: https://review.gluster.org/#/c/18558/
>

Also fixes the bz1501714

Change-Id: I31b8cbd95eaa3af5ff916a969458e8e4020c86bb
BUG: 1505473
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/121726
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/protocol/server/src/server-common.c | 60 ++++++++++++++---------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/xlators/protocol/server/src/server-common.c b/xlators/protocol/server/src/server-common.c
index 100b19884..999eb1421 100644
--- a/xlators/protocol/server/src/server-common.c
+++ b/xlators/protocol/server/src/server-common.c
@@ -12,22 +12,22 @@
 void
 server_post_stat (server_state_t *state, gfs3_stat_rsp *rsp, struct iatt *stbuf)
 {
-        if (state->client->subdir_mount) {
-                if (gf_uuid_compare (stbuf->ia_gfid,
-                                     state->client->subdir_gfid)) {
-                        /* This is very important as when we send iatt of
-                           root-inode, fuse/client expect the gfid to be 1,
-                           along with inode number. As for subdirectory mount,
-                           we use inode table which is shared by everyone, but
-                           make sure we send fops only from subdir and below,
-                           we have to alter inode gfid and send it to client */
-                        uuid_t gfid = {0,};
-
-                        gfid[15] = 1;
-                        stbuf->ia_ino = 1;
-                        gf_uuid_copy (stbuf->ia_gfid, gfid);
-                }
+        if (state->client->subdir_mount &&
+            !gf_uuid_compare (stbuf->ia_gfid,
+                              state->client->subdir_gfid)) {
+                /* This is very important as when we send iatt of
+                   root-inode, fuse/client expect the gfid to be 1,
+                   along with inode number. As for subdirectory mount,
+                   we use inode table which is shared by everyone, but
+                   make sure we send fops only from subdir and below,
+                   we have to alter inode gfid and send it to client */
+                uuid_t gfid = {0,};
+
+                gfid[15] = 1;
+                stbuf->ia_ino = 1;
+                gf_uuid_copy (stbuf->ia_gfid, gfid);
         }
+
         gf_stat_from_iatt (&rsp->stat, stbuf);
 }
 
@@ -185,22 +185,22 @@ void
 server_post_fstat (server_state_t *state, gfs3_fstat_rsp *rsp,
                    struct iatt *stbuf)
 {
-        if (state->client->subdir_mount) {
-                if (gf_uuid_compare (stbuf->ia_gfid,
-                                     state->client->subdir_gfid)) {
-                        /* This is very important as when we send iatt of
-                           root-inode, fuse/client expect the gfid to be 1,
-                           along with inode number. As for subdirectory mount,
-                           we use inode table which is shared by everyone, but
-                           make sure we send fops only from subdir and below,
-                           we have to alter inode gfid and send it to client */
-                        uuid_t gfid = {0,};
-
-                        gfid[15] = 1;
-                        stbuf->ia_ino = 1;
-                        gf_uuid_copy (stbuf->ia_gfid, gfid);
-                }
+        if (state->client->subdir_mount &&
+            !gf_uuid_compare (stbuf->ia_gfid,
+                              state->client->subdir_gfid)) {
+                /* This is very important as when we send iatt of
+                   root-inode, fuse/client expect the gfid to be 1,
+                   along with inode number. As for subdirectory mount,
+                   we use inode table which is shared by everyone, but
+                   make sure we send fops only from subdir and below,
+                   we have to alter inode gfid and send it to client */
+                uuid_t gfid = {0,};
+
+                gfid[15] = 1;
+                stbuf->ia_ino = 1;
+                gf_uuid_copy (stbuf->ia_gfid, gfid);
         }
+
         gf_stat_from_iatt (&rsp->stat, stbuf);
 }
 
-- 
2.13.6