summaryrefslogtreecommitdiffstats
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-11-02 14:29:54 -0400
committerJens Axboe <axboe@kernel.dk>2017-11-03 12:31:48 -0400
commitea435e1b9392a33deceaea2a16ebaa3397bead93 (patch)
tree73c80a2bfed2bc37cedc4d38d9534e231c61dbd8 /block/blk-mq.c
parent8ddcd653257c18a669fcb75ee42c37054908e0d6 (diff)
block: add a poll_fn callback to struct request_queue
That we we can also poll non blk-mq queues. Mostly needed for the NVMe multipath code, but could also be useful elsewhere. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e4d2490f4e7e..95ea5889b825 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -37,6 +37,7 @@
37#include "blk-wbt.h" 37#include "blk-wbt.h"
38#include "blk-mq-sched.h" 38#include "blk-mq-sched.h"
39 39
40static bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie);
40static void blk_mq_poll_stats_start(struct request_queue *q); 41static void blk_mq_poll_stats_start(struct request_queue *q);
41static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb); 42static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb);
42 43
@@ -2499,6 +2500,8 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
2499 spin_lock_init(&q->requeue_lock); 2500 spin_lock_init(&q->requeue_lock);
2500 2501
2501 blk_queue_make_request(q, blk_mq_make_request); 2502 blk_queue_make_request(q, blk_mq_make_request);
2503 if (q->mq_ops->poll)
2504 q->poll_fn = blk_mq_poll;
2502 2505
2503 /* 2506 /*
2504 * Do this after blk_queue_make_request() overrides it... 2507 * Do this after blk_queue_make_request() overrides it...
@@ -2961,20 +2964,14 @@ static bool __blk_mq_poll(struct blk_mq_hw_ctx *hctx, struct request *rq)
2961 return false; 2964 return false;
2962} 2965}
2963 2966
2964bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie) 2967static bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie)
2965{ 2968{
2966 struct blk_mq_hw_ctx *hctx; 2969 struct blk_mq_hw_ctx *hctx;
2967 struct blk_plug *plug;
2968 struct request *rq; 2970 struct request *rq;
2969 2971
2970 if (!q->mq_ops || !q->mq_ops->poll || !blk_qc_t_valid(cookie) || 2972 if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
2971 !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
2972 return false; 2973 return false;
2973 2974
2974 plug = current->plug;
2975 if (plug)
2976 blk_flush_plug_list(plug, false);
2977
2978 hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)]; 2975 hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)];
2979 if (!blk_qc_t_is_internal(cookie)) 2976 if (!blk_qc_t_is_internal(cookie))
2980 rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie)); 2977 rq = blk_mq_tag_to_rq(hctx->tags, blk_qc_t_to_tag(cookie));
@@ -2992,7 +2989,6 @@ bool blk_mq_poll(struct request_queue *q, blk_qc_t cookie)
2992 2989
2993 return __blk_mq_poll(hctx, rq); 2990 return __blk_mq_poll(hctx, rq);
2994} 2991}
2995EXPORT_SYMBOL_GPL(blk_mq_poll);
2996 2992
2997static int __init blk_mq_init(void) 2993static int __init blk_mq_init(void)
2998{ 2994{