aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-core.c21
-rw-r--r--block/blk-mq-tag.c14
-rw-r--r--block/blk-mq-tag.h1
-rw-r--r--block/blk-mq.c10
-rw-r--r--block/blk-mq.h1
5 files changed, 42 insertions, 5 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 /*
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 32e8dbb9ad1c..60c9d4a93fe4 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -68,9 +68,9 @@ bool __blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
68} 68}
69 69
70/* 70/*
71 * Wakeup all potentially sleeping on normal (non-reserved) tags 71 * Wakeup all potentially sleeping on tags
72 */ 72 */
73static void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags) 73void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool include_reserve)
74{ 74{
75 struct blk_mq_bitmap_tags *bt; 75 struct blk_mq_bitmap_tags *bt;
76 int i, wake_index; 76 int i, wake_index;
@@ -85,6 +85,12 @@ static void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags)
85 85
86 wake_index = bt_index_inc(wake_index); 86 wake_index = bt_index_inc(wake_index);
87 } 87 }
88
89 if (include_reserve) {
90 bt = &tags->breserved_tags;
91 if (waitqueue_active(&bt->bs[0].wait))
92 wake_up(&bt->bs[0].wait);
93 }
88} 94}
89 95
90/* 96/*
@@ -100,7 +106,7 @@ void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)
100 106
101 atomic_dec(&tags->active_queues); 107 atomic_dec(&tags->active_queues);
102 108
103 blk_mq_tag_wakeup_all(tags); 109 blk_mq_tag_wakeup_all(tags, false);
104} 110}
105 111
106/* 112/*
@@ -584,7 +590,7 @@ int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int tdepth)
584 * static and should never need resizing. 590 * static and should never need resizing.
585 */ 591 */
586 bt_update_count(&tags->bitmap_tags, tdepth); 592 bt_update_count(&tags->bitmap_tags, tdepth);
587 blk_mq_tag_wakeup_all(tags); 593 blk_mq_tag_wakeup_all(tags, false);
588 return 0; 594 return 0;
589} 595}
590 596
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index 6206ed17ef76..a6fa0fc9d41a 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -54,6 +54,7 @@ extern bool blk_mq_has_free_tags(struct blk_mq_tags *tags);
54extern ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page); 54extern ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page);
55extern void blk_mq_tag_init_last_tag(struct blk_mq_tags *tags, unsigned int *last_tag); 55extern void blk_mq_tag_init_last_tag(struct blk_mq_tags *tags, unsigned int *last_tag);
56extern int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int depth); 56extern int blk_mq_tag_update_depth(struct blk_mq_tags *tags, unsigned int depth);
57extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool);
57 58
58enum { 59enum {
59 BLK_MQ_TAG_CACHE_MIN = 1, 60 BLK_MQ_TAG_CACHE_MIN = 1,
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 97ebb84b5633..1a41d7aefbd5 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -152,6 +152,16 @@ void blk_mq_unfreeze_queue(struct request_queue *q)
152} 152}
153EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue); 153EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue);
154 154
155void blk_mq_wake_waiters(struct request_queue *q)
156{
157 struct blk_mq_hw_ctx *hctx;
158 unsigned int i;
159
160 queue_for_each_hw_ctx(q, hctx, i)
161 if (blk_mq_hw_queue_mapped(hctx))
162 blk_mq_tag_wakeup_all(hctx->tags, true);
163}
164
155bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx) 165bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx)
156{ 166{
157 return blk_mq_has_free_tags(hctx->tags); 167 return blk_mq_has_free_tags(hctx->tags);
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 206230e64f79..4f4f943c22c3 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -32,6 +32,7 @@ void blk_mq_free_queue(struct request_queue *q);
32void blk_mq_clone_flush_request(struct request *flush_rq, 32void blk_mq_clone_flush_request(struct request *flush_rq,
33 struct request *orig_rq); 33 struct request *orig_rq);
34int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr); 34int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr);
35void blk_mq_wake_waiters(struct request_queue *q);
35 36
36/* 37/*
37 * CPU hotplug helpers 38 * CPU hotplug helpers