* udf deadlock (was Re: hugetlbfs lockdep spew revisited.)
[not found] ` <20120217004922.GN23916@ZenIV.linux.org.uk>
@ 2012-02-17 17:48 ` Al Viro
2012-02-20 16:01 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Al Viro @ 2012-02-17 17:48 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Jan Kara, Josh Boyer, Dave Jones, Linux Kernel, Tyler Hicks
On Fri, Feb 17, 2012 at 12:49:22AM +0000, Al Viro wrote:
> Folks, this is not a false positive and it has nothing to do with misannotation
> for directories. Deadlock is real; I have no idea WTF do we what ->i_mutex
> held over that area in hugetlbfs ->mmap(), but doing that is really, really
> wrong, whatever the reason.
Arrrrgh... Some grepping around has uncovered another deadlock on
i_mutex/mmap_sem and this one is not hard to hit at all.
Thread A:
opens file on UDF (O_RDWR open)
does big, fat write() to it
Thread B:
opens the same file (also O_RDWR)
mmaps it
closes
does munmap()
and there we are - munmap() will end up closing the second struct file,
call udf_release_file() and we are hitting ->i_mutex while under
->mmap_sem. Blocking on it, actually, since generic_file_aio_write()
in the first thread is holding ->i_mutex. And as soon as thread A gets
around to faulting the next piece of data in, well... To widen the
window a lot, mmap something large sitting on NFS and do write() from
that mmapped area. Race window as wide as one could ask for...
What happens there is prealloc discard on close; do we even want ->i_mutex
there these days? Note that there's also
down_write(&UDF_I(inode)->i_data_sem);
in udf_release_file()...
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: udf deadlock (was Re: hugetlbfs lockdep spew revisited.)
2012-02-17 17:48 ` udf deadlock (was Re: hugetlbfs lockdep spew revisited.) Al Viro
@ 2012-02-20 16:01 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2012-02-20 16:01 UTC (permalink / raw)
To: Al Viro
Cc: linux-fsdevel, Jan Kara, Josh Boyer, Dave Jones, Linux Kernel,
Tyler Hicks
On Fri 17-02-12 17:48:18, Al Viro wrote:
> On Fri, Feb 17, 2012 at 12:49:22AM +0000, Al Viro wrote:
> > Folks, this is not a false positive and it has nothing to do with misannotation
> > for directories. Deadlock is real; I have no idea WTF do we what ->i_mutex
> > held over that area in hugetlbfs ->mmap(), but doing that is really, really
> > wrong, whatever the reason.
>
> Arrrrgh... Some grepping around has uncovered another deadlock on
> i_mutex/mmap_sem and this one is not hard to hit at all.
>
> Thread A:
> opens file on UDF (O_RDWR open)
> does big, fat write() to it
> Thread B:
> opens the same file (also O_RDWR)
> mmaps it
> closes
> does munmap()
>
> and there we are - munmap() will end up closing the second struct file,
> call udf_release_file() and we are hitting ->i_mutex while under
> ->mmap_sem. Blocking on it, actually, since generic_file_aio_write()
> in the first thread is holding ->i_mutex. And as soon as thread A gets
> around to faulting the next piece of data in, well... To widen the
> window a lot, mmap something large sitting on NFS and do write() from
> that mmapped area. Race window as wide as one could ask for...
Right, I didn't realize ->release() may be called with mmap_sem held.
Thanks for spotting this. BTW: Documentation/filesystems/Locking might
need an update since it states:
locking rules:
All may block except for ->setlease.
No VFS locks held on entry except for ->setlease.
> What happens there is prealloc discard on close; do we even want ->i_mutex
> there these days? Note that there's also
> down_write(&UDF_I(inode)->i_data_sem);
> in udf_release_file()...
I've looked around and it seems we don't need i_mutex for anything.
i_data_sem should be enough. So I'll just remove i_mutex.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-20 16:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20120217000856.GA13112@redhat.com>
[not found] ` <20120217001634.GH23550@zod.bos.redhat.com>
[not found] ` <20120217003848.GB20071@boyd>
[not found] ` <20120217004922.GN23916@ZenIV.linux.org.uk>
2012-02-17 17:48 ` udf deadlock (was Re: hugetlbfs lockdep spew revisited.) Al Viro
2012-02-20 16:01 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).