Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex



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(struct
super_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/



Relevant Pages

  • Re: 2.6.4-rc1 oops on HPFS filesystem file rename
    ... and cross-directory rename(), of all things. ... update directory entry in the parent, so it gets the parent inode and locks ... then grab rwsem on parentfor writing. ... Order among semaphores and among rwsems, ...
    (Linux-Kernel)
  • Re: Rename Parent worksheet.name?
    ... The Parent of a Worksheet is a Workbook, and a Workbook cannot be renamed. ... but I can not seem to rename the parent name. ...
    (microsoft.public.excel.programming)
  • Re: How to create a duplicate (not sub) class.
    ... then classloc would point to the orignial.vcx and would ... Let 's say you have a original.vcx with classes parent and child, ... If you now rename a ...
    (microsoft.public.fox.programmer.exchange)
  • Re: ODS5 and hardlinks
    ... IIRC ODS-2 maintains up-pointers in each file header to each file's/directory's parent - but of course it has room for only one such. ... The file name field in the file header (which IIRC is updated on RENAME operations to the original parent) is in the same boat when it comes to having multiple parents, but I think may always have been defined as being merely informational in nature rather than being used by the system in any manner - save perhaps that the combination of the two fields could be used to determine whether a RENAME was being applied to the original parent entry and hence whether the name should be updated. ...
    (comp.os.vms)
  • Re: Exception OU in Delegated Environment
    ... You have delete child permission on the parent ... remove the delete permission from the parent. ... Note also that a rename is effectively a move. ... The only way round this that springs to mind is to use a custom app for ...
    (microsoft.public.windows.server.active_directory)