Skip to content

Commit 347bde9

Browse files
damien-lemoalaxboe
authored andcommitted
block: Improve zone write request completion handling
blk_zone_complete_request() must be called to handle the completion of a zone write request handled with zone write plugging. This function is called from blk_complete_request(), blk_update_request() and also in blk_mq_submit_bio() error path. Improve this by moving this function call into blk_mq_finish_request() as all requests are processed with this function when they complete as well as when they are freed without being executed. This also improves blk_update_request() used by scsi devices as these may repeatedly call this function to handle partial completions. To be consistent with this change, blk_zone_complete_request() is renamed to blk_zone_finish_request() and blk_zone_write_plug_complete_request() is renamed to blk_zone_write_plug_finish_request(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20240501110907.96950-12-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c4c3ffd commit 347bde9

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

block/blk-mq.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ static void blk_mq_finish_request(struct request *rq)
691691
{
692692
struct request_queue *q = rq->q;
693693

694+
blk_zone_finish_request(rq);
695+
694696
if (rq->rq_flags & RQF_USE_SCHED) {
695697
q->elevator->type->ops.finish_request(rq);
696698
/*
@@ -828,8 +830,6 @@ static void blk_complete_request(struct request *req)
828830
bio = next;
829831
} while (bio);
830832

831-
blk_zone_complete_request(req);
832-
833833
/*
834834
* Reset counters so that the request stacking driver
835835
* can find how many bytes remain in the request
@@ -940,7 +940,6 @@ bool blk_update_request(struct request *req, blk_status_t error,
940940
* completely done
941941
*/
942942
if (!req->bio) {
943-
blk_zone_complete_request(req);
944943
/*
945944
* Reset counters so that the request stacking driver
946945
* can find how many bytes remain in the request
@@ -2996,7 +2995,6 @@ void blk_mq_submit_bio(struct bio *bio)
29962995
if (ret != BLK_STS_OK) {
29972996
bio->bi_status = ret;
29982997
bio_endio(bio);
2999-
blk_zone_complete_request(rq);
30002998
blk_mq_free_request(rq);
30012999
return;
30023000
}

block/blk-zoned.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
531531
/*
532532
* Completions of BIOs with blk_zone_write_plug_bio_endio() may
533533
* happen after handling a request completion with
534-
* blk_zone_write_plug_complete_request() (e.g. with split BIOs
534+
* blk_zone_write_plug_finish_request() (e.g. with split BIOs
535535
* that are chained). In such case, disk_zone_wplug_unplug_bio()
536536
* should not attempt to remove the zone write plug until all BIO
537537
* completions are seen. Check by looking at the zone write plug
@@ -921,7 +921,7 @@ void blk_zone_write_plug_init_request(struct request *req)
921921

922922
/*
923923
* Indicate that completion of this request needs to be handled with
924-
* blk_zone_write_plug_complete_request(), which will drop the reference
924+
* blk_zone_write_plug_finish_request(), which will drop the reference
925925
* on the zone write plug we took above on entry to this function.
926926
*/
927927
req->rq_flags |= RQF_ZONE_WRITE_PLUGGING;
@@ -1255,7 +1255,7 @@ void blk_zone_write_plug_bio_endio(struct bio *bio)
12551255
disk_put_zone_wplug(zwplug);
12561256

12571257
/*
1258-
* For BIO-based devices, blk_zone_write_plug_complete_request()
1258+
* For BIO-based devices, blk_zone_write_plug_finish_request()
12591259
* is not called. So we need to schedule execution of the next
12601260
* plugged BIO here.
12611261
*/
@@ -1266,11 +1266,12 @@ void blk_zone_write_plug_bio_endio(struct bio *bio)
12661266
disk_put_zone_wplug(zwplug);
12671267
}
12681268

1269-
void blk_zone_write_plug_complete_request(struct request *req)
1269+
void blk_zone_write_plug_finish_request(struct request *req)
12701270
{
12711271
struct gendisk *disk = req->q->disk;
1272-
struct blk_zone_wplug *zwplug = disk_get_zone_wplug(disk, req->__sector);
1272+
struct blk_zone_wplug *zwplug;
12731273

1274+
zwplug = disk_get_zone_wplug(disk, req->__sector);
12741275
if (WARN_ON_ONCE(!zwplug))
12751276
return;
12761277

block/blk.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ static inline void blk_zone_bio_endio(struct bio *bio)
453453
blk_zone_write_plug_bio_endio(bio);
454454
}
455455

456-
void blk_zone_write_plug_complete_request(struct request *rq);
457-
static inline void blk_zone_complete_request(struct request *rq)
456+
void blk_zone_write_plug_finish_request(struct request *rq);
457+
static inline void blk_zone_finish_request(struct request *rq)
458458
{
459459
if (rq->rq_flags & RQF_ZONE_WRITE_PLUGGING)
460-
blk_zone_write_plug_complete_request(rq);
460+
blk_zone_write_plug_finish_request(rq);
461461
}
462462
int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
463463
unsigned long arg);
@@ -491,7 +491,7 @@ static inline void blk_zone_update_request_bio(struct request *rq,
491491
static inline void blk_zone_bio_endio(struct bio *bio)
492492
{
493493
}
494-
static inline void blk_zone_complete_request(struct request *rq)
494+
static inline void blk_zone_finish_request(struct request *rq)
495495
{
496496
}
497497
static inline int blkdev_report_zones_ioctl(struct block_device *bdev,

0 commit comments

Comments
 (0)