diff options
author | Poornima G <pgurusid@redhat.com> | 2015-02-19 21:29:02 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2015-03-04 07:15:12 -0800 |
commit | 9c5011b8e49e34d736ba7cfadc0802e8b80682a7 (patch) | |
tree | cacffa0ab6ba732d72a9c6f9eadd050c60cbae15 /xlators | |
parent | f82756b4909cebaf533570aec2b05ba55a7dcc95 (diff) |
glfs_fini: Clean up all the resources allocated in glfs_new.
Initially even after calling glfs_fini(), all the threads created
during init and many other resources like memory pool, iobuf pool,
event pool and other memory allocs were not being freed.
With this patch these resources are freed in glfs_fini().
The two thumb rules followed in this patch are:
- The threads are not killed, they are made to exit voluntarily,
once the queued tasks are completed. The main thread waits for
the other threads to exit.
- Free the memory pools and destroy the graphs only after all the
other threads are stopped, so that there are less chances of
hitting access after free.
Resources freed and its order:
1. Destroy the inode table of all the graphs - Call forget on all the inodes.
This will not be required when the cleanup during graph switch is
implemented to perform inode table destroy.
2. Deactivate the current graph, call fini of all the xlators.
3. Syncenv destroy - Join the synctask threads and cleanup syncenv resources
Sets the destroy mode, complete the existing synctasks, then join the
synctask threads.
After entering the destroy mode,
-if a new synctask is submitted, it fails.
-if syncenv_new() is called, it will end up creating new threads,
but this is called only during init.
4. Poller thread destroy
Register an event handler which sets the destroy mode for the poller.
Once the poller is done processing all the events, it exits.
5. Tear down the logging framework
The log file is closed and the log level is set to none, after this
point no log messages appear either in log file or in stderr.
6. Destroy the timer thread
Set the destroy bit, once the pending timer events are processed
the timer thread exits.
Note: Log infrastructure should be shutdown before destroying the timer
thread as gf_log uses timers.
7. Destroy the glusterfs_ctx_t
For all the graphs(active and passive), free graph, xlator structs and few other lists.
Free the memory pools - iobuf pool, event pool, dict, logbuf pool,
stub mem pool, stack mem pool, frame mem pool.
Few things not addressed in this patch:
1. rpc_transport object not destroyed, the PARENT_DOWN should have
destroyed this object but has not, needs to be addressed as a part
of different patch
2. Each xlator fini should clean up the local pool allocated by its xlator.
Needs to be addresses as a part of different patch.
3. Each xlator should implement forget to free its inode_ctx.
Needs to be addresses as a part of different patch.
3. Few other leaks reported by valgrind.
4. fd and fd contexts
The numbers:
The resource usage by the test case in this patch:
Without the fix, Memory: ~3GB; Threads: ~81
With this fix, Memory: 300MB; Threads: 1(main thread)
Change-Id: I96b9277541737aa8372b4e6c9eed380cb871e7c2
BUG: 1093594
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: http://review.gluster.org/7642
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 1 | ||||
-rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 04a90aae4c6..f954b1399db 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -4073,7 +4073,6 @@ afr_priv_destroy (afr_private_t *priv) if (!priv) goto out; - inode_unref (priv->root_inode); GF_FREE (priv->last_event); if (priv->pending_key) { for (i = 0; i < priv->child_count; i++) diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index facff5038a7..21acad02657 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -2062,7 +2062,6 @@ fini (xlator_t *this) { ioc_table_t *table = NULL; struct ioc_priority *curr = NULL, *tmp = NULL; - int i = 0; table = this->private; @@ -2082,11 +2081,15 @@ fini (xlator_t *this) GF_FREE (curr); } - for (i = 0; i < table->max_pri; i++) { + /* inode_lru and inodes list can be empty in case fini() is + * called soon after init()? Hence commenting the below asserts. + */ + /*for (i = 0; i < table->max_pri; i++) { GF_ASSERT (list_empty (&table->inode_lru[i])); } GF_ASSERT (list_empty (&table->inodes)); + */ pthread_mutex_destroy (&table->table_lock); GF_FREE (table); |