dm rq: factor out dm_mq_stop_queue()
authorBart Van Assche <bart.vanassche@sandisk.com>
Wed, 31 Aug 2016 22:18:11 +0000 (15:18 -0700)
committerMike Snitzer <snitzer@redhat.com>
Wed, 14 Sep 2016 17:56:38 +0000 (13:56 -0400)
Also, check that the blk-mq request_queue isn't already stopped.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-rq.c

index 1ca7463e8bb2b26c799f63f5d54a4a33d570704c..2f605f62e47d6e61dc0f8338c8da81c4031e0e43 100644 (file)
@@ -98,18 +98,30 @@ static void dm_old_stop_queue(struct request_queue *q)
        spin_unlock_irqrestore(q->queue_lock, flags);
 }
 
+static void dm_mq_stop_queue(struct request_queue *q)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(q->queue_lock, flags);
+       if (blk_queue_stopped(q)) {
+               spin_unlock_irqrestore(q->queue_lock, flags);
+               return;
+       }
+
+       queue_flag_set(QUEUE_FLAG_STOPPED, q);
+       spin_unlock_irqrestore(q->queue_lock, flags);
+
+       /* Avoid that requeuing could restart the queue. */
+       blk_mq_cancel_requeue_work(q);
+       blk_mq_stop_hw_queues(q);
+}
+
 void dm_stop_queue(struct request_queue *q)
 {
        if (!q->mq_ops)
                dm_old_stop_queue(q);
-       else {
-               spin_lock_irq(q->queue_lock);
-               queue_flag_set(QUEUE_FLAG_STOPPED, q);
-               spin_unlock_irq(q->queue_lock);
-
-               blk_mq_cancel_requeue_work(q);
-               blk_mq_stop_hw_queues(q);
-       }
+       else
+               dm_mq_stop_queue(q);
 }
 
 static struct dm_rq_target_io *alloc_old_rq_tio(struct mapped_device *md,