mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
block: fix bio_split_rw_at to take zone_write_granularity into account
[ Upstream commit7ecd2cd4fa
] Otherwise it can create unaligned writes on zoned devices. Fixes:a805a4fa4f
("block: introduce zone_write_granularity limit") Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20241104062647.91160-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ddab02607e
commit
2cd22baf74
@ -247,6 +247,14 @@ static bool bvec_split_segs(struct queue_limits *lim, const struct bio_vec *bv,
|
||||
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 - split a bio in two bios
|
||||
* @bio: [in] bio to be split
|
||||
@ -317,7 +325,7 @@ static struct bio *bio_split_rw(struct bio *bio, 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
|
||||
|
Loading…
Reference in New Issue
Block a user