summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2019-06-21 09:04:19 +0530
committerhari gowtham <hari.gowtham005@gmail.com>2019-07-03 06:36:46 +0000
commit93aec95ee88d3b5313fae8f7d58b1322dabf444d (patch)
treeec21fa04779df61ac47f5fe0b552f89fb5ff0e3e /xlators/cluster
parent3d10901842cdc11f5cf9ed5c97837b4d2efe0b60 (diff)
cluster/dht: Fixed a memleak in dht_rename_cbk
Fixed a memleak in dht_rename_cbk when creating a linkto file. >Change-Id: I705adef3cb79e33806520fc2b15558e90e2c211c >fixes: bz#1722698 Change-Id: I705adef3cb79e33806520fc2b15558e90e2c211c fixes: bz#1726294 Signed-off-by: N Balachandran <nbalacha@redhat.com> (cherry picked from commit 532b0fc8b1ace9ad48fdaf643e0b1a34020b6cd8)
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-rename.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
index 893b4513628..5ba2373484a 100644
--- a/xlators/cluster/dht/src/dht-rename.c
+++ b/xlators/cluster/dht/src/dht-rename.c
@@ -1009,9 +1009,11 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
{
xlator_t *prev = NULL;
dht_local_t *local = NULL;
+ call_frame_t *main_frame = NULL;
prev = cookie;
local = frame->local;
+ main_frame = local->main_frame;
/* TODO: Handle this case in lookup-optimize */
if (op_ret == -1) {
@@ -1024,7 +1026,8 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
dht_linkfile_attr_heal(frame, this);
}
- dht_rename_unlink(frame, this);
+ dht_rename_unlink(main_frame, this);
+ DHT_STACK_DESTROY(frame);
return 0;
}
@@ -1040,7 +1043,8 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
xlator_t *src_cached = NULL;
xlator_t *dst_hashed = NULL;
xlator_t *dst_cached = NULL;
- loc_t link_loc = {0};
+ call_frame_t *link_frame = NULL;
+ dht_local_t *link_local = NULL;
local = frame->local;
prev = cookie;
@@ -1110,18 +1114,36 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
/* Create the linkto file for the dst file */
if ((src_cached == dst_cached) && (dst_hashed != dst_cached)) {
- loc_copy(&link_loc, &local->loc2);
- if (link_loc.inode)
- inode_unref(link_loc.inode);
- link_loc.inode = inode_ref(local->loc.inode);
- gf_uuid_copy(local->gfid, local->loc.inode->gfid);
- gf_uuid_copy(link_loc.gfid, local->loc.inode->gfid);
-
- dht_linkfile_create(frame, dht_rename_links_create_cbk, this,
- src_cached, dst_hashed, &link_loc);
+ link_frame = copy_frame(frame);
+ if (!link_frame) {
+ goto unlink;
+ }
+
+ /* fop value sent as maxvalue because it is not used
+ * anywhere in this case */
+ link_local = dht_local_init(link_frame, &local->loc2, NULL,
+ GF_FOP_MAXVALUE);
+ if (!link_local) {
+ goto unlink;
+ }
+
+ if (link_local->loc.inode)
+ inode_unref(link_local->loc.inode);
+ link_local->loc.inode = inode_ref(local->loc.inode);
+ link_local->main_frame = frame;
+ link_local->stbuf = local->stbuf;
+ gf_uuid_copy(link_local->gfid, local->loc.inode->gfid);
+
+ dht_linkfile_create(link_frame, dht_rename_links_create_cbk, this,
+ src_cached, dst_hashed, &link_local->loc);
return 0;
}
+unlink:
+
+ if (link_frame) {
+ DHT_STACK_DESTROY(link_frame);
+ }
dht_rename_unlink(frame, this);
return 0;