summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2013-01-23 09:59:59 +0530
committerAnand Avati <avati@redhat.com>2013-01-23 23:43:39 -0800
commit6fd654dc94fae49fb84336bd2e92c7cc893280e3 (patch)
treef4924f097f79a2c846c230efcb731a7b20d91e5d
parent8dc7707c1b32465551d5d5553057e04748945fda (diff)
cluster/distribute: get_layout should account only available subvolsv3.4.0qa7
The earlier logic used to check if (layout-spread-count <= subvol_cnt - decommissioned bricks). With this if a subvol was down, and layout-spread was > upsubvols, a mkdir ended up creating holes in the layout. The fix is to consider only the combination of subvols which are usable (not down or not decommissioned). Change-Id: I61ad3bcaf4589f5a75f7887cfa595c98311ae3bb BUG: 902610 Signed-off-by: shishir gowda <sgowda@redhat.com> Reviewed-on: http://review.gluster.org/4412 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rwxr-xr-xtests/bugs/bug-902610.t58
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c7
2 files changed, 61 insertions, 4 deletions
diff --git a/tests/bugs/bug-902610.t b/tests/bugs/bug-902610.t
new file mode 100755
index 00000000000..f5eb6be0287
--- /dev/null
+++ b/tests/bugs/bug-902610.t
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+
+cleanup;
+
+## Layout-spread set to 3, but subvols up are 2. So layout should split 50-50
+function get_layout()
+{
+ layout1=`getfattr -n trusted.glusterfs.dht -e hex $1 2>&1|grep dht |cut -d = -f2`
+ layout2=`getfattr -n trusted.glusterfs.dht -e hex $2 2>&1|grep dht |cut -d = -f2`
+
+ if [ $layout1 == "0x0000000100000000000000007ffffffe" ]
+ then
+ if [ $layout2 == "0x00000001000000007fffffffffffffff" ]
+ then
+ return 0
+ else
+ return 1
+ fi
+ fi
+
+ if [ $layout2 == "0x0000000100000000000000007ffffffe" ]
+ then
+ if [ $layout1 == "0x00000001000000007fffffffffffffff" ]
+ then
+ return 0
+ else
+ return 1
+ fi
+ fi
+ return 1
+}
+
+BRICK_COUNT=4
+
+TEST glusterd
+TEST pidof glusterd
+
+TEST $CLI volume create $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 $H0:$B0/${V0}2 $H0:$B0/${V0}3
+## set subvols-per-dir option
+TEST $CLI volume set $V0 subvols-per-directory 3
+TEST $CLI volume start $V0
+
+## Mount FUSE
+TEST glusterfs -s $H0 --volfile-id $V0 $M0 --entry-timeout=0 --attribute-timeout=0;
+
+TEST ls -l $M0
+
+## kill 2 bricks to bring down available subvol < spread count
+kill -9 `cat /var/lib/glusterd/vols/$V0/run/$H0-d-backends-${V0}2.pid`;
+kill -9 `cat /var/lib/glusterd/vols/$V0/run/$H0-d-backends-${V0}3.pid`;
+
+mkdir $M0/dir1 2>/dev/null
+
+get_layout $B0/${V0}0/dir1 $B0/${V0}1/dir1
+EXPECT "0" echo $?
+
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index fbe4cab3ea3..8463abdbfaf 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -550,11 +550,10 @@ dht_get_layout_count (xlator_t *this, dht_layout_t *layout, int new_layout)
}
/* if layout->spread_cnt is set, check if it is <= available
- * subvolumes (excluding bricks that are being decommissioned). Else
- * return count */
+ * subvolumes (down brick and decommissioned bricks are considered
+ * un-availbale). Else return count (available up bricks) */
count = ((layout->spread_cnt &&
- (layout->spread_cnt <=
- (conf->subvolume_cnt - conf->decommission_subvols_cnt))) ?
+ (layout->spread_cnt <= count)) ?
layout->spread_cnt : ((count) ? count : 1));
return count;