tracing: Have mkdir and rmdir be part of tracefs

The tracing "instances" directory can create sub tracing buffers
with mkdir, and remove them with rmdir. As a mkdir will also create
all the files and directories that control the sub buffer the locks
needed to be released before doing so to avoid deadlock. This method
was not very robust, and could potentially have a race somewhere due
to the lock releasing within the removing of the directory. But this
was needed because debugfs did not provide a mkdir or rmdir method
from syscalls.

Now that tracing has been converted over to tracefs, the tracefs file
system can be modified to accommodate this feature. Instead of needing
to release the locks, keep them locked but add a way to flag that they
are locked and do not need to be locked again.

A struct trace_dir_ops is created that holds the methods to be called
for both mkdir and rmdir, as well as a pointer to let the tracefs subsystem
know that the current inode's lock is already held by the calling process.

The pointer holds the current owner of the lock, and this is checked when
creating new files or removing old ones, and if the pointer matches current,
then the lock is not taken to avoid the deadlock.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
3 files changed