Commit 7ecd2cd4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

block: fix bio_split_rw_at to take zone_write_granularity into account



Otherwise it can create unaligned writes on zoned devices.

Fixes: a805a4fa ("block: introduce zone_write_granularity limit")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20241104062647.91160-3-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 60dc5ea6
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -292,6 +292,14 @@ static bool bvec_split_segs(const struct queue_limits *lim,
	return len > 0 || bv->bv_len > max_len;
}

static unsigned int bio_split_alignment(struct bio *bio,
		const struct queue_limits *lim)
{
	if (op_is_write(bio_op(bio)) && lim->zone_write_granularity)
		return lim->zone_write_granularity;
	return lim->logical_block_size;
}

/**
 * bio_split_rw_at - check if and where to split a read/write bio
 * @bio:  [in] bio to be split
@@ -354,7 +362,7 @@ int bio_split_rw_at(struct bio *bio, const struct queue_limits *lim,
	 * split size so that each bio is properly block size aligned, even if
	 * we do not use the full hardware limits.
	 */
	bytes = ALIGN_DOWN(bytes, lim->logical_block_size);
	bytes = ALIGN_DOWN(bytes, bio_split_alignment(bio, lim));

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