summaryrefslogtreecommitdiffstats
path: root/block/blk-zoned.c
diff options
context:
space:
mode:
authorDamien Le Moal <dlemoal@kernel.org>2024-05-01 13:09:02 +0200
committerJens Axboe <axboe@kernel.dk>2024-05-01 16:08:43 +0200
commit096bc7ea335bc5dfbaed1d005ff27f008ec9d710 (patch)
tree8393c99e90fdac1e4c5102704ce956b46c0235c9 /block/blk-zoned.c
parentblock: Fix flush request sector restore (diff)
downloadlinux-096bc7ea335bc5dfbaed1d005ff27f008ec9d710.tar.xz
linux-096bc7ea335bc5dfbaed1d005ff27f008ec9d710.zip
block: Fix handling of non-empty flush write requests to zones
Zone write plugging ignores empty (no data) flush operations but handles flush BIOs that have data to ensure that the flush machinery generated write is processed in order. However, the call to blk_zone_write_plug_attempt_merge() which sets a request RQF_ZONE_WRITE_PLUGGING flag is called after blk_insert_flush(), thus missing indicating that a non empty flush request completion needs handling by zone write plugging. Fix this by moving the call to blk_zone_write_plug_attempt_merge() before blk_insert_flush(). And while at it, rename that function as blk_zone_write_plug_init_request() to be clear that it is not just about merging plugged BIOs in the request. While at it, also add a WARN_ONCE() check that the zone write plug for the request is not NULL. Fixes: dd291d77cc90 ("block: Introduce zone write plugging") Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Link: https://lore.kernel.org/r/20240501110907.96950-10-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-zoned.c')
-rw-r--r--block/blk-zoned.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 1e5f362f0409..cd0049f5bf2f 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -874,8 +874,9 @@ void blk_zone_write_plug_bio_merged(struct bio *bio)
/*
* If the BIO was already plugged, then we were called through
- * blk_zone_write_plug_attempt_merge() -> blk_attempt_bio_merge().
- * For this case, blk_zone_write_plug_attempt_merge() will handle the
+ * blk_zone_write_plug_init_request() -> blk_attempt_bio_merge().
+ * For this case, we already hold a reference on the zone write plug for
+ * the BIO and blk_zone_write_plug_init_request() will handle the
* zone write pointer offset update.
*/
if (bio_flagged(bio, BIO_ZONE_WRITE_PLUGGING))
@@ -899,7 +900,7 @@ void blk_zone_write_plug_bio_merged(struct bio *bio)
* already went through zone write plugging (either a new BIO or one that was
* unplugged).
*/
-void blk_zone_write_plug_attempt_merge(struct request *req)
+void blk_zone_write_plug_init_request(struct request *req)
{
sector_t req_back_sector = blk_rq_pos(req) + blk_rq_sectors(req);
struct request_queue *q = req->q;
@@ -910,6 +911,9 @@ void blk_zone_write_plug_attempt_merge(struct request *req)
unsigned long flags;
struct bio *bio;
+ if (WARN_ON_ONCE(!zwplug))
+ return;
+
/*
* Indicate that completion of this request needs to be handled with
* blk_zone_write_plug_complete_request(), which will drop the reference
@@ -1269,7 +1273,7 @@ void blk_zone_write_plug_complete_request(struct request *req)
/*
* Drop the reference we took when the request was initialized in
- * blk_zone_write_plug_attempt_merge().
+ * blk_zone_write_plug_init_request().
*/
disk_put_zone_wplug(zwplug);