Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp520058rdh; Sat, 23 Sep 2023 23:37:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNaE89Grom5SF2JoU6qnouB5ku0sDPP/zYooteT9PEDiCsdva34OBB1+1GZMroofxcT60p X-Received: by 2002:a17:902:b58d:b0:1c5:cbfb:c166 with SMTP id a13-20020a170902b58d00b001c5cbfbc166mr3634928pls.37.1695537455101; Sat, 23 Sep 2023 23:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695537455; cv=none; d=google.com; s=arc-20160816; b=cczBaK/f4wN9dtWlWB0SuP9HzMEZYqRF/ABHBTuvdgdjmRcYEo6ulfASDcreqKaykM nez1AeyiDID6dsJZXfYL8kbHe2wFA2ps+Ac8dPH0GgjZB69w1DG7mRanZB0f8MCkYL8T OaMjCqpGzXbK5P0so2giFQ+BvCZCYtg3CAcK0KSWfLMNVK+NSM0mZkKmVj2lJyC0RoDC vRUrru2P7LsXDTjqaFUf6WpsupLwZOkjmWIi4haBdR+0FbSEVO9JJnDpFdtN/qUMsufg Vjtlpxx3Qt8QLXOozhLmyl25vTMCZ2ot9B2Ka7SzVOivL/UffXYkP5ralE+BPg7FsoDM GDmw== 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=mfOPnitGyP6i1g+dqmfT6Aj2Hi51yFg+6cxWbh9xTuQ=; fh=57H+KIJSEytfllLX/iXRD/ADuU8hPLjUhYkNX1MAvNk=; b=BgdXmyXrZSqsST3EYinehK7dTi8lqCnhOYHECpTJFXFUBZFv80SXzmyXYRbh++mQIp rW6Q3vboD+1w1dGyrRG9LDSRsSuVcmVB1gXUK+Jg+WvbxC427slyo3QwfHVGRtXjxvxz NmVnKt2R4UfLQ6UsWBNaPiXQBsBhycvNN+UuwLGuqFvzMt5g9jyDvWYuNe2bvtB0iJ3Q 9fNud6Hk8/Bc4Otoa85byax5WBtNkGgBuNMc8vW+OpnMvFcMyxVtFNrV9pTzm1S03JHX PAIiqUTx77lhWI4kHeEw97SMOtRxtXnXyylmFXtGQ7F2lfmr95zatE+cQ4e0yatreK7o UhhQ== 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:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b15-20020a170903228f00b001c611ca886bsi517632plh.478.2023.09.23.23.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 23:37:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id A42D981BFCEC; Sat, 23 Sep 2023 23:37:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229549AbjIXGhP (ORCPT + 99 others); Sun, 24 Sep 2023 02:37:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIXGhO (ORCPT ); Sun, 24 Sep 2023 02:37:14 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B7E107; Sat, 23 Sep 2023 23:37:07 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RtbpP15LZz15NRG; Sun, 24 Sep 2023 14:34:53 +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; Sun, 24 Sep 2023 14:37:03 +0800 Message-ID: <407be945-9fd2-8e00-e72b-82e2f311dbeb@huawei.com> Date: Sun, 24 Sep 2023 14:37:02 +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: Bart Van Assche , "James E . J . Bottomley" , "Martin K . Petersen" CC: , , References: <20230922093636.2645961-1-haowenchao2@huawei.com> <20230922093636.2645961-2-haowenchao2@huawei.com> <50b20a3e-e264-4788-8e52-f7b57cf944f0@acm.org> From: Wenchao Hao In-Reply-To: <50b20a3e-e264-4788-8e52-f7b57cf944f0@acm.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.220] 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=-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 pete.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 (pete.vger.email [0.0.0.0]); Sat, 23 Sep 2023 23:37:32 -0700 (PDT) On 2023/9/22 23:23, Bart Van Assche wrote: > On 9/22/23 02: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. > > Why not? I think the blk_mq_destroy_queue() call in __scsi_remove_device() will cause it to fail. > > Thanks, > > Bart. > Sorry, I did not describe in detail, the __scsi_remove_device() would be blocked in blk_mq_freeze_queue_wait() to wait all block requests finished, so blk_mq_destroy_queue() would not be called, and the task which try to remove scsi_device would be hung.