cluster/dht: fixes to should_layout_fix logic

* Don't consider "dir-spread-count" option. This option is not
supported.
* Consider transition to weighted to equal distribution or vice-versa
a valid case for fixing the layout.

Change-Id: I0dcfe555dae9269ce20a41611cfdaa4f96c9e98b
BUG: 1196615
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-on: http://review.gluster.org/9809
Reviewed-by: N Balachandran <nbalacha@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
Raghavendra G 2015-03-05 14:23:38 +05:30
parent e08aea2fd6
commit e944ff1f5a
2 changed files with 53 additions and 12 deletions

View File

@ -392,6 +392,11 @@ typedef enum {
GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS
} gf_dht_migrate_data_type_t;
typedef enum {
GF_DHT_EQUAL_DISTRIBUTION,
GF_DHT_WEIGHTED_DISTRIBUTION
} dht_distribution_type_t;
#define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT)
#define is_revalidate(loc) (dht_inode_ctx_layout_get (loc->inode, this, NULL) == 0)

View File

@ -405,16 +405,49 @@ out:
return count;
}
dht_distribution_type_t
dht_distribution_type (xlator_t *this, dht_layout_t *layout)
{
dht_distribution_type_t type = GF_DHT_EQUAL_DISTRIBUTION;
int i = 0;
uint32_t start_range = 0, range = 0, diff = 0;
if ((this == NULL) || (layout == NULL) || (layout->cnt < 1)) {
goto out;
}
for (i = 0; i < layout->cnt; i++) {
if (start_range == 0) {
start_range = layout->list[i].stop
- layout->list[i].start;
continue;
}
range = layout->list[i].stop - layout->list[i].start;
diff = abs (range - start_range);
if ((range != 0) && (diff > layout->cnt)) {
type = GF_DHT_WEIGHTED_DISTRIBUTION;
break;
}
}
out:
return type;
}
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, decommissioned_bricks = 0;
int spread_count = 0;
int ret = 0;
dht_conf_t *conf = NULL;
gf_boolean_t fixit = _gf_true;
dht_local_t *local = NULL;
int layout_span = 0;
int ondisk_decommissioned_bricks = 0;
int ret = 0;
dht_conf_t *conf = NULL;
dht_distribution_type_t inmem_dist_type = 0;
dht_distribution_type_t ondisk_dist_type = 0;
conf = frame->this->private;
@ -444,13 +477,16 @@ dht_should_fix_layout (call_frame_t *frame, dht_layout_t **inmem,
layout_span = dht_layout_span (*ondisk);
decommissioned_bricks = dht_decommissioned_bricks_in_layout (frame->this,
*ondisk);
spread_count = conf->dir_spread_cnt ? conf->dir_spread_cnt
: conf->subvolume_cnt;
ondisk_decommissioned_bricks
= dht_decommissioned_bricks_in_layout (frame->this,
*ondisk);
inmem_dist_type = dht_distribution_type (frame->this, *inmem);
ondisk_dist_type = dht_distribution_type (frame->this, *ondisk);
if ((decommissioned_bricks == 0) && (layout_span
== spread_count))
if ((ondisk_decommissioned_bricks == 0)
&& (layout_span == (conf->subvolume_cnt
- conf->decommission_subvols_cnt))
&& (inmem_dist_type == ondisk_dist_type))
fixit = _gf_false;
out: