summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-09-27 23:10:58 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-28 10:39:48 -0700
commitdd400b5c5c49f1479db668b185a81fd434f7b219 (patch)
tree9c6412f9c2613528c25728e925130d4d75b9833a
parent8b539b2a3d91df2be314665bda15bdedd898d347 (diff)
glusterd rebalance: minor enhancements
* honor 'stop' command as early as possible * don't send a setxattr() call if file doesn't have dht linkfile Change-Id: I159641d03cd15e5818b811ad113d298f7f0112db BUG: 3584 Reviewed-on: http://review.gluster.com/520 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shishir Gowda <shishirng@gluster.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index ed87a5bb7..7fe2b8cb2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -56,6 +56,7 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
struct dirent *entry = NULL;
struct stat stbuf = {0,};
char full_path[PATH_MAX] = {0,};
+ char linkinfo[PATH_MAX] = {0,};
char force_string[64] = {0,};
if (!volinfo->defrag)
@@ -78,6 +79,16 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
if (!entry)
break;
+ /* We have to honor 'stop' (or 'pause'|'commit') as early
+ as possible */
+ if (volinfo->defrag_status !=
+ GF_DEFRAG_STATUS_MIGRATE_DATA_STARTED) {
+ /* It can be one of 'stopped|paused|commit' etc */
+ closedir (fd);
+ ret = 1;
+ goto out;
+ }
+
if (!strcmp (entry->d_name, ".") || !strcmp (entry->d_name, ".."))
continue;
@@ -92,9 +103,20 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
defrag->num_files_lookedup += 1;
+ /* TODO: bring in feature to support hardlink rebalance */
if (stbuf.st_nlink > 1)
continue;
+ /* if distribute is present, it will honor this key.
+ -1 is returned if distribute is not present or file doesn't
+ have a link-file. If file has link-file, the path of
+ link-file will be the value, and also that guarantees
+ that file has to be mostly migrated */
+ ret = sys_lgetxattr (full_path, GF_XATTR_LINKINFO_KEY,
+ &linkinfo, PATH_MAX);
+ if (ret <= 0)
+ continue;
+
ret = sys_lsetxattr (full_path, "distribute.migrate-data",
force_string, strlen (force_string), 0);
if (ret < 0)
@@ -106,14 +128,6 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
defrag->total_data += stbuf.st_size;
}
UNLOCK (&defrag->lock);
-
- if (volinfo->defrag_status !=
- GF_DEFRAG_STATUS_MIGRATE_DATA_STARTED) {
- /* It can be one of 'stopped|paused|commit' etc */
- closedir (fd);
- ret = 1;
- goto out;
- }
}
closedir (fd);
@@ -124,6 +138,16 @@ gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir)
if (!entry)
break;
+ /* We have to honor 'stop' (or 'pause'|'commit') as early
+ as possible */
+ if (volinfo->defrag_status !=
+ GF_DEFRAG_STATUS_MIGRATE_DATA_STARTED) {
+ /* It can be one of 'stopped|paused|commit' etc */
+ closedir (fd);
+ ret = 1;
+ goto out;
+ }
+
if (!strcmp (entry->d_name, ".") || !strcmp (entry->d_name, ".."))
continue;
@@ -169,6 +193,16 @@ gf_glusterd_rebalance_fix_layout (glusterd_volinfo_t *volinfo, const char *dir)
if (!entry)
break;
+ /* We have to honor 'stop' (or 'pause'|'commit') as early
+ as possible */
+ if (volinfo->defrag_status !=
+ GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED) {
+ /* It can be one of 'stopped|paused|commit' etc */
+ closedir (fd);
+ ret = 1;
+ goto out;
+ }
+
if (!strcmp (entry->d_name, ".") || !strcmp (entry->d_name, ".."))
continue;
@@ -180,6 +214,7 @@ gf_glusterd_rebalance_fix_layout (glusterd_volinfo_t *volinfo, const char *dir)
if (S_ISDIR (stbuf.st_mode)) {
/* Fix the layout of the directory */
+ /* TODO: isn't error code not important ? */
sys_lsetxattr (full_path, "trusted.distribute.fix.layout",
"yes", 3, 0);
@@ -191,14 +226,6 @@ gf_glusterd_rebalance_fix_layout (glusterd_volinfo_t *volinfo, const char *dir)
if (ret)
break;
}
-
- if (volinfo->defrag_status !=
- GF_DEFRAG_STATUS_LAYOUT_FIX_STARTED) {
- /* It can be one of 'stopped|paused|commit' etc */
- closedir (fd);
- ret = 1;
- goto out;
- }
}
closedir (fd);