From f4c4007263255c49b00eaf62542ec2386ca60302 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 31 May 2011 01:01:01 +0000 Subject: gluster rebalance: prevent data migration from higher disk space to lower this is done using the 'statfs()' on inode feature. Signed-off-by: Amar Tumballi Signed-off-by: Anand Avati BUG: 2258 (enhance gluster volume rebalance) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2258 --- xlators/mgmt/glusterd/src/glusterd-rebalance.c | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index ee778d21534..57b1772c227 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -21,8 +21,10 @@ #define _CONFIG_H #include "config.h" #endif + #include #include +#include #include "globals.h" #include "compat.h" @@ -56,6 +58,8 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) char tmp_filename[PATH_MAX] = {0,}; char value[16] = {0,}; char linkinfo[PATH_MAX] = {0,}; + struct statfs src_statfs = {0,}; + struct statfs dst_statfs = {0,}; if (!volinfo->defrag) goto out; @@ -111,6 +115,31 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) if (dst_fd == -1) continue; + /* Prevent data movement from a node which has higher + disk-space to a node with lesser */ + { + ret = statfs (full_path, &src_statfs); + if (ret) + gf_log ("", GF_LOG_INFO, "statfs on %s failed", + full_path); + + ret = statfs (tmp_filename, &dst_statfs); + if (ret) + gf_log ("", GF_LOG_INFO, "statfs on %s failed", + tmp_filename); + + if (dst_statfs.f_bavail < src_statfs.f_bavail) { + gf_log ("", GF_LOG_INFO, + "data movement attempted from node with" + " higher disk space to a node with " + "lesser disk space (%s)", full_path); + + close (dst_fd); + unlink (tmp_filename); + continue; + } + } + src_fd = open (full_path, O_RDONLY); if (src_fd == -1) { close (dst_fd); -- cgit