[PATCH v21 04/12] blk-zoned: Split an if-statement

Bart Van Assche
2025-07-17T20:58:50Z

Split an if-statement and also the comment above that if-statement. This
patch prepares for moving code from disk_zone_wplug_add_bio() into its
caller. No functionality has been changed.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
block/blk-zoned.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 7e0f90626459..d7bdc92bedae 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -1036,13 +1036,14 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
bio_set_flag(bio, BIO_ZONE_WRITE_PLUGGING);

/*
- * If the zone is already plugged, add the BIO to the plug BIO list.
- * Do the same for REQ_NOWAIT BIOs to ensure that we will not see a
+ * Add REQ_NOWAIT BIOs to the plug list to ensure that we will not see a
* BLK_STS_AGAIN failure if we let the BIO execute.
- * Otherwise, plug and let the BIO execute.
*/
- if ((zwplug->flags & BLK_ZONE_WPLUG_PLUGGED) ||
- (bio->bi_opf & REQ_NOWAIT))
+ if (bio->bi_opf & REQ_NOWAIT)
+ goto plug;
+
+ /* If the zone is already plugged, add the BIO to the plug BIO list. */
+ if (zwplug->flags & BLK_ZONE_WPLUG_PLUGGED)
goto plug;

if (!blk_zone_wplug_prepare_bio(zwplug, bio)) {
@@ -1051,6 +1052,7 @@ static bool blk_zone_wplug_handle_write(struct bio *bio, unsigned int nr_segs)
return true;
}

+ /* Otherwise, plug and submit the BIO. */
zwplug->flags |= BLK_ZONE_WPLUG_PLUGGED;

spin_unlock_irqrestore(&zwplug->lock, flags);