summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-07-01 04:41:54 +0000
committerAnand Avati <avati@gluster.com>2011-07-14 01:01:44 -0700
commit8d18bc22d1cfc8a481bc8d20da5843c65b567226 (patch)
tree680b1a4884b382aef8a8789a6dc6623797965fc4 /xlators/cluster/dht/src/dht-common.c
parent3f76fe277ec0a826bf3052134ad877ee65ce9e79 (diff)
distribute: bring in feature to do rebalance from inside
do the 'rebalance' on a file with 'setxattr()' with 'distribute.migrate-data' key. the valid 'value' is "force" or anything else. current implementation of 'rebalance' is same as 'glusterd-rebalance', and hence comes with limitation of not rebalancing hardlinks, non-regular files, and files with open-fds. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 3070 (After 'rebalance', the gfid of the file gets changed) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3070
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r--xlators/cluster/dht/src/dht-common.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index d5ee7ad1b90..c4bc0b4dfd9 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -2084,6 +2084,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
data_t *tmp = NULL;
uint32_t dir_spread = 0;
char value[4096] = {0,};
+ int forced_rebalance = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -2115,16 +2116,51 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
- tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY);
+ ret = loc_dup (loc, &local->loc);
+ if (ret == -1) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ tmp = dict_get (xattr, "distribute.migrate-data");
if (tmp) {
- gf_log (this->name, GF_LOG_INFO,
- "fixing the layout of %s", loc->path);
+ if (!IA_ISREG (loc->inode->ia_type)) {
+ op_errno = ENOTSUP;
+ goto err;
+ }
- ret = loc_dup (loc, &local->loc);
- if (ret == -1) {
- op_errno = ENOMEM;
+ /* TODO: need to interpret the 'value' for more meaning
+ (ie, 'target' subvolume given there, etc) */
+ memcpy (value, tmp->data, tmp->len);
+ if (strcmp (value, "force") == 0)
+ forced_rebalance = 1;
+
+ local->to_subvol = dht_subvol_get_hashed (this, loc);
+ local->from_subvol = dht_subvol_get_cached (this, loc->inode);
+ if (local->to_subvol == local->from_subvol) {
+ op_errno = ENOTSUP;
goto err;
}
+ if (local->to_subvol) {
+ local->flags = forced_rebalance;
+
+ ret = dht_start_rebalance_task (this, frame);
+ if (!ret)
+ return 0;
+
+ gf_log (this->name, GF_LOG_ERROR,
+ "%s: failed to create a new synctask",
+ loc->path);
+ }
+ op_errno = ENOTSUP;
+ goto err;
+
+ }
+
+ tmp = dict_get (xattr, GF_XATTR_FIX_LAYOUT_KEY);
+ if (tmp) {
+ gf_log (this->name, GF_LOG_INFO,
+ "fixing the layout of %s", loc->path);
dht_fix_directory_layout (frame, dht_common_setxattr_cbk,
layout);
@@ -2140,11 +2176,6 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
(dir_spread > 0))) {
layout->spread_cnt = dir_spread;
- ret = loc_dup (loc, &local->loc);
- if (ret == -1) {
- op_errno = ENOMEM;
- goto err;
- }
dht_fix_directory_layout (frame,
dht_common_setxattr_cbk,
layout);
@@ -4869,7 +4900,7 @@ dht_forget (xlator_t *this, inode_t *inode)
uint64_t tmp_layout = 0;
dht_layout_t *layout = NULL;
- inode_ctx_get (inode, this, &tmp_layout);
+ inode_ctx_del (inode, this, &tmp_layout);
if (!tmp_layout)
return 0;