|
|
12a457 |
From ca01872122788dd3923541590c2884c55cadf5ba Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
Date: Fri, 13 May 2016 11:40:57 +0530
|
|
|
12a457 |
Subject: [PATCH 158/158] cluster/distribute: heal layout in discover codepath too
|
|
|
12a457 |
|
|
|
12a457 |
BUG: 1325760
|
|
|
12a457 |
Change-Id: I4259d88f2b6e4f9d4ad689bc4e438f1db9cfd177
|
|
|
12a457 |
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
|
|
|
12a457 |
Reviewed-on: http://review.gluster.org/14365
|
|
|
12a457 |
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
12a457 |
Smoke: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/74435
|
|
|
12a457 |
---
|
|
|
12a457 |
tests/bugs/distribute/bug-1088231.t | 14 +++++++++++-
|
|
|
12a457 |
xlators/cluster/dht/src/dht-common.c | 40 ++++++----------------------------
|
|
|
12a457 |
2 files changed, 20 insertions(+), 34 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/tests/bugs/distribute/bug-1088231.t b/tests/bugs/distribute/bug-1088231.t
|
|
|
12a457 |
index b2347ef..8d4d1db 100755
|
|
|
12a457 |
--- a/tests/bugs/distribute/bug-1088231.t
|
|
|
12a457 |
+++ b/tests/bugs/distribute/bug-1088231.t
|
|
|
12a457 |
@@ -31,6 +31,11 @@ gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
|
|
|
12a457 |
|
|
|
12a457 |
TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a
|
|
|
12a457 |
|
|
|
12a457 |
+## new healing code don't attempt healing if inode is already
|
|
|
12a457 |
+## populated. So, unmount and remount before we do stat.
|
|
|
12a457 |
+TEST umount $M0
|
|
|
12a457 |
+TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
|
|
|
12a457 |
+
|
|
|
12a457 |
TEST stat $M0/.gfid/$gfid_with_hyphen
|
|
|
12a457 |
|
|
|
12a457 |
## Assuming that we have two bricks, we can have two permutations of layout
|
|
|
12a457 |
@@ -57,6 +62,8 @@ TEST stat $M0/.gfid/$gfid_with_hyphen
|
|
|
12a457 |
|
|
|
12a457 |
|
|
|
12a457 |
##Extract Layout
|
|
|
12a457 |
+echo `get_layout $B0/$V0"0"/a`
|
|
|
12a457 |
+echo `get_layout $B0/$V0"1"/a`
|
|
|
12a457 |
layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26`
|
|
|
12a457 |
layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34`
|
|
|
12a457 |
layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26`
|
|
|
12a457 |
@@ -70,7 +77,6 @@ layout_b1_s="0x"$layout_b1_s
|
|
|
12a457 |
layout_b1_e="0x"$layout_b1_e
|
|
|
12a457 |
|
|
|
12a457 |
|
|
|
12a457 |
-
|
|
|
12a457 |
## Logic of converting starting layout "0" to "Max_value of layout + 1"
|
|
|
12a457 |
comp1=$(($layout_b0_s + 0))
|
|
|
12a457 |
if [ "$comp1" == "0" ];then
|
|
|
12a457 |
@@ -114,9 +120,15 @@ gfid_with_hyphen=`getfattr -n glusterfs.gfid.string $M0/a 2>/dev/null \
|
|
|
12a457 |
TEST setfattr -x trusted.glusterfs.dht $B0/$V0"0"/a
|
|
|
12a457 |
TEST setfattr -x trusted.glusterfs.dht $B0/$V0"1"/a
|
|
|
12a457 |
|
|
|
12a457 |
+## new healing code don't attempt healing if inode is already
|
|
|
12a457 |
+## populated. So, unmount and remount before we do stat.
|
|
|
12a457 |
+TEST umount $M0
|
|
|
12a457 |
+TEST glusterfs --volfile-id=/$V0 --aux-gfid-mount --volfile-server=$H0 $M0
|
|
|
12a457 |
+
|
|
|
12a457 |
TEST stat $M0/.gfid/$gfid_with_hyphen
|
|
|
12a457 |
|
|
|
12a457 |
##Extract Layout
|
|
|
12a457 |
+
|
|
|
12a457 |
layout_b0_s=`get_layout $B0/$V0"0"/a | cut -c19-26`
|
|
|
12a457 |
layout_b0_e=`get_layout $B0/$V0"0"/a | cut -c27-34`
|
|
|
12a457 |
layout_b1_s=`get_layout $B0/$V0"1"/a | cut -c19-26`
|
|
|
12a457 |
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
index 10d47de..ebf074c 100644
|
|
|
12a457 |
--- a/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
+++ b/xlators/cluster/dht/src/dht-common.c
|
|
|
12a457 |
@@ -255,7 +255,7 @@ dht_discover_complete (xlator_t *this, call_frame_t *discover_frame)
|
|
|
12a457 |
int heal_path = 0;
|
|
|
12a457 |
int i = 0;
|
|
|
12a457 |
loc_t loc = {0 };
|
|
|
12a457 |
- int8_t is_read_only = 0;
|
|
|
12a457 |
+ int8_t is_read_only = 0, layout_anomalies = 0;
|
|
|
12a457 |
|
|
|
12a457 |
local = discover_frame->local;
|
|
|
12a457 |
layout = local->layout;
|
|
|
12a457 |
@@ -310,26 +310,10 @@ dht_discover_complete (xlator_t *this, call_frame_t *discover_frame)
|
|
|
12a457 |
"(overlaps/holes present: %s, "
|
|
|
12a457 |
"ENOENT errors: %d)", local->loc.path,
|
|
|
12a457 |
(ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0);
|
|
|
12a457 |
- if ((ret > 0) && (ret == conf->subvolume_cnt)) {
|
|
|
12a457 |
- op_errno = ESTALE;
|
|
|
12a457 |
- goto out;
|
|
|
12a457 |
- }
|
|
|
12a457 |
-
|
|
|
12a457 |
- /* For fixing the directory layout, we need to choose
|
|
|
12a457 |
- * the subvolume on which layout will be set first.
|
|
|
12a457 |
- * Because in nameless lookup, we have gfid only,
|
|
|
12a457 |
- * we are dependent on gfid. Therefore if conf->
|
|
|
12a457 |
- * randomize_by_gfid is set, then only we proceed for
|
|
|
12a457 |
- * healing layout of directory otherwise we don't heal.
|
|
|
12a457 |
- */
|
|
|
12a457 |
-
|
|
|
12a457 |
- if (local->inode && conf->randomize_by_gfid &&
|
|
|
12a457 |
- !is_read_only)
|
|
|
12a457 |
- goto selfheal;
|
|
|
12a457 |
- }
|
|
|
12a457 |
-
|
|
|
12a457 |
- if (local->inode)
|
|
|
12a457 |
+ layout_anomalies = 1;
|
|
|
12a457 |
+ } else if (local->inode) {
|
|
|
12a457 |
dht_layout_set (this, local->inode, layout);
|
|
|
12a457 |
+ }
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
if (!conf->vch_forced) {
|
|
|
12a457 |
@@ -349,11 +333,13 @@ dht_discover_complete (xlator_t *this, call_frame_t *discover_frame)
|
|
|
12a457 |
layout->list[i].err == ESTALE) {
|
|
|
12a457 |
heal_path = 1;
|
|
|
12a457 |
}
|
|
|
12a457 |
+
|
|
|
12a457 |
if (source && heal_path)
|
|
|
12a457 |
break;
|
|
|
12a457 |
}
|
|
|
12a457 |
}
|
|
|
12a457 |
- if (source && heal_path) {
|
|
|
12a457 |
+
|
|
|
12a457 |
+ if (source && (heal_path || layout_anomalies)) {
|
|
|
12a457 |
gf_uuid_copy (loc.gfid, local->gfid);
|
|
|
12a457 |
if (gf_uuid_is_null (loc.gfid)) {
|
|
|
12a457 |
goto done;
|
|
|
12a457 |
@@ -408,18 +394,6 @@ out:
|
|
|
12a457 |
NULL);
|
|
|
12a457 |
|
|
|
12a457 |
return ret;
|
|
|
12a457 |
-
|
|
|
12a457 |
-selfheal:
|
|
|
12a457 |
-
|
|
|
12a457 |
- main_frame->local = local;
|
|
|
12a457 |
- discover_frame->local = NULL;
|
|
|
12a457 |
- FRAME_SU_DO (main_frame, dht_local_t);
|
|
|
12a457 |
- gf_uuid_copy (local->loc.gfid, local->gfid);
|
|
|
12a457 |
- ret = dht_selfheal_directory_for_nameless_lookup (main_frame,
|
|
|
12a457 |
- dht_lookup_selfheal_cbk,
|
|
|
12a457 |
- &local->loc, layout);
|
|
|
12a457 |
- return ret;
|
|
|
12a457 |
-
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
int
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|