summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2014-06-04 19:53:50 +0530
committerVijay Bellur <vbellur@redhat.com>2014-06-08 07:53:09 -0700
commitbf5a9778c4c05ddd1f2b371abb3d5f70fedf4752 (patch)
tree92f6fdaa9725b45cc188f25feded0ed58f6786de /xlators
parentd64d0129ee8e0c32f027cf9df17e8debfaf73ab2 (diff)
features/gfid-access: calloc gfid and set in xdata
Problem: the gfid passed to ga_fill_tmp_loc() was a stack variable which the function set in the xdata dictionary. Accessing it in a later point in time gave unexpected values. This was easy to hit when AFR was involved like so: ga_mknod()--->xxx-->afr_mknod(): In afr_mknod transaction, once the stack-winds for the lock-phase are sent, the gfid in xdata becomes out of scope. When we send the actual op i.e. afr_mknod_wind(), the gfid in xdata is stale, causing posix to set junk gfids on the files. Fix: calloc the gfid and set it in the dict. Thanks to Pranith for the RCA! Change-Id: I0291fce34745268dc63095fc41fe31c7213dd5e1 BUG: 1104707 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: http://review.gluster.org/7978 Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index 5cb6ecfbd4a..8adf85bb55b 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -258,6 +258,7 @@ ga_fill_tmp_loc (loc_t *loc, xlator_t *this, uuid_t gfid,
int ret = -1;
uint64_t value = 0;
inode_t *parent = NULL;
+ uuid_t *gfid_ptr = NULL;
parent = loc->inode;
ret = inode_ctx_get (loc->inode, this, &value);
@@ -278,17 +279,21 @@ ga_fill_tmp_loc (loc_t *loc, xlator_t *this, uuid_t gfid,
loc_path (new_loc, bname);
new_loc->name = basename (new_loc->path);
- /* As GFID would not be set on the entry yet, lets not send entry
- gfid in the request */
- /*uuid_copy (new_loc->gfid, (const unsigned char *)gfid); */
-
- ret = dict_set_static_bin (xdata, "gfid-req", gfid, 16);
+ gfid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
+ if (!gfid_ptr) {
+ ret = -1;
+ goto out;
+ }
+ uuid_copy (*gfid_ptr, gfid);
+ ret = dict_set_dynptr (xdata, "gfid-req", gfid_ptr, sizeof (uuid_t));
if (ret < 0)
goto out;
ret = 0;
out:
+ if (ret && gfid_ptr)
+ GF_FREE (gfid_ptr);
return ret;
}