diff options
author | N Balachandran <nbalacha@redhat.com> | 2017-12-28 11:23:29 +0530 |
---|---|---|
committer | jiffin tony Thottan <jthottan@redhat.com> | 2018-01-12 05:37:34 +0000 |
commit | 19b74478fc87909b95a6c87ab212f21b79c809f3 (patch) | |
tree | 42abce2dd6352483829529526cf3d2a4950bc3f3 /xlators | |
parent | 0e0f277d83634328d2f0dff51411aea4b716cb96 (diff) |
cluster/dht: Use percentages for space check
With heterogenous bricks now being supported in DHT
we could run into issues where files are not migrated
even though there is sufficient space in newly added bricks
which just happen to be considerably smaller than older
bricks. Using percentages instead of absolute available
space for space checks can mitigate that to some extent.
Marking bug-1247563.t as that used to depend on the easier
code to prevent a file from migrating. This will be removed
once we find a way to force a file migration failure.
> Change-Id: I3452520511f304dbf5af86f0632f654a92fcb647
> BUG: 1529440
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
Change-Id: I3452520511f304dbf5af86f0632f654a92fcb647
BUG: 1530455
Signed-off-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 72826e5ff32..d0945650c9e 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -894,8 +894,10 @@ __dht_check_free_space (xlator_t *this, xlator_t *to, xlator_t *from, dht_layout_t *layout = NULL; uint64_t src_statfs_blocks = 1; uint64_t dst_statfs_blocks = 1; - double post_availspacepercent = 0; + double dst_post_availspacepercent = 0; + double src_post_availspacepercent = 0; uint64_t file_blocks = 0; + uint64_t src_total_blocks = 0; uint64_t dst_total_blocks = 0; xdata = dict_new (); @@ -956,6 +958,10 @@ __dht_check_free_space (xlator_t *this, xlator_t *to, xlator_t *from, (dst_statfs.f_frsize / GF_DISK_SECTOR_SIZE); + src_total_blocks = src_statfs.f_blocks * + (src_statfs.f_frsize / + GF_DISK_SECTOR_SIZE); + /* if force option is given, do not check for space @ dst. * Check only if space is avail for the file */ if (flag != GF_DHT_MIGRATE_DATA) @@ -967,6 +973,9 @@ __dht_check_free_space (xlator_t *this, xlator_t *to, xlator_t *from, subvol gains certain 'blocks' of free space. A valid check is necessary here to avoid errorneous move to destination where the space could be scantily available. + With heterogenous brick support, an actual space comparison could + prevent any files being migrated to newly added bricks if they are + smaller then the free space available on the existing bricks. */ if (stbuf) { if (!conf->use_fallocate) { @@ -980,7 +989,13 @@ __dht_check_free_space (xlator_t *this, xlator_t *to, xlator_t *from, } } - if (dst_statfs_blocks <= src_statfs_blocks) { + src_post_availspacepercent = + ((src_statfs_blocks + file_blocks) * 100) / src_total_blocks; + + dst_post_availspacepercent = + (dst_statfs_blocks * 100) / dst_total_blocks; + + if (dst_post_availspacepercent < src_post_availspacepercent) { gf_msg (this->name, GF_LOG_WARNING, 0, DHT_MSG_MIGRATE_FILE_FAILED, "data movement of file " @@ -1001,15 +1016,15 @@ __dht_check_free_space (xlator_t *this, xlator_t *to, xlator_t *from, check_avail_space: if (conf->disk_unit == 'p' && dst_statfs.f_blocks) { - post_availspacepercent = + dst_post_availspacepercent = (dst_statfs_blocks * 100) / dst_total_blocks; gf_msg_debug (this->name, 0, "file : %s, post_availspacepercent" " : %lf f_bavail : %lu min-free-disk: %lf", - loc->path, post_availspacepercent, + loc->path, dst_post_availspacepercent, dst_statfs.f_bavail, conf->min_free_disk); - if (post_availspacepercent < conf->min_free_disk) { + if (dst_post_availspacepercent < conf->min_free_disk) { gf_msg (this->name, GF_LOG_WARNING, 0, 0, "Write will cross min-free-disk for " "file - %s on subvol - %s. Looking " |