summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2015-03-05 14:23:38 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-03-05 10:03:25 -0800
commite944ff1f5a187863343691dfc108237c10dde287 (patch)
treeecf049b50283935f9dccfd8482055bd1685c829b /xlators
parente08aea2fd67a06275423ded157431305a7925cf6 (diff)
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>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.h5
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c60
2 files changed, 53 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 9e0228aa279..779b470585c 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -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)
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 1583ee5c602..a6658cc4cbb 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -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: