]> git.hungrycats.org Git - linux/commitdiff
block: Fix race triggered by blk_set_queue_dying()
authorBart Van Assche <bart.vanassche@sandisk.com>
Tue, 16 Aug 2016 23:48:36 +0000 (16:48 -0700)
committerSasha Levin <alexander.levin@verizon.com>
Wed, 31 Aug 2016 23:21:09 +0000 (19:21 -0400)
[ Upstream commit 1b856086813be9371929b6cc62045f9fd470f5a0 ]

blk_set_queue_dying() can be called while another thread is
submitting I/O or changing queue flags, e.g. through dm_stop_queue().
Hence protect the QUEUE_FLAG_DYING flag change with locking.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
block/blk-core.c

index 7f29dc0237d1ce9113b604776bb2503e92b9a3fb..bbbf36e6066b452c53619d85a828c1b802cfac3f 100644 (file)
@@ -475,7 +475,9 @@ EXPORT_SYMBOL_GPL(blk_queue_bypass_end);
 
 void blk_set_queue_dying(struct request_queue *q)
 {
-       queue_flag_set_unlocked(QUEUE_FLAG_DYING, q);
+       spin_lock_irq(q->queue_lock);
+       queue_flag_set(QUEUE_FLAG_DYING, q);
+       spin_unlock_irq(q->queue_lock);
 
        if (q->mq_ops)
                blk_mq_wake_waiters(q);