dm: fix request-based dm's use of dm_wait_for_completion
authorMike Snitzer <snitzer@redhat.com>
Tue, 11 Dec 2018 14:10:26 +0000 (09:10 -0500)
committerJens Axboe <axboe@kernel.dk>
Tue, 11 Dec 2018 14:40:02 +0000 (07:40 -0700)
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")
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/dm-rq.c
drivers/md/dm.c

index d2397d8fcbd1c5fa359a50190753e3324fb12bde..4e06be4f0a6204f7282d48f4351f86a1b782fb2b 100644 (file)
@@ -131,10 +131,8 @@ static void rq_end_stats(struct mapped_device *md, struct request *orig)
 static void rq_completed(struct mapped_device *md, int rw, bool run_queue)
 {
        /* 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
index 79ad4b3d215c86a7ef380e968a2b32d9f95b99f0..c414d40d645dcbb206d37802ed57c5ab63ae03f2 100644 (file)
@@ -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;