summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/blk-mq.c6
-rw-r--r--block/blk-zoned.c12
-rw-r--r--block/blk.h4
3 files changed, 13 insertions, 9 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 434d45219e23..0fae9bd0ecd4 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3001,12 +3001,12 @@ new_request:
return;
}
+ if (bio_zone_write_plugging(bio))
+ blk_zone_write_plug_init_request(rq);
+
if (op_is_flush(bio->bi_opf) && blk_insert_flush(rq))
return;
- if (bio_zone_write_plugging(bio))
- blk_zone_write_plug_attempt_merge(rq);
-
if (plug) {
blk_add_rq_to_plug(plug, rq);
return;
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);
diff --git a/block/blk.h b/block/blk.h
index 1140c4a0be03..8a62b861453c 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -427,7 +427,7 @@ static inline bool bio_is_zone_append(struct bio *bio)
bio_flagged(bio, BIO_EMULATES_ZONE_APPEND);
}
void blk_zone_write_plug_bio_merged(struct bio *bio);
-void blk_zone_write_plug_attempt_merge(struct request *rq);
+void blk_zone_write_plug_init_request(struct request *rq);
static inline void blk_zone_update_request_bio(struct request *rq,
struct bio *bio)
{
@@ -481,7 +481,7 @@ static inline bool bio_is_zone_append(struct bio *bio)
static inline void blk_zone_write_plug_bio_merged(struct bio *bio)
{
}
-static inline void blk_zone_write_plug_attempt_merge(struct request *rq)
+static inline void blk_zone_write_plug_init_request(struct request *rq)
{
}
static inline void blk_zone_update_request_bio(struct request *rq,