summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2014-05-05 09:18:35 +0530
committerAnand Avati <avati@redhat.com>2014-05-08 11:25:17 -0700
commit1b042296ddc65f5eab9d6e5f1e30e353413d9bbb (patch)
treebd7e26ecb63976522ad4f9879d893cb0ef53d984
parent933f60796d69686a153659c7b178dbd1475f9cb6 (diff)
cluster/afr: Remove stale index in self-heal codepath
Change-Id: I635fc0fa955b33590f1c5b4dfec22d591ea8575c BUG: 1032894 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/6592 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--tests/bugs/bug-1032894.t33
-rw-r--r--tests/volume.rc5
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c2
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c10
4 files changed, 45 insertions, 5 deletions
diff --git a/tests/bugs/bug-1032894.t b/tests/bugs/bug-1032894.t
new file mode 100644
index 00000000000..2a2b77fece9
--- /dev/null
+++ b/tests/bugs/bug-1032894.t
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+#Check stale indices are deleted as part of self-heal-daemon crawl.
+cleanup;
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
+TEST $CLI volume set $V0 cluster.self-heal-daemon off
+TEST $CLI volume start $V0
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0
+cd $M0
+TEST mkdir a
+cd a
+TEST kill_brick $V0 $H0 $B0/${V0}0
+# Create stale indices
+for i in {1..10}; do echo abc > $i; done
+for i in {1..10}; do rm -f $i; done
+
+TEST $CLI volume start $V0 force
+EXPECT_WITHIN 20 "1" afr_child_up_status_in_shd $V0 0
+TEST $CLI volume set $V0 cluster.self-heal-daemon on
+EXPECT_WITHIN 20 "Y" glustershd_up_status
+
+#Since maximum depth of the directory structure that needs healin is 2
+#Trigger two self-heals. That should make sure the heal is complete
+TEST $CLI volume heal $V0
+
+EXPECT_WITHIN 20 "0" afr_get_index_count $B0/${V0}1
+cleanup
diff --git a/tests/volume.rc b/tests/volume.rc
index 7d2494067e8..301b57b8d42 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -359,3 +359,8 @@ function volume_exists() {
return 0
fi
}
+
+function afr_get_index_count {
+ local brick=$1
+ ls $1/.glusterfs/indices/xattrop | grep -v xattrop | wc -l
+}
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index 6b39dcf9dbc..df14cbb0fb7 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -907,7 +907,7 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
goto out;
}
} else if (valid_cnt < 2) {
- ret = -ENOTCONN;
+ ret = -ENOTCONN;
goto out;
}
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index 787cb4ff557..0ff4c0cb1fc 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -303,6 +303,11 @@ afr_shd_selfheal (struct subvol_healer *healer, int child, uuid_t gfid)
subvol = priv->children[child];
+ //If this fails with ENOENT/ESTALE index is stale
+ ret = afr_shd_gfid_to_path (this, subvol, gfid, &path);
+ if (ret < 0)
+ return ret;
+
ret = afr_selfheal (this, gfid);
if (ret == -EIO) {
@@ -316,10 +321,6 @@ afr_shd_selfheal (struct subvol_healer *healer, int child, uuid_t gfid)
crawl_event->healed_count++;
}
- afr_shd_gfid_to_path (this, subvol, gfid, &path);
- if (!path)
- return ret;
-
if (eh) {
shd_event = GF_CALLOC (1, sizeof(*shd_event),
gf_afr_mt_shd_event_t);
@@ -334,6 +335,7 @@ afr_shd_selfheal (struct subvol_healer *healer, int child, uuid_t gfid)
if (eh_save_history (eh, shd_event) < 0) {
GF_FREE (shd_event);
GF_FREE (path);
+ return ret;
}
}
return ret;