libnvdimm fixes for 4.3-rc2
Subsystems (6)
Hi Linus, please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes
...to receive:
1/ A boot regression (since v4.2) fix for some ARM configurations from Tyler
2/ Regression (since v4.1) fixes for mkfs.xfs on a DAX enabled device from Jeff. These are tagged for -stable.
3/ A pair of locking fixes from Axel that are hidden from lockdep since they involve device_lock(). The "btt" one is tagged for -stable, the other only applies to the new "pfn" mechanism in v4.3.
4/ A fix for the pmem ->rw_page() path to use wmb_pmem() from Ross.
Full log and diff below.
---
The following changes since commit 6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f:
Linux 4.3-rc1 (2015-09-12 16:35:56 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes
for you to fetch changes up to ae4f976968896f8f41b3a7aa21be6146492211e5:
mm: fix type cast in __pfn_to_phys() (2015-09-19 03:58:10 -0400)
----------------------------------------------------------------
Axel Lin (2):
libnvdimm: btt_devs: Fix locking in namespace_store
libnvdimm: pfn_devs: Fix locking in namespace_store
Jeff Moyer (2):
dax: fix O_DIRECT I/O to the last block of a blockdev
blockdev: don't set S_DAX for misaligned partitions
Ross Zwisler (1):
pmem: add proper fencing to pmem_rw_page()
Tyler Baker (1):
mm: fix type cast in __pfn_to_phys()
drivers/nvdimm/btt_devs.c | 4 ++-- drivers/nvdimm/pfn_devs.c | 4 ++-- drivers/nvdimm/pmem.c | 2 ++ fs/block_dev.c | 7 +++++++ fs/dax.c | 3 ++- include/asm-generic/memory_model.h | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-)
commit ae4f976968896f8f41b3a7aa21be6146492211e5
Author: Tyler Baker <[email protected]> Date: Sat Sep 19 03:58:10 2015 -0400
mm: fix type cast in __pfn_to_phys()
The various definitions of __pfn_to_phys() have been consolidated to use a generic macro in include/asm-generic/memory_model.h. This hit mainline in the form of 012dcef3f058 "mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h". When the generic macro was implemented the type cast to phys_addr_t was dropped which caused boot regressions on ARM platforms with more than 4GB of memory and LPAE enabled.
It was suggested to use PFN_PHYS() defined in include/linux/pfn.h as provides the correct logic and avoids further duplication.
commit ba8fe0f85e15d047686caf8a42463b592c63c98c
Author: Ross Zwisler <[email protected]> Date: Wed Sep 16 14:52:21 2015 -0600
pmem: add proper fencing to pmem_rw_page()
pmem_rw_page() needs to call wmb_pmem() on writes to make sure that the newly written data is durable. This flow was added to pmem_rw_bytes() and pmem_make_request() with this commit:
commit 61031952f4c8 ("arch, x86: pmem api for ensuring durability of
persistent memory updates")
...the pmem_rw_page() path was missed.
commit 4ca8b57a0af145f4e791f21dbca6ad789da9ee8b
Author: Axel Lin <[email protected]> Date: Wed Sep 16 21:25:38 2015 +0800
libnvdimm: pfn_devs: Fix locking in namespace_store
Always take device_lock() before nvdimm_bus_lock() to prevent deadlock.
commit 4be9c1fc3df9c3b03c9bde8aec5e44fc73996a3f
Author: Axel Lin <[email protected]> Date: Wed Sep 16 21:24:47 2015 +0800
libnvdimm: btt_devs: Fix locking in namespace_store
Always take device_lock() before nvdimm_bus_lock() to prevent deadlock.
commit f0b2e563bc419df7c1b3d2f494574c25125f6aed
Author: Jeff Moyer <[email protected]> Date: Fri Aug 14 16:15:32 2015 -0400
blockdev: don't set S_DAX for misaligned partitions
The dax code doesn't currently support misaligned partitions, so disable O_DIRECT via dax until such time as that support materializes.
commit e94f5a2285fc94202a9efb2c687481f29b64132c
Author: Jeff Moyer <[email protected]> Date: Fri Aug 14 16:15:31 2015 -0400
dax: fix O_DIRECT I/O to the last block of a blockdev
commit bbab37ddc20b (block: Add support for DAX reads/writes to block devices) caused a regression in mkfs.xfs. That utility sets the block size of the device to the logical block size using the BLKBSZSET ioctl, and then issues a single sector read from the last sector of the device. This results in the dax_io code trying to do a page-sized read from 512 bytes from the end of the device. The result is -ERANGE being returned to userspace.
The fix is to align the block to the page size before calling get_block.
Thanks to willy for simplifying my original patch.
drivers/nvdimm/btt_devs.c +2 -2
@@ -128,13 +128,13 @@ static ssize_t namespace_store(struct device *dev,struct nd_btt *nd_btt =to_nd_btt (dev);ssize_t rc; -nvdimm_bus_lock (dev);device_lock (dev); +nvdimm_bus_lock (dev); rc =nd_namespace_store (dev, &nd_btt->ndns, buf, len);dev_dbg (dev,"%s: result: %zd wrote: %s%s" , __func__, rc, buf, buf[len -1 ] =='\n' ?"" :"\n" ); -device_unlock (dev);nvdimm_bus_unlock (dev); +device_unlock (dev);return rc; }
drivers/nvdimm/pfn_devs.c +2 -2
@@ -148,13 +148,13 @@ static ssize_t namespace_store(struct device *dev,struct nd_pfn *nd_pfn =to_nd_pfn (dev);ssize_t rc; -nvdimm_bus_lock (dev);device_lock (dev); +nvdimm_bus_lock (dev); rc =nd_namespace_store (dev, &nd_pfn->ndns, buf, len);dev_dbg (dev,"%s: result: %zd wrote: %s%s" , __func__, rc, buf, buf[len -1 ] =='\n' ?"" :"\n" ); -device_unlock (dev);nvdimm_bus_unlock (dev); +device_unlock (dev);return rc; }
drivers/nvdimm/pmem.c +2 -0
@@ -92,6 +92,8 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,struct pmem_device *pmem = bdev->bd_disk->private_data;pmem_do_bvec (pmem, page,PAGE_CACHE_SIZE ,0 , rw, sector); +if (rw &WRITE ) +wmb_pmem ();page_endio (page, rw &WRITE ,0 );return 0 ;
fs/block_dev.c +7 -0
@@ -1242,6 +1242,13 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) goto out_clear; }bd_set_size (bdev, (loff_t )bdev->bd_part->nr_sects <<9 ); +/* +* If the partition is not aligned on a page +* boundary, we can't do dax I/O to it. +*/ +if ((bdev->bd_part->start_sect % (PAGE_SIZE /512 )) || + (bdev->bd_part->nr_sects % (PAGE_SIZE /512 ))) + bdev->bd_inode->i_flags &= ~S_DAX ; } }else {if (bdev->bd_contains == bdev) {
fs/dax.c +2 -1
@@ -119,7 +119,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,size_t len;if (pos == max) {unsigned blkbits = inode->i_blkbits; -sector_t block = pos >> blkbits; +long page = pos >>PAGE_SHIFT ; +sector_t block = page << (PAGE_SHIFT - blkbits);unsigned first = pos - (block << blkbits);long size;
include/asm-generic/memory_model.h +1 -1
@@ -73,7 +73,7 @@* Convert a physical address to a Page Frame Number and back */ #define __phys_to_pfn (paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) -#define __pfn_to_phys (pfn) ((pfn) << PAGE_SHIFT) +#define __pfn_to_phys (pfn) PFN_PHYS(pfn)#define page_to_pfn __page_to_pfn#define pfn_to_page __pfn_to_page