diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2016-08-31 15:18:11 -0700 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2016-09-14 13:56:38 -0400 |
commit | 2397a15aff35b5b4eed732ce81fda5a9d15053f9 (patch) | |
tree | 7e0bf6c491f3f4a416cb805184491ed0e5ca4a40 /drivers/md | |
parent | 3b785fbcf81c3533772c52b717f77293099498d3 (diff) | |
download | linux-2397a15aff35b5b4eed732ce81fda5a9d15053f9.tar.gz linux-2397a15aff35b5b4eed732ce81fda5a9d15053f9.tar.bz2 linux-2397a15aff35b5b4eed732ce81fda5a9d15053f9.zip |
dm rq: factor out dm_mq_stop_queue()
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-rq.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c index 1ca7463e8bb2..2f605f62e47d 100644 --- a/drivers/md/dm-rq.c +++ b/drivers/md/dm-rq.c @@ -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, |