summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2016-02-20 06:38:47 +0100
committerMike Snitzer <snitzer@redhat.com>2016-02-23 04:33:09 +0100
commit818c5f3bef750eb5998b468f84391e4d656b97ed (patch)
tree870376e3cae6542564325980b7c0d11b1f2b0345 /drivers/md/dm.c
parentdm: allocate blk_mq_tag_set rather than embed in mapped_device (diff)
downloadlinux-818c5f3bef750eb5998b468f84391e4d656b97ed.tar.xz
linux-818c5f3bef750eb5998b468f84391e4d656b97ed.zip
dm: fix a couple locking issues with use of block interfaces
old_stop_queue() was checking blk_queue_stopped() without holding the q->queue_lock. dm_requeue_original_request() needed to check blk_queue_stopped(), with q->queue_lock held, before calling blk_mq_kick_requeue_list(). And a side-effect of that change is start_queue() must also call blk_mq_kick_requeue_list(). Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index e9035959f904..8a62e43fbff5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1215,6 +1215,18 @@ static void old_requeue_request(struct request *rq)
spin_unlock_irqrestore(q->queue_lock, flags);
}
+static void dm_mq_requeue_request(struct request *rq)
+{
+ struct request_queue *q = rq->q;
+ unsigned long flags;
+
+ blk_mq_requeue_request(rq);
+ spin_lock_irqsave(q->queue_lock, flags);
+ if (!blk_queue_stopped(q))
+ blk_mq_kick_requeue_list(q);
+ spin_unlock_irqrestore(q->queue_lock, flags);
+}
+
static void dm_requeue_original_request(struct mapped_device *md,
struct request *rq)
{
@@ -1225,10 +1237,8 @@ static void dm_requeue_original_request(struct mapped_device *md,
rq_end_stats(md, rq);
if (!rq->q->mq_ops)
old_requeue_request(rq);
- else {
- blk_mq_requeue_request(rq);
- blk_mq_kick_requeue_list(rq->q);
- }
+ else
+ dm_mq_requeue_request(rq);
rq_completed(md, rw, false);
}
@@ -1237,10 +1247,12 @@ static void old_stop_queue(struct request_queue *q)
{
unsigned long flags;
- if (blk_queue_stopped(q))
+ spin_lock_irqsave(q->queue_lock, flags);
+ if (blk_queue_stopped(q)) {
+ spin_unlock_irqrestore(q->queue_lock, flags);
return;
+ }
- spin_lock_irqsave(q->queue_lock, flags);
blk_stop_queue(q);
spin_unlock_irqrestore(q->queue_lock, flags);
}
@@ -1267,8 +1279,10 @@ static void start_queue(struct request_queue *q)
{
if (!q->mq_ops)
old_start_queue(q);
- else
+ else {
blk_mq_start_stopped_hw_queues(q, true);
+ blk_mq_kick_requeue_list(q);
+ }
}
static void dm_done(struct request *clone, int error, bool mapped)