2006-03-02 03:22:22

by Joshua Hudson

[permalink] [raw]
Subject: Fwd: Possible deadlock in vfs layer, namei.c

On 3/1/06, Al Viro <[email protected]> wrote:
> On Wed, Mar 01, 2006 at 06:46:42PM -0800, Joshua Hudson wrote:
> > I've been hunting down various deadlocks caused by hard links to directories.
> > I found one that can happen *without* such things.
>
> > 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
>
> No, it doesn't. Wrong order - it will take dir before dir/subdir.
> RTFM - Documentation/filesystems/directory-locking is there for
> purpose.
>
Well, bloody stupid of me, didn't notice the slight differences of the
locking in the for loops.