summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r--xlators/cluster/dht/src/dht-common.c81
1 files changed, 32 insertions, 49 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index c120dffbf23..cd35080e243 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -809,8 +809,6 @@ dht_lookup_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!op_ret && gf_uuid_is_null (local->gfid))
memcpy (local->gfid, stbuf->ia_gfid, 16);
- memcpy (local->loc.gfid, local->gfid, 16);
-
/* Check if the gfid is different for file from other node */
if (!op_ret && gf_uuid_compare (local->gfid, stbuf->ia_gfid)) {
@@ -879,6 +877,8 @@ unlock:
this_call_cnt = dht_frame_return (frame);
if (is_last_call (this_call_cnt)) {
+ gf_uuid_copy (local->loc.gfid, local->gfid);
+
if (local->need_selfheal) {
local->need_selfheal = 0;
dht_lookup_everywhere (frame, this, &local->loc);
@@ -919,7 +919,6 @@ unlock:
selfheal:
FRAME_SU_DO (frame, dht_local_t);
- gf_uuid_copy (local->loc.gfid, local->gfid);
ret = dht_selfheal_directory (frame, dht_lookup_selfheal_cbk,
&local->loc, layout);
out:
@@ -3826,6 +3825,7 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this,
goto err;
}
+ local->xattr_req = xdata ? dict_ref (xdata) : dict_new ();
local->call_cnt = call_cnt = layout->cnt;
if (IA_ISDIR (fd->inode->ia_type)) {
@@ -3833,7 +3833,7 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this,
STACK_WIND (frame, dht_err_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->fsetxattr,
- fd, xattr, flags, NULL);
+ fd, xattr, flags, xdata);
}
} else {
@@ -3842,10 +3842,8 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this,
local->rebalance.xattr = dict_ref (xattr);
local->rebalance.flags = flags;
- xdata = xdata ? dict_ref (xdata) : dict_new ();
- if (xdata)
- ret = dict_set_dynstr_with_alloc (xdata,
- DHT_IATT_IN_XDATA_KEY, "yes");
+ ret = dict_set_dynstr_with_alloc (local->xattr_req,
+ DHT_IATT_IN_XDATA_KEY, "yes");
if (ret) {
gf_msg_debug (this->name, 0,
"Failed to set dictionary key %s for fd=%p",
@@ -3853,11 +3851,8 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this,
}
STACK_WIND (frame, dht_file_setxattr_cbk, subvol,
- subvol->fops->fsetxattr, fd, xattr, flags, xdata);
-
- if (xdata)
- dict_unref (xdata);
-
+ subvol->fops->fsetxattr, fd, xattr, flags,
+ local->xattr_req);
}
return 0;
@@ -3953,12 +3948,12 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
STACK_WIND (frame, dht_file_setxattr_cbk, subvol,
subvol->fops->setxattr, &local->loc,
local->rebalance.xattr, local->rebalance.flags,
- NULL);
+ local->xattr_req);
} else {
STACK_WIND (frame, dht_file_setxattr_cbk, subvol,
subvol->fops->fsetxattr, local->fd,
local->rebalance.xattr, local->rebalance.flags,
- NULL);
+ local->xattr_req);
}
return 0;
@@ -4242,6 +4237,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
if (tmp) {
return dht_nuke_dir (frame, this, loc, tmp);
}
+ local->xattr_req = xdata ? dict_ref (xdata) : dict_new ();
if (IA_ISDIR (loc->inode->ia_type)) {
@@ -4258,17 +4254,12 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
local->rebalance.flags = flags;
local->call_cnt = 1;
- xdata = xdata ? dict_ref (xdata) : dict_new ();
- if (xdata)
- ret = dict_set_dynstr_with_alloc (xdata,
- DHT_IATT_IN_XDATA_KEY, "yes");
+ ret = dict_set_dynstr_with_alloc (local->xattr_req,
+ DHT_IATT_IN_XDATA_KEY, "yes");
STACK_WIND (frame, dht_file_setxattr_cbk,
subvol, subvol->fops->setxattr,
- loc, xattr, flags, xdata);
-
- if (xdata)
- dict_unref (xdata);
+ loc, xattr, flags, local->xattr_req);
}
return 0;
@@ -4387,11 +4378,11 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame,
if (local->fop == GF_FOP_REMOVEXATTR) {
STACK_WIND (frame, dht_file_removexattr_cbk, subvol,
subvol->fops->removexattr, &local->loc,
- local->key, NULL);
+ local->key, local->xattr_req);
} else {
STACK_WIND (frame, dht_file_removexattr_cbk, subvol,
subvol->fops->fremovexattr, local->fd,
- local->key, NULL);
+ local->key, local->xattr_req);
}
return 0;
@@ -4428,8 +4419,6 @@ dht_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
unlock:
UNLOCK (&frame->lock);
-
-
this_call_cnt = dht_frame_return (frame);
if (is_last_call (this_call_cnt)) {
DHT_STACK_UNWIND (removexattr, frame, local->op_ret,
@@ -4485,6 +4474,7 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
op_errno = EINVAL;
goto err;
}
+ local->xattr_req = (xdata) ? dict_ref (xdata) : dict_new ();
local->call_cnt = call_cnt = layout->cnt;
local->key = gf_strdup (key);
@@ -4494,16 +4484,15 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
STACK_WIND (frame, dht_removexattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->removexattr,
- loc, key, NULL);
+ loc, key, local->xattr_req);
}
} else {
local->call_cnt = 1;
- xdata = xdata ? dict_ref (xdata) : dict_new ();
- if (xdata)
- ret = dict_set_dynstr_with_alloc (xdata,
- DHT_IATT_IN_XDATA_KEY, "yes");
+
+ ret = dict_set_dynstr_with_alloc (local->xattr_req,
+ DHT_IATT_IN_XDATA_KEY, "yes");
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
DHT_MSG_DICT_SET_FAILED, "Failed to "
@@ -4513,10 +4502,7 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
STACK_WIND (frame, dht_file_removexattr_cbk,
subvol, subvol->fops->removexattr,
- loc, key, xdata);
-
- if (xdata)
- dict_unref (xdata);
+ loc, key, local->xattr_req);
}
return 0;
@@ -4574,6 +4560,7 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this,
op_errno = EINVAL;
goto err;
}
+ local->xattr_req = xdata ? dict_ref (xdata) : dict_new ();
local->call_cnt = call_cnt = layout->cnt;
local->key = gf_strdup (key);
@@ -4583,29 +4570,23 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this,
STACK_WIND (frame, dht_removexattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->fremovexattr,
- fd, key, NULL);
+ fd, key, local->xattr_req);
}
} else {
local->call_cnt = 1;
- xdata = xdata ? dict_ref (xdata) : dict_new ();
- if (xdata)
- ret = dict_set_dynstr_with_alloc (xdata,
- DHT_IATT_IN_XDATA_KEY, "yes");
+ ret = dict_set_dynstr_with_alloc (local->xattr_req,
+ DHT_IATT_IN_XDATA_KEY, "yes");
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
DHT_MSG_DICT_SET_FAILED, "Failed to "
"set dictionary key %s for fd=%p",
DHT_IATT_IN_XDATA_KEY, fd);
}
-
STACK_WIND (frame, dht_file_removexattr_cbk,
subvol, subvol->fops->fremovexattr,
- fd, key, xdata);
-
- if (xdata)
- dict_unref (xdata);
+ fd, key, local->xattr_req);
}
return 0;
@@ -6527,7 +6508,7 @@ dht_link2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
local->call_cnt = 2;
STACK_WIND (frame, dht_link_cbk, subvol, subvol->fops->link,
- &local->loc, &local->loc2, NULL);
+ &local->loc, &local->loc2, local->xattr_req);
return 0;
err:
@@ -6554,7 +6535,7 @@ dht_link_linkfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
srcvol = local->linkfile.srcvol;
STACK_WIND (frame, dht_link_cbk, srcvol, srcvol->fops->link,
- &local->loc, &local->loc2, xdata);
+ &local->loc, &local->loc2, local->xattr_req);
return 0;
@@ -6563,7 +6544,7 @@ err:
dht_set_fixed_dir_stat (preparent);
dht_set_fixed_dir_stat (postparent);
DHT_STACK_UNWIND (link, frame, op_ret, op_errno, inode, stbuf, preparent,
- postparent, NULL);
+ postparent, xdata);
return 0;
}
@@ -6614,6 +6595,8 @@ dht_link (call_frame_t *frame, xlator_t *this,
op_errno = ENOMEM;
goto err;
}
+ if (xdata)
+ local->xattr_req = dict_ref (xdata);
if (hashed_subvol != cached_subvol) {
gf_uuid_copy (local->gfid, oldloc->inode->gfid);