Re: [patch 12/16] fix race between writeback and unlink

Chris Mason
2002-06-03T22:12:30Z

On Sat, 2002-06-01 at 15:19, Andrew Morton wrote:
> Linus Torvalds wrote:
> >
> > On Sat, 1 Jun 2002, Andrew Morton wrote:
> > >
> > > So run __iget prior to dropping inode_lock.
> >
> > This part looks horrible:
> >
> > + spin_unlock(&inode_lock);
> > + iput(inode);
> > + spin_lock(&inode_lock);
>
> Yup. The inode refcounting APIs are really awkward. Note how I recently
> added dopey code in ext2_put_inode() to only drop the prealloc window on
> the "final" iput().

Hmmm, a quick glance makes the test in ext2_put_inode look unsafe.

iput calls put_inode before decrementing i_count. So, nothing stops 5
iput callers from all deciding i_count > 2 and leaving the preallocation
blocks hanging.

Also, a knfsd triggered iget/iput pair should hit the same race with an
put_inode call.

Or am I missing something?

-chris