Skip to content

gfs2: Handle page faults during read and write

Andreas Gruenbacher cluster-devel linux-fsdevel linux-mm stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6gfs2: Fix mmap + page fault deadlocks (part 1)fs/gfs2/file.c+30 -100 replies
2/6iov_iter: Add iov_iter_fault_in_writeable()include/linux/uio.h lib/iov_iter.c+20 -10 replies
3/6gfs2: Add wrappers for accessing journal_infofs/gfs2/aops.c fs/gfs2/bmap.c fs/gfs2/incore.h +6 more+43 -330 replies
4/6gfs2: Encode glock holding and retry flags in journal_infofs/gfs2/incore.h+33 -20 replies
5/6gfs2: Add LM_FLAG_OUTER glock holder flagfs/gfs2/glock.c fs/gfs2/glock.h+22 -30 replies
6/6gfs2: Fix mmap + page fault deadlocks (part 2)fs/gfs2/bmap.c fs/gfs2/file.c+58 -75 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/6] gfs2: Handle page faults during read and write

Hello,

this is an update to my previous posting [1] on how to deal with potential mmap + page fault deadlocks in gfs2.

What's happening is that a page fault triggers during a read or write operation, while we're holding a glock (the cluster-wide gfs2 inode lock), and the page fault requires another glock. We can recognize and handle the case when both glocks are the same, but when the page fault requires another glock, there is a chance that taking that other glock will deadlock.

The solution I've come up with for this is to turn locking requests into locking attempts when we're in a potential recursive locking situation, and to actively fault in pages and retry at the outer level when a locking attempt fails. Those kinds of conflicts should be relatively rare.

Note that we need to fault in pages writable in ->read_iter, so this patch set adds a new iov_iter_fault_in_writeable() helper hat mirrors iov_iter_fault_in_readable().

In the initial prototype [1], I've added a restart_hack flag to struct task_struct; this has now been moved to the lower two bits of current->journal_info.

I've posted a new fstest [2] that triggers the self-recursion case so that those kind of bugs will be caught early next time, with no feedback in the last two weeks.

Those patches are currently on the gfs2 for-next branch [3]. If there are no objections, I'll ask Linus to pull them from there.

Thanks,
Andreas

[1] [RFC] Trigger retry from fault vm operation,
https://lore.kernel.org/linux-fsdevel/20210511140113.1225981-1-agruenba at redhat.com/

[2] https://lore.kernel.org/fstests/20210520114218.1595735-1-agruenba at redhat.com/T/#u

[3] https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/log/?h=for-next

Andreas Gruenbacher (6):
gfs2: Fix mmap + page fault deadlocks (part 1)
iov_iter: Add iov_iter_fault_in_writeable()
gfs2: Add wrappers for accessing journal_info
gfs2: Encode glock holding and retry flags in journal_info
gfs2: Add LM_FLAG_OUTER glock holder flag
gfs2: Fix mmap + page fault deadlocks (part 2)

 fs/gfs2/aops.c      |   6 +--
 fs/gfs2/bmap.c      |  31 +++++++-------
 fs/gfs2/file.c      | 102 +++++++++++++++++++++++++++++++++++++-------
 fs/gfs2/glock.c     |  12 ++++++
 fs/gfs2/glock.h     |  13 ++++--
 fs/gfs2/incore.h    |  41 ++++++++++++++++++
 fs/gfs2/inode.c     |   2 +-
 fs/gfs2/log.c       |   4 +-
 fs/gfs2/lops.c      |   2 +-
 fs/gfs2/meta_io.c   |   6 +--
 fs/gfs2/super.c     |   2 +-
 fs/gfs2/trans.c     |  16 +++----
 include/linux/uio.h |   1 +
 lib/iov_iter.c      |  20 ++++++++-
 14 files changed, 204 insertions(+), 54 deletions(-)
Signature · 1 line
2.26.3