diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2015-04-01 14:39:01 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-04 10:46:07 -0700 |
commit | 0aebfaa349c7c68c2d59531eabae5a03a748e16a (patch) | |
tree | 4ec7ce4889c66701f184191e9f69779bd0417f3d /xlators/features | |
parent | 13dbf333c47f0bc0efffddd4b8b83c4031cb7f36 (diff) |
features/shard: Create and use xattr_req dict as and when needed
Reusing local->xattr_req for the several calls and callbacks per xlator fop
would cause keys set from previous call/cbk (sometimes even by the xlators
below) to remain which in some cases can lead to errors. For instance, the
presence of "trusted.glusterfs.dht.*" keys (which are remnants of the previous
call/cbk), can cause the GF_IF_INTERNAL_XATTR_GOTO() check in DHT to fail when
the same dict is used to wind [f]setxattr.
Change-Id: I8612d020f83f3dc55e4a34d10ccbdaf11d7b4fdd
BUG: 1205661
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/10095
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/shard/src/shard.c | 42 | ||||
-rw-r--r-- | xlators/features/shard/src/shard.h | 1 |
2 files changed, 38 insertions, 5 deletions
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 29e131080f6..af90404d9a8 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -196,6 +196,8 @@ shard_local_wipe (shard_local_t *local) if (local->xattr_req) dict_unref (local->xattr_req); + if (local->xattr_rsp) + dict_unref (local->xattr_rsp); for (i = 0; i < count; i++) { if (local->inode_list[i]) @@ -1258,14 +1260,36 @@ unwind: int shard_lookup_dot_shard (call_frame_t *frame, xlator_t *this) { - shard_local_t *local = NULL; + int ret = -1; + dict_t *xattr_req = NULL; + shard_priv_t *priv = NULL; + shard_local_t *local = NULL; local = frame->local; + priv = this->private; + + xattr_req = dict_new (); + if (!xattr_req) + goto err; + + ret = dict_set_static_bin (xattr_req, "gfid-req", priv->dot_shard_gfid, + 16); + if (!ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set gfid of " + "/.shard into dict"); + goto err; + } STACK_WIND (frame, shard_lookup_dot_shard_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, &local->dot_shard_loc, - local->xattr_req); + xattr_req); + dict_unref (xattr_req); + return 0; +err: + if (xattr_req) + dict_unref (xattr_req); + SHARD_STACK_UNWIND (writev, frame, -1, ENOMEM, NULL, NULL, NULL); return 0; } @@ -1307,10 +1331,15 @@ shard_writev_mkdir_dot_shard (call_frame_t *frame, xlator_t *this) shard_local_t *local = NULL; shard_priv_t *priv = NULL; loc_t *dot_shard_loc = NULL; + dict_t *xattr_req = NULL; local = frame->local; priv = this->private; + xattr_req = dict_new (); + if (!xattr_req) + goto err; + dot_shard_loc = &local->dot_shard_loc; dot_shard_loc->inode = inode_new (this->itable); @@ -1327,8 +1356,8 @@ shard_writev_mkdir_dot_shard (call_frame_t *frame, xlator_t *this) if (dot_shard_loc->name) dot_shard_loc->name++; - ret = dict_set_static_bin (local->xattr_req, "gfid-req", - priv->dot_shard_gfid, 16); + ret = dict_set_static_bin (xattr_req, "gfid-req", priv->dot_shard_gfid, + 16); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to set gfid-req for " "/.shard"); @@ -1337,10 +1366,13 @@ shard_writev_mkdir_dot_shard (call_frame_t *frame, xlator_t *this) STACK_WIND (frame, shard_writev_mkdir_dot_shard_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, &local->dot_shard_loc, - 0755, 0, local->xattr_req); + 0755, 0, xattr_req); + dict_unref (xattr_req); return 0; err: + if (xattr_req) + dict_unref (xattr_req); SHARD_STACK_UNWIND (writev, frame, -1, ENOMEM, NULL, NULL, NULL); return 0; } diff --git a/xlators/features/shard/src/shard.h b/xlators/features/shard/src/shard.h index aa1f8851e15..4c4637567da 100644 --- a/xlators/features/shard/src/shard.h +++ b/xlators/features/shard/src/shard.h @@ -98,6 +98,7 @@ typedef struct shard_local { loc_t dot_shard_loc; fd_t *fd; dict_t *xattr_req; + dict_t *xattr_rsp; inode_t **inode_list; struct iovec *vector; struct iobref *iobref; |