Skip to content

Fix mmap + page fault deadlocks

Anand Jain linux-btrfs stable 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest18 patches 0 repliesNew
  2. v218 patches 1 replySuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v3 from the cover letter

Fix the patch order and fix the missing symbol compile error when compiled after each patch is applied.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18gup: Turn fault_in_pages_{readable,writeable} into fault_in_{readable,writeable}arch/powerpc/kernel/kvm.c arch/powerpc/kernel/signal_32.c arch/powerpc/kernel/signal_64.c +7 more+93 -760 replies
2/18iov_iter: Turn iov_iter_fault_in_readable into fault_in_iov_iter_readablefs/btrfs/file.c fs/f2fs/file.c fs/fuse/file.c +6 more+29 -200 replies
3/18iov_iter: Introduce fault_in_iov_iter_writeableinclude/linux/pagemap.h include/linux/uio.h lib/iov_iter.c +1 more+104 -00 replies
4/18gfs2: Add wrapper for iomap_file_buffered_writefs/gfs2/file.c+17 -100 replies
5/18gfs2: Clean up function may_grantfs/gfs2/glock.c+69 -500 replies
6/18gfs2: Introduce flag for glock holder auto-demotionfs/gfs2/glock.c fs/gfs2/glock.h fs/gfs2/incore.h+200 -360 replies
7/18gfs2: Move the inode glock locking to gfs2_file_buffered_writefs/gfs2/bmap.c fs/gfs2/file.c+28 -590 replies
8/18gfs2: Eliminate ip->i_ghfs/gfs2/file.c fs/gfs2/incore.h+22 -150 replies
9/18gfs2: Fix mmap + page fault deadlocks for buffered I/Ofs/gfs2/file.c+94 -50 replies
10/18iomap: Fix iomap_dio_rw return value for user copiesfs/iomap/direct-io.c+4 -00 replies
11/18iomap: Support partial direct I/O on user copy failuresfs/iomap/direct-io.c include/linux/iomap.h+13 -00 replies
12/18iomap: Add done_before argument to iomap_dio_rwfs/btrfs/file.c fs/erofs/data.c fs/ext4/file.c +5 more+32 -170 replies
13/18gup: Introduce FOLL_NOFAULT flag to disable page faultsinclude/linux/mm.h mm/gup.c+5 -20 replies
14/18iov_iter: Introduce nofault flag to disable page faultsinclude/linux/uio.h lib/iov_iter.c+16 -50 replies
15/18gfs2: Fix mmap + page fault deadlocks for direct I/Ofs/gfs2/file.c+87 -120 replies
16/18btrfs: fix deadlock due to page faults during direct IO reads and writesfs/btrfs/file.c+123 -160 replies
17/18btrfs: fallback to blocking mode when doing async dio over multiple extentsfs/btrfs/inode.c+28 -00 replies
18/18mm: gup: make fault_in_safe_writeable() use fixup_user_fault()mm/gup.c+19 -380 replies

Reviews trailers per patch

6 of 18 patches have a Reviewed-by or Acked-by.

PatchDarrick J. WongChristoph HellwigJosef BacikAndreas GruenbacherDavid Hildenbrand
1/18
2/18
3/18
4/18
5/18
6/18
7/18
8/18
9/18
10/18R-b R-b
11/18R-b
12/18R-b
13/18
14/18
15/18
16/18R-b
17/18R-b
18/18Reported-and-tested-by A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/18 stable-5.15.y] Fix mmap + page fault deadlocks

v3:
Fix the patch order and fix the missing symbol compile error when compiled after each patch is applied.

v2:
Rebase on the latest stable-5.15.33.
Adds the following commits to the v1 patchset as they fix issues in the merged commit.

ca93e44bfb5f btrfs: fallback to blocking mode when doing async dio over multiple extents fe673d3f5bf1 mm: gup: make fault_in_safe_writeable() use fixup_user_fault()

And this set drops the following patch as it is already in the stable-5.15.y.

[PATCH 01/17 stable-5.15.y] powerpc/kvm: Fix kvm_use_magic_page

------- original cover letter --------
This set fixes a process hang issue in btrfs and gf2 filesystems. When we do a direct IO read or write when the buffer given by the user is memory-mapped to the file range we are going to do IO, we end up ending in a deadlock. This is triggered by the test case generic/647 from fstests.

This fix depends on the iov_iter and iomap changes introduced in the commit c03098d4b9ad ("Merge tag 'gfs2-v5.15-rc5-mmap-fault' of
git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2") and they are part of this set for stable-5.15.y.

Please note that patch 2/18 (in v2) (was 3/17 in v1) in the patchset changes the prototype and renames an exported symbol as below. All its references are updated as well.

-EXPORT_SYMBOL(iov_iter_fault_in_readable);
+EXPORT_SYMBOL(fault_in_iov_iter_readable);

Andreas Gruenbacher (14):
gup: Turn fault_in_pages_{readable,writeable} into

    fault_in_{readable,writeable}

iov_iter: Turn iov_iter_fault_in_readable into
fault_in_iov_iter_readable
iov_iter: Introduce fault_in_iov_iter_writeable
gfs2: Add wrapper for iomap_file_buffered_write
gfs2: Clean up function may_grant
gfs2: Move the inode glock locking to gfs2_file_buffered_write
gfs2: Eliminate ip->i_gh
gfs2: Fix mmap + page fault deadlocks for buffered I/O
iomap: Fix iomap_dio_rw return value for user copies
iomap: Support partial direct I/O on user copy failures
iomap: Add done_before argument to iomap_dio_rw
gup: Introduce FOLL_NOFAULT flag to disable page faults
iov_iter: Introduce nofault flag to disable page faults
gfs2: Fix mmap + page fault deadlocks for direct I/O

Bob Peterson (1):
gfs2: Introduce flag for glock holder auto-demotion

Filipe Manana (2):
btrfs: fix deadlock due to page faults during direct IO reads and
writes
btrfs: fallback to blocking mode when doing async dio over multiple
extents

Linus Torvalds (1):
mm: gup: make fault_in_safe_writeable() use fixup_user_fault()

 arch/powerpc/kernel/kvm.c           |   3 +-
 arch/powerpc/kernel/signal_32.c     |   4 +-
 arch/powerpc/kernel/signal_64.c     |   2 +-
 arch/x86/kernel/fpu/signal.c        |   7 +-
 drivers/gpu/drm/armada/armada_gem.c |   7 +-
 fs/btrfs/file.c                     | 142 ++++++++++--
 fs/btrfs/inode.c                    |  28 +++
 fs/btrfs/ioctl.c                    |   5 +-
 fs/erofs/data.c                     |   2 +-
 fs/ext4/file.c                      |   5 +-
 fs/f2fs/file.c                      |   2 +-
 fs/fuse/file.c                      |   2 +-
 fs/gfs2/bmap.c                      |  60 +----
 fs/gfs2/file.c                      | 252 +++++++++++++++++++--
 fs/gfs2/glock.c                     | 330 +++++++++++++++++++++-------
 fs/gfs2/glock.h                     |  20 ++
 fs/gfs2/incore.h                    |   4 +-
 fs/iomap/buffered-io.c              |   2 +-
 fs/iomap/direct-io.c                |  29 ++-
 fs/ntfs/file.c                      |   2 +-
 fs/ntfs3/file.c                     |   2 +-
 fs/xfs/xfs_file.c                   |   6 +-
 fs/zonefs/super.c                   |   4 +-
 include/linux/iomap.h               |  11 +-
 include/linux/mm.h                  |   3 +-
 include/linux/pagemap.h             |  58 +----
 include/linux/uio.h                 |   4 +-
 lib/iov_iter.c                      |  98 +++++++--
 mm/filemap.c                        |   4 +-
 mm/gup.c                            | 120 +++++++++-
 30 files changed, 920 insertions(+), 298 deletions(-)
Signature · 1 line
2.33.1