Possible deadlock in vfs layer, namei.c

From: Joshua Hudson
Date: Wed Mar 01 2006 - 21:45:25 EST


I've been hunting down various deadlocks caused by hard links to directories.
I found one that can happen *without* such things.

Consider this:

17 3 drwxr-xr-x root sys 4096 dir
18 2 drwxr-xr-x root sys 4096 dir/subdir
19 1 -rwxr-xr-x root sys 1733 dir/subdir/file

process 1 does: rename("dir/subdir/file", "dir/file")
process 2 does: rmdir("dir/subdir")

from namei.c (function: lock_rename), rename takes:
1. s_vfs_rename_sem,
2. dir/subdir: p1->d_inode->i_sem
3. dir: p2->d_inode->i_sem

rmdir takes (multiple functions):
1. dir (sys_rename)
2. dir/subdir (vfs_rename)

Suppose this happends:
[proc 1] s_vfs_rename_sem
[proc 1] dir/subdir
*task switch*
[proc 2] dir
[proc 2] dir/subdir ->deadlock

preempt_disable() won't help here. Could also be triggered on a SMP
machine w/o preempt.
Am studying situation, doesn't look promising.
-
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/