On Fri, May 16, 2008 at 08:07:57AM +1000, David Chinner wrote:
> Fundamentally - if a filesystem takes the same lock in
> ->file_aio_read as it does in ->release, then this will happen.
> The lock outside the filesystem (the mmap lock) is can be taken
> before we enter the filesystem or while we are inside a filesystem
> method reading or writing data.
>
> In this case, XFS uses the iolock to serialise I/O vs truncate.
> We hold the iolock shared over read I/O, and exclusive when we
> do a truncate. The truncate in this case is a truncate of blocks
> past EOF on ->release.
>
> Whether this can deadlock depends on whether these two things can
> happen on the same mmap->sem and same inode at the same time.
> I know they can happen onteh same inode at the same time, but
> can this happen on the same mmap->sem? VM gurus?
I think it can. Think of a process with two threads, and two open file
instances of the same inode.
thread 1:
in read() fauling in from the inode via file 1
thread 2:
at the same time dropping the last reference to a file via
munmap.
Getting this right would mean not doing any fputs from under the
mmap_seem in munmap.
|