From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:38422 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbdK0FIc (ORCPT ); Mon, 27 Nov 2017 00:08:32 -0500 From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Mike Snitzer , dm-devel@redhat.com Cc: Christoph Hellwig , Bart Van Assche , linux-kernel@vger.kernel.org, Hannes Reinecke , Omar Sandoval , Ming Lei Subject: [PATCH V2 3/5] blk-mq: move actual issue into one helper Date: Mon, 27 Nov 2017 13:07:19 +0800 Message-Id: <20171127050721.5884-4-ming.lei@redhat.com> In-Reply-To: <20171127050721.5884-1-ming.lei@redhat.com> References: <20171127050721.5884-1-ming.lei@redhat.com> Sender: linux-block-owner@vger.kernel.org List-Id: linux-block@vger.kernel.org No functional change, just to clean up code a bit, so that the following change of using direct issue for blk_mq_request_bypass_insert() which is needed by DM can be easier to do. Signed-off-by: Ming Lei --- block/blk-mq.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 11097477eeab..fe82d7a47b35 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1593,15 +1593,38 @@ static blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, struct request *rq) return blk_tag_to_qc_t(rq->internal_tag, hctx->queue_num, true); } -static void __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, - struct request *rq, - blk_qc_t *cookie, bool may_sleep) +/* return true if insert is needed */ +static bool __blk_mq_issue_req(struct blk_mq_hw_ctx *hctx, + struct request *rq, + blk_qc_t *new_cookie, + blk_status_t *ret) { struct request_queue *q = rq->q; struct blk_mq_queue_data bd = { .rq = rq, .last = true, }; + + if (!blk_mq_get_driver_tag(rq, NULL, false)) + return true; + + if (!blk_mq_get_dispatch_budget(hctx)) { + blk_mq_put_driver_tag(rq); + return true; + } + + *new_cookie = request_to_qc_t(hctx, rq); + + *ret = q->mq_ops->queue_rq(hctx, &bd); + + return false; +} + +static void __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, + struct request *rq, + blk_qc_t *cookie, bool may_sleep) +{ + struct request_queue *q = rq->q; blk_qc_t new_cookie; blk_status_t ret; bool run_queue = true; @@ -1615,22 +1638,14 @@ static void __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, if (q->elevator) goto insert; - if (!blk_mq_get_driver_tag(rq, NULL, false)) + if (__blk_mq_issue_req(hctx, rq, &new_cookie, &ret)) goto insert; - if (!blk_mq_get_dispatch_budget(hctx)) { - blk_mq_put_driver_tag(rq); - goto insert; - } - - new_cookie = request_to_qc_t(hctx, rq); - /* * For OK queue, we are done. For error, kill it. Any other * error (busy), just add it to our list as we previously * would have done */ - ret = q->mq_ops->queue_rq(hctx, &bd); switch (ret) { case BLK_STS_OK: *cookie = new_cookie; -- 2.9.5