Skip to content

dax fixes / cleanups: pmd vs thp, lifetime, and locking

Dan Williams linux-ext4 linux-fsdevel linux-nvdimm nvdimm stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8ext2, ext4: warn when mounting with dax enabledfs/ext2/super.c fs/ext4/super.c+7 -10 replies
2/8dax: disable pmd mappingsfs/Kconfig fs/dax.c+10 -01 reply
3/8mm, dax: fix DAX deadlocks (COW fault)mm/memory.c+4 -40 replies
4/8mm, dax: truncate dax mappings at bdev or fs shutdownfs/inode.c mm/truncate.c+38 -210 replies
5/8pmem, dax: clean up clear_pmem()arch/x86/include/asm/pmem.h fs/dax.c+2 -90 replies
6/8dax: increase granularity of dax_clear_blocks() operationsfs/dax.c+8 -140 replies
7/8dax: guarantee page aligned results from bdev_direct_access()fs/block_dev.c fs/dax.c+2 -10 replies
8/8dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()block/blk.h fs/block_dev.c fs/dax.c +1 more+151 -900 replies

Reviews trailers per patch

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

PatchJan KaraRoss ZwislerJeff Moyer
1/8A-b
2/8A-b
3/8A-b
4/8
5/8R-b R-b
6/8R-b R-b
7/8
8/8R-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 3 reviewers.

Read the v1 thread

Cover letter [PATCH 0/8] dax fixes / cleanups: pmd vs thp, lifetime, and locking

Changes since last posting [1]:

1/ Further cleanups to dax_clear_blocks(): Dropped increments of 'addr'
since we call bdev_direct_access() before the next use, and dropped the BUG_ON for sector unaligned return values from bdev_direct_access().

2/ In [PATCH 8/8] introduce blk_dax_ctl to remove the need to have
separate dax_map_atomic and __dax_map_atomic routines. Note, blk_dax_ctl is not passed through to drivers, it gets unpacked in bdev_direct_access. (Willy)

3/ New [PATCH 2/8]: Disable huge page dax mappings while we resolve
various crash scenarios in this development cycle.

4/ New [PATCH 4/8]: Unmap all dax mappings at block device shutdown

I have kept the reviewed-by's received to date, let me know if these incremental updates invalidate that review.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-November/002733.html

---

The first 4 patches in this series I consider 4.4-rc / -stable material. The rest are for 4.5. [PATCH 4/8] needs scrutiny. It is yet another example of where DAX behavior necessarily differs from page cache behavior. I still maintain that we should not be surprising unaware applications with DAX semantics, i.e. that DAX should be per-inode opt-in, not globally enabled for all inodes at fs mount time.

The largest patch in the set, [PATCH 8/8], addresses the lifetime of the 'addr' returned by bdev_direct_access. That address is only valid while the device driver is enabled. The new dax_map_atomic() / dax_unmap_atomic() pairing guarantees that 'addr' stays valid for the duration of that mapping.

While dax_map_atomic() protects against 'addr' going invalid, the new calls to truncate_pagecache() via invalidate_inodes() protect against the 'pfn' returned from bdev_direct_access() going invalid. Otherwise, the storage media can be directly accessed after the driver has been disabled.

---

[PATCH 1/8] ext2, ext4: warn when mounting with dax enabled [PATCH 2/8] dax: disable pmd mappings
[PATCH 3/8] mm, dax: fix DAX deadlocks (COW fault)
[PATCH 4/8] mm, dax: truncate dax mappings at bdev or fs shutdown [PATCH 5/8] pmem, dax: clean up clear_pmem()
[PATCH 6/8] dax: increase granularity of dax_clear_blocks() operations [PATCH 7/8] dax: guarantee page aligned results from bdev_direct_access() [PATCH 8/8] dax: fix lifetime of in-kernel dax mappings with dax_map_atomic()

 arch/x86/include/asm/pmem.h |    7 -
 block/blk.h                 |    2 
 fs/Kconfig                  |    6 +
 fs/block_dev.c              |   15 +--
 fs/dax.c                    |  228 ++++++++++++++++++++++++++-----------------
 fs/ext2/super.c             |    2 
 fs/ext4/super.c             |    6 +
 fs/inode.c                  |   27 +++++
 include/linux/blkdev.h      |   19 +++-
 mm/memory.c                 |    8 +-
 mm/truncate.c               |   13 ++
 11 files changed, 217 insertions(+), 116 deletions(-)