All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	dm-devel@lists.linux.dev, Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 11/13] block: Improve zone write request completion handling
Date: Tue, 30 Apr 2024 21:51:29 +0900	[thread overview]
Message-ID: <20240430125131.668482-12-dlemoal@kernel.org> (raw)
In-Reply-To: <20240430125131.668482-1-dlemoal@kernel.org>

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>
---
 block/blk-mq.c    | 6 ++----
 block/blk-zoned.c | 9 +++++----
 block/blk.h       | 8 ++++----
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0fae9bd0ecd4..9f677ea85a52 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -691,6 +691,8 @@ static void blk_mq_finish_request(struct request *rq)
 {
 	struct request_queue *q = rq->q;
 
+	blk_zone_finish_request(rq);
+
 	if (rq->rq_flags & RQF_USE_SCHED) {
 		q->elevator->type->ops.finish_request(rq);
 		/*
@@ -828,8 +830,6 @@ static void blk_complete_request(struct request *req)
 		bio = next;
 	} while (bio);
 
-	blk_zone_complete_request(req);
-
 	/*
 	 * Reset counters so that the request stacking driver
 	 * can find how many bytes remain in the request
@@ -940,7 +940,6 @@ bool blk_update_request(struct request *req, blk_status_t error,
 	 * completely done
 	 */
 	if (!req->bio) {
-		blk_zone_complete_request(req);
 		/*
 		 * Reset counters so that the request stacking driver
 		 * can find how many bytes remain in the request
@@ -2996,7 +2995,6 @@ void blk_mq_submit_bio(struct bio *bio)
 	if (ret != BLK_STS_OK) {
 		bio->bi_status = ret;
 		bio_endio(bio);
-		blk_zone_complete_request(rq);
 		blk_mq_free_request(rq);
 		return;
 	}
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index d962ba7c9ae1..0047fe66f22d 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -902,7 +902,7 @@ void blk_zone_write_plug_init_request(struct request *req)
 
 	/*
 	 * Indicate that completion of this request needs to be handled with
-	 * blk_zone_write_plug_complete_request(), which will drop the reference
+	 * blk_zone_write_plug_finish_request(), which will drop the reference
 	 * on the zone write plug we took above on entry to this function.
 	 */
 	req->rq_flags |= RQF_ZONE_WRITE_PLUGGING;
@@ -1236,7 +1236,7 @@ void blk_zone_write_plug_bio_endio(struct bio *bio)
 	disk_put_zone_wplug(zwplug);
 
 	/*
-	 * For BIO-based devices, blk_zone_write_plug_complete_request()
+	 * For BIO-based devices, blk_zone_write_plug_finish_request()
 	 * is not called. So we need to schedule execution of the next
 	 * plugged BIO here.
 	 */
@@ -1247,11 +1247,12 @@ void blk_zone_write_plug_bio_endio(struct bio *bio)
 	disk_put_zone_wplug(zwplug);
 }
 
-void blk_zone_write_plug_complete_request(struct request *req)
+void blk_zone_write_plug_finish_request(struct request *req)
 {
 	struct gendisk *disk = req->q->disk;
-	struct blk_zone_wplug *zwplug = disk_get_zone_wplug(disk, req->__sector);
+	struct blk_zone_wplug *zwplug;
 
+	zwplug = disk_get_zone_wplug(disk, req->__sector);
 	if (WARN_ON_ONCE(!zwplug))
 		return;
 
diff --git a/block/blk.h b/block/blk.h
index 8a62b861453c..ee4f782d1496 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -453,11 +453,11 @@ static inline void blk_zone_bio_endio(struct bio *bio)
 		blk_zone_write_plug_bio_endio(bio);
 }
 
-void blk_zone_write_plug_complete_request(struct request *rq);
-static inline void blk_zone_complete_request(struct request *rq)
+void blk_zone_write_plug_finish_request(struct request *rq);
+static inline void blk_zone_finish_request(struct request *rq)
 {
 	if (rq->rq_flags & RQF_ZONE_WRITE_PLUGGING)
-		blk_zone_write_plug_complete_request(rq);
+		blk_zone_write_plug_finish_request(rq);
 }
 int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
 		unsigned long arg);
@@ -491,7 +491,7 @@ static inline void blk_zone_update_request_bio(struct request *rq,
 static inline void blk_zone_bio_endio(struct bio *bio)
 {
 }
-static inline void blk_zone_complete_request(struct request *rq)
+static inline void blk_zone_finish_request(struct request *rq)
 {
 }
 static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
-- 
2.44.0


  parent reply	other threads:[~2024-04-30 12:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 12:51 [PATCH 00/13] Zone write plugging fixes and cleanup Damien Le Moal
2024-04-30 12:51 ` [PATCH 01/13] dm: Check that a zoned table leads to a valid mapped device Damien Le Moal
2024-04-30 12:51 ` [PATCH 02/13] block: Exclude conventional zones when faking max open limit Damien Le Moal
2024-04-30 15:24   ` Christoph Hellwig
2024-04-30 19:04     ` Jens Axboe
2024-05-01  4:57       ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 03/13] block: Fix zone write plug initialization from blk_revalidate_zone_cb() Damien Le Moal
2024-04-30 15:26   ` Christoph Hellwig
2024-04-30 22:50     ` Damien Le Moal
2024-04-30 23:54       ` Damien Le Moal
2024-04-30 12:51 ` [PATCH 04/13] block: Fix reference counting for zone write plugs in error state Damien Le Moal
2024-04-30 15:28   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 05/13] block: Hold a reference on zone write plugs to schedule submission Damien Le Moal
2024-04-30 15:30   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 06/13] block: Unhash a zone write plug only if needed Damien Le Moal
2024-04-30 15:31   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 07/13] block: Do not remove zone write plugs still in use Damien Le Moal
2024-04-30 15:34   ` Christoph Hellwig
2024-04-30 23:06     ` Damien Le Moal
2024-04-30 23:55       ` Damien Le Moal
2024-04-30 12:51 ` [PATCH 08/13] block: Fix flush request sector restore Damien Le Moal
2024-04-30 15:26   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 09/13] block: Fix handling of non-empty flush write requests to zones Damien Le Moal
2024-04-30 15:34   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 10/13] block: Improve blk_zone_write_plug_bio_merged() Damien Le Moal
2024-04-30 15:35   ` Christoph Hellwig
2024-04-30 12:51 ` Damien Le Moal [this message]
2024-04-30 15:39   ` [PATCH 11/13] block: Improve zone write request completion handling Christoph Hellwig
2024-04-30 12:51 ` [PATCH 12/13] block: Simplify blk_zone_write_plug_bio_endio() Damien Le Moal
2024-04-30 15:36   ` Christoph Hellwig
2024-04-30 12:51 ` [PATCH 13/13] block: Simplify zone write plug BIO abort Damien Le Moal
2024-04-30 15:36   ` Christoph Hellwig
2024-04-30 17:00 ` [PATCH 00/13] Zone write plugging fixes and cleanup Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240430125131.668482-12-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.