summaryrefslogtreecommitdiff
path: root/fs/iomap
diff options
context:
space:
mode:
authorFengnan Chang <changfengnan@bytedance.com>2026-07-01 11:32:51 +0800
committerChristian Brauner <brauner@kernel.org>2026-07-01 15:00:20 +0200
commitd12fd544419535aa31c40e213161a3fd17bb77ba (patch)
tree5213584283747ecc56ef91041259093bccc6b834 /fs/iomap
parent562e5ff95de15ae94eff169417366564ef14735d (diff)
downloadlinux-next-d12fd544419535aa31c40e213161a3fd17bb77ba.tar.gz
linux-next-d12fd544419535aa31c40e213161a3fd17bb77ba.zip
iomap: factor out iomap_dio_alignment helper
Extract the alignment computation from iomap_dio_bio_iter() into a standalone helper so the upcoming simple direct I/O path can reuse it without requiring a struct iomap_dio. No functional change. Signed-off-by: Fengnan Chang <changfengnan@bytedance.com> Link: https://patch.msgid.link/20260701033253.46420-2-changfengnan@bytedance.com Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'fs/iomap')
-rw-r--r--fs/iomap/direct-io.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index b485e3b191da..487c4763f3fd 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -398,6 +398,14 @@ out_put_bio:
return ret;
}
+static inline unsigned int iomap_dio_alignment(struct inode *inode,
+ struct block_device *bdev, unsigned int dio_flags)
+{
+ if (dio_flags & IOMAP_DIO_FSBLOCK_ALIGNED)
+ return i_blocksize(inode);
+ return bdev_logical_block_size(bdev);
+}
+
static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
{
const struct iomap *iomap = &iter->iomap;
@@ -416,10 +424,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
* File systems that write out of place and always allocate new blocks
* need each bio to be block aligned as that's the unit of allocation.
*/
- if (dio->flags & IOMAP_DIO_FSBLOCK_ALIGNED)
- alignment = fs_block_size;
- else
- alignment = bdev_logical_block_size(iomap->bdev);
+ alignment = iomap_dio_alignment(inode, iomap->bdev, dio->flags);
if ((pos | length) & (alignment - 1))
return -EINVAL;