887953
From 1e1495a8d5356e6a4f724c211cdd17c5e3f399b5 Mon Sep 17 00:00:00 2001
887953
From: Sanju Rakonde <srakonde@redhat.com>
887953
Date: Tue, 30 Oct 2018 16:36:50 +0530
887953
Subject: [PATCH 412/444] glusterd: set fsid while performing replace brick
887953
887953
While performing the replace-brick operation, we should set
887953
fsid value to the new brick.
887953
887953
> fixes: bz#1637196
887953
> Change-Id: I9e9a4962fc0c2f5dff43e4ac11767814a0c0beaf
887953
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
887953
887953
upstream patch: https://review.gluster.org/#/c/glusterfs/+/21513/
887953
887953
Change-Id: I9e9a4962fc0c2f5dff43e4ac11767814a0c0beaf
887953
BUG: 1644279
887953
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
887953
Reviewed-on: https://code.engineering.redhat.com/gerrit/154907
887953
Tested-by: RHGS Build Bot <nigelb@redhat.com>
887953
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
887953
---
887953
 .../df-results-post-replace-brick-operations.t     | 58 ++++++++++++++++++++++
887953
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 15 ++++++
887953
 2 files changed, 73 insertions(+)
887953
 create mode 100644 tests/bugs/glusterd/df-results-post-replace-brick-operations.t
887953
887953
diff --git a/tests/bugs/glusterd/df-results-post-replace-brick-operations.t b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t
887953
new file mode 100644
887953
index 0000000..443911c
887953
--- /dev/null
887953
+++ b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t
887953
@@ -0,0 +1,58 @@
887953
+#!/bin/bash
887953
+
887953
+. $(dirname $0)/../../include.rc
887953
+. $(dirname $0)/../../volume.rc
887953
+
887953
+cleanup
887953
+TEST glusterd
887953
+
887953
+#Create brick partitions
887953
+TEST truncate -s 100M $B0/brick1
887953
+TEST truncate -s 100M $B0/brick2
887953
+TEST truncate -s 100M $B0/brick3
887953
+TEST truncate -s 100M $B0/brick4
887953
+TEST truncate -s 100M $B0/brick5
887953
+
887953
+LO1=`SETUP_LOOP $B0/brick1`
887953
+TEST [ $? -eq 0 ]
887953
+TEST MKFS_LOOP $LO1
887953
+
887953
+LO2=`SETUP_LOOP $B0/brick2`
887953
+TEST [ $? -eq 0 ]
887953
+TEST MKFS_LOOP $LO2
887953
+
887953
+LO3=`SETUP_LOOP $B0/brick3`
887953
+TEST [ $? -eq 0 ]
887953
+TEST MKFS_LOOP $LO3
887953
+
887953
+LO4=`SETUP_LOOP $B0/brick4`
887953
+TEST [ $? -eq 0 ]
887953
+TEST MKFS_LOOP $LO4
887953
+
887953
+LO5=`SETUP_LOOP $B0/brick5`
887953
+TEST [ $? -eq 0 ]
887953
+TEST MKFS_LOOP $LO5
887953
+
887953
+TEST mkdir -p $B0/${V0}1 $B0/${V0}2 $B0/${V0}3 $B0/${V0}4 $B0/${V0}5
887953
+TEST MOUNT_LOOP $LO1 $B0/${V0}1
887953
+TEST MOUNT_LOOP $LO2 $B0/${V0}2
887953
+TEST MOUNT_LOOP $LO3 $B0/${V0}3
887953
+TEST MOUNT_LOOP $LO4 $B0/${V0}4
887953
+TEST MOUNT_LOOP $LO5 $B0/${V0}5
887953
+
887953
+# create a subdirectory in mount point and use it for volume creation
887953
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}1/brick1 $H0:$B0/${V0}2/brick1 $H0:$B0/${V0}3/brick1
887953
+TEST $CLI volume start $V0
887953
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" online_brick_count
887953
+
887953
+# mount the volume and check the size at mount point
887953
+TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0
887953
+total_space=$(df -P $M0 | tail -1 | awk '{ print $2}')
887953
+
887953
+# perform replace brick operations
887953
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1/brick1 $H0:$B0/${V0}4/brick1 commit force
887953
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}2/brick1 $H0:$B0/${V0}5/brick1 commit force
887953
+
887953
+# check for the size at mount point, it should be same as previous
887953
+total_space_new=$(df -P $M0 | tail -1 | awk '{ print $2}')
887953
+TEST [ $total_space -eq $total_space_new ]
887953
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
887953
index a037323..5fc3669 100644
887953
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
887953
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
887953
@@ -362,6 +362,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t  *volinfo,
887953
         int32_t                                 ret = -1;
887953
         xlator_t                                *this = NULL;
887953
         glusterd_conf_t                         *conf = NULL;
887953
+        struct                                  statvfs brickstat = {0,};
887953
 
887953
         this = THIS;
887953
         GF_ASSERT (this);
887953
@@ -379,6 +380,20 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t  *volinfo,
887953
         ret = glusterd_resolve_brick (new_brickinfo);
887953
         if (ret)
887953
                 goto out;
887953
+        if (!gf_uuid_compare(new_brickinfo->uuid, MY_UUID)) {
887953
+                ret = sys_statvfs(new_brickinfo->path, &brickstat);
887953
+                if (ret) {
887953
+                        gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_STATVFS_FAILED,
887953
+                               "Failed to fetch disk utilization "
887953
+                               "from the brick (%s:%s). Please check the health of "
887953
+                               "the brick. Error code was %s",
887953
+                               new_brickinfo->hostname, new_brickinfo->path,
887953
+                               strerror(errno));
887953
+
887953
+                        goto out;
887953
+                }
887953
+                new_brickinfo->statfs_fsid = brickstat.f_fsid;
887953
+        }
887953
 
887953
         ret = glusterd_volume_brickinfo_get_by_brick (old_brick,
887953
                                                       volinfo, &old_brickinfo,
887953
-- 
887953
1.8.3.1
887953