From 881d48d3278f4fe04eea899f2f45c0f45d6ee56e Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Thu, 7 Mar 2013 19:41:33 +0530 Subject: cluster/distribute: Fix layout overlaps due to spread-count in selfheal path We needed to zero out the layout range, before we re-calculate the range. When spread-count is issued, we would end up with stale ranges in the layout. Replaced dht_selfheal_dir_xattr with dht_fix_dir_xattr, which correctly resets the un-used (after re-cal) layouts. Change-Id: I1a900d15df07335f59356bd23182ccec34381ab2 BUG: 884455 Signed-off-by: shishir gowda Reviewed-on: http://review.gluster.org/4648 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- tests/bugs/bug-884455.t | 10 ++++-- xlators/cluster/dht/src/dht-selfheal.c | 62 +++++++--------------------------- 2 files changed, 20 insertions(+), 52 deletions(-) mode change 100644 => 100755 tests/bugs/bug-884455.t diff --git a/tests/bugs/bug-884455.t b/tests/bugs/bug-884455.t old mode 100644 new mode 100755 index e5b782267d0..c193cd8aad6 --- a/tests/bugs/bug-884455.t +++ b/tests/bugs/bug-884455.t @@ -1,6 +1,7 @@ #!/bin/bash . $(dirname $0)/../include.rc +. $(dirname $0)/../dht.rc cleanup; @@ -54,13 +55,18 @@ TEST $CLI volume start $V0 ## Mount FUSE TEST glusterfs -s $H0 --volfile-id $V0 $M0; -TEST mkdir $M0/dir{1..10}; +TEST mkdir $M0/dir{1..10} 2>/dev/null; ## Add-brick n run rebalance to force re-write of layout TEST $CLI volume add-brick $V0 $H0:$B0/${V0}2 sleep 5; + +## trigger dir self heal on client +TEST ls -l $M0 2>/dev/null; + TEST $CLI volume rebalance $V0 start force -sleep 30; + +EXPECT_WITHIN 15 "0" rebalance_completed ## check for layout overlaps. EXPECT "0" get_layout $B0/${V0}0 $B0/${V0}1 $B0/${V0}2 diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 77afde82e16..df7a475e035 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -28,7 +28,13 @@ layout->list[i].xlator->name, path); \ } while (0) - +#define DHT_RESET_LAYOUT_RANGE(layout) do { \ + int cnt = 0; \ + for (cnt = 0; cnt < layout->cnt; cnt++ ) { \ + layout->list[cnt].start = 0; \ + layout->list[cnt].stop = 0; \ + } \ + } while (0) static uint32_t dht_overlap_calc (dht_layout_t *old, int o, dht_layout_t *new, int n) { @@ -230,52 +236,6 @@ out: return 0; } -int -dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout) -{ - dht_local_t *local = NULL; - int missing_xattr = 0; - int i = 0; - xlator_t *this = NULL; - - local = frame->local; - this = frame->this; - - for (i = 0; i < layout->cnt; i++) { - if (layout->list[i].err != -1 || !layout->list[i].stop) { - /* err != -1 would mean xattr present on the directory - * or the directory is non existent. - * !layout->list[i].stop would mean layout absent - */ - - continue; - } - missing_xattr++; - } - - gf_log (this->name, GF_LOG_TRACE, - "%d subvolumes missing xattr for %s", - missing_xattr, loc->path); - - if (missing_xattr == 0) { - dht_selfheal_dir_finish (frame, this, 0); - return 0; - } - - local->call_cnt = missing_xattr; - - for (i = 0; i < layout->cnt; i++) { - if (layout->list[i].err != -1 || !layout->list[i].stop) - continue; - - dht_selfheal_dir_xattr_persubvol (frame, loc, layout, i, NULL); - - if (--missing_xattr == 0) - break; - } - return 0; -} - int dht_selfheal_dir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct iatt *statpre, @@ -291,7 +251,7 @@ dht_selfheal_dir_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, this_call_cnt = dht_frame_return (frame); if (is_last_call (this_call_cnt)) { - dht_selfheal_dir_xattr (frame, &local->loc, layout); + dht_fix_dir_xattr (frame, &local->loc, layout); } return 0; @@ -316,7 +276,7 @@ dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf, } if (missing_attr == 0) { - dht_selfheal_dir_xattr (frame, loc, layout); + dht_fix_dir_xattr (frame, loc, layout); return 0; } @@ -741,6 +701,8 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc, start_subvol = dht_selfheal_layout_alloc_start (this, loc, layout); + /* clear out the range, as we are re-computing here */ + DHT_RESET_LAYOUT_RANGE (layout); for (i = start_subvol; i < layout->cnt; i++) { err = layout->list[i].err; if (err == -1) { @@ -818,7 +780,7 @@ dht_selfheal_new_directory (call_frame_t *frame, dht_layout_sort_volname (layout); dht_selfheal_layout_new_directory (frame, &local->loc, layout); - dht_selfheal_dir_xattr (frame, &local->loc, layout); + dht_fix_dir_xattr (frame, &local->loc, layout); return 0; } -- cgit