Skip to content

Commit 93e52aa

Browse files
bvanasschekawasaki
authored andcommitted
blk-zoned: Move code from disk_zone_wplug_add_bio() into its caller
Move the following code into the only caller of disk_zone_wplug_add_bio(): - The code for clearing the REQ_NOWAIT flag. - The code that sets the BLK_ZONE_WPLUG_PLUGGED flag. - The disk_zone_wplug_schedule_bio_work() call. No functionality has been changed. This patch prepares for zoned write pipelining by removing the code from disk_zone_wplug_add_bio() that does not apply to all zoned write pipelining bio processing cases. Cc: Damien Le Moal <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
1 parent 8083564 commit 93e52aa

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

block/blk-zoned.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
782782
struct blk_zone_wplug *zwplug,
783783
struct bio *bio, unsigned int nr_segs)
784784
{
785-
bool schedule_bio_work = false;
786-
787785
/*
788786
* Grab an extra reference on the BIO request queue usage counter.
789787
* This reference will be reused to submit a request for the BIO for
@@ -799,16 +797,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
799797
*/
800798
bio_clear_polled(bio);
801799

802-
/*
803-
* REQ_NOWAIT BIOs are always handled using the zone write plug BIO
804-
* work, which can block. So clear the REQ_NOWAIT flag and schedule the
805-
* work if this is the first BIO we are plugging.
806-
*/
807-
if (bio->bi_opf & REQ_NOWAIT) {
808-
schedule_bio_work = !(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED);
809-
bio->bi_opf &= ~REQ_NOWAIT;
810-
}
811-
812800
/*
813801
* Reuse the poll cookie field to store the number of segments when
814802
* split to the hardware limits.
@@ -824,11 +812,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
824812
bio_list_add(&zwplug->bio_list, bio);
825813
trace_disk_zone_wplug_add_bio(zwplug->disk->queue, zwplug->zone_no,
826814
bio->bi_iter.bi_sector, bio_sectors(bio));
827-
828-
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;
829-
830-
if (schedule_bio_work)
831-
disk_zone_wplug_schedule_bio_work(disk, zwplug);
832815
}
833816

834817
/*
@@ -993,6 +976,7 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
993976
{
994977
struct gendisk *disk = bio->bi_bdev->bd_disk;
995978
sector_t sector = bio->bi_iter.bi_sector;
979+
bool schedule_bio_work = false;
996980
struct blk_zone_wplug *zwplug;
997981
gfp_t gfp_mask = GFP_NOIO;
998982
unsigned long flags;
@@ -1039,12 +1023,14 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
10391023
* Add REQ_NOWAIT BIOs to the plug list to ensure that we will not see a
10401024
* BLK_STS_AGAIN failure if we let the BIO execute.
10411025
*/
1042-
if (bio->bi_opf & REQ_NOWAIT)
1043-
goto plug;
1026+
if (bio->bi_opf & REQ_NOWAIT) {
1027+
bio->bi_opf &= ~REQ_NOWAIT;
1028+
goto add_to_bio_list;
1029+
}
10441030

10451031
/* If the zone is already plugged, add the BIO to the plug BIO list. */
10461032
if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)
1047-
goto plug;
1033+
goto add_to_bio_list;
10481034

10491035
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
10501036
spin_unlock_irqrestore(&zwplug->lock, flags);
@@ -1059,8 +1045,13 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
10591045

10601046
return false;
10611047

1062-
plug:
1048+
add_to_bio_list:
1049+
schedule_bio_work = !(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED);
1050+
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;
1051+
10631052
disk_zone_wplug_add_bio(disk, zwplug, bio, nr_segs);
1053+
if (schedule_bio_work)
1054+
disk_zone_wplug_schedule_bio_work(disk, zwplug);
10641055

10651056
spin_unlock_irqrestore(&zwplug->lock, flags);
10661057

0 commit comments

Comments
 (0)