]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: introduce bdev_iter_is_aligned helper
authorKeith Busch <kbusch@kernel.org>
Fri, 10 Jun 2022 19:58:28 +0000 (12:58 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 27 Jun 2022 12:29:11 +0000 (06:29 -0600)
Provide a convenient function for this repeatable coding pattern.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220610195830.3574005-10-kbusch@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/blkdev.h

index 2556fcdb645b12924190df3a380d1eea7ec25e4d..0b8bc1fe0b2c7817061ec08521c3f92993292b1b 100644 (file)
@@ -1370,6 +1370,13 @@ static inline unsigned int bdev_dma_alignment(struct block_device *bdev)
        return queue_dma_alignment(bdev_get_queue(bdev));
 }
 
+static inline bool bdev_iter_is_aligned(struct block_device *bdev,
+                                       struct iov_iter *iter)
+{
+       return iov_iter_is_aligned(iter, bdev_dma_alignment(bdev),
+                                  bdev_logical_block_size(bdev) - 1);
+}
+
 static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
                                 unsigned int len)
 {