diff options
author | Mohit Agrawal <moagrawa@redhat.com> | 2018-02-10 12:25:15 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-02-27 07:11:15 +0000 |
commit | 7c3cc485054e4ede1efb358552135b432fb7047a (patch) | |
tree | 5657500860f795b7c895bce14069545d8ba463e2 /glusterfsd/src | |
parent | 430bff7dc330eec9447423e95f2cae49744a79c3 (diff) |
glusterfsd: Memleak in glusterfsd process while brick mux is on
Problem: At the time of stopping the volume while brick multiplex is
enabled memory is not cleanup from all server side xlators.
Solution: To cleanup memory for all server side xlators call fini
in glusterfs_handle_terminate after send GF_EVENT_CLEANUP
notification to top xlator.
BUG: 1544090
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Note: Run all test-cases in separate build (https://review.gluster.org/19574)
with same patch after enable brick mux forcefully, all test cases are
passed.
Change-Id: Ia10dc7f2605aa50f2b90b3fe4eb380ba9299e2fc
Diffstat (limited to 'glusterfsd/src')
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 68 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 13 | ||||
-rw-r--r-- | glusterfsd/src/glusterfsd.h | 3 |
3 files changed, 71 insertions, 13 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index fa824de9996..f3a7c75517d 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -197,6 +197,73 @@ glusterfs_autoscale_threads (glusterfs_ctx_t *ctx, int incr, xlator_t *this) rpcsvc_ownthread_reconf (conf->rpc, pool->eventthreadcount); } +static int +xlator_mem_free (xlator_t *xl) +{ + volume_opt_list_t *vol_opt = NULL; + volume_opt_list_t *tmp = NULL; + + if (!xl) + return 0; + + GF_FREE (xl->name); + GF_FREE (xl->type); + xl->name = NULL; + xl->type = NULL; + + if (xl->options) { + dict_ref (xl->options); + dict_unref (xl->options); + xl->options = NULL; + } + + list_for_each_entry_safe (vol_opt, tmp, &xl->volume_options, list) { + list_del_init (&vol_opt->list); + GF_FREE (vol_opt); + } + + return 0; +} + +void +xlator_call_fini (xlator_t *this) { + if (!this) + return; + xlator_call_fini (this->next); + this->fini (this); +} + +void +xlator_mem_cleanup (xlator_t *this) { + xlator_list_t *list = this->children; + xlator_t *trav = list->xlator; + inode_table_t *inode_table = NULL; + xlator_t *prev = trav; + + inode_table = this->itable; + + xlator_call_fini (trav); + + while (prev) { + trav = prev->next; + xlator_mem_free (prev); + prev = trav; + } + + if (inode_table) { + inode_table_destroy (inode_table); + this->itable = NULL; + } + + if (this->fini) { + this->fini (this); + } + + xlator_mem_free (this); + +} + + int glusterfs_handle_terminate (rpcsvc_request_t *req) { @@ -263,6 +330,7 @@ glusterfs_handle_terminate (rpcsvc_request_t *req) gf_log (THIS->name, GF_LOG_INFO, "detaching not-only" " child %s", xlator_req.name); top->notify (top, GF_EVENT_CLEANUP, victim); + xlator_mem_cleanup (victim); } err: if (!lockflag) diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index added9a08c2..32cf20eed02 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -1448,20 +1448,7 @@ cleanup_and_exit (int signum) } #endif - /* call fini() of each xlator */ - - /*call fini for glusterd xlator */ - /* TODO : Invoke fini for rest of the xlators */ trav = NULL; - if (ctx->active) - trav = ctx->active->top; - while (trav) { - if (should_call_fini(ctx,trav)) { - THIS = trav; - trav->fini (trav); - } - trav = trav->next; - } /* NOTE: Only the least significant 8 bits i.e (signum & 255) will be available to parent process on calling exit() */ diff --git a/glusterfsd/src/glusterfsd.h b/glusterfsd/src/glusterfsd.h index 516eef864c0..1854a7e00d4 100644 --- a/glusterfsd/src/glusterfsd.h +++ b/glusterfsd/src/glusterfsd.h @@ -128,5 +128,8 @@ int glusterfs_volume_top_read_perf (uint32_t blk_size, uint32_t blk_count, void glusterfs_autoscale_threads (glusterfs_ctx_t *ctx, int incr, xlator_t *this); +void +xlator_mem_cleanup (xlator_t *this); + extern glusterfs_ctx_t *glusterfsd_ctx; #endif /* __GLUSTERFSD_H__ */ |