[ltt-dev] [PATCH v4 3/4] Add get_ltt_root() to get dentry of ltt's root dir
Zhaolei
zhaolei at cn.fujitsu.com
Thu Nov 13 04:54:34 EST 2008
get_ltt_root() is necessary for ltt-trace-control to create subdirs in ltt's
debugfs dir.
Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
---
include/linux/ltt-core.h | 8 ++++++++
ltt/ltt-core.c | 14 ++++++++++++++
ltt/ltt-relay.c | 8 +-------
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/include/linux/ltt-core.h b/include/linux/ltt-core.h
index 7e5ee8b..076c3ed 100644
--- a/include/linux/ltt-core.h
+++ b/include/linux/ltt-core.h
@@ -10,6 +10,9 @@
#include <linux/list.h>
#include <linux/percpu.h>
+/* ltt's root dir in debugfs */
+#define LTT_ROOT "ltt"
+
/*
* All modifications of ltt_traces must be done by ltt-tracer.c, while holding
* the semaphore. Only reading of this information can be done elsewhere, with
@@ -24,6 +27,11 @@ struct ltt_traces {
extern struct ltt_traces ltt_traces;
+/*
+ * get dentry of ltt's root dir
+ */
+struct dentry *get_ltt_root(void);
+
/* Keep track of trap nesting inside LTT */
DECLARE_PER_CPU(unsigned int, ltt_nesting);
diff --git a/ltt/ltt-core.c b/ltt/ltt-core.c
index aaad358..0ed1d06 100644
--- a/ltt/ltt-core.c
+++ b/ltt/ltt-core.c
@@ -9,6 +9,7 @@
#include <linux/ltt-core.h>
#include <linux/percpu.h>
#include <linux/module.h>
+#include <linux/debugfs.h>
/* Traces structures */
struct ltt_traces ltt_traces = {
@@ -20,6 +21,19 @@ EXPORT_SYMBOL(ltt_traces);
/* Traces list writer locking */
static DEFINE_MUTEX(ltt_traces_mutex);
+/* dentry of ltt's root dir */
+static struct dentry *ltt_root_dentry;
+struct dentry *get_ltt_root(void)
+{
+ if (!ltt_root_dentry) {
+ ltt_root_dentry = debugfs_create_dir(LTT_ROOT, NULL);
+ if (!ltt_root_dentry)
+ printk(KERN_ERR "LTT : ctrate ltt root dir failed\n");
+ }
+ return ltt_root_dentry;
+}
+EXPORT_SYMBOL_GPL(get_ltt_root);
+
void ltt_lock_traces(void)
{
mutex_lock(<t_traces_mutex);
diff --git a/ltt/ltt-relay.c b/ltt/ltt-relay.c
index c6e1d52..535bd2e 100644
--- a/ltt/ltt-relay.c
+++ b/ltt/ltt-relay.c
@@ -131,7 +131,6 @@ static inline int last_tsc_overflow(struct ltt_channel_buf_struct *ltt_buf,
}
#endif
-static struct dentry *ltt_root_dentry;
static struct file_operations ltt_file_operations;
/*
@@ -803,7 +802,7 @@ end:
static int ltt_relay_create_dirs(struct ltt_trace_struct *new_trace)
{
new_trace->dentry.trace_root = debugfs_create_dir(new_trace->trace_name,
- ltt_root_dentry);
+ get_ltt_root());
if (new_trace->dentry.trace_root == NULL) {
printk(KERN_ERR "LTT : Trace directory name %s already taken\n",
new_trace->trace_name);
@@ -1614,9 +1613,6 @@ static struct ltt_transport ltt_relay_transport = {
static int __init ltt_relay_init(void)
{
printk(KERN_INFO "LTT : ltt-relay init\n");
- ltt_root_dentry = debugfs_create_dir(LTT_RELAY_ROOT, NULL);
- if (ltt_root_dentry == NULL)
- return -EEXIST;
ltt_file_operations = ltt_relay_file_operations;
ltt_file_operations.owner = THIS_MODULE;
@@ -1637,8 +1633,6 @@ static void __exit ltt_relay_exit(void)
printk(KERN_INFO "LTT : ltt-relay exit\n");
ltt_transport_unregister(<t_relay_transport);
-
- debugfs_remove(ltt_root_dentry);
}
module_init(ltt_relay_init);
--
1.5.5.3
More information about the lttng-dev
mailing list