[PATCH 04/12] iomap: use common blkdev alignment check

Keith Busch kbusch at fb.com
Thu Jun 30 13:42:04 PDT 2022


From: Keith Busch <kbusch at kernel.org>

The block layer provides a generic io alignment check, so use that.

Signed-off-by: Keith Busch <kbusch at kernel.org>
---
 fs/iomap/direct-io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 40cbf2025386..10a113358365 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -241,7 +241,6 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
 	const struct iomap *iomap = &iter->iomap;
 	struct inode *inode = iter->inode;
 	struct block_device *bdev = iomap->bdev;
-	unsigned int blksz = bdev_logical_block_size(bdev);
 	unsigned int fs_block_size = i_blocksize(inode), pad;
 	loff_t length = iomap_length(iter);
 	loff_t pos = iter->pos;
@@ -253,8 +252,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
 	size_t copied = 0;
 	size_t orig_count;
 
-	if ((pos | length) & (blksz - 1) ||
-	    !bdev_iter_is_aligned(bdev, dio->submit.iter))
+	if (blkdev_dio_unaligned(bdev, pos | length, dio->submit.iter))
 		return -EINVAL;
 
 	if (iomap->type == IOMAP_UNWRITTEN) {
-- 
2.30.2




More information about the Linux-nvme mailing list