summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht')
-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: