From: Valdis.Kletnieks@vt.edu
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC] Hack to use mkdir/rmdir in debugfs
Date: Thu, 24 Jan 2013 17:39:22 -0500 [thread overview]
Message-ID: <28808.1359067162@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Tue, 22 Jan 2013 23:44:09 -0500." <1358916249.21576.105.camel@gandalf.local.home>
[-- Attachment #1: Type: text/plain, Size: 2461 bytes --]
On Tue, 22 Jan 2013 23:44:09 -0500, Steven Rostedt said:
> Again, I want to stress that this doesn't touch the debugfs code. Here's
> the real change that I've been testing. It includes the code for the
> "new" and "free" files but those are not created because of an early
> 'return' I added. Notice that it's all contained in
> kernel/trace/trace.c.
So I was looking through here, and something caught my eye....
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 253cb51..851eb4a 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> +static int instance_mkdir (struct inode *inode, struct dentry *dentry, umode
_t mode)
> +{
> + struct dentry *parent;
> + int ret;
> +
> + /* Paranoid: Make sure the parent is the "instances" directory */
> + parent = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
> + if (WARN_ON_ONCE(parent != trace_instance_dir))
> + return -ENOENT;
> +
> + /*
> + * The inode mutex is locked, but debugfs_create_dir() will also
> + * take the mutex. As the instances directory can not be destroyed
> + * or changed in any other way, it is safe to unlock it, and
> + * let the dentry try. If two users try to make the same dir at
> + * the same time, then the new_instance_create() will determine the
> + * winner.
> + */
> + mutex_unlock(&inode->i_mutex);
> +
> + ret = new_instance_create(dentry->d_iname);
> +
> + mutex_lock(&inode->i_mutex);
> +
> + return ret;
> +}
> +
> +static int instance_rmdir(struct inode *inode, struct dentry *dentry)
> +{
> + struct dentry *parent;
> + int ret;
> +
> + /* Paranoid: Make sure the parent is the "instances" directory */
> + parent = hlist_entry(inode->i_dentry.first, struct dentry, d_alias);
> + if (WARN_ON_ONCE(parent != trace_instance_dir))
> + return -ENOENT;
> +
> + /* The caller did a dget() on dentry */
> + mutex_unlock(&dentry->d_inode->i_mutex);
> +
> + /*
> + * The inode mutex is locked, but debugfs_create_dir() will also
> + * take the mutex. As the instances directory can not be destroyed
> + * or changed in any other way, it is safe to unlock it, and
> + * let the dentry try. If two users try to make the same dir at
> + * the same time, then the instance_delete() will determine the
> + * winner.
> + */
> + mutex_unlock(&inode->i_mutex);
Looks like the rmdir comment was slice-n-miced from the mkdir one?
What exactly *are* the race condition rules here, especially for mkdir
racing against an rmdir?
[-- Attachment #2: Type: application/pgp-signature, Size: 865 bytes --]
next prev parent reply other threads:[~2013-01-24 22:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-23 3:01 Steven Rostedt
2013-01-23 3:47 ` Steven Rostedt
2013-01-23 4:08 ` Greg Kroah-Hartman
2013-01-23 4:31 ` Steven Rostedt
2013-01-23 4:41 ` Greg Kroah-Hartman
2013-01-23 4:52 ` Steven Rostedt
2013-01-23 4:44 ` Steven Rostedt
2013-01-23 4:48 ` Steven Rostedt
2013-01-23 4:55 ` Greg Kroah-Hartman
2013-01-23 5:05 ` Steven Rostedt
2013-01-24 22:39 ` Valdis.Kletnieks [this message]
2013-01-24 23:53 ` Steven Rostedt
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=28808.1359067162@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®