Skip to content

Commit 1b0081e

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. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 8b17420 commit 1b0081e

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

block/blk-zoned.c

Lines changed: 14 additions & 20 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,16 @@ 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+
if (!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED))
1029+
goto plug;
1030+
goto add_to_bio_list;
1031+
}
10441032

10451033
/* If the zone is already plugged, add the BIO to the plug BIO list. */
10461034
if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)
1047-
goto plug;
1035+
goto add_to_bio_list;
10481036

10491037
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
10501038
spin_unlock_irqrestore(&zwplug->lock, flags);
@@ -1060,7 +1048,13 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
10601048
return false;
10611049

10621050
plug:
1051+
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;
1052+
schedule_bio_work = true;
1053+
1054+
add_to_bio_list:
10631055
disk_zone_wplug_add_bio(disk, zwplug, bio, nr_segs);
1056+
if (schedule_bio_work)
1057+
disk_zone_wplug_schedule_bio_work(disk, zwplug);
10641058

10651059
spin_unlock_irqrestore(&zwplug->lock, flags);
10661060

0 commit comments

Comments
 (0)