linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>,
	Damien Le Moal <dlemoal@kernel.org>,
	Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH v24 10/18] blk-zoned: Introduce a loop in blk_zone_wplug_bio_work()
Date: Wed, 27 Aug 2025 14:29:29 -0700	[thread overview]
Message-ID: <20250827212937.2759348-11-bvanassche@acm.org> (raw)
In-Reply-To: <20250827212937.2759348-1-bvanassche@acm.org>

Prepare for submitting multiple bios from inside a single
blk_zone_wplug_bio_work() call. No functionality has been changed.

Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/blk-zoned.c | 70 +++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index fb6e7407d173..eb81278acb38 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -1301,44 +1301,48 @@ static void blk_zone_wplug_bio_work(struct work_struct *work)
 	struct bio *bio;
 	bool prepared;
 
-	/*
-	 * Submit the next plugged BIO. If we do not have any, clear
-	 * the plugged flag.
-	 */
-again:
-	spin_lock_irqsave(&zwplug->lock, flags);
-	bio = bio_list_pop(&zwplug->bio_list);
-	if (!bio) {
-		zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED;
-		spin_unlock_irqrestore(&zwplug->lock, flags);
-		goto put_zwplug;
-	}
+	do {
+		/*
+		 * Submit the next plugged BIO. If we do not have any, clear
+		 * the plugged flag.
+		 */
+		spin_lock_irqsave(&zwplug->lock, flags);
+		bio = bio_list_pop(&zwplug->bio_list);
+		if (!bio) {
+			zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED;
+			spin_unlock_irqrestore(&zwplug->lock, flags);
+			goto put_zwplug;
+		}
 
-	trace_blk_zone_wplug_bio(zwplug->disk->queue, zwplug->zone_no,
-				 bio->bi_iter.bi_sector, bio_sectors(bio));
+		trace_blk_zone_wplug_bio(zwplug->disk->queue,
+					 zwplug->zone_no,
+					 bio->bi_iter.bi_sector,
+					 bio_sectors(bio));
 
-	prepared = blk_zone_wplug_prepare_bio(zwplug, bio);
-	spin_unlock_irqrestore(&zwplug->lock, flags);
+		prepared = blk_zone_wplug_prepare_bio(zwplug, bio);
+		spin_unlock_irqrestore(&zwplug->lock, flags);
 
-	if (!prepared) {
-		blk_zone_wplug_bio_io_error(zwplug, bio);
-		goto again;
-	}
+		if (!prepared) {
+			blk_zone_wplug_bio_io_error(zwplug, bio);
+			continue;
+		}
 
-	bdev = bio->bi_bdev;
 
-	/*
-	 * blk-mq devices will reuse the extra reference on the request queue
-	 * usage counter we took when the BIO was plugged, but the submission
-	 * path for BIO-based devices will not do that. So drop this extra
-	 * reference here.
-	 */
-	if (bdev_test_flag(bdev, BD_HAS_SUBMIT_BIO)) {
-		bdev->bd_disk->fops->submit_bio(bio);
-		blk_queue_exit(bdev->bd_disk->queue);
-	} else {
-		blk_mq_submit_bio(bio);
-	}
+		bdev = bio->bi_bdev;
+
+		/*
+		 * blk-mq devices will reuse the extra reference on the request
+		 * queue usage counter we took when the BIO was plugged, but the
+		 * submission path for BIO-based devices will not do that. So
+		 * drop this extra reference here.
+		 */
+		if (bdev_test_flag(bdev, BD_HAS_SUBMIT_BIO)) {
+			bdev->bd_disk->fops->submit_bio(bio);
+			blk_queue_exit(bdev->bd_disk->queue);
+		} else {
+			blk_mq_submit_bio(bio);
+		}
+	} while (0);
 
 put_zwplug:
 	/* Drop the reference we took in disk_zone_wplug_schedule_bio_work(). */

  parent reply	other threads:[~2025-08-27 21:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 21:29 [PATCH v24 00/18] Improve write performance for zoned UFS devices Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 01/18] block: Support block devices that preserve the order of write requests Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 02/18] blk-mq: Always insert sequential zoned writes into a software queue Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 03/18] blk-mq: Restore the zone write order when requeuing Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 04/18] blk-mq: Move the blk_queue_sq_sched() calls Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 05/18] blk-mq: Run all hwqs for sq scheds if write pipelining is enabled Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 06/18] block/mq-deadline: Enable zoned write pipelining Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 07/18] blk-zoned: Add an argument to blk_zone_plug_bio() Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 08/18] blk-zoned: Split an if-statement Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 09/18] blk-zoned: Move code from disk_zone_wplug_add_bio() into its caller Bart Van Assche
2025-08-27 21:29 ` Bart Van Assche [this message]
2025-08-27 21:29 ` [PATCH v24 11/18] blk-zoned: Document disk_zone_wplug_schedule_bio_work() locking Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 12/18] blk-zoned: Support pipelining of zoned writes Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 13/18] null_blk: Add the preserves_write_order attribute Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 14/18] scsi: core: Retry unaligned zoned writes Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 15/18] scsi: sd: Increase retry count for " Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 16/18] scsi: scsi_debug: Add the preserves_write_order module parameter Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 17/18] scsi: scsi_debug: Support injecting unaligned write errors Bart Van Assche
2025-08-27 21:29 ` [PATCH v24 18/18] ufs: core: Inform the block layer about write ordering Bart Van Assche
2025-08-28 11:23 ` [PATCH v24 00/18] Improve write performance for zoned UFS devices Hannes Reinecke
2025-08-28 13:32   ` Bart Van Assche

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=20250827212937.2759348-11-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).