|
|
a3470f |
From 4c7460554f2f7c6515b77e70c878fc15d3813237 Mon Sep 17 00:00:00 2001
|
|
|
a3470f |
From: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
a3470f |
Date: Sat, 4 Aug 2018 12:05:03 +0530
|
|
|
a3470f |
Subject: [PATCH 344/351] glusterd: Compare volume_id before start/attach a
|
|
|
a3470f |
brick
|
|
|
a3470f |
|
|
|
a3470f |
Problem: After reboot a node brick is not coming up because
|
|
|
a3470f |
fsid comparison is failed before start a brick
|
|
|
a3470f |
|
|
|
a3470f |
Solution: Instead of comparing fsid compare volume_id to
|
|
|
a3470f |
resolve the same because fsid is changed after
|
|
|
a3470f |
reboot a node but volume_id persist as a xattr
|
|
|
a3470f |
on brick_root path at the time of creating a volume.
|
|
|
a3470f |
|
|
|
a3470f |
> Change-Id: Ic289aab1b4ebfd83bbcae8438fee26ae61a0fff4
|
|
|
a3470f |
> fixes: bz#1612418
|
|
|
a3470f |
> (Cherry pick from commit bd8fc26a278697c30537d879ea5402db7ebab577)
|
|
|
a3470f |
> (Reviwed on upstream link https://review.gluster.org/#/c/glusterfs/+/20638/)
|
|
|
a3470f |
|
|
|
a3470f |
Change-Id: Ia183c1d67af662584debcb301171c35be5ac0d9d
|
|
|
a3470f |
BUG: 1612098
|
|
|
a3470f |
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
a3470f |
Reviewed-on: https://code.engineering.redhat.com/gerrit/146835
|
|
|
a3470f |
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
a3470f |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
a3470f |
---
|
|
|
a3470f |
tests/{basic => bugs/glusterd}/bug-1595320.t | 9 +++---
|
|
|
a3470f |
xlators/mgmt/glusterd/src/glusterd-utils.c | 47 ++++++++++++++++------------
|
|
|
a3470f |
2 files changed, 32 insertions(+), 24 deletions(-)
|
|
|
a3470f |
rename tests/{basic => bugs/glusterd}/bug-1595320.t (94%)
|
|
|
a3470f |
|
|
|
a3470f |
diff --git a/tests/basic/bug-1595320.t b/tests/bugs/glusterd/bug-1595320.t
|
|
|
a3470f |
similarity index 94%
|
|
|
a3470f |
rename from tests/basic/bug-1595320.t
|
|
|
a3470f |
rename to tests/bugs/glusterd/bug-1595320.t
|
|
|
a3470f |
index 9d856ee..f41df9d 100644
|
|
|
a3470f |
--- a/tests/basic/bug-1595320.t
|
|
|
a3470f |
+++ b/tests/bugs/glusterd/bug-1595320.t
|
|
|
a3470f |
@@ -1,8 +1,8 @@
|
|
|
a3470f |
#!/bin/bash
|
|
|
a3470f |
|
|
|
a3470f |
-. $(dirname $0)/../include.rc
|
|
|
a3470f |
-. $(dirname $0)/../volume.rc
|
|
|
a3470f |
-. $(dirname $0)/../snapshot.rc
|
|
|
a3470f |
+. $(dirname $0)/../../include.rc
|
|
|
a3470f |
+. $(dirname $0)/../../volume.rc
|
|
|
a3470f |
+. $(dirname $0)/../../snapshot.rc
|
|
|
a3470f |
|
|
|
a3470f |
cleanup
|
|
|
a3470f |
|
|
|
a3470f |
@@ -52,7 +52,7 @@ EXPECT 0 count_brick_processes
|
|
|
a3470f |
|
|
|
a3470f |
# Unmount 3rd brick root from node
|
|
|
a3470f |
brick_root=$L3
|
|
|
a3470f |
-TEST umount -l $brick_root 2>/dev/null
|
|
|
a3470f |
+_umount_lv 3
|
|
|
a3470f |
|
|
|
a3470f |
# Start the volume only 2 brick should be start
|
|
|
a3470f |
TEST $CLI volume start $V0 force
|
|
|
a3470f |
@@ -70,6 +70,7 @@ n=`ls -lrth /proc/$brick_pid/fd | grep -iw $L3 | grep -v ".glusterfs" | wc -l`
|
|
|
a3470f |
TEST [ $n -eq 0 ]
|
|
|
a3470f |
|
|
|
a3470f |
# Mount the brick root
|
|
|
a3470f |
+TEST mkdir -p $brick_root
|
|
|
a3470f |
TEST mount -t xfs -o nouuid /dev/test_vg_3/brick_lvm $brick_root
|
|
|
a3470f |
|
|
|
a3470f |
# Replace brick_pid file to test brick_attach code
|
|
|
a3470f |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
a3470f |
index 6f7c787..1752425 100644
|
|
|
a3470f |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
a3470f |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
a3470f |
@@ -5439,6 +5439,12 @@ attach_brick_callback (struct rpc_req *req, struct iovec *iov, int count,
|
|
|
a3470f |
frame->local = NULL;
|
|
|
a3470f |
frame->cookie = NULL;
|
|
|
a3470f |
|
|
|
a3470f |
+ if (!iov) {
|
|
|
a3470f |
+ gf_log (frame->this->name, GF_LOG_ERROR, "iov is NULL");
|
|
|
a3470f |
+ ret = -1;
|
|
|
a3470f |
+ goto out;
|
|
|
a3470f |
+ }
|
|
|
a3470f |
+
|
|
|
a3470f |
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp);
|
|
|
a3470f |
if (ret < 0) {
|
|
|
a3470f |
gf_log (frame->this->name, GF_LOG_ERROR, "XDR decoding error");
|
|
|
a3470f |
@@ -6073,17 +6079,19 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
|
|
|
a3470f |
gf_boolean_t wait,
|
|
|
a3470f |
gf_boolean_t only_connect)
|
|
|
a3470f |
{
|
|
|
a3470f |
- int ret = -1;
|
|
|
a3470f |
+ int ret = -1;
|
|
|
a3470f |
xlator_t *this = NULL;
|
|
|
a3470f |
glusterd_brickinfo_t *other_brick;
|
|
|
a3470f |
glusterd_conf_t *conf = NULL;
|
|
|
a3470f |
- int32_t pid = -1;
|
|
|
a3470f |
- char pidfile[PATH_MAX] = {0};
|
|
|
a3470f |
- char socketpath[PATH_MAX] = {0};
|
|
|
a3470f |
- char *brickpath = NULL;
|
|
|
a3470f |
+ int32_t pid = -1;
|
|
|
a3470f |
+ char pidfile[PATH_MAX] = {0};
|
|
|
a3470f |
+ char socketpath[PATH_MAX] = {0};
|
|
|
a3470f |
+ char *brickpath = NULL;
|
|
|
a3470f |
glusterd_volinfo_t *other_vol;
|
|
|
a3470f |
- struct statvfs brickstat = {0,};
|
|
|
a3470f |
gf_boolean_t is_service_running = _gf_false;
|
|
|
a3470f |
+ uuid_t volid = {0,};
|
|
|
a3470f |
+ ssize_t size = -1;
|
|
|
a3470f |
+
|
|
|
a3470f |
|
|
|
a3470f |
this = THIS;
|
|
|
a3470f |
GF_ASSERT (this);
|
|
|
a3470f |
@@ -6130,24 +6138,23 @@ glusterd_brick_start (glusterd_volinfo_t *volinfo,
|
|
|
a3470f |
|
|
|
a3470f |
GLUSTERD_GET_BRICK_PIDFILE (pidfile, volinfo, brickinfo, conf);
|
|
|
a3470f |
|
|
|
a3470f |
- ret = sys_statvfs (brickinfo->path, &brickstat);
|
|
|
a3470f |
- if (ret) {
|
|
|
a3470f |
- gf_msg (this->name, GF_LOG_ERROR,
|
|
|
a3470f |
- errno, GD_MSG_BRICKINFO_CREATE_FAIL,
|
|
|
a3470f |
- "failed to get statfs() call on brick %s",
|
|
|
a3470f |
- brickinfo->path);
|
|
|
a3470f |
+ /* Compare volume-id xattr is helpful to ensure the existence of a brick_root
|
|
|
a3470f |
+ path before the start/attach a brick
|
|
|
a3470f |
+ */
|
|
|
a3470f |
+ size = sys_lgetxattr (brickinfo->path, GF_XATTR_VOL_ID_KEY, volid, 16);
|
|
|
a3470f |
+ if (size != 16) {
|
|
|
a3470f |
+ gf_log (this->name, GF_LOG_ERROR,
|
|
|
a3470f |
+ "Missing %s extended attribute on brick root (%s),"
|
|
|
a3470f |
+ " brick is deemed not to be a part of the volume (%s) ",
|
|
|
a3470f |
+ GF_XATTR_VOL_ID_KEY, brickinfo->path, volinfo->volname);
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
|
|
|
a3470f |
- /* Compare fsid is helpful to ensure the existence of a brick_root
|
|
|
a3470f |
- path before the start/attach a brick
|
|
|
a3470f |
- */
|
|
|
a3470f |
- if (brickinfo->statfs_fsid &&
|
|
|
a3470f |
- (brickinfo->statfs_fsid != brickstat.f_fsid)) {
|
|
|
a3470f |
+ if (strncmp (uuid_utoa (volinfo->volume_id), uuid_utoa(volid), GF_UUID_BUF_SIZE)) {
|
|
|
a3470f |
gf_log (this->name, GF_LOG_ERROR,
|
|
|
a3470f |
- "fsid comparison is failed it means Brick root path"
|
|
|
a3470f |
- " %s is not created by glusterd, start/attach will also fail",
|
|
|
a3470f |
- brickinfo->path);
|
|
|
a3470f |
+ "Mismatching %s extended attribute on brick root (%s),"
|
|
|
a3470f |
+ " brick is deemed not to be a part of the volume (%s)",
|
|
|
a3470f |
+ GF_XATTR_VOL_ID_KEY, brickinfo->path, volinfo->volname);
|
|
|
a3470f |
goto out;
|
|
|
a3470f |
}
|
|
|
a3470f |
is_service_running = gf_is_service_running (pidfile, &pid;;
|
|
|
a3470f |
--
|
|
|
a3470f |
1.8.3.1
|
|
|
a3470f |
|