Skip to content

Introduce a mmap sem to deal with some mmap issues

Josef Bacik linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 2 repliesIn review
  2. v14 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Rebase against misc-next.
- Add Filipe's reviewed-bys.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: add a i_mmap_lock to our inodefs/btrfs/btrfs_inode.h fs/btrfs/ctree.h fs/btrfs/inode.c+12 -00 replies
2/4btrfs: cleanup inode_lock/inode_unlock usesfs/btrfs/delayed-inode.c fs/btrfs/file.c fs/btrfs/ioctl.c +2 more+28 -280 replies
3/4btrfs: exclude mmaps while doing remapfs/btrfs/reflink.c+24 -60 replies
4/4btrfs: exclude mmap from happening during all fallocate operationsfs/btrfs/file.c+6 -60 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchFilipe Manana
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/4] Introduce a mmap sem to deal with some mmap issues

v1->v2:
- Rebase against misc-next.
- Add Filipe's reviewed-bys.

--- Original email ---

Hello,

Both Filipe and I have found different issues that result in the same thing, we need to be able to exclude mmap from happening in certain scenarios. The specifics are well described in the commit logs, but generally there's 2 issues

1) dedupe needs to validate that pages match, and since the validation is done outside of the extent lock we can race with mmap and dedupe pages that do not match.
2) We can deadlock in certain low metadata scenarios where we need to flush an ordered extent, but can't because mmap is holding the page lock.

These issues exist for remap and fallocate, so add an i_mmap_sem to allow us to disallow mmap in these cases. I'm still waiting on xfstests to finish with this, but 2 hours in and no lockdep or deadlocks. Thanks,

Josef Bacik (4):
btrfs: add a i_mmap_lock to our inode
btrfs: cleanup inode_lock/inode_unlock uses
btrfs: exclude mmaps while doing remap
btrfs: exclude mmap from happening during all fallocate operations

 fs/btrfs/btrfs_inode.h   |  1 +
 fs/btrfs/ctree.h         |  1 +
 fs/btrfs/delayed-inode.c |  4 ++--
 fs/btrfs/file.c          | 20 ++++++++++----------
 fs/btrfs/inode.c         | 10 ++++++++++
 fs/btrfs/ioctl.c         | 26 +++++++++++++-------------
 fs/btrfs/reflink.c       | 30 ++++++++++++++++++++++++------
 fs/btrfs/relocation.c    |  4 ++--
 8 files changed, 63 insertions(+), 33 deletions(-)
Signature · 1 line
2.26.2