diff options
author | Pranith Kumar Karampuri <pranith.karampuri@phonepe.com> | 2021-03-17 11:02:21 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-17 11:02:21 +0530 |
commit | 088d8a575c59479defb5dbe8bf03f4211156df7f (patch) | |
tree | ff09397bf546cfea43ea9a8ded29a69946296d83 /xlators | |
parent | d96e4c8dc5e7095aac0f81852d342e7a7c6238cc (diff) | |
download | glusterfs-088d8a575c59479defb5dbe8bf03f4211156df7f.tar.gz glusterfs-088d8a575c59479defb5dbe8bf03f4211156df7f.tar.xz glusterfs-088d8a575c59479defb5dbe8bf03f4211156df7f.zip |
cluster/dht: Provide option to disable fsync in data migration (#2259)
At the moment dht rebalance doesn't give any option to disable fsync
after data migration. Making this an option would give admins take
responsibility of data in a way that is suitable for their cluster.
Default value is still 'on', so that the behavior is intact for people
who don't care about this.
For example: If the data that is going to be migrated is already backed
up or snapshotted, there is no need for fsync to happen right after
migration which can affect active I/O on the volume from applications.
fixes: #2258
Change-Id: I7a50b8d3a2f270d79920ef306ceb6ba6451150c4
Signed-off-by: Pranith Kumar K <pranith.karampuri@phonepe.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 2 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 28 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-shared.c | 14 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 5 |
4 files changed, 37 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 712a2e98c4..2bf595175e 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -615,6 +615,8 @@ struct dht_conf { gf_boolean_t do_weighting; gf_boolean_t randomize_by_gfid; + + gf_boolean_t ensure_durability; }; typedef struct dht_conf dht_conf_t; diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index a1cd715f58..c3d60b7d2d 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -1818,19 +1818,23 @@ dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *cached_subvol, /* TODO: Sync the locks */ - xdata = dict_new(); - if (!xdata || dict_set_int8(xdata, "last-fsync", 1)) { - gf_log(this->name, GF_LOG_ERROR, - "%s: failed to set last-fsync flag on " - "%s (%s)", - loc->path, hashed_subvol->name, strerror(ENOMEM)); - } + if (conf->ensure_durability) { + xdata = dict_new(); + if (!xdata || dict_set_int8(xdata, "last-fsync", 1)) { + gf_log(this->name, GF_LOG_ERROR, + "%s: failed to set last-fsync flag on " + "%s (%s)", + loc->path, hashed_subvol->name, strerror(ENOMEM)); + } - ret = syncop_fsync(hashed_subvol, dst_fd, 0, NULL, NULL, xdata, NULL); - if (ret) { - gf_log(this->name, GF_LOG_WARNING, "%s: failed to fsync on %s (%s)", - loc->path, hashed_subvol->name, strerror(-ret)); - *fop_errno = -ret; + ret = syncop_fsync(hashed_subvol, dst_fd, 0, NULL, NULL, xdata, NULL); + if (ret) { + gf_log(this->name, GF_LOG_WARNING, "%s: failed to fsync on %s (%s)", + loc->path, hashed_subvol->name, strerror(-ret)); + *fop_errno = -ret; + ret = -1; + goto out; + } } /* Phase 2 - Data-Migration Complete, Housekeeping updates pending */ diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 75356c60a2..4c1f17abf5 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -476,6 +476,9 @@ dht_reconfigure(xlator_t *this, dict_t *options) GF_OPTION_RECONF("force-migration", conf->force_migration, options, bool, out); + GF_OPTION_RECONF("ensure-durability", conf->ensure_durability, options, + bool, out); + if (conf->defrag) { if (dict_get_str(options, "rebal-throttle", &temp_str) == 0) { ret = dht_configure_throttle(this, conf, temp_str); @@ -748,6 +751,8 @@ dht_init(xlator_t *this) GF_OPTION_INIT("force-migration", conf->force_migration, bool, err); + GF_OPTION_INIT("ensure-durability", conf->ensure_durability, bool, err); + if (defrag) { defrag->lock_migration_enabled = conf->lock_migration_enabled; @@ -1098,6 +1103,15 @@ struct volume_options dht_options[] = { .level = OPT_STATUS_ADVANCED, .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, + {.key = {"ensure-durability"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "on", + .description = "If disabled, rebalance will not fsync files after " + "migration", + .op_version = {GD_OP_VERSION_10_0}, + .level = OPT_STATUS_ADVANCED, + .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, + {.key = {NULL}}, }; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index bb4ae8c4b3..f598f78725 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -3103,4 +3103,9 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = GD_OP_VERSION_9_0, .value = "yes", .flags = VOLOPT_FLAG_CLIENT_OPT}, + + {.key = "rebalance.ensure-durability", + .voltype = "cluster/distribute", + .op_version = GD_OP_VERSION_10_0, + .flags = VOLOPT_FLAG_CLIENT_OPT}, {.key = NULL}}; |