From patchwork Tue Jul 11 18:21:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9835397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C12D0602A0 for ; Tue, 11 Jul 2017 18:22:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B59402852D for ; Tue, 11 Jul 2017 18:22:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A725E2856B; Tue, 11 Jul 2017 18:22:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562D92852D for ; Tue, 11 Jul 2017 18:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756384AbdGKSWE (ORCPT ); Tue, 11 Jul 2017 14:22:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60936 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756325AbdGKSWE (ORCPT ); Tue, 11 Jul 2017 14:22:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF09761D38; Tue, 11 Jul 2017 18:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF09761D38 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ming.lei@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DF09761D38 Received: from localhost (ovpn-12-90.pek2.redhat.com [10.72.12.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EA055D9C0; Tue, 11 Jul 2017 18:21:50 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig Cc: Bart Van Assche , Sagi Grimberg , Ming Lei Subject: [PATCH 3/6] blk-mq: send the request to dispatch list if direct issue returns busy Date: Wed, 12 Jul 2017 02:21:00 +0800 Message-Id: <20170711182103.11461-4-ming.lei@redhat.com> In-Reply-To: <20170711182103.11461-1-ming.lei@redhat.com> References: <20170711182103.11461-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 11 Jul 2017 18:22:04 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Before mq IO scheduler is in, we always send the request to dispatch list if .queue_rq() return busy. After mq IO scheduler is introduced, we only do this way when scheduler is used in case of direct issue. Actually we can do that when scheduler isn't used too. Signed-off-by: Ming Lei --- block/blk-mq.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 041f7b7fa0d6..6e0fc80aa151 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1463,6 +1463,16 @@ 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_direct_dispatch(struct blk_mq_hw_ctx *hctx, + struct request *rq) +{ + spin_lock(&hctx->lock); + list_add(&rq->queuelist, &hctx->dispatch); + spin_unlock(&hctx->lock); + + blk_mq_run_hw_queue(hctx, false); +} + static void __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, struct request *rq, blk_qc_t *cookie, bool may_sleep) @@ -1499,15 +1509,17 @@ static void __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, switch (ret) { case BLK_STS_OK: *cookie = new_cookie; - return; + break; case BLK_STS_RESOURCE: __blk_mq_requeue_request(rq); - goto insert; + blk_mq_direct_dispatch(hctx, rq); + break; default: *cookie = BLK_QC_T_NONE; blk_mq_end_request(rq, ret); - return; + break; } + return; insert: blk_mq_sched_insert_request(rq, false, run_queue, false, may_sleep);