Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1339012rdh; Mon, 25 Sep 2023 09:37:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh4ghTb7Mbv2yEEq7PlqyN6y9ZnzmtNLuujaTmEug9UoXtCAGrLbCsDbyeQombJsb0wX5C X-Received: by 2002:a05:6a20:96d7:b0:14c:d5d8:9fed with SMTP id hq23-20020a056a2096d700b0014cd5d89fedmr4560259pzc.54.1695659857651; Mon, 25 Sep 2023 09:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695659857; cv=none; d=google.com; s=arc-20160816; b=o08X5+KV10x1rsi8Pw16xDBTKeLw3GLQA8nEV+bhodYYZ+XMbrE2YQlCazLeSKLIKa UIyAdpz/dWfoyTu8jC6vqbrIokW2zIvhhBodIAv3oMVo5CIGd+6XoFAAB1zAnmgED+vU lW3Oc0s9NAS/y4NX4f8Fy791Fg++LNiCbn4jhme94a2uqbsf6DwgfUnLyNC1dohN9N69 A4VKewDLaFillHAwlgNYq1a6SpXmxcf7XrHpXqKOrfvxqmHxL6dj30oj07AjuHV1Sx+A Kabx5TF3f6kMJUiTrQjwF4NBlHrD2M+XUaetvyMhOyez3mVd6lQt/Iii4ypjpGNciOul pqTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=myBtwJ1YT03oPB5KnjPWG8S16nesO2KCX8qvY+sOtbU=; fh=3rjMYMZEu1wJh4UGfsBfwyaUNBYmqdQ38cGIGwsNVRg=; b=BkRJdjcTIyGQCk5rWOyM+y62PjyKhE91PCBU+MT58MbkW1di5YjrgapMkgI78t+2OL yJPMTp+JJCpdAJgu5696tcf4Udt8nxTiOG46vCHflhSMzA/6jgcNm46ivgvaLIGVkCUX U6L5UKByM7T5q3veYrPJ4X3g2M5Dw4Fu77XNCChY9dGb2Q9uh/SW5CDmEnKqOoexZDxA NDKPvWaIbDCjJI5ait9vtUv3S1AKocjDKkbmp56LJXtp/8JoNVTCEcRiCQiHidcue3rX HiUVyF+PzdfnEK6MMWJtzUMSUVypr5EQV0a6RpBklEGGYgW0SQ0BrR0+qY2OUl4u/4CD oRBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m123-20020a632681000000b00578bea2771asi11288947pgm.176.2023.09.25.09.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 09:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7FE2380B06CE; Mon, 25 Sep 2023 08:02:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232464AbjIYPCX (ORCPT + 99 others); Mon, 25 Sep 2023 11:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjIYPCW (ORCPT ); Mon, 25 Sep 2023 11:02:22 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C48EB101; Mon, 25 Sep 2023 08:02:15 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RvQym20rJzrSxy; Mon, 25 Sep 2023 23:00:00 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) 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; Mon, 25 Sep 2023 23:02:13 +0800 Message-ID: <6531a3b0-915d-8078-b265-95231405ac4d@huawei.com> Date: Mon, 25 Sep 2023 23:02:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH 1/2] scsi: core: scsi_device_online() return false if state is SDEV_CANCEL Content-Language: en-US To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: , References: <20230922093636.2645961-1-haowenchao2@huawei.com> <20230922093636.2645961-2-haowenchao2@huawei.com> From: Wenchao Hao In-Reply-To: <20230922093636.2645961-2-haowenchao2@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 08:02:27 -0700 (PDT) On 2023/9/22 17:36, Wenchao Hao wrote: > SDEV_CANCEL is set when removing device and scsi_device_online() should > return false if sdev_state is SDEV_CANCEL. > > 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) > scsi_eh_flush_done_q() > if (scsi_device_online(sdev)) > scsi_queue_insert(scmd,...) > > The command added by scsi_queue_insert() would never be handled any > more. > > Signed-off-by: Wenchao Hao > --- > include/scsi/scsi_device.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h > index 75b2235b99e2..c498a12f7715 100644 > --- a/include/scsi/scsi_device.h > +++ b/include/scsi/scsi_device.h > @@ -517,7 +517,8 @@ static inline int scsi_device_online(struct scsi_device *sdev) > { > return (sdev->sdev_state != SDEV_OFFLINE && > sdev->sdev_state != SDEV_TRANSPORT_OFFLINE && > - sdev->sdev_state != SDEV_DEL); > + sdev->sdev_state != SDEV_DEL && > + sdev->sdev_state != SDEV_CANCEL); > } > static inline int scsi_device_blocked(struct scsi_device *sdev) > { Return false when if sdev_state is SDEV_CANCEL seems change some flow in error handle, but I don't know if we should introduce these changes. I think it's both ok to finish the failed command or try more recovery steps. For example, in scsi_eh_bus_device_reset(), when scsi_try_bus_device_reset() returned SUCCEED but the sdev_state is SDEV_CANCEL, should skip TUR and just call scsi_eh_finish_cmd() to add this LUN's error command to done_q? We can address the issue of IO hang described in this patch by running scsi_device's queue regardless of the scsi_device's state and it seems a better solution because the main reason of IO hang is as following: scsi_restart_operations() -> scsi_run_host_queues() -> shost_for_each_device() // skip scsi_device with SDEV_DEL // or SDEV_CANCEL state