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:
pgpgKqYHdePoz.pgp
Description: PGP signature