summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-05-31 01:01:01 +0000
committerAnand Avati <avati@gluster.com>2011-05-31 22:52:05 -0700
commitf4c4007263255c49b00eaf62542ec2386ca60302 (patch)
tree29f9b696b287cfb5fb4697255dd5e3e349e8a5dd /xlators/mgmt/glusterd/src
parent0d2d861849a3b066eac676ebed4e16accdfe8598 (diff)
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 <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2258 (enhance gluster volume rebalance) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2258
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c29
1 files changed, 29 insertions, 0 deletions
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 <inttypes.h>
#include <sys/resource.h>
+#include <sys/vfs.h>
#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);