summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-02-02 12:35:16 +0530
committerN Balachandran <nbalacha@redhat.com>2018-02-07 06:24:57 +0000
commit187e8e8d879675048b1b133e5eb8a06ad3cc6f2a (patch)
treea87a4cd0fe9e2726b5971d0fb7d4fbbe58265142
parente19b3354a173b3e4d652a9aca5cc066eccc08332 (diff)
cluster/dht: Fixed leak in dht_populate_inode_for_dentry
Fixed an issue in dht_populate_inode_for_dentry where a layout is set in the inode without checking if it is already set. This overwrites the value each time without freeing the already existing layout. Also includes the changes in https://review.gluster.org/19471 > Change-Id: I651bf539a0b82b4ddc4c355890c16a8e91f5f1fd > BUG: 1541264 > Signed-off-by: N Balachandran <nbalacha@redhat.com> Change-Id: I651bf539a0b82b4ddc4c355890c16a8e91f5f1fd BUG: 1541267 Signed-off-by: N Balachandran <nbalacha@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-common.c14
-rw-r--r--xlators/cluster/dht/src/dht-common.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 63a54cb3138..d977c1f87a1 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -5116,29 +5116,32 @@ dht_populate_inode_for_dentry (xlator_t *this, xlator_t *subvol,
int ret = 0;
loc_t loc = {0, };
+ gf_uuid_copy (loc.gfid, orig_entry->d_stat.ia_gfid);
+ loc.inode = inode_ref (orig_entry->inode);
+
+ if (is_revalidate (&loc)) {
+ goto out;
+ }
+
layout = dht_layout_new (this, 1);
if (!layout)
goto out;
ret = dht_layout_merge (this, layout, subvol, 0, 0, orig_entry->dict);
if (!ret) {
- gf_uuid_copy (loc.gfid, orig_entry->d_stat.ia_gfid);
- loc.inode = inode_ref (orig_entry->inode);
-
ret = dht_layout_normalize (this, &loc, layout);
if (ret == 0) {
dht_layout_set (this, orig_entry->inode, layout);
entry->inode = inode_ref (orig_entry->inode);
layout = NULL;
}
-
- loc_wipe (&loc);
}
if (layout)
dht_layout_unref (this, layout);
out:
+ loc_wipe (&loc);
return;
}
@@ -5286,6 +5289,7 @@ list:
entry,
orig_entry);
}
+
}
} else {
if (orig_entry->inode) {
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 7c6b1191048..9e7e12a51ca 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -731,7 +731,7 @@ typedef struct dht_fd_ctx {
#define ENTRY_MISSING(op_ret, op_errno) (op_ret == -1 && op_errno == ENOENT)
-#define is_revalidate(loc) (dht_inode_ctx_layout_get (loc->inode, this, NULL) == 0)
+#define is_revalidate(loc) (dht_inode_ctx_layout_get ((loc)->inode, this, NULL) == 0)
#define is_last_call(cnt) (cnt == 0)