]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: only update request sector if needed
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 6 May 2025 11:27:30 +0000 (13:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:13:54 +0000 (11:13 +0200)
[ Upstream commit db492e24f9b05547ba12b4783f09c9d943cf42fe ]

In case of a ZONE APPEND write, regardless of native ZONE APPEND or the
emulation layer in the zone write plugging code, the sector the data got
written to by the device needs to be updated in the bio.

At the moment, this is done for every native ZONE APPEND write and every
request that is flagged with 'BIO_ZONE_WRITE_PLUGGING'. But thus
superfluously updates the sector for regular writes to a zoned block
device.

Check if a bio is a native ZONE APPEND write or if the bio is flagged as
'BIO_EMULATES_ZONE_APPEND', meaning the block layer's zone write plugging
code handles the ZONE APPEND and translates it into a regular write and
back. Only if one of these two criterion is met, update the sector in the
bio upon completion.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/dea089581cb6b777c1cd1500b38ac0b61df4b2d1.1746530748.git.jth@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk.h

index 9dcc92c7f2b50d2c19c81506d2b7b326069782a4..c14f415de5228e82dca6e2ba569424997004da7f 100644 (file)
@@ -480,7 +480,8 @@ static inline void blk_zone_update_request_bio(struct request *rq,
         * the original BIO sector so that blk_zone_write_plug_bio_endio() can
         * lookup the zone write plug.
         */
-       if (req_op(rq) == REQ_OP_ZONE_APPEND || bio_zone_write_plugging(bio))
+       if (req_op(rq) == REQ_OP_ZONE_APPEND ||
+           bio_flagged(bio, BIO_EMULATES_ZONE_APPEND))
                bio->bi_iter.bi_sector = rq->__sector;
 }
 void blk_zone_write_plug_bio_endio(struct bio *bio);