Skip to content

Commit 7651a21

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(): - bio->bi_opf &= ~REQ_NOWAIT - wplug->flags |= BLK_ZONE_WPLUG_PLUGGED - 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 95139b4 commit 7651a21

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
@@ -778,8 +778,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
778778
struct blk_zone_wplug *zwplug,
779779
struct bio *bio, unsigned int nr_segs)
780780
{
781-
bool schedule_bio_work = false;
782-
783781
/*
784782
* Grab an extra reference on the BIO request queue usage counter.
785783
* This reference will be reused to submit a request for the BIO for
@@ -795,16 +793,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
795793
*/
796794
bio_clear_polled(bio);
797795

798-
/*
799-
* REQ_NOWAIT BIOs are always handled using the zone write plug BIO
800-
* work, which can block. So clear the REQ_NOWAIT flag and schedule the
801-
* work if this is the first BIO we are plugging.
802-
*/
803-
if (bio->bi_opf & REQ_NOWAIT) {
804-
schedule_bio_work = !(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED);
805-
bio->bi_opf &= ~REQ_NOWAIT;
806-
}
807-
808796
/*
809797
* Reuse the poll cookie field to store the number of segments when
810798
* split to the hardware limits.
@@ -818,11 +806,6 @@ static inline void disk_zone_wplug_add_bio(struct gendisk *disk,
818806
* at the tail of the list to preserve the sequential write order.
819807
*/
820808
bio_list_add(&zwplug->bio_list, bio);
821-
822-
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;
823-
824-
if (schedule_bio_work)
825-
disk_zone_wplug_schedule_bio_work(disk, zwplug);
826809
}
827810

828811
/*
@@ -987,6 +970,7 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
987970
{
988971
struct gendisk *disk = bio->bi_bdev->bd_disk;
989972
sector_t sector = bio->bi_iter.bi_sector;
973+
bool schedule_bio_work = false;
990974
struct blk_zone_wplug *zwplug;
991975
gfp_t gfp_mask = GFP_NOIO;
992976
unsigned long flags;
@@ -1031,13 +1015,17 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
10311015

10321016
/* If the zone is already plugged, add the BIO to the plug BIO list. */
10331017
if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)
1034-
goto plug;
1018+
goto queue_bio;
10351019
/*
10361020
* Do the same for REQ_NOWAIT BIOs to ensure that we will not see a
10371021
* BLK_STS_AGAIN failure if we let the BIO execute.
10381022
*/
1039-
if (bio->bi_opf & REQ_NOWAIT)
1040-
goto plug;
1023+
if (bio->bi_opf & REQ_NOWAIT) {
1024+
bio->bi_opf &= ~REQ_NOWAIT;
1025+
if (!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED))
1026+
goto plug;
1027+
goto queue_bio;
1028+
}
10411029

10421030
if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
10431031
spin_unlock_irqrestore(&zwplug->lock, flags);
@@ -1053,7 +1041,13 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
10531041
return false;
10541042

10551043
plug:
1044+
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;
1045+
schedule_bio_work = true;
1046+
1047+
queue_bio:
10561048
disk_zone_wplug_add_bio(disk, zwplug, bio, nr_segs);
1049+
if (schedule_bio_work)
1050+
disk_zone_wplug_schedule_bio_work(disk, zwplug);
10571051

10581052
spin_unlock_irqrestore(&zwplug->lock, flags);
10591053

0 commit comments

Comments
 (0)