Received: by 10.223.148.5 with SMTP id 5csp6835885wrq; Wed, 17 Jan 2018 20:08:03 -0800 (PST) X-Google-Smtp-Source: ACJfBoti1mJaqn+TPTVaOMSyhOGCFRMro118nbqFbT/3DUCSK9iOhltvTKkVvgYO1/mKt5Kknvgm X-Received: by 10.84.130.8 with SMTP id 8mr19256235plc.359.1516248483736; Wed, 17 Jan 2018 20:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516248483; cv=none; d=google.com; s=arc-20160816; b=OmB+qYuKpIkjUuFeI0fdLcRAp2BwkwAPzxI+fKD14DfRalA1VjEkJcQwtF0EJ6xxo5 +/vWaRPtNOlgh9vPSV2UBUNnFe1SzWwUGWuELV3Zr07sS43UBwGYemzPBKa1eCzk6EIz mUlpsweBzyQs9X3jybQX165cAIkyIp9eG9TLdPRSwplNWU5gaYOOqMqSu/vtR0xykoci pTUrTOAVcHvmDFB8r2O9HsT1zecDAnXZ47xJd3pwpxiUYOet+IqYo4oiVfqzQ2Sfy6D2 oXTX0KD7okELOeKkBZzuMgORfU7kd+WaB2Tx0HpbQ8vIpevHS4TNkxcA/h4tT46jZfA6 fFXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BionvWgTwLyGglahp3GNR8YZGgmlorH/rOm6ni8Jdz0=; b=cpW7c0CTRkRYJUg7L+ES/nZnJPA/47pRTwlK5hUzEdJpNdiDpowB53R6VjbQa1jmBq SPIcpicT/NcA92pXFwz4qPP2NKoro5ElDWQqWPkEmuJSDs5LpFRICVAlqQdFoQXVCzDa JB50y8LADcDYCbNXeqAZ0/JH7OyvmCObFpTAWvNNhcOUWnUjtlsmo8ScUQ+kqr+2kraX FNnKPU1V1dV8KvaZ8xREUrLY6NKADdWL7W4CMiq8hJtL3S/aXuaI71KJY9oYF+rvuqN8 X3vA7EDFQSL1dSRkJVnFrbYNblGthzLS1W9WWxrMk7mrP4J7i0cq/p3xfyGHOClCb7tK SeRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si4965312pgt.92.2018.01.17.20.07.49; Wed, 17 Jan 2018 20:08:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753787AbeAREHW (ORCPT + 99 others); Wed, 17 Jan 2018 23:07:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54404 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752659AbeAREHV (ORCPT ); Wed, 17 Jan 2018 23:07:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC74BC057FAF; Thu, 18 Jan 2018 04:07:21 +0000 (UTC) Received: from localhost (ovpn-12-94.pek2.redhat.com [10.72.12.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 964E160CA1; Thu, 18 Jan 2018 04:07:07 +0000 (UTC) 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, Ming Lei Subject: [PATCH] blk-mq: don't dispatch request in blk_mq_request_direct_issue if queue is busy Date: Thu, 18 Jan 2018 12:06:59 +0800 Message-Id: <20180118040659.20202-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Jan 2018 04:07:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we run into blk_mq_request_direct_issue(), when queue is busy, we don't want to dispatch this request into hctx->dispatch_list, and what we need to do is to return the queue busy info to caller, so that caller can deal with it well. Fixes: 396eaf21ee ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback") Reported-by: Laurence Oberman Reviewed-by: Mike Snitzer Signed-off-by: Ming Lei --- block/blk-mq.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 4d4af8d712da..1af7fa70993b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1856,15 +1856,6 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx, return ret; } -static void __blk_mq_fallback_to_insert(struct request *rq, - bool run_queue, bool bypass_insert) -{ - if (!bypass_insert) - blk_mq_sched_insert_request(rq, false, run_queue, false); - else - blk_mq_request_bypass_insert(rq, run_queue); -} - static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, struct request *rq, blk_qc_t *cookie, @@ -1873,9 +1864,16 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, struct request_queue *q = rq->q; bool run_queue = true; - /* RCU or SRCU read lock is needed before checking quiesced flag */ + /* + * RCU or SRCU read lock is needed before checking quiesced flag. + * + * When queue is stopped or quiesced, ignore 'bypass_insert' from + * blk_mq_request_direct_issue(), and return BLK_STS_OK to caller, + * and avoid driver to try to dispatch again. + */ if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q)) { run_queue = false; + bypass_insert = false; goto insert; } @@ -1892,10 +1890,10 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, return __blk_mq_issue_directly(hctx, rq, cookie); insert: - __blk_mq_fallback_to_insert(rq, run_queue, bypass_insert); if (bypass_insert) return BLK_STS_RESOURCE; + blk_mq_sched_insert_request(rq, false, run_queue, false); return BLK_STS_OK; } @@ -1911,7 +1909,7 @@ static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, ret = __blk_mq_try_issue_directly(hctx, rq, cookie, false); if (ret == BLK_STS_RESOURCE) - __blk_mq_fallback_to_insert(rq, true, false); + blk_mq_sched_insert_request(rq, false, true, false); else if (ret != BLK_STS_OK) blk_mq_end_request(rq, ret); -- 2.9.5