blk-mq: Provide freeze queue timeout
authorKeith Busch <keith.busch@intel.com>
Wed, 1 Mar 2017 19:22:11 +0000 (14:22 -0500)
committerJens Axboe <axboe@fb.com>
Thu, 2 Mar 2017 15:56:04 +0000 (08:56 -0700)
A driver may wish to take corrective action if queued requests do not
complete within a set time.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-mq.c
include/linux/blk-mq.h

index 8da2c04bb88f4762a07149e48223a6df66957af3..a5e66a7a3506f95a121320b2e611ea3ad67b304c 100644 (file)
@@ -81,6 +81,15 @@ void blk_mq_freeze_queue_wait(struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait);
 
+int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,
+                                    unsigned long timeout)
+{
+       return wait_event_timeout(q->mq_freeze_wq,
+                                       percpu_ref_is_zero(&q->q_usage_counter),
+                                       timeout);
+}
+EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait_timeout);
+
 /*
  * Guarantee no request is in use, so we can change any data structure of
  * the queue afterward.
index 8dacf680c8516ddf70d4d36647be557f592f67d2..b296a900611790e25639293fd51b0fa7a9beab41 100644 (file)
@@ -246,6 +246,8 @@ void blk_mq_freeze_queue(struct request_queue *q);
 void blk_mq_unfreeze_queue(struct request_queue *q);
 void blk_mq_freeze_queue_start(struct request_queue *q);
 void blk_mq_freeze_queue_wait(struct request_queue *q);
+int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,
+                                    unsigned long timeout);
 int blk_mq_reinit_tagset(struct blk_mq_tag_set *set);
 
 int blk_mq_map_queues(struct blk_mq_tag_set *set);