Skip to content

Commit 52f3f03

Browse files
author
Andreas Gruenbacher
committed
gfs2: Disable page faults during lockless buffered reads
During lockless buffered reads, filemap_read() holds page cache page references while trying to copy data to the user-space buffer. The calling process isn't holding the inode glock, but the page references it holds prevent those pages from being removed from the page cache, and that prevents the underlying inode glock from being moved to another node. Thus, we can end up in the same kinds of distributed deadlock situations as with normal (non-lockless) buffered reads. Fix that by disabling page faults during lockless reads as well. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent bb7f5d9 commit 52f3f03

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/gfs2/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,14 +957,16 @@ static ssize_t gfs2_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
957957
return ret;
958958
iocb->ki_flags &= ~IOCB_DIRECT;
959959
}
960+
pagefault_disable();
960961
iocb->ki_flags |= IOCB_NOIO;
961962
ret = generic_file_read_iter(iocb, to);
962963
iocb->ki_flags &= ~IOCB_NOIO;
964+
pagefault_enable();
963965
if (ret >= 0) {
964966
if (!iov_iter_count(to))
965967
return ret;
966968
written = ret;
967-
} else {
969+
} else if (ret != -EFAULT) {
968970
if (ret != -EAGAIN)
969971
return ret;
970972
if (iocb->ki_flags & IOCB_NOWAIT)

0 commit comments

Comments
 (0)