fix regression in direct I/O to pmem devices
Subsystems (2)
cover fix regression in direct I/O to pmem devices
Linda Knippers noticed that commit bbab37ddc20b (block: Add support for DAX reads/writes to block devices) caused a regression in mkfs.xfs. Further investigation also uncovered issues related to misaligned partitions. This patch set addresses the two issues.
[PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev [PATCH 2/2] blockdev: don't set S_DAX for misaligned partitions
fs/block_dev.c | 7 +++++++ fs/dax.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)
PATCH 1/2 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.
--- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/dax.c +2 -1
@@ -116,7 +116,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,unsigned 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;
Signature · 1 line
1.8.3.1
Re: [PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev
Quoted 8 lines · Jeff Moyer
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 thedax_iocode trying to do a page-sized read from 512 bytes from the end of the device. The result is-ERANGEbeing returned to userspace.
Quoted 6 lines
The fix is to align the block to the page size before calling
get_block.Thanks to willy for simplifying my original patch.
Signed-off-by Jeff Moyer <[email protected]>
Quoted 19 lines
--- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/dax.c +2
-1@@ -116,7 +116,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,unsigned 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;
Re: [PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev
This patch and the 2/2 patch don't seem to have gone anywhere. Willy? or Ross?
-- ljk
Quoted 38 lines · Linda Knippers
Quoted 8 lines · Jeff Moyer
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 thedax_iocode trying to do a page-sized read from 512 bytes from the end of the device. The result is-ERANGEbeing returned to userspace.Quoted 6 lines
The fix is to align the block to the page size before calling
get_block.Thanks to willy for simplifying my original patch.
Signed-off-by Jeff Moyer <[email protected]>Tested-by Linda Knippers <[email protected]>Quoted 19 lines
--- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/dax.c +2
-1@@ -116,7 +116,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,unsigned 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;
Re: [PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev
Quoted 3 lines · Linda Knippers
This patch and the 2/2 patch don't seem to have gone anywhere. Willy? or Ross?
Yes, these should have gone into 4.2, The nvdimm.git tree will pick them up after 4.3-rc1 and tag them for -stable.
PATCH 2/2 blockdev: don't set S_DAX for misaligned partitions
In reply to Jeff MoyerThe dax code doesn't currently support misaligned partitions, so disable O_DIRECT via dax until such time as that support materializes.
--- fs/block_dev.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/block_dev.c +7 -0
@@ -1241,6 +1241,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) {
Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] blockdev: don't set S_DAX for misaligned partitions
Quoted 16 lines · Jeff Moyer
The dax code doesn't currently support misaligned partitions, so disable
O_DIRECTvia dax until such time as that support materializes.Suggested-by Boaz Harrosh <[email protected]>Signed-off-by Jeff Moyer <[email protected]>---
fs/block_dev.c| 7 +++++++1 file changed, 7 insertions(+)fs/block_dev.c +0
-0
fs/block_dev.c static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · line 1249
Quoted 9 lines
fs/block_dev.c +6
-0@@ -1241,6 +1241,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 )))
Maybe I'm missing something, but doesn't the second condition above disable DAX for the case that the 1/2 patch is fixing (i.e. the last sectors at the end of a non-PAGE_SIZE-multiple device)? It seems a shame to disable DAX for the whole device because of the last sector.
Quoted 6 lines
fs/block_dev.c +1
-0+ bdev->bd_inode->i_flags &= ~S_DAX ; } }else {if (bdev->bd_contains == bdev) {Signature · 1 line
1.8.3.1
Cheers, Andreas
Re: [PATCH 2/2] blockdev: don't set S_DAX for misaligned partitions
Quoted 23 lines · Andreas Dilger
Quoted 22 lines · Jeff Moyer
The dax code doesn't currently support misaligned partitions, so disable
O_DIRECTvia dax until such time as that support materializes.Suggested-by Boaz Harrosh <[email protected]>Signed-off-by Jeff Moyer <[email protected]>---
fs/block_dev.c| 7 +++++++1 file changed, 7 insertions(+)fs/block_dev.c +3
-0@@ -1241,6 +1241,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.
Quoted 8 lines
fs/block_dev.c static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · line 1249
Quoted 3 lines
fs/block_dev.c +3
-0+*/ +if ((bdev->bd_part->start_sect % (PAGE_SIZE /512 )) || + (bdev->bd_part->nr_sects % (PAGE_SIZE /512 )))Maybe I'm missing something, but doesn't the second condition above disable DAX for the case that the 1/2 patch is fixing (i.e. the last sectors at the end of a non-PAGE_SIZE-multiple device)? It seems a shame to disable DAX for the whole device because of the last sector.
No. Patch 1/2 fixes a 512 byte read of the last sector of a properly aligned partiton. The goal is to eventually fix things so we can enable the dax path for misaligned partitions, but it's not going to happen in time for 4.2. Also, keep in mind that this is just for opening the block device itself with O_DIRECT.
Thanks for taking a look.
Cheers,
Jeff
Quoted 7 lines · Jeff Moyer
Linda Knippers noticed that commit
bbab37ddc20b(block: Add support for DAX reads/writes to block devices) caused a regression in mkfs.xfs. Further investigation also uncovered issues related to misaligned partitions. This patch set addresses the two issues.[PATCH 1/2] dax: fix
O_DIRECTI/O to the last block of a blockdev [PATCH 2/2] blockdev: don't setS_DAXfor misaligned partitions
Should these be "Cc: <[email protected]>" given the regression fix is applicable back to 4.0?
Quoted 11 lines · Dan Williams
Quoted 7 lines · Jeff Moyer
Linda Knippers noticed that commit
bbab37ddc20b(block: Add support for DAX reads/writes to block devices) caused a regression in mkfs.xfs. Further investigation also uncovered issues related to misaligned partitions. This patch set addresses the two issues.[PATCH 1/2] dax: fix
O_DIRECTI/O to the last block of a blockdev [PATCH 2/2] blockdev: don't setS_DAXfor misaligned partitionsShould these be "Cc: <[email protected]>" given the regression fix is applicable back to 4.0?
Sorry, regression *since* 4.0.
Quoted 7 lines · Dan Williams
Quoted 6 lines · Dan Williams
Quoted 5 lines · Jeff Moyer
Linda Knippers noticed that commit
bbab37ddc20b(block: Add support for DAX reads/writes to block devices) caused a regression in mkfs.xfs. Further investigation also uncovered issues related to misaligned partitions. This patch set addresses the two issues.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
[PATCH 1/2] dax: fix
O_DIRECTI/O to the last block of a blockdev [PATCH 2/2] blockdev: don't setS_DAXfor misaligned partitionsShould these be "Cc: <[email protected]>" given the regression fix is applicable back to 4.0?
Sorry, regression *since* 4.0.
$ git describe --contains bbab37ddc20b v4.2-rc1~2^2~4
Looks like this was not sprung on the public yet.
-Jeff