Skip to contentSkip to conversation

dm: fix request-based dm's use of dm_wait_for_completion

PATCH Applied Mike Snitzer 2 participants 2 messages Dec 11, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: fix request-based dm's use of dm_wait_for_completion

The md->wait waitqueue is used by both bio-based and request-based DM. Commit dbd3bbd291 ("dm rq: leverage blk_mq_queue_busy() to check for outstanding IO") lost sight of the requirement that dm_wait_for_completion() must work with all types of DM devices.

Fix md_in_flight() to call the blk-mq or bio-based method accordingly.

Fixes dbd3bbd291 ("dm rq: leverage blk_mq_queue_busy() to check for outstanding IO")
---
 drivers/md/dm-rq.c |  6 ++----
 drivers/md/dm.c    | 10 +++++++++-
 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/md/dm-rq.c +2 -4
index 5af22e165fb7..202e9be5aea7 100644
@@ -131,10 +131,8 @@ static void rq_end_stats(struct mapped_device *md, struct request *orig)
 static void rq_completed(struct mapped_device *md)
 {
 	/* nudge anyone waiting on suspend queue */
-	if (unlikely(waitqueue_active(&md->wait))) {
-		if (!blk_mq_queue_busy(md->queue))
-			wake_up(&md->wait);
-	}
+	if (unlikely(waitqueue_active(&md->wait)))
+		wake_up(&md->wait);
 
 	/*
 	 * dm_put() must be at the end of this function. See the comment above
drivers/md/dm.c +9 -1
index d80c34a34a2d..3a50675cfc1a 100644
@@ -646,7 +646,7 @@ static void free_tio(struct dm_target_io *tio)
 	bio_put(&tio->clone);
 }
 
-static bool md_in_flight(struct mapped_device *md)
+static bool md_in_flight_bios(struct mapped_device *md)
 {
 	int cpu;
 	struct hd_struct *part = &dm_disk(md)->part0;
@@ -660,6 +660,14 @@ static bool md_in_flight(struct mapped_device *md)
 	return sum != 0;
 }
 
+static bool md_in_flight(struct mapped_device *md)
+{
+	if (queue_is_mq(md->queue))
+		return blk_mq_queue_busy(md->queue);
+	else
+		return md_in_flight_bios(md);
+}
+
 static void start_io_acct(struct dm_io *io)
 {
 	struct mapped_device *md = io->md;
Signature · 1 line
2.15.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Mike Snitzer

The md->wait waitqueue is used by both bio-based and request-based DM. Commit dbd3bbd291 ("dm rq: leverage blk_mq_queue_busy() to check for outstanding IO") lost sight of the requirement that dm_wait_for_completion() must work with all types of DM devices.

Fix md_in_flight() to call the blk-mq or bio-based method accordingly.

Applied, thanks.

Signature · 1 line
Jens Axboe