Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2970429rdb; Mon, 4 Dec 2023 12:37:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5FXiyd2q9Y5kYc2foSgU5VQ9AIrTCC6cnj4GBy797tru7V3DkAKh/0TGUZMqZnI5tMqHk X-Received: by 2002:a05:6a20:e48a:b0:18c:63cb:e86e with SMTP id ni10-20020a056a20e48a00b0018c63cbe86emr4001439pzb.2.1701722240906; Mon, 04 Dec 2023 12:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722240; cv=none; d=google.com; s=arc-20160816; b=txnZKWFwBW2eHL+fx5r0MtyRaGDSXVBHKRnJsyKK7f7mrBo7h1LDIwYcHNIxep8kMR WxRT/I4olEca8TooWzjTcTPNQzeVUeBbHN93AiB4JwBz11MFZFT2jdh/By2hq/+lgOVx +b30DdJ9lqKW52Wz/ouaBTWiB0UYvHAoCOGxzvaBKxI+P/xcanea71DkS6mwuxBInQ6v sskRxRYO+1VznCeWEBNcuJcZ5BqF7GnvVDsjjcWxuSE/GL7JqdZo3QySeq5fIRoafm3c fz3HuwBjx8zYr4fm8tytvwiwKwqKpTddFcfAA4B0U85/jRq3D83gAmjEd08qxEpmF0hA lqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jPUJ4JmPhPrMgjsaPzqOaOAX0F40WKZTAQPfXw9PzK8=; fh=3z6GjWWRL3MpYTDujKxpwkx26hBNkumIifdpyfunM8A=; b=oQG5+FOUGx7EHoIl9ukPYudkNXk0uMOpWldYdDb6DQmjkL0o1XEpk9JVFzzsshqd7g YFZj04C37AKZIW6LphboaLh+0gH2uqBJ5x16T6EJoJUWGq5Z/Vi3OyRZOfVx3BS/Os9b a+syFXzhpnoHiuz5lPPZt2hlgeUqSHa2hJUlKLQ2BCG+aMfVTvw1PlIgxNoxZm91LzHB dWd07soJWyJrrR5NmLapVtGZ6RbjZ+v3vqv/vgZXVXKXUlnxN5YUWgr+98pyvJwbJRp1 Ogu++hlE+0WhhXcHxMqZ5jwgpVQuFzEtpAfopPEz/YB89wi6leV3HMgVuZMLMWEsYJ98 +9tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dAOMjfBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id r5-20020a632045000000b005b95f5f8976si8502201pgm.634.2023.12.04.12.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:37:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dAOMjfBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9BACA8043EFE; Mon, 4 Dec 2023 12:37:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235516AbjLDUgx (ORCPT + 99 others); Mon, 4 Dec 2023 15:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbjLDUgd (ORCPT ); Mon, 4 Dec 2023 15:36:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B66C2D6B for ; Mon, 4 Dec 2023 12:34:59 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E247C433CD; Mon, 4 Dec 2023 20:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722098; bh=utnA4ZmxMlETtUMbXwSY4jNxpOOsInsvF7s/KcfzNhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAOMjfBKK4fws254udE6FcHWyUyRRcLqNhri20RAc5Q6CtXX3dmf/wHdplAZZ02S/ GfTRcaRH6MhqcY5xqe0rET6cZPUgLY2tPoT85ZQVMc0oYkuzTgfTag85/Jy7/yrAJ1 QzWqZ7hVno2t1csZQB9hwjIBUPsEQYAt8jwmeD/sKwygptESF1dqn5acJdHd3N090K 5ea2/7cge4/2RjvA39F6GdkyVRApIeevDTh6WCOBa9HJnvCr8AvH9Bc4D1UUJaA9Ln sV7Ag1Y0lApYbm32qTZHrQTimU+G33HL49Tcr4sDOmI3BrtMfBFtQ7y8aZsQXNGr7H D9HWhHKYSztSA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ming Lei , Mike Snitzer , David Jeffery , John Pittman , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 31/32] blk-mq: don't count completed flush data request as inflight in case of quiesce Date: Mon, 4 Dec 2023 15:32:51 -0500 Message-ID: <20231204203317.2092321-31-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204203317.2092321-1-sashal@kernel.org> References: <20231204203317.2092321-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:37:17 -0800 (PST) From: Ming Lei [ Upstream commit 0e4237ae8d159e3d28f3cd83146a46f576ffb586 ] Request queue quiesce may interrupt flush sequence, and the original request may have been marked as COMPLETE, but can't get finished because of queue quiesce. This way is fine from driver viewpoint, because flush sequence is block layer concept, and it isn't related with driver. However, driver(such as dm-rq) can call blk_mq_queue_inflight() to count & drain inflight requests, then the wait & drain never gets done because the completed & not-finished flush request is counted as inflight. Fix this issue by not counting completed flush data request as inflight in case of quiesce. Cc: Mike Snitzer Cc: David Jeffery Cc: John Pittman Signed-off-by: Ming Lei Link: https://lore.kernel.org/r/20231201085605.577730-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 6ab7f360ff2ac..20ecd0ab616f7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1511,14 +1511,26 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q, } EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list); +static bool blk_is_flush_data_rq(struct request *rq) +{ + return (rq->rq_flags & RQF_FLUSH_SEQ) && !is_flush_rq(rq); +} + static bool blk_mq_rq_inflight(struct request *rq, void *priv) { /* * If we find a request that isn't idle we know the queue is busy * as it's checked in the iter. * Return false to stop the iteration. + * + * In case of queue quiesce, if one flush data request is completed, + * don't count it as inflight given the flush sequence is suspended, + * and the original flush data request is invisible to driver, just + * like other pending requests because of quiesce */ - if (blk_mq_request_started(rq)) { + if (blk_mq_request_started(rq) && !(blk_queue_quiesced(rq->q) && + blk_is_flush_data_rq(rq) && + blk_mq_request_completed(rq))) { bool *busy = priv; *busy = true; -- 2.42.0