diff options
author | Susant Palai <spalai@redhat.com> | 2017-03-08 14:45:15 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2017-12-11 04:54:28 +0000 |
commit | c7a3e0ba9fa68503917e694e2595ee4e97d4e608 (patch) | |
tree | a4b48d58fdf7ddae210b8172e245fb3d95bd26d4 /xlators/cluster/dht/src/dht-rebalance.c | |
parent | 70b6be35dd299b47ce53b0de18386e5a458eb96a (diff) |
cluster/dht: fix memory leaks in rebalance
From code reading it was found that in gf_defrag_process_dir, GF_FREE
was called directly on dir_dfmeta->equeue leading to leaks of memory for
list of entries read from all the local subvols in case of a failure.
This patch frees the entries read from all the local subvols.
Change-Id: If5e8f557372a8fc2af86628b401e8de1b54986a1
BUG: 1430305
Signed-off-by: Susant Palai <spalai@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-rebalance.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index b8ba8ba70a1..c1c8a8a6ecf 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -37,20 +37,27 @@ idx %= sv_cnt; \ } -#define GF_FREE_DIR_DFMETA(dir_dfmeta) { \ - if (dir_dfmeta) { \ - GF_FREE (dir_dfmeta->head); \ - GF_FREE (dir_dfmeta->equeue); \ - GF_FREE (dir_dfmeta->iterator); \ - GF_FREE (dir_dfmeta->offset_var); \ - GF_FREE (dir_dfmeta->fetch_entries); \ - GF_FREE (dir_dfmeta); \ - } \ - } \ - uint64_t g_totalfiles = 0; uint64_t g_totalsize = 0; +void +gf_defrag_free_dir_dfmeta (struct dir_dfmeta *meta, int local_subvols_cnt) +{ + int i = 0; + + if (meta) { + for (i = 0; i < local_subvols_cnt; i++) { + gf_dirent_free (&meta->equeue[i]); + } + + GF_FREE (meta->equeue); + GF_FREE (meta->head); + GF_FREE (meta->iterator); + GF_FREE (meta->offset_var); + GF_FREE (meta->fetch_entries); + GF_FREE (meta); + } +} void gf_defrag_free_container (struct dht_container *container) @@ -3371,7 +3378,7 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc, ret = 0; out: - GF_FREE_DIR_DFMETA (dir_dfmeta); + gf_defrag_free_dir_dfmeta (dir_dfmeta, local_subvols_cnt); if (xattr_req) dict_unref(xattr_req); |