aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-12-22 16:04:42 -0500
committerJens Axboe <axboe@fb.com>2014-12-31 11:39:16 -0500
commitaed3ea94bdd2ac0a21ed0103d34097e202ee77f6 (patch)
treee432ae8b2224a4172e4c91350b0135b14c587442 /block/blk-core.c
parent2b25d981790b830f0e045881386866b970bf9066 (diff)
block: wake up waiters when a queue is marked dying
If it's dying, we can't expect new request to complete and come in an wake up other tasks waiting for requests. So after we have marked it as dying, wake up everybody currently waiting for a request. Once they wake, they will retry their allocation and fail appropriately due to the state of the queue. Tested-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 30f6153a40c2..3ad405571dcc 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -473,6 +473,25 @@ void blk_queue_bypass_end(struct request_queue *q)
473} 473}
474EXPORT_SYMBOL_GPL(blk_queue_bypass_end); 474EXPORT_SYMBOL_GPL(blk_queue_bypass_end);
475 475
476void blk_set_queue_dying(struct request_queue *q)
477{
478 queue_flag_set_unlocked(QUEUE_FLAG_DYING, q);
479
480 if (q->mq_ops)
481 blk_mq_wake_waiters(q);
482 else {
483 struct request_list *rl;
484
485 blk_queue_for_each_rl(rl, q) {
486 if (rl->rq_pool) {
487 wake_up(&rl->wait[BLK_RW_SYNC]);
488 wake_up(&rl->wait[BLK_RW_ASYNC]);
489 }
490 }
491 }
492}
493EXPORT_SYMBOL_GPL(blk_set_queue_dying);
494
476/** 495/**
477 * blk_cleanup_queue - shutdown a request queue 496 * blk_cleanup_queue - shutdown a request queue
478 * @q: request queue to shutdown 497 * @q: request queue to shutdown
@@ -486,7 +505,7 @@ void blk_cleanup_queue(struct request_queue *q)
486 505
487 /* mark @q DYING, no new request or merges will be allowed afterwards */ 506 /* mark @q DYING, no new request or merges will be allowed afterwards */
488 mutex_lock(&q->sysfs_lock); 507 mutex_lock(&q->sysfs_lock);
489 queue_flag_set_unlocked(QUEUE_FLAG_DYING, q); 508 blk_set_queue_dying(q);
490 spin_lock_irq(lock); 509 spin_lock_irq(lock);
491 510
492 /* 511 /*