Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
- From: ebiederm@xxxxxxxxxxxx (Eric W. Biederman)
- Date: Wed, 08 Aug 2007 02:28:52 -0600
Tejun Heo <htejun@xxxxxxxxx> writes:
Hello, Eric.
Eric W. Biederman wrote:
Looking carefully at the rename code we have a subtle dependency
that the structure of sysfs not change while we are performing
a rename. If the parent directory of the object we are renaming
changes while the rename is being performed nasty things could
happen when we go to release our locks.
So introduce a sysfs_rename_mutex to prevent this highly
unlikely theoretical issue.
Yeah, it's a theoretical issue. Rename/move implementation has always
depended on the parent structure not changing beneath it, but it's nice
to tighten up loose ends.
+DEFINE_MUTEX(sysfs_rename_mutex);
Probably doesn't really matter but wouldn't a rwsem fit better?
Maybe. I didn't feel any loss in when I was writing the code.
Very few code paths actually seem to care.
@@ -774,7 +775,7 @@ static struct dentry *__sysfs_get_dentry(structsuper_block *sb, struct sysfs_di
* down from there looking up dentry for each step.
*
* LOCKING:
- * Kernel thread context (may sleep)
+ * mutex_lock(sysfs_rename_mutex)
Well this is weird in that it should be on sysfs_get_dentry
more then __sysfs_get_dentry but otherwise it's ok.
LOCKING describes what locks should be held when entering the function,
so proper description would be something like...
Kernel thread context, grabs sysfs_rename_mutex
For rename_dir and move_dir yes. I was updating the rules
for sysfs_get_dentry. Which really wants it's parents to
hold that lock.
Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- References:
- [PATCH 5/5] sysfs: make sysfs_addrm_finish() return void
- From: Tejun Heo
- [PATCH 0/25] Sysfs cleanups & tagged directory support
- From: Eric W. Biederman
- [PATCH 01/25] sysfs: Move all of inode initialization into sysfs_init_inode
- From: Eric W. Biederman
- [PATCH 02/25] sysfs: Remove sysfs_instantiate
- From: Eric W. Biederman
- [PATCH 03/25] sysfs: Use kill_anon_super
- From: Eric W. Biederman
- [PATCH 04/25] sysfs: Make sysfs_mount static
- From: Eric W. Biederman
- [PATCH 05/25] sysfs: In sysfs_lookup don't open code sysfs_find_dirent
- From: Eric W. Biederman
- [PATCH 06/25] sysfs: Simplify readdir.
- From: Eric W. Biederman
- [PATCH 07/25] sysfs: Rewrite sysfs_drop_dentry.
- From: Eric W. Biederman
- [PATCH 08/25] sysfs: Implement __sysfs_get_dentry
- From: Eric W. Biederman
- [PATCH 09/25] sysfs: Move sysfs_get_dentry below __sysfs_get_dentry
- From: Eric W. Biederman
- [PATCH 10/25] sysfs: Rewrite sysfs_get_dentry in terms of __sysfs_get_dentry
- From: Eric W. Biederman
- [PATCH 11/25] sysfs: Remove s_dentry
- From: Eric W. Biederman
- [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
- From: Eric W. Biederman
- Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
- From: Tejun Heo
- [PATCH 5/5] sysfs: make sysfs_addrm_finish() return void
- Prev by Date: Re: [PATCH 13/25] sysfs: Simply sysfs_get_dentry
- Next by Date: Re: PATCH/RFC: [kdump] fix APIC shutdown sequence
- Previous by thread: Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
- Next by thread: Re: [PATCH 11/25] sysfs: Remove s_dentry
- Index(es):
Relevant Pages
|