|
|
f338ef |
From 5f304e003cc24ff7877ab51bdfded0dbf8ec581b Mon Sep 17 00:00:00 2001
|
|
|
f338ef |
From: N Balachandran <nbalacha@redhat.com>
|
|
|
f338ef |
Date: Fri, 21 Jun 2019 09:04:19 +0530
|
|
|
f338ef |
Subject: [PATCH 222/255] cluster/dht: Fixed a memleak in dht_rename_cbk
|
|
|
f338ef |
|
|
|
f338ef |
Fixed a memleak in dht_rename_cbk when creating
|
|
|
f338ef |
a linkto file.
|
|
|
f338ef |
|
|
|
f338ef |
upstream: https://review.gluster.org/#/c/glusterfs/+/22912/
|
|
|
f338ef |
|
|
|
f338ef |
>Change-Id: I705adef3cb79e33806520fc2b15558e90e2c211c
|
|
|
f338ef |
>fixes: bz#1722698
|
|
|
f338ef |
>Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
f338ef |
|
|
|
f338ef |
BUG:1722512
|
|
|
f338ef |
Change-Id: I8450cac82a0e1611e698ffac476ea5516e614236
|
|
|
f338ef |
Signed-off-by: N Balachandran <nbalacha@redhat.com>
|
|
|
f338ef |
Reviewed-on: https://code.engineering.redhat.com/gerrit/175181
|
|
|
f338ef |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
f338ef |
Reviewed-by: Susant Palai <spalai@redhat.com>
|
|
|
f338ef |
---
|
|
|
f338ef |
xlators/cluster/dht/src/dht-rename.c | 44 +++++++++++++++++++++++++++---------
|
|
|
f338ef |
1 file changed, 33 insertions(+), 11 deletions(-)
|
|
|
f338ef |
|
|
|
f338ef |
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
|
|
|
f338ef |
index 893b451..5ba2373 100644
|
|
|
f338ef |
--- a/xlators/cluster/dht/src/dht-rename.c
|
|
|
f338ef |
+++ b/xlators/cluster/dht/src/dht-rename.c
|
|
|
f338ef |
@@ -1009,9 +1009,11 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
f338ef |
{
|
|
|
f338ef |
xlator_t *prev = NULL;
|
|
|
f338ef |
dht_local_t *local = NULL;
|
|
|
f338ef |
+ call_frame_t *main_frame = NULL;
|
|
|
f338ef |
|
|
|
f338ef |
prev = cookie;
|
|
|
f338ef |
local = frame->local;
|
|
|
f338ef |
+ main_frame = local->main_frame;
|
|
|
f338ef |
|
|
|
f338ef |
/* TODO: Handle this case in lookup-optimize */
|
|
|
f338ef |
if (op_ret == -1) {
|
|
|
f338ef |
@@ -1024,7 +1026,8 @@ dht_rename_links_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
f338ef |
dht_linkfile_attr_heal(frame, this);
|
|
|
f338ef |
}
|
|
|
f338ef |
|
|
|
f338ef |
- dht_rename_unlink(frame, this);
|
|
|
f338ef |
+ dht_rename_unlink(main_frame, this);
|
|
|
f338ef |
+ DHT_STACK_DESTROY(frame);
|
|
|
f338ef |
return 0;
|
|
|
f338ef |
}
|
|
|
f338ef |
|
|
|
f338ef |
@@ -1040,7 +1043,8 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
f338ef |
xlator_t *src_cached = NULL;
|
|
|
f338ef |
xlator_t *dst_hashed = NULL;
|
|
|
f338ef |
xlator_t *dst_cached = NULL;
|
|
|
f338ef |
- loc_t link_loc = {0};
|
|
|
f338ef |
+ call_frame_t *link_frame = NULL;
|
|
|
f338ef |
+ dht_local_t *link_local = NULL;
|
|
|
f338ef |
|
|
|
f338ef |
local = frame->local;
|
|
|
f338ef |
prev = cookie;
|
|
|
f338ef |
@@ -1110,18 +1114,36 @@ dht_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
f338ef |
|
|
|
f338ef |
/* Create the linkto file for the dst file */
|
|
|
f338ef |
if ((src_cached == dst_cached) && (dst_hashed != dst_cached)) {
|
|
|
f338ef |
- loc_copy(&link_loc, &local->loc2);
|
|
|
f338ef |
- if (link_loc.inode)
|
|
|
f338ef |
- inode_unref(link_loc.inode);
|
|
|
f338ef |
- link_loc.inode = inode_ref(local->loc.inode);
|
|
|
f338ef |
- gf_uuid_copy(local->gfid, local->loc.inode->gfid);
|
|
|
f338ef |
- gf_uuid_copy(link_loc.gfid, local->loc.inode->gfid);
|
|
|
f338ef |
-
|
|
|
f338ef |
- dht_linkfile_create(frame, dht_rename_links_create_cbk, this,
|
|
|
f338ef |
- src_cached, dst_hashed, &link_loc);
|
|
|
f338ef |
+ link_frame = copy_frame(frame);
|
|
|
f338ef |
+ if (!link_frame) {
|
|
|
f338ef |
+ goto unlink;
|
|
|
f338ef |
+ }
|
|
|
f338ef |
+
|
|
|
f338ef |
+ /* fop value sent as maxvalue because it is not used
|
|
|
f338ef |
+ * anywhere in this case */
|
|
|
f338ef |
+ link_local = dht_local_init(link_frame, &local->loc2, NULL,
|
|
|
f338ef |
+ GF_FOP_MAXVALUE);
|
|
|
f338ef |
+ if (!link_local) {
|
|
|
f338ef |
+ goto unlink;
|
|
|
f338ef |
+ }
|
|
|
f338ef |
+
|
|
|
f338ef |
+ if (link_local->loc.inode)
|
|
|
f338ef |
+ inode_unref(link_local->loc.inode);
|
|
|
f338ef |
+ link_local->loc.inode = inode_ref(local->loc.inode);
|
|
|
f338ef |
+ link_local->main_frame = frame;
|
|
|
f338ef |
+ link_local->stbuf = local->stbuf;
|
|
|
f338ef |
+ gf_uuid_copy(link_local->gfid, local->loc.inode->gfid);
|
|
|
f338ef |
+
|
|
|
f338ef |
+ dht_linkfile_create(link_frame, dht_rename_links_create_cbk, this,
|
|
|
f338ef |
+ src_cached, dst_hashed, &link_local->loc);
|
|
|
f338ef |
return 0;
|
|
|
f338ef |
}
|
|
|
f338ef |
|
|
|
f338ef |
+unlink:
|
|
|
f338ef |
+
|
|
|
f338ef |
+ if (link_frame) {
|
|
|
f338ef |
+ DHT_STACK_DESTROY(link_frame);
|
|
|
f338ef |
+ }
|
|
|
f338ef |
dht_rename_unlink(frame, this);
|
|
|
f338ef |
return 0;
|
|
|
f338ef |
|
|
|
f338ef |
--
|
|
|
f338ef |
1.8.3.1
|
|
|
f338ef |
|