diff options
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-selfheal.c | 20 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-shared.c | 16 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 8 |
5 files changed, 40 insertions, 8 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 6fa5b91d97d..e1e3a5a4e38 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -303,6 +303,7 @@ struct dht_conf { char *xattr_name; char *link_xattr_name; char *wild_xattr_name; + gf_boolean_t randomize_by_gfid; }; typedef struct dht_conf dht_conf_t; diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c index 84b0f2f4679..04e58903147 100644 --- a/xlators/cluster/dht/src/dht-selfheal.c +++ b/xlators/cluster/dht/src/dht-selfheal.c @@ -566,16 +566,26 @@ dht_selfheal_dir_mkdir (call_frame_t *frame, loc_t *loc, return 0; } - int dht_selfheal_layout_alloc_start (xlator_t *this, loc_t *loc, dht_layout_t *layout) { - int start = 0; - uint32_t hashval = 0; - int ret = 0; + int start = 0; + uint32_t hashval = 0; + int ret = 0; + const char *str = NULL; + dht_conf_t *conf = NULL; + char buf[UUID_CANONICAL_FORM_LEN + 1] = {0, }; + + conf = this->private; + + if (conf->randomize_by_gfid) { + str = uuid_utoa_r (loc->gfid, buf); + } else { + str = loc->path; + } - ret = dht_hash_compute (this, layout->type, loc->path, &hashval); + ret = dht_hash_compute (this, layout->type, str, &hashval); if (ret == 0) { start = (hashval % layout->cnt); } diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 3d1d635b4ed..53082c505ff 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -395,6 +395,10 @@ dht_reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("readdir-optimize", conf->readdir_optimize, options, bool, out); + GF_OPTION_RECONF ("randomize-hash-range-by-gfid", + conf->randomize_by_gfid, + options, bool, out); + if (conf->defrag) { GF_OPTION_RECONF ("rebalance-stats", conf->defrag->stats, options, bool, out); @@ -643,6 +647,9 @@ dht_init (xlator_t *this) goto err; } + GF_OPTION_INIT ("randomize-hash-range-by-gfid", + conf->randomize_by_gfid, bool, err); + GF_OPTION_INIT ("xattr-name", conf->xattr_name, str, err); gf_asprintf (&conf->link_xattr_name, "%s."DHT_LINKFILE_STR, conf->xattr_name); @@ -793,5 +800,14 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_ANY }, + { .key = {"randomize-hash-range-by-gfid"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "Use gfid of directory to determine the subvolume " + "from which hash ranges are allocated starting with 0. " + "Note that we still use a directory/file's name to determine the " + "subvolume to which it hashes" + }, + { .key = {NULL} }, }; diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 66b92a712af..fddd1f8f5dc 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -13079,7 +13079,7 @@ glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option) conf = this->private; GF_ASSERT (conf); - if (conf->op_version >= 4) { + if (conf->op_version >= GD_OP_VERSION_3_6_0) { /* Set needed volume options in volinfo->dict * For ex., * @@ -13088,7 +13088,6 @@ glusterd_enable_default_options (glusterd_volinfo_t *volinfo, char *option) * ... * } * */ - } out: return ret; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 4421e4ddbf7..b1d3fe54f88 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -398,7 +398,13 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = 3, .flags = OPT_FLAG_CLIENT_OPT }, - + { .key = "cluster.randomize-hash-range-by-gfid", + .voltype = "cluster/distribute", + .option = "randomize-hash-range-by-gfid", + .type = NO_DOC, + .op_version = GD_OP_VERSION_3_6_0, + .flags = OPT_FLAG_CLIENT_OPT, + }, /* NUFA xlator options (Distribute special case) */ { .key = "cluster.nufa", .voltype = "cluster/distribute", |