summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-11-04 07:26:30 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-05 14:01:14 +0100
commit731d5bdc7426e9921ada4ccae21a8e5d4156df52 (patch)
tree4bc6eab9159fba5cf3114286f0213e741e1941e1 /block
parent7044259018f2ac79c322e22e29d18beab4d04c31 (diff)
downloadlinux-731d5bdc7426e9921ada4ccae21a8e5d4156df52.tar.gz
linux-731d5bdc7426e9921ada4ccae21a8e5d4156df52.tar.bz2
linux-731d5bdc7426e9921ada4ccae21a8e5d4156df52.zip
block: fix bio_split_rw_at to take zone_write_granularity into account
[ Upstream commit 7ecd2cd4fae3e8410c0a6620f3a83dcdbb254f02 ] Otherwise it can create unaligned writes on zoned devices. Fixes: a805a4fa4fa3 ("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>
Diffstat (limited to 'block')
-rw-r--r--block/blk-merge.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 75d2461b69e4..5baa950f34fe 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -287,6 +287,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
@@ -349,7 +357,7 @@ split:
* 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