Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: guijianfeng@cn.fujitsu.com (Gui Jianfeng)
Subject: [ltt-dev] [PATCH v3] lttng: remove ltt root directory if it's no needed
Date: Thu, 19 Feb 2009 09:39:49 +0800	[thread overview]
Message-ID: <499CB865.6080307@cn.fujitsu.com> (raw)
In-Reply-To: <499CB2F4.50805@cn.fujitsu.com>

We have to cleanup the lttng's root directory of debugfs if 
there is nobody uses it any more. Because any related lttng
modules are unloaded, no need to keep this directory.

This patch is based on 2.6.29-rc3-lttng-0.92.

Signed-off-by: Gui Jianfeng <guijianfeng at cn.fujitsu.com>
---
 include/linux/ltt-core.h  |    1 +
 ltt/ltt-core.c            |   10 ++++++++++
 ltt/ltt-trace-control.c   |    2 ++
 ltt/ltt-userspace-event.c |    1 +
 4 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/linux/ltt-core.h b/include/linux/ltt-core.h
index bc244c6..28394cb 100644
--- a/include/linux/ltt-core.h
+++ b/include/linux/ltt-core.h
@@ -30,6 +30,7 @@ extern struct ltt_traces ltt_traces;
 /*
  * get dentry of ltt's root dir
  */
+void put_ltt_root(void);
 struct dentry *get_ltt_root(void);
 
 /* Keep track of trap nesting inside LTT */
diff --git a/ltt/ltt-core.c b/ltt/ltt-core.c
index 18db91d..314750b 100644
--- a/ltt/ltt-core.c
+++ b/ltt/ltt-core.c
@@ -23,6 +23,16 @@ static DEFINE_MUTEX(ltt_traces_mutex);
 
 /* dentry of ltt's root dir */
 static struct dentry *ltt_root_dentry;
+
+void put_ltt_root(void)
+{
+	if (ltt_root_dentry && list_empty(&ltt_root_dentry->d_subdirs)) {
+		debugfs_remove(ltt_root_dentry);
+		ltt_root_dentry = NULL;
+	}
+}
+EXPORT_SYMBOL_GPL(put_ltt_root);
+
 struct dentry *get_ltt_root(void)
 {
 	if (!ltt_root_dentry) {
diff --git a/ltt/ltt-trace-control.c b/ltt/ltt-trace-control.c
index 16502a2..d7c9119 100644
--- a/ltt/ltt-trace-control.c
+++ b/ltt/ltt-trace-control.c
@@ -740,6 +740,7 @@ err_create_destroy_trace_file:
 err_create_setup_trace_file:
 	debugfs_remove(ltt_control_dir);
 err_create_control_dir:
+	put_ltt_root();
 err_no_root:
 	return err;
 }
@@ -759,6 +760,7 @@ static void __exit ltt_trace_control_exit(void)
 	debugfs_remove(ltt_setup_trace_file);
 	debugfs_remove(ltt_destroy_trace_file);
 	debugfs_remove_recursive(ltt_control_dir);
+	put_ltt_root();
 }
 
 module_init(ltt_trace_control_init);
diff --git a/ltt/ltt-userspace-event.c b/ltt/ltt-userspace-event.c
index 385bd3b..a48f336 100644
--- a/ltt/ltt-userspace-event.c
+++ b/ltt/ltt-userspace-event.c
@@ -118,6 +118,7 @@ err_no_root:
 static void __exit ltt_userspace_exit(void)
 {
 	debugfs_remove(ltt_event_file);
+	put_ltt_root();
 }
 
 module_init(ltt_userspace_init);
-- 
1.5.4.rc3






  reply	other threads:[~2009-02-19  1:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-18  8:16 [ltt-dev] [PATCH] " Gui Jianfeng
2009-02-18  8:28 ` Mathieu Desnoyers
2009-02-18  9:00   ` Gui Jianfeng
2009-02-18 11:50   ` [ltt-dev] [PATCH v2] " Gui Jianfeng
2009-02-18 23:50     ` KOSAKI Motohiro
2009-02-19  1:16       ` Gui Jianfeng
2009-02-19  1:39         ` Gui Jianfeng [this message]
2009-02-19  2:02           ` [ltt-dev] [PATCH v3] " KOSAKI Motohiro
2009-02-19  2:19             ` Gui Jianfeng
2009-02-19  2:38             ` Mathieu Desnoyers
2009-02-19  3:14           ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=499CB865.6080307@cn.fujitsu.com \
    --to=guijianfeng@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox