diff options
author | Amar Tumballi <amar@gluster.com> | 2011-07-01 04:40:05 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-14 01:01:39 -0700 |
commit | 3f76fe277ec0a826bf3052134ad877ee65ce9e79 (patch) | |
tree | 802ddcc8c34de9c65563e64635c8ba2ac1f1c59f /xlators/cluster/dht/src/dht-common.c | |
parent | 6cf06cfd4bf72b16ac7665323629d354b78b6b05 (diff) |
cluster/distribute: bring in directory-spread-count option
global spread count option is given through volume file
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2257 (enhance distribute to control the spread count (ie, control the hashing range))
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2257
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 237a07894..d5ee7ad1b 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2062,8 +2062,8 @@ err: static int -dht_fix_layout_cbk (call_frame_t *frame, void *cookie, - xlator_t *this, int32_t op_ret, int32_t op_errno) +dht_common_setxattr_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno) { DHT_STACK_UNWIND (setxattr, frame, op_ret, op_errno); @@ -2082,6 +2082,9 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, int op_errno = EINVAL; int ret = -1; data_t *tmp = NULL; + uint32_t dir_spread = 0; + char value[4096] = {0,}; + VALIDATE_OR_GOTO (frame, err); VALIDATE_OR_GOTO (this, err); @@ -2123,11 +2126,36 @@ dht_setxattr (call_frame_t *frame, xlator_t *this, goto err; } - dht_fix_directory_layout (frame, dht_fix_layout_cbk, + dht_fix_directory_layout (frame, dht_common_setxattr_cbk, layout); return 0; } + tmp = dict_get (xattr, "distribute.directory-spread-count"); + if (tmp) { + /* Setxattr value is packed as 'binary', not string */ + memcpy (value, tmp->data, ((tmp->len < 4095)?tmp->len:4095)); + ret = gf_string2uint32 (value, &dir_spread); + if (!ret && ((dir_spread <= conf->subvolume_cnt) && + (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); + return 0; + } + gf_log (this->name, GF_LOG_ERROR, + "wrong 'directory-spread-count' value (%s)", value); + op_errno = ENOTSUP; + goto err; + } + local->call_cnt = layout->cnt; for (i = 0; i < layout->cnt; i++) { |