*/
 static void rq_completed(struct mapped_device *md, int rw, bool run_queue)
 {
-       atomic_dec(&md->pending[rw]);
-
        /* nudge anyone waiting on suspend queue */
-       if (!md_in_flight(md))
-               wake_up(&md->wait);
+       if (unlikely(waitqueue_active(&md->wait))) {
+               if (!blk_mq_queue_busy(md->queue))
+                       wake_up(&md->wait);
+       }
 
        /*
         * dm_put() must be at the end of this function. See the comment above
 static void dm_start_request(struct mapped_device *md, struct request *orig)
 {
        blk_mq_start_request(orig);
-       atomic_inc(&md->pending[rq_data_dir(orig)]);
 
        if (unlikely(dm_stats_used(&md->stats))) {
                struct dm_rq_target_io *tio = tio_from_request(orig);