From a613fd3185fbe316602e31513f8f1417987e35e1 Mon Sep 17 00:00:00 2001 From: Jeffle Xu Date: Thu, 12 Nov 2020 17:09:28 +0800 Subject: [PATCH 2284/2944] alinux: block: add back ->poll_fn in request queue ->poll_fn is introduced in commit ea435e1b9392 ("block: add a poll_fn callback to struct request_queue") for supporting non-mq queues such as nvme multipath, but removed in commit 529262d56dbe ("block: remove ->poll_fn"). To add support of IO polling for dm device, support for non-mq device should be added and thus we need ->poll_fn back. Signed-off-by: Jeffle Xu Reviewed-by: Joseph Qi --- block/blk-mq.c | 18 +++++++++++++----- include/linux/blkdev.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index b480310..a796770 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -37,6 +37,7 @@ #include "blk-mq-sched.h" #include "blk-rq-qos.h" +static int blk_mq_poll(struct request_queue *q, blk_qc_t cookie, bool spin); static void blk_mq_poll_stats_start(struct request_queue *q); static void blk_mq_poll_stats_fn(struct blk_stat_callback *cb); @@ -2845,8 +2846,10 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->tag_set = set; q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; - if (q->mq_ops->poll) + if (q->mq_ops->poll) { + q->poll_fn = blk_mq_poll; queue_flag_set_unlocked(QUEUE_FLAG_POLL, q); + } if (!(set->flags & BLK_MQ_F_SG_MERGE)) queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); @@ -3447,9 +3450,6 @@ static bool blk_mq_poll_hybrid(struct request_queue *q, */ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin) { - struct blk_mq_hw_ctx *hctx; - long state; - if (!blk_qc_t_valid(cookie) || !test_bit(QUEUE_FLAG_POLL, &q->queue_flags)) return 0; @@ -3457,6 +3457,15 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin) if (current->plug) blk_flush_plug_list(current->plug, false); + return q->poll_fn(q, cookie, spin); +} +EXPORT_SYMBOL_GPL(blk_poll); + +static int blk_mq_poll(struct request_queue *q, blk_qc_t cookie, bool spin) +{ + struct blk_mq_hw_ctx *hctx; + long state; + hctx = q->queue_hw_ctx[blk_qc_t_to_queue_num(cookie)]; /* @@ -3497,7 +3506,6 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin) __set_current_state(TASK_RUNNING); return 0; } -EXPORT_SYMBOL_GPL(blk_poll); static int __init blk_mq_init(void) { diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ccb2551..f28b0c6 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -321,6 +321,7 @@ static inline unsigned short req_get_ioprio(struct request *req) typedef void (request_fn_proc) (struct request_queue *q); typedef blk_qc_t (make_request_fn) (struct request_queue *q, struct bio *bio); +typedef int (poll_q_fn) (struct request_queue *, blk_qc_t, bool spin); typedef int (prep_rq_fn) (struct request_queue *, struct request *); typedef void (unprep_rq_fn) (struct request_queue *, struct request *); @@ -469,6 +470,7 @@ struct request_queue { request_fn_proc *request_fn; make_request_fn *make_request_fn; + poll_q_fn *poll_fn; prep_rq_fn *prep_rq_fn; unprep_rq_fn *unprep_rq_fn; softirq_done_fn *softirq_done_fn; -- 1.8.3.1