gfs2: Fix mmap + page fault deadlocks for direct I/O
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 14 Apr 2022 22:28:53 +0000 (06:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 May 2022 15:22:33 +0000 (17:22 +0200)
commit640a6be8e8618ba1dd3ec6bc9beb92a0409ef9da
treefa2aabf3db3f5736d4319b15a02c6b1e181dfa87
parentf86f8d27840a97afc09077528048d39aab3e7df3
gfs2: Fix mmap + page fault deadlocks for direct I/O

commit b01b2d72da25c000aeb124bc78daf3fb998be2b6 upstream

Also disable page faults during direct I/O requests and implement a
similar kind of retry logic as in the buffered I/O case.

The retry logic in the direct I/O case differs from the buffered I/O
case in the following way: direct I/O doesn't provide the kinds of
consistency guarantees between concurrent reads and writes that buffered
I/O provides, so once we lose the inode glock while faulting in user
pages, we always resume the operation.  We never need to return a
partial read or write.

This locking problem was originally reported by Jan Kara.  Linus came up
with the idea of disabling page faults.  Many thanks to Al Viro and
Matthew Wilcox for their feedback.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/gfs2/file.c