From e2a76e76e3d9174fa77f40f3abd0212705283f00 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 18 Sep 2014 14:36:38 +0530 Subject: cluster/dht: Fix dict_t leaks in rebalance process' execution path Backport of: http://review.gluster.org/8763 Two dict_t objects are leaked for every file migrated in success codepath. It is the caller's responsibility to unref dict that it gets from calls to syncop_getxattr(); and rebalance performs two syncop_getxattr()s per file without freeing them. Also, syncop_getxattr() on GF_XATTR_LINKINFO_KEY doesn't seem to be using the response dict. Hence, NULL is now passed as opposed to @dict to syncop_getxattr(). Change-Id: I59556ee6e135e7e65d4ddd31ba0f39e7eb50b02d BUG: 1144792 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/8789 Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY --- xlators/cluster/dht/src/dht-rebalance.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index c181bebd131..23efa8d57b3 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -1121,6 +1121,12 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc, free_entries = _gf_true; list_for_each_entry_safe (entry, tmp, &entries.list, list) { + + if (dict) { + dict_unref (dict); + dict = NULL; + } + if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) { ret = 1; goto out; @@ -1210,16 +1216,13 @@ gf_defrag_migrate_data (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc, uuid_str = NULL; - dict_del (dict, GF_XATTR_NODE_UUID_KEY); - - /* if distribute is present, it will honor this key. * -1 is returned if distribute is not present or file * doesn't have a link-file. If file has link-file, the * path of link-file will be the value, and also that * guarantees that file has to be mostly migrated */ - ret = syncop_getxattr (this, &entry_loc, &dict, + ret = syncop_getxattr (this, &entry_loc, NULL, GF_XATTR_LINKINFO_KEY); if (ret < 0) { gf_log (this->name, GF_LOG_TRACE, "failed to " -- cgit