Skip to content

Commit 5aa860b

Browse files
bvanasschekawasaki
authored andcommitted
blk-zoned: Introduce a loop in blk_zone_wplug_bio_work()
Prepare for submitting multiple bios from inside a single blk_zone_wplug_bio_work() call. No functionality has been changed. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 1b0081e commit 5aa860b

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

block/blk-zoned.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,47 +1283,47 @@ static void blk_zone_wplug_bio_work(struct work_struct *work)
12831283
struct blk_zone_wplug *zwplug =
12841284
container_of(work, struct blk_zone_wplug, bio_work);
12851285
struct block_device *bdev;
1286-
unsigned long flags;
12871286
struct bio *bio;
12881287

1289-
/*
1290-
* Submit the next plugged BIO. If we do not have any, clear
1291-
* the plugged flag.
1292-
*/
1293-
spin_lock_irqsave(&zwplug->lock, flags);
1294-
1288+
do {
12951289
again:
1296-
bio = bio_list_pop(&zwplug->bio_list);
1297-
if (!bio) {
1298-
zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED;
1299-
spin_unlock_irqrestore(&zwplug->lock, flags);
1300-
goto put_zwplug;
1301-
}
1302-
1303-
trace_blk_zone_wplug_bio(zwplug->disk->queue, zwplug->zone_no,
1304-
bio->bi_iter.bi_sector, bio_sectors(bio));
1305-
1306-
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
1307-
blk_zone_wplug_bio_io_error(zwplug, bio);
1308-
goto again;
1309-
}
1310-
1311-
spin_unlock_irqrestore(&zwplug->lock, flags);
1290+
/*
1291+
* Submit the next plugged BIO. If we do not have any, clear
1292+
* the plugged flag.
1293+
*/
1294+
scoped_guard(spinlock_irqsave, &zwplug->lock) {
1295+
bio = bio_list_pop(&zwplug->bio_list);
1296+
if (!bio) {
1297+
zwplug->flags &= ~BLK_ZONE_WPLUG_PLUGGED;
1298+
goto put_zwplug;
1299+
}
1300+
1301+
trace_blk_zone_wplug_bio(zwplug->disk->queue,
1302+
zwplug->zone_no,
1303+
bio->bi_iter.bi_sector,
1304+
bio_sectors(bio));
1305+
1306+
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
1307+
blk_zone_wplug_bio_io_error(zwplug, bio);
1308+
goto again;
1309+
}
1310+
}
13121311

1313-
bdev = bio->bi_bdev;
1312+
bdev = bio->bi_bdev;
13141313

1315-
/*
1316-
* blk-mq devices will reuse the extra reference on the request queue
1317-
* usage counter we took when the BIO was plugged, but the submission
1318-
* path for BIO-based devices will not do that. So drop this extra
1319-
* reference here.
1320-
*/
1321-
if (bdev_test_flag(bdev, BD_HAS_SUBMIT_BIO)) {
1322-
bdev->bd_disk->fops->submit_bio(bio);
1323-
blk_queue_exit(bdev->bd_disk->queue);
1324-
} else {
1325-
blk_mq_submit_bio(bio);
1326-
}
1314+
/*
1315+
* blk-mq devices will reuse the extra reference on the request
1316+
* queue usage counter we took when the BIO was plugged, but the
1317+
* submission path for BIO-based devices will not do that. So
1318+
* drop this extra reference here.
1319+
*/
1320+
if (bdev_test_flag(bdev, BD_HAS_SUBMIT_BIO)) {
1321+
bdev->bd_disk->fops->submit_bio(bio);
1322+
blk_queue_exit(bdev->bd_disk->queue);
1323+
} else {
1324+
blk_mq_submit_bio(bio);
1325+
}
1326+
} while (0);
13271327

13281328
put_zwplug:
13291329
/* Drop the reference we took in disk_zone_wplug_schedule_bio_work(). */

0 commit comments

Comments
 (0)