cluster/dht: Fixes to should_fix_layout logic

* With recent introduction of locking in self-heal codepath,
  fix layout was not allowed to progress during remove-brick.
  This patch fixes the issue.

* dht_should_fix_layout also considers "dir-spread-count" option if
  set, to determine whether we should proceed with fix-layout or not.

Change-Id: Icd96986f7af705744131d62e7f1456114ac1ee53
BUG: 1196615
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/9764
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: N Balachandran <nbalacha@redhat.com>
This commit is contained in:
Raghavendra G 2015-02-26 22:50:25 +05:30
parent 95d5e60afb
commit ef061b67f1

View File

@ -380,15 +380,41 @@ dht_layout_span (dht_layout_t *layout)
return count;
}
int
dht_decommissioned_bricks_in_layout (xlator_t *this, dht_layout_t *layout)
{
dht_conf_t *conf = NULL;
int count = 0, i = 0, j = 0;
if ((this == NULL) || (layout == NULL))
goto out;
conf = this->private;
for (i = 0; i < layout->cnt; i++) {
for (j = 0; j < conf->subvolume_cnt; j++) {
if (conf->decommissioned_bricks[j] &&
conf->decommissioned_bricks[j]
== layout->list[i].xlator) {
count++;
}
}
}
out:
return count;
}
gf_boolean_t
dht_should_fix_layout (call_frame_t *frame, dht_layout_t **inmem,
dht_layout_t **ondisk)
{
gf_boolean_t fixit = _gf_true;
dht_local_t *local = NULL;
int layout_span = 0;
int ret = 0;
dht_conf_t *conf = NULL;
gf_boolean_t fixit = _gf_true;
dht_local_t *local = NULL;
int layout_span = 0, decommissioned_bricks = 0;
int spread_count = 0;
int ret = 0;
dht_conf_t *conf = NULL;
conf = frame->this->private;
@ -418,7 +444,13 @@ dht_should_fix_layout (call_frame_t *frame, dht_layout_t **inmem,
layout_span = dht_layout_span (*ondisk);
if (layout_span == conf->subvolume_cnt)
decommissioned_bricks = dht_decommissioned_bricks_in_layout (frame->this,
*ondisk);
spread_count = conf->dir_spread_cnt ? conf->dir_spread_cnt
: conf->subvolume_cnt;
if ((decommissioned_bricks == 0) && (layout_span
== spread_count))
fixit = _gf_false;
out: