From patchwork Tue Jul 11 16:04:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 13309021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABDFFEB64DC for ; Tue, 11 Jul 2023 16:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbjGKQGe (ORCPT ); Tue, 11 Jul 2023 12:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232250AbjGKQGP (ORCPT ); Tue, 11 Jul 2023 12:06:15 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 11 Jul 2023 09:05:57 PDT Received: from esa3.hc3370-68.iphmx.com (esa3.hc3370-68.iphmx.com [216.71.145.155]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B14741FCB for ; Tue, 11 Jul 2023 09:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1689091557; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CQ07KOad9rBrX25HAdPxBhuEPDkFzDLdIlc2phuivUw=; b=f9yNXNyBqx322S2xNCrys2N8H8wcVl+RAaVeP2S5n1pDBEKtv1ygPMmk gg+P1uTot01JeyDSmecoFhwa0DDFM/xUtHBzfDKUFhNv7TF1/H1lpax/Z U6EVaI8RWeUPiv1ZjvSjtMtYpyIwYRQ2QFKJoEFYl30FdNKmsLrDjzPf3 M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 115870688 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:TiNRL60c5KI7ha1NBfbD5dpxkn2cJEfYwER7XKvMYLTBsI5bp2YHz zYXDTuAOayMZGr0KNt0PNzl9R8AuMDXxodrSQBkpC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8teTb8XuDgNyo4GlD5gNnPKgS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfDSZP6 qQoNRMxPlOMnsOJ7a68E/BCmZF2RCXrFNt3VnBIyDjYCbAtQIzZQrWM7thdtNsyrpkQR7CEP ZNfMGcxKk2aOHWjOX9OYH46tP2vnWK5dzRXpUiKrK4zy2PS0BZwwP7mN9+9ltmiHJwIzhnA+ DKWl4j/Kg85EvO+7Bq6y3at2eXQsAz5cb0RPqLto5aGh3XMnzdOWXX6T2CTpfi/l177UdZYI E885CUjt+4x+VatQ927WAe3yFaAvxgBS59THvc85QWl1KXZ+UCaC3ICQzoHb8Yp3Oc/VTYt2 3eKksnvCDgpvL79dJ6G3u7K93XoY3FTdDJcI3ZeFmPp/uUPvqk/yRPQFuZ+M5LlzdLsOA7d3 zfTtQYh0uB7YdEw60mrwbzWq2vy9smREVVstlu/snGNtV0gOtP8D2C8wR2CtKsbct7EJrWUl CJc8/Vy+tziGn1keMalZOwWVI+k6P+eWNE3qQ4+RsJxn9hBFpPKQGyx3N2dDB0zWir8UWW1C HI/QCsIjHOpAFOkbLVsf6W6ANkwwK7rGLzND66EP4IXPsEpKFPepUmCgHJ8OEi0wCARfVwXY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U2Zx2LPf5zBR2cE6IspNXzClEfNAHPoSmlwaYK4VVjJ4Y17xp8= X-Talos-MUID: 9a23:JRVNTw3Arg2tLSRrqGbYl35nojUj/YeIJ2Eosao/v8jbPzNdFDW0szedXdpy X-IronPort-AV: E=Sophos;i="6.01,196,1684814400"; d="scan'208";a="115870688" From: Ross Lagerwall To: , CC: Jens Axboe , Ross Lagerwall Subject: [PATCH] blk-mq: Fix stall due to recursive flush plug Date: Tue, 11 Jul 2023 17:04:34 +0100 Message-ID: <20230711160434.248868-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We have seen rare IO stalls as follows: * blk_mq_plug_issue_direct() is entered with an mq_list containing two requests. * For the first request, it sets last == false and enters the driver's queue_rq callback. * The driver queue_rq callback indirectly calls schedule() which calls blk_flush_plug(). * blk_flush_plug() handles the remaining request in the mq_list. mq_list is now empty. * The original call to queue_rq resumes (with last == false). * The loop in blk_mq_plug_issue_direct() terminates because there are no remaining requests in mq_list. The IO is now stalled because the last request submitted to the driver had last == false and there was no subsequent call to commit_rqs(). Fix this by returning early in blk_mq_flush_plug_list() if rq_count is 0 which it will be in the recursive case, rather than checking if the mq_list is empty. At the same time, adjust one of the callers to skip the mq_list empty check as it is not necessary. Fixes: dc5fc361d891 ("block: attempt direct issue of plug list") Signed-off-by: Ross Lagerwall --- I'm not 100% sure if I've got the correct Fixes commit. block/blk-core.c | 3 +-- block/blk-mq.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 99d8b9812b18..90de50082146 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1144,8 +1144,7 @@ void __blk_flush_plug(struct blk_plug *plug, bool from_schedule) { if (!list_empty(&plug->cb_list)) flush_plug_callbacks(plug, from_schedule); - if (!rq_list_empty(plug->mq_list)) - blk_mq_flush_plug_list(plug, from_schedule); + blk_mq_flush_plug_list(plug, from_schedule); /* * Unconditionally flush out cached requests, even if the unplug * event came from schedule. Since we know hold references to the diff --git a/block/blk-mq.c b/block/blk-mq.c index 5504719b970d..d5a7f36e634f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2742,7 +2742,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule) { struct request *rq; - if (rq_list_empty(plug->mq_list)) + if (plug->rq_count == 0) return; plug->rq_count = 0;