Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3057159rdh; Thu, 28 Sep 2023 00:50:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn76MT/traL2qt/S/th5QpxYohEmMnjeV3avWP86rNC8he2x6g7dG52Nxn7zH0AsYfnNIt X-Received: by 2002:a17:90b:383:b0:26d:416a:b027 with SMTP id ga3-20020a17090b038300b0026d416ab027mr451239pjb.31.1695887406900; Thu, 28 Sep 2023 00:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695887406; cv=none; d=google.com; s=arc-20160816; b=UviHRt18/uMJFGwTd5/GTPLVKn+QUF561P2fvlDRKtJ3b+RQtx56U1lkDDXX/jAcWr KZkc5XQZtsFNRJyQI48rWlQdeJeLh8PsYadHU61Zl8yR+RMmYR7hx4a3vSxPDg/tc0tn aoXvWxDJ4l2lrHCI/DUn8yMWS36RQRN+dM+SArAFOqsScNmyfk6VhorDgy2o9pWl5AZc I7XnfjxaQOFCbjJR1eu8/y8MJ4BOroaRcTK0KmndbYXpdvVFpCPTbwYkVDx7mJXr7Sox +COs4oD59h1ezHGmglsFu7+DfYaPouqLQKXVox2k5tWB0N6jfmUQQl3ZkUwD+x1arNXT WB3Q== 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; bh=ThCZhS48x9nh1Y0x8coixMzMXCiKIJyACeQi2w6iK3U=; fh=ZDcIlyYggP5K3GvQBQF3K/GzUnCJV+bQb/1GDPxM7E4=; b=JAzL76HmAa1Mv/pavjtWa8UedsElKcBmpHofWo2fP1wv5EEx/pcPdjXq72g+PGlSTg mazPo1UllSrATYvdzZdUG0p+NXSSNXV8oJlRm1eD+kSejWNGDnwqLLcCcUOspLnw0HtL 6NQglu6LCxtTIALUMcLfCTfdKX37Xl95GF0yRS+oPrJLDkxDQKaEAhcOADUYoFGa+Vq6 pOYJrYLrpfyE28m7Wf9tdUgs4IQsy6n2EgFXPhB9od2ZlXpyvkxOx71qEV/Aw1L17HUh 4gszdtkK6GGIwJ0zdErpNgPDuUek9FDShnz7RGlg43Sl71srShxsEP+2M1hewgni0uoR eRFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b2-20020a17090a9bc200b0027743a2eeb9si11539321pjw.124.2023.09.28.00.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 00:50:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5DE9E801B998; Thu, 28 Sep 2023 00:36:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbjI1Hgl (ORCPT + 99 others); Thu, 28 Sep 2023 03:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229758AbjI1HgX (ORCPT ); Thu, 28 Sep 2023 03:36:23 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF5D89C; Thu, 28 Sep 2023 00:36:18 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rx4wl3XVWzrT3D; Thu, 28 Sep 2023 15:33:59 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 15:36:15 +0800 From: Wenchao Hao To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: , , Wenchao Hao Subject: [PATCH v2 4/4] scsi: scsi_core: Fix IO hang when device removing Date: Thu, 28 Sep 2023 15:35:43 +0800 Message-ID: <20230928073543.3496394-5-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230928073543.3496394-1-haowenchao2@huawei.com> References: <20230928073543.3496394-1-haowenchao2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 28 Sep 2023 00:36:53 -0700 (PDT) shost_for_each_device() would skip devices which is in progress of removing, so scsi_run_queue() for these devices would be skipped in scsi_run_host_queues() after blocking hosts' IO. IO hang would be caused if return true when state is SDEV_CANCEL with following order: T1: T2:scsi_error_handler __scsi_remove_device() scsi_device_set_state(sdev, SDEV_CANCEL) ... sd_remove() del_gendisk() blk_mq_freeze_queue_wait() scsi_eh_flush_done_q() scsi_queue_insert(scmd,...) Because scsi_queue_insert() would not kick device's queue after commit 8b566edbdbfb ("scsi: core: Only kick the requeue list if necessary") After scsi_unjam_host(), the scsi error handler would call scsi_run_queue() to trigger run queue for devices, while it would not run queue for devices which is in progress of removing because shost_for_each_device() would skip them. So the requests added to these queues would not be handled any more, and the removing device process would hang too. Fix this issue by using shost_for_each_device_include_deleted() in scsi_run_queue() to trigger a run queue for devices in removing. Signed-off-by: Wenchao Hao --- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index c2f647a7c1b0..34b408d182e2 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -466,7 +466,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost) { struct scsi_device *sdev; - shost_for_each_device(sdev, shost) + shost_for_each_device_include_deleted(sdev, shost) scsi_run_queue(sdev->request_queue); } -- 2.32.0