Prepare for submitting multiple bios from inside a single blk_zone_wplug_bio_work() call. No functionality has been changed. Cc: Damien Le Moal Cc: Christoph Hellwig Signed-off-by: Bart Van Assche --- 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(). */