aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-01-20 15:48:46 -0500
committerSteven Rostedt <rostedt@goodmis.org>2015-02-03 12:48:42 -0500
commitf76180bc07abc399977bfbe8c43bf58c4570e893 (patch)
tree6638b15592e2af975cd7ed7bd0815bb0def51ffb /kernel/trace/trace.c
parent8434dc9340cd2e117fc944cf7526263bf490a52a (diff)
tracing: Automatically mount tracefs on debugfs/tracing
As tools currently rely on the tracing directory in debugfs, we can not just created a tracefs infrastructure and expect sysadmins to mount the new tracefs to have their old tools work. Instead, the debugfs tracing directory is still created and the tracefs file system is mounted there when the debugfs filesystem is mounted. No longer does the tracing infrastructure update the debugfs file system, but instead interacts with the tracefs file system. But now, it still appears to the user like nothing changed, except you also have the feature of mounting just the tracing system without needing all of debugfs! Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6c4739bee4bb..b4aa936509d2 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -32,6 +32,7 @@
32#include <linux/splice.h> 32#include <linux/splice.h>
33#include <linux/kdebug.h> 33#include <linux/kdebug.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/mount.h>
35#include <linux/rwsem.h> 36#include <linux/rwsem.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
37#include <linux/ctype.h> 38#include <linux/ctype.h>
@@ -6535,6 +6536,28 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
6535 6536
6536} 6537}
6537 6538
6539static struct vfsmount *trace_automount(void *ingore)
6540{
6541 struct vfsmount *mnt;
6542 struct file_system_type *type;
6543
6544 /*
6545 * To maintain backward compatibility for tools that mount
6546 * debugfs to get to the tracing facility, tracefs is automatically
6547 * mounted to the debugfs/tracing directory.
6548 */
6549 type = get_fs_type("tracefs");
6550 if (!type)
6551 return NULL;
6552 mnt = vfs_kern_mount(type, 0, "tracefs", NULL);
6553 put_filesystem(type);
6554 if (IS_ERR(mnt))
6555 return NULL;
6556 mntget(mnt);
6557
6558 return mnt;
6559}
6560
6538/** 6561/**
6539 * tracing_init_dentry - initialize top level trace array 6562 * tracing_init_dentry - initialize top level trace array
6540 * 6563 *
@@ -6546,14 +6569,21 @@ struct dentry *tracing_init_dentry(void)
6546{ 6569{
6547 struct trace_array *tr = &global_trace; 6570 struct trace_array *tr = &global_trace;
6548 6571
6572 /* The top level trace array uses NULL as parent */
6549 if (tr->dir) 6573 if (tr->dir)
6550 return tr->dir; 6574 return NULL;
6551 6575
6552 if (WARN_ON(!debugfs_initialized())) 6576 if (WARN_ON(!debugfs_initialized()))
6553 return ERR_PTR(-ENODEV); 6577 return ERR_PTR(-ENODEV);
6554 6578
6555 tr->dir = debugfs_create_dir("tracing", NULL); 6579 /*
6556 6580 * As there may still be users that expect the tracing
6581 * files to exist in debugfs/tracing, we must automount
6582 * the tracefs file system there, so older tools still
6583 * work with the newer kerenl.
6584 */
6585 tr->dir = debugfs_create_automount("tracing", NULL,
6586 trace_automount, NULL);
6557 if (!tr->dir) { 6587 if (!tr->dir) {
6558 pr_warn_once("Could not create debugfs directory 'tracing'\n"); 6588 pr_warn_once("Could not create debugfs directory 'tracing'\n");
6559 return ERR_PTR(-ENOMEM); 6589 return ERR_PTR(-ENOMEM);