From 215fea41a96479312a5ab8783c13b30ab9fe00fa Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 16 Sep 2013 22:36:10 -0700 Subject: cluster/distribute: Rebalance should also verify free inodes Currently during `MIGRATE_DATA` we never verified about the total inode usage among new and old bricks. Such checks are available for disk space usage but it is also needed for inodes during data migration. Such a check leads to uniform outcome of file distribution upon rebalance. Patch provides: - Check dst_inodes < src_inodes, a friendly `warning` message to indicate we have to ignore such an attempt - Rename __dht_check_free_space() --> __dht_check_free_space_and_inodes() Change-Id: I7bc4dd8b507883f0fb836300e99f0bb083493f5f BUG: 982919 Signed-off-by: Harshavardhana Reviewed-on: http://review.gluster.org/5948 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/cluster/dht/src/dht-rebalance.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'xlators/cluster/dht/src/dht-rebalance.c') diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 5300ff2fe..c6a8e4177 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -332,8 +332,8 @@ out: } static inline int -__dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc, - struct iatt *stbuf, int flag) +__dht_check_free_space_and_inodes (xlator_t *to, xlator_t *from, loc_t *loc, + struct iatt *stbuf, int flag) { struct statvfs src_statfs = {0,}; struct statvfs dst_statfs = {0,}; @@ -379,9 +379,27 @@ __dht_check_free_space (xlator_t *to, xlator_t *from, loc_t *loc, goto out; } + /* NOTE: + For dynamically allocated inode filesystems since we have no + awareness on inodes, this logic fits well so that distribute + rebalance has nothing to worry about total inodes rather let the + files be `rebalanced` on the basis of hashing. + */ + if (dst_statfs.f_files && src_statfs.f_files) { + if (dst_statfs.f_ffree < src_statfs.f_ffree) { + gf_log (this->name, GF_LOG_WARNING, + "data movement attempted from node (%s) with" + " plenty free inodes to a node (%s) with " + "scanty free inodes (%s)", + from->name, to->name, loc->path); + ret = 1; + goto out; + } + } + check_avail_space: if (((dst_statfs.f_bavail * dst_statfs.f_bsize) / - GF_DISK_SECTOR_SIZE) < stbuf->ia_blocks) { + GF_DISK_SECTOR_SIZE) < stbuf->ia_blocks) { gf_log (this->name, GF_LOG_ERROR, "data movement attempted from node (%s) with " "to node (%s) which does not have required free space" @@ -389,7 +407,6 @@ check_avail_space: ret = 1; goto out; } - ret = 0; out: return ret; @@ -714,7 +731,7 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to, if (ret) goto out; - ret = __dht_check_free_space (to, from, loc, &stbuf, flag); + ret = __dht_check_free_space_and_inodes (to, from, loc, &stbuf, flag); if (ret) { goto out; } -- cgit