mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
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>
This commit is contained in:
parent
e08fd61191
commit
27b7efca5b
|
|
@ -398,6 +398,14 @@ static ssize_t iomap_dio_bio_iter_one(struct iomap_iter *iter,
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user