Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3298289rwa; Tue, 23 Aug 2022 02:14:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4iKjmG0wR9vcz4ms86KlQvPPyH1Gp48a0yINlINh9RIuoL1h3rZ2zvIrQpL9X5ZIe2Gf1l X-Received: by 2002:a17:906:5d08:b0:734:bf6a:6309 with SMTP id g8-20020a1709065d0800b00734bf6a6309mr15318587ejt.516.1661246060622; Tue, 23 Aug 2022 02:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661246060; cv=none; d=google.com; s=arc-20160816; b=T7P8ipdxWyfEBP/eJndEPCgjyonYoog8c+xR7ST5NLttPZQMpmht8T+oS/HiVnRLbi QQXz7u6R8QrD7qdsdOuLNxgSi/0qOrxThKHuMqzYPKlJCku/As2tkvHgDW5P41w0o2Sr lC8jQYQ5wBfZSJHbl/hNYU2PM3BB001gTdxLStFEOqPRjj6yYoWC4TvokeMlJKzHocv8 F0BOhNwvt8oRI/U1SJDpYz378Cdpqex7ExLK14uCNgKpVNIG9DHTSL6IxlaLJIQgr4Ph GTOYpYShAjvdDbG4lDgix+0GeaeR4mG7JTKEvfvpNwc8q5d1V0PjkEYwG1KdXkBbdXIU vIlQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0mhXtvPlBdiNKqK7+LYsNZ6vj5R9jMs8gFACy3/pyHM=; b=dEP0QDmmaGDdsz+ZXHV3TmtcLFQhXBlcI+SW1Ja/3NzJboh9RwdhcpTAohDrzJq/ya w7ht3KBbROt8uwRXCiXcisG5KQOWUVFETR7pGSix8MI+ccXg3YmVNEt0plawaQ7o6W7K wqvA/3gmFQmXPgcr2Dg9QYQAspE3TnxKsF/zATMrRQMXftYfumFyO4H+ftyCWRFsrDjD o3/50SRlr9pMu9ZqPcWirZ/C56v37uh0+y+Xlk9bx9ipzyY3wEkAwH7gUnAbn9rODLgI QjrE1SvcYZnqjGxpYyRDRnyX5hIR476UNOVxs/KTtk72H6Kj5TjNszuJ/MpQ8Htx7SO8 deMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dWgw/VAW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a056402440400b00445e286d000si2284913eda.365.2022.08.23.02.13.53; Tue, 23 Aug 2022 02:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dWgw/VAW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348236AbiHWJJ7 (ORCPT + 99 others); Tue, 23 Aug 2022 05:09:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347950AbiHWJIc (ORCPT ); Tue, 23 Aug 2022 05:08:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812E585FDA; Tue, 23 Aug 2022 01:30:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 89B6A6148E; Tue, 23 Aug 2022 08:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87CB4C433B5; Tue, 23 Aug 2022 08:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243354; bh=9a8VWOB3kHtWZih/DNfyhw7RMpOevoUeaUMm2JCDfYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWgw/VAWW4OWC8KkB/IvltvKg6+hF7kwc1tLcfRBokMUGmzss3tZ1JjEl18Yz45NL /9Ng+IN6+I4R76adl4y0QUCBetj4SYHP6qXEWKlwjM1CS9Ufn8gqai7ay9QRd40IM4 UXA2f4NP6DMwB44/e1/WQCxDfgWTTMwFzMiCVpxk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufen Yu , Ming Lei , Jens Axboe Subject: [PATCH 5.19 233/365] blk-mq: run queue no matter whether the request is the last request Date: Tue, 23 Aug 2022 10:02:14 +0200 Message-Id: <20220823080127.972131997@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yufen Yu commit d3b38596875dbc709b4e721a5873f4663d8a9ea2 upstream. We do test on a virtio scsi device (/dev/sda) and the default mq scheduler is 'none'. We found a IO hung as following: blk_finish_plug blk_mq_plug_issue_direct scsi_mq_get_budget //get budget_token fail and sdev->restarts=1 scsi_end_request scsi_run_queue_async //sdev->restart=0 and run queue blk_mq_request_bypass_insert //add request to hctx->dispatch list //continue to dispath plug list blk_mq_dispatch_plug_list blk_mq_try_issue_list_directly //success issue all requests from plug list After .get_budget fail, scsi_mq_get_budget will increase 'restarts'. Normally, it will run hw queue when io complete and set 'restarts' as 0. But if we run queue before adding request to the dispatch list and blk_mq_dispatch_plug_list also success issue all requests, then on one will run queue, and the request will be stall in the dispatch list and cannot complete forever. It is wrong to use last request of plug list to decide if run queue is needed since all the remained requests in plug list may be from other hctxs. To fix the bug, pass run_queue as true always to blk_mq_request_bypass_insert(). Fix-suggested-by: Ming Lei Signed-off-by: Yufen Yu Reviewed-by: Ming Lei Fixes: dc5fc361d891 ("block: attempt direct issue of plug list") Link: https://lore.kernel.org/r/20220803023355.3687360-1-yuyufen@huaweicloud.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2568,7 +2568,7 @@ static void blk_mq_plug_issue_direct(str break; case BLK_STS_RESOURCE: case BLK_STS_DEV_RESOURCE: - blk_mq_request_bypass_insert(rq, false, last); + blk_mq_request_bypass_insert(rq, false, true); blk_mq_commit_rqs(hctx, &queued, from_schedule); return; default: