]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: split blk_zone_update_request_bio into two functions
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 15 Jul 2025 11:53:21 +0000 (13:53 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Jul 2025 14:03:49 +0000 (08:03 -0600)
blk_zone_update_request_bio() does two things. First it checks if the
request to be completed was written via ZONE APPEND and if yes it then
updates the sector to the one that the data was written to.

This is small enough to be an inline function. But upcoming changes adding
a tracepoint don't work if the function is inlined.

Split the function into two, the first is blk_req_bio_is_zone_append()
checking if the sector needs to be updated. This can still be an inline
function. The second is blk_zone_append_update_request_bio() doing the
sector update.

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20250715115324.53308-3-johannes.thumshirn@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c
block/blk-zoned.c
block/blk.h

index 0c61492724d228736f975f1d8f195515603801b6..b1d81839679fb42b2122194e0afe3baebbaa9f07 100644 (file)
@@ -883,7 +883,8 @@ static void blk_complete_request(struct request *req)
                /* Completion has already been traced */
                bio_clear_flag(bio, BIO_TRACE_COMPLETION);
 
-               blk_zone_update_request_bio(req, bio);
+               if (blk_req_bio_is_zone_append(req, bio))
+                       blk_zone_append_update_request_bio(req, bio);
 
                if (!is_flush)
                        bio_endio(bio);
@@ -982,7 +983,8 @@ bool blk_update_request(struct request *req, blk_status_t error,
 
                /* Don't actually finish bio if it's part of flush sequence */
                if (!bio->bi_iter.bi_size) {
-                       blk_zone_update_request_bio(req, bio);
+                       if (blk_req_bio_is_zone_append(req, bio))
+                               blk_zone_append_update_request_bio(req, bio);
                        if (!is_flush)
                                bio_endio(bio);
                }
index efe71b1a1da138dde26bc5e920ff37a557ae9ccf..88deb751b621e013de7e6186287742633e1db0cf 100644 (file)
@@ -1187,6 +1187,19 @@ static void disk_zone_wplug_unplug_bio(struct gendisk *disk,
        spin_unlock_irqrestore(&zwplug->lock, flags);
 }
 
+void blk_zone_append_update_request_bio(struct request *rq, struct bio *bio)
+{
+       /*
+        * For zone append requests, the request sector indicates the location
+        * at which the BIO data was written. Return this value to the BIO
+        * issuer through the BIO iter sector.
+        * For plugged zone writes, which include emulated zone append, we need
+        * the original BIO sector so that blk_zone_write_plug_bio_endio() can
+        * lookup the zone write plug.
+        */
+       bio->bi_iter.bi_sector = rq->__sector;
+}
+
 void blk_zone_write_plug_bio_endio(struct bio *bio)
 {
        struct gendisk *disk = bio->bi_bdev->bd_disk;
index 1141b343d0b5cef6bf03d211b9f0aca744808b66..468aa83c5a223232191b0e2f219a2e04ea3fdfbb 100644 (file)
@@ -476,23 +476,15 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
 {
        return bio_flagged(bio, BIO_ZONE_WRITE_PLUGGING);
 }
-void blk_zone_write_plug_bio_merged(struct bio *bio);
-void blk_zone_write_plug_init_request(struct request *rq);
-static inline void blk_zone_update_request_bio(struct request *rq,
-                                              struct bio *bio)
+static inline bool blk_req_bio_is_zone_append(struct request *rq,
+                                             struct bio *bio)
 {
-       /*
-        * For zone append requests, the request sector indicates the location
-        * at which the BIO data was written. Return this value to the BIO
-        * issuer through the BIO iter sector.
-        * For plugged zone writes, which include emulated zone append, we need
-        * 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_flagged(bio, BIO_EMULATES_ZONE_APPEND))
-               bio->bi_iter.bi_sector = rq->__sector;
+       return req_op(rq) == REQ_OP_ZONE_APPEND ||
+              bio_flagged(bio, BIO_EMULATES_ZONE_APPEND);
 }
+void blk_zone_write_plug_bio_merged(struct bio *bio);
+void blk_zone_write_plug_init_request(struct request *rq);
+void blk_zone_append_update_request_bio(struct request *rq, struct bio *bio);
 void blk_zone_write_plug_bio_endio(struct bio *bio);
 static inline void blk_zone_bio_endio(struct bio *bio)
 {
@@ -525,14 +517,19 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
 {
        return false;
 }
+static inline bool blk_req_bio_is_zone_append(struct request *req,
+                                             struct bio *bio)
+{
+       return false;
+}
 static inline void blk_zone_write_plug_bio_merged(struct bio *bio)
 {
 }
 static inline void blk_zone_write_plug_init_request(struct request *rq)
 {
 }
-static inline void blk_zone_update_request_bio(struct request *rq,
-                                              struct bio *bio)
+static inline void blk_zone_append_update_request_bio(struct request *rq,
+                                                     struct bio *bio)
 {
 }
 static inline void blk_zone_bio_endio(struct bio *bio)