Skip to content

Commit 7ecd2cd

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: fix bio_split_rw_at to take zone_write_granularity into account
Otherwise it can create unaligned writes on zoned devices. Fixes: a805a4f ("block: introduce zone_write_granularity limit") Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 60dc5ea commit 7ecd2cd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

block/blk-merge.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ static bool bvec_split_segs(const struct queue_limits *lim,
292292
return len > 0 || bv->bv_len > max_len;
293293
}
294294

295+
static unsigned int bio_split_alignment(struct bio *bio,
296+
const struct queue_limits *lim)
297+
{
298+
if (op_is_write(bio_op(bio)) && lim->zone_write_granularity)
299+
return lim->zone_write_granularity;
300+
return lim->logical_block_size;
301+
}
302+
295303
/**
296304
* bio_split_rw_at - check if and where to split a read/write bio
297305
* @bio: [in] bio to be split
@@ -354,7 +362,7 @@ int bio_split_rw_at(struct bio *bio, const struct queue_limits *lim,
354362
* split size so that each bio is properly block size aligned, even if
355363
* we do not use the full hardware limits.
356364
*/
357-
bytes = ALIGN_DOWN(bytes, lim->logical_block_size);
365+
bytes = ALIGN_DOWN(bytes, bio_split_alignment(bio, lim));
358366

359367
/*
360368
* Bio splitting may cause subtle trouble such as hang when doing sync

0 commit comments

Comments
 (0)