]> www.infradead.org Git - users/hch/xfs.git/commitdiff
block: fix bio_split_rw_at to take zone_write_granularity into account
authorChristoph Hellwig <hch@lst.de>
Thu, 31 Oct 2024 13:16:37 +0000 (14:16 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 5 Nov 2024 08:26:38 +0000 (09:26 +0100)
Otherwise it can create unaligned writes on zoned devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk-merge.c

index e7244ff8ae5eaca0600751ea2aeacf31105c83d0..1877c84c6fe00c78e526bdedaf2c064832a64f61 100644 (file)
@@ -296,6 +296,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
@@ -358,7 +366,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