From e349e5d45f216ce4f716f1a5eef3e027aeacddaf Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 17 Mar 2016 16:18:14 -0400 Subject: [PATCH] Clean-up shm directory tree after freeing the channel MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit On NFS, an unlinked file that is still mmaped or unclosed is kept around by creating a .nfsXXXX file since it may still be in use. [1] This prevents the effective cleanup of the shm tree directory because it happens before the userspace consumer shm handles table cleanup. [2] Moving the tree removal to lttng_ustconsumer_free_channel ensures that the cleanup is done when the files are completely closed/unmapped. [1] http://nfs.sourceforge.net/ Look for "silly rename" [2] See channel_free subcall to shm_object_table_destroy Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- src/common/ust-consumer/ust-consumer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 481bbeba0..7ebc7ba34 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -1851,11 +1851,6 @@ void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan) } } } - /* Try to rmdir all directories under shm_path root. */ - if (chan->root_shm_path[0]) { - (void) run_as_recursive_rmdir(chan->root_shm_path, - chan->uid, chan->gid); - } } void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) @@ -1865,6 +1860,11 @@ void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) consumer_metadata_cache_destroy(chan); ustctl_destroy_channel(chan->uchan); + /* Try to rmdir all directories under shm_path root. */ + if (chan->root_shm_path[0]) { + (void) run_as_recursive_rmdir(chan->root_shm_path, + chan->uid, chan->gid); + } free(chan->stream_fds); } -- 2.34.1