[ltt-dev] [PATCH v4 3/4] Add get_ltt_root() to get dentry of ltt's root dir

Mathieu Desnoyers compudj at krystal.dyndns.org
Thu Nov 13 09:09:19 EST 2008


* Zhaolei (zhaolei at cn.fujitsu.com) wrote:
> 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 +-------

Hrm, shouldn't this patch change ltt-relay-locked.c in a similar way ?

>  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");

ctrate -> create

Thanks,

Mathieu

> +	}
> +	return ltt_root_dentry;
> +}
> +EXPORT_SYMBOL_GPL(get_ltt_root);
> +
>  void ltt_lock_traces(void)
>  {
>  	mutex_lock(&ltt_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(&ltt_relay_transport);
> -
> -	debugfs_remove(ltt_root_dentry);
>  }
>  
>  module_init(ltt_relay_init);
> -- 
> 1.5.5.3
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list