3604df
From 9acb9b61f0a025990924ef5ce2fffa59f8e515ed Mon Sep 17 00:00:00 2001
3604df
From: Susant Palai <spalai@redhat.com>
3604df
Date: Mon, 8 Aug 2016 17:05:10 +0530
3604df
Subject: [PATCH 93/94] dht: udpate stbuf from servers those have layout
3604df
3604df
Problem: For healing of uid/gid we check if local->stbuf.ia_ctime is
3604df
lesser than stbuf->ia_ctime (received from brick). If yes then uid/gid
3604df
is updated to local->prebuf(source of healing).
3604df
3604df
But we merge local->stbuf also form the newly added brick. So if we
3604df
receive response from the newly added brick first and update the
3604df
local->stbuf, then local->prebuf will remain empty since the newly added
3604df
brick will have the latest ctime among all servers. And this can result
3604df
in healing wrong uid/gids to the rest of servers.
3604df
3604df
Hence, we should update local->stbuf from servers with a layout which
3604df
will ignore merging stbufs from newly added bricks.
3604df
3604df
> Reviewed-on: http://review.gluster.org/15126
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
3604df
(cherry picked from commit 36af81ac7cb2d459f9bfc0c436f0038a68f85235)
3604df
3604df
Change-Id: If4b64f75a0ea669abdbe9f5a3d1d18ff19374c2f
3604df
BUG: 1294035
3604df
Reviewed-on: http://review.gluster.org/15464
3604df
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
3604df
Signed-off-by: Susant Palai <spalai@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/85965
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 xlators/cluster/dht/src/dht-common.c |   32 +++++++++++++++++++++++++++++---
3604df
 1 files changed, 29 insertions(+), 3 deletions(-)
3604df
3604df
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
3604df
index 2eb44a1..c0ebff2 100644
3604df
--- a/xlators/cluster/dht/src/dht-common.c
3604df
+++ b/xlators/cluster/dht/src/dht-common.c
3604df
@@ -910,9 +910,22 @@ dht_revalidate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3604df
                         }
3604df
                 }
3604df
 
3604df
-                dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
3604df
-                dht_iatt_merge (this, &local->postparent, postparent,
3604df
-                                prev->this);
3604df
+
3604df
+                /* Update stbuf from the servers where layout is present. This
3604df
+                 * is an indication that the server is not a newly added brick.
3604df
+                 * Merging stbuf from newly added brick may result in the added
3604df
+                 * brick being the source of heal for uid/gid */
3604df
+                if (!is_dir || (is_dir &&
3604df
+                    dht_dir_has_layout (xattr, conf->xattr_name) >= 0)
3604df
+                    || conf->subvolume_cnt == 1) {
3604df
+
3604df
+                        dht_iatt_merge (this, &local->stbuf, stbuf, prev->this);
3604df
+                        dht_iatt_merge (this, &local->postparent, postparent,
3604df
+                                        prev->this);
3604df
+                } else {
3604df
+                        /* copy the gfid anyway */
3604df
+                        gf_uuid_copy (local->stbuf.ia_gfid, stbuf->ia_gfid);
3604df
+                }
3604df
 
3604df
                 local->op_ret = 0;
3604df
 
3604df
@@ -1007,6 +1020,19 @@ cont:
3604df
 
3604df
                 DHT_STRIP_PHASE1_FLAGS (&local->stbuf);
3604df
                 dht_set_fixed_dir_stat (&local->postparent);
3604df
+
3604df
+                /* local->stbuf is udpated only from subvols which have a layout
3604df
+                 * The reason is to avoid choosing attr heal source from newly
3604df
+                 * added bricks. In case e.g we have only one subvol and for
3604df
+                 * some reason layout is not present on it, then local->stbuf
3604df
+                 * will be EINVAL. This is an indication that the subvols
3604df
+                 * active in the cluster do not have layouts on disk.
3604df
+                 * Unwind with ESTALE to trigger a fresh lookup */
3604df
+                if (is_dir && local->stbuf.ia_type == IA_INVAL) {
3604df
+                        local->op_ret = -1;
3604df
+                        local->op_errno = ESTALE;
3604df
+                }
3604df
+
3604df
                 DHT_STACK_UNWIND (lookup, frame, local->op_ret, local->op_errno,
3604df
                                   local->inode, &local->stbuf, local->xattr,
3604df
                                   &local->postparent);
3604df
-- 
3604df
1.7.1
3604df