Blob Blame History Raw
From 1e1495a8d5356e6a4f724c211cdd17c5e3f399b5 Mon Sep 17 00:00:00 2001
From: Sanju Rakonde <srakonde@redhat.com>
Date: Tue, 30 Oct 2018 16:36:50 +0530
Subject: [PATCH 412/444] glusterd: set fsid while performing replace brick

While performing the replace-brick operation, we should set
fsid value to the new brick.

> fixes: bz#1637196
> Change-Id: I9e9a4962fc0c2f5dff43e4ac11767814a0c0beaf
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>

upstream patch: https://review.gluster.org/#/c/glusterfs/+/21513/

Change-Id: I9e9a4962fc0c2f5dff43e4ac11767814a0c0beaf
BUG: 1644279
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/154907
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 .../df-results-post-replace-brick-operations.t     | 58 ++++++++++++++++++++++
 xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 15 ++++++
 2 files changed, 73 insertions(+)
 create mode 100644 tests/bugs/glusterd/df-results-post-replace-brick-operations.t

diff --git a/tests/bugs/glusterd/df-results-post-replace-brick-operations.t b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t
new file mode 100644
index 0000000..443911c
--- /dev/null
+++ b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup
+TEST glusterd
+
+#Create brick partitions
+TEST truncate -s 100M $B0/brick1
+TEST truncate -s 100M $B0/brick2
+TEST truncate -s 100M $B0/brick3
+TEST truncate -s 100M $B0/brick4
+TEST truncate -s 100M $B0/brick5
+
+LO1=`SETUP_LOOP $B0/brick1`
+TEST [ $? -eq 0 ]
+TEST MKFS_LOOP $LO1
+
+LO2=`SETUP_LOOP $B0/brick2`
+TEST [ $? -eq 0 ]
+TEST MKFS_LOOP $LO2
+
+LO3=`SETUP_LOOP $B0/brick3`
+TEST [ $? -eq 0 ]
+TEST MKFS_LOOP $LO3
+
+LO4=`SETUP_LOOP $B0/brick4`
+TEST [ $? -eq 0 ]
+TEST MKFS_LOOP $LO4
+
+LO5=`SETUP_LOOP $B0/brick5`
+TEST [ $? -eq 0 ]
+TEST MKFS_LOOP $LO5
+
+TEST mkdir -p $B0/${V0}1 $B0/${V0}2 $B0/${V0}3 $B0/${V0}4 $B0/${V0}5
+TEST MOUNT_LOOP $LO1 $B0/${V0}1
+TEST MOUNT_LOOP $LO2 $B0/${V0}2
+TEST MOUNT_LOOP $LO3 $B0/${V0}3
+TEST MOUNT_LOOP $LO4 $B0/${V0}4
+TEST MOUNT_LOOP $LO5 $B0/${V0}5
+
+# create a subdirectory in mount point and use it for volume creation
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}1/brick1 $H0:$B0/${V0}2/brick1 $H0:$B0/${V0}3/brick1
+TEST $CLI volume start $V0
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" online_brick_count
+
+# mount the volume and check the size at mount point
+TEST $GFS --volfile-server=$H0 --volfile-id=$V0 $M0
+total_space=$(df -P $M0 | tail -1 | awk '{ print $2}')
+
+# perform replace brick operations
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1/brick1 $H0:$B0/${V0}4/brick1 commit force
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}2/brick1 $H0:$B0/${V0}5/brick1 commit force
+
+# check for the size at mount point, it should be same as previous
+total_space_new=$(df -P $M0 | tail -1 | awk '{ print $2}')
+TEST [ $total_space -eq $total_space_new ]
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index a037323..5fc3669 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -362,6 +362,7 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t  *volinfo,
         int32_t                                 ret = -1;
         xlator_t                                *this = NULL;
         glusterd_conf_t                         *conf = NULL;
+        struct                                  statvfs brickstat = {0,};
 
         this = THIS;
         GF_ASSERT (this);
@@ -379,6 +380,20 @@ glusterd_op_perform_replace_brick (glusterd_volinfo_t  *volinfo,
         ret = glusterd_resolve_brick (new_brickinfo);
         if (ret)
                 goto out;
+        if (!gf_uuid_compare(new_brickinfo->uuid, MY_UUID)) {
+                ret = sys_statvfs(new_brickinfo->path, &brickstat);
+                if (ret) {
+                        gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_STATVFS_FAILED,
+                               "Failed to fetch disk utilization "
+                               "from the brick (%s:%s). Please check the health of "
+                               "the brick. Error code was %s",
+                               new_brickinfo->hostname, new_brickinfo->path,
+                               strerror(errno));
+
+                        goto out;
+                }
+                new_brickinfo->statfs_fsid = brickstat.f_fsid;
+        }
 
         ret = glusterd_volume_brickinfo_get_by_brick (old_brick,
                                                       volinfo, &old_brickinfo,
-- 
1.8.3.1