diff options
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 2 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 26 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-selfheal.c | 16 | 
3 files changed, 41 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 3b05540e290..8f0cbfb7b81 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -209,6 +209,8 @@ dht_selfheal_new_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t cbk,  int  dht_selfheal_restore (call_frame_t *frame, dht_selfheal_dir_cbk_t cbk,  		      loc_t *loc, dht_layout_t *layout); +int +dht_layout_sort_volname (dht_layout_t *layout);  int dht_rename (call_frame_t *frame, xlator_t *this,  		loc_t *oldloc, loc_t *newloc); diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 8698df4dc7a..25cfef39af9 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -303,6 +303,12 @@ dht_layout_entry_swap (dht_layout_t *layout, int i, int j)  	layout->list[j].err    = err_swap;  } +int64_t +dht_layout_entry_cmp_volname (dht_layout_t *layout, int i, int j) +{ +	return (strcmp (layout->list[i].xlator->name,  +			layout->list[j].xlator->name)); +}  int64_t  dht_layout_entry_cmp (dht_layout_t *layout, int i, int j) @@ -339,6 +345,26 @@ dht_layout_sort (dht_layout_t *layout)  	return 0;  } +int +dht_layout_sort_volname (dht_layout_t *layout) +{ +	int       i = 0; +	int       j = 0; +	int64_t   ret = 0; + +	/* TODO: O(n^2) -- bad bad */ + +	for (i = 0; i < layout->cnt - 1; i++) { +		for (j = i + 1; j < layout->cnt; j++) { +			ret = dht_layout_entry_cmp_volname (layout, i, j); +			if (ret > 0) +				dht_layout_entry_swap (layout, i, j); +		} +	} + +	return 0; +} +  int  dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout, diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 7bb22b1a758..45c9586cf4d 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -287,7 +287,8 @@ dht_selfheal_layout_new_directory (call_frame_t *frame, loc_t *loc,  	for (i = 0; i < layout->cnt; i++) {  		err = layout->list[i].err; -		if (err == -1) { +		if (err == -1 || err == 0) { +			layout->list[i].err = -1;  			cnt++;  		}  	} @@ -328,6 +329,7 @@ dht_selfheal_dir_getafix (call_frame_t *frame, loc_t *loc,  	int          holes = -1;  	int          ret = -1;  	int          i = -1; +	int          overlaps = -1;  	this = frame->this;  	conf = this->private; @@ -336,6 +338,7 @@ dht_selfheal_dir_getafix (call_frame_t *frame, loc_t *loc,  	missing = local->selfheal.missing;  	down = local->selfheal.down;  	holes = local->selfheal.hole_cnt; +	overlaps = local->selfheal.overlaps_cnt;  	if ((missing + down) == conf->subvolume_cnt) {  		dht_selfheal_layout_new_directory (frame, loc, layout); @@ -347,6 +350,11 @@ dht_selfheal_dir_getafix (call_frame_t *frame, loc_t *loc,  		ret = 0;  	} +	if (holes || missing || overlaps) { +		dht_selfheal_layout_new_directory (frame, loc, layout); +		ret = 0; +	} +  	for (i = 0; i < layout->cnt; i++) {  		/* directory not present */  		if (layout->list[i].err == ENOENT) { @@ -361,7 +369,8 @@ dht_selfheal_dir_getafix (call_frame_t *frame, loc_t *loc,  }  int -dht_selfheal_new_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk, +dht_selfheal_new_directory (call_frame_t *frame,  +			    dht_selfheal_dir_cbk_t dir_cbk,  			    dht_layout_t *layout)  {  	dht_local_t *local = NULL; @@ -371,6 +380,7 @@ dht_selfheal_new_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,  	local->selfheal.dir_cbk = dir_cbk;  	local->selfheal.layout = layout; +	dht_layout_sort_volname (layout);  	dht_selfheal_layout_new_directory (frame, &local->loc, layout);	  	dht_selfheal_dir_xattr (frame, &local->loc, layout);  	return 0; @@ -390,7 +400,6 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,  	int          ret      = 0;  	xlator_t    *this     = NULL; -  	local = frame->local;  	this = frame->this; @@ -441,6 +450,7 @@ dht_selfheal_directory (call_frame_t *frame, dht_selfheal_dir_cbk_t dir_cbk,  		goto sorry_no_fix;  	}  */ +	dht_layout_sort_volname (layout);  	ret = dht_selfheal_dir_getafix (frame, loc, layout);  	if (ret == -1) {  | 
