From patchwork Sat Mar 25 01:17:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 74808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp151004vqo; Fri, 24 Mar 2023 19:12:04 -0700 (PDT) X-Google-Smtp-Source: AKy350YHYze664g2tFTiQsMfa8Fw/fZuR5fwWvfzelIqORLuk8PCZL59C1jyNw9oLD9zrT2pLb6d X-Received: by 2002:a17:907:2be8:b0:877:8a55:2a26 with SMTP id gv40-20020a1709072be800b008778a552a26mr4192533ejc.60.1679710324430; Fri, 24 Mar 2023 19:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679710324; cv=none; d=google.com; s=arc-20160816; b=YCQ5gy3SVy7xQPWZCeB7OIDKuue4wdGFoPK7rvI6K8JjilmY7CM3tgOEmfbJrYht3z vCUUQMd3RNwz9+67m0Tl1SHjo/uhrMlmbdbWSzYJobgkAun+pkeH4caq9vGNHOTz7igC nF/wSvugXIu5pIXU4xvIKnyQr1cZEtoAiBC4fnMfR/PKvjg+G57jjyKMWCP2kPsgTnBh zPbwryq9kMz1xmpXnTHyqKva5PWO80qBjUDxJBkX0F4eEQ40N84nVLUOEheG11dJGV1L iM9rlLgAZpHzu7RScrRa9n6Vy+iKvFdXYyyX29ydT8CCkLRB3IlkLsGmAQnrbJb1HaGP ypGw== 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=Ewu+eFMD3vqKfpsp4JRgmmV37DeX2wtnKSLW/qsFXO8=; b=orEQksH1UJFG4qU/XFDcvveR+rG2jB8KPeLKZa1oWQ6M6TBJq/3TxRosZXWN2Ffsbg c9LjqLx/FU+lx8QpnQ8iHDGVnzEBFERj2a806uArAtvPXj2mOM0+PAK6784OTYA0eSq0 9xtOMMHWgk4g1k2TRMFHuOZCOrhIPRMQZgFUZoJuOB/EYaUdjDVRlWDRhdT8iZMZ8OvG +bYX/f+ZLtFrIOyycZWK8gE8uHqAZzM+KNWPjV+ZrrCOkoa6ZgV7o1Bt3hcHLiDIQQzk 7MmPLDTWx/r7tc72FOai/fJaiOXIpvOx0zf7julvkzHnre9eYcMBR9+HWVtfNsZ2X98g bOnQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020a170906341900b0093018c7c47csi20591115ejb.10.2023.03.24.19.11.40; Fri, 24 Mar 2023 19:12:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232177AbjCYBS6 (ORCPT + 99 others); Fri, 24 Mar 2023 21:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbjCYBSk (ORCPT ); Fri, 24 Mar 2023 21:18:40 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A68381A94A; Fri, 24 Mar 2023 18:18:38 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Pk1Rt1cfDz4f3mLK; Sat, 25 Mar 2023 09:18:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCnUiDpSx5kmy0NFg--.49234S6; Sat, 25 Mar 2023 09:18:36 +0800 (CST) From: Ye Bin To: jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ye Bin Subject: [PATCH 2/5] scsi: introduce SHOST_BLOCKED state to support blocking IO Date: Sat, 25 Mar 2023 09:17:31 +0800 Message-Id: <20230325011734.507453-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230325011734.507453-1-yebin@huaweicloud.com> References: <20230325011734.507453-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnUiDpSx5kmy0NFg--.49234S6 X-Coremail-Antispam: 1UD129KBjvJXoW7tr4xGw47ur4DuF4xury7trb_yoW8KryfpF WDXw1xC3y8GayIkwnIg3Z8Gr95Ka97WrWqqFyUWa47Wa4jy34Y9w4DCFyUZay8GrW7Krnx WF4DWF1DCFWrJrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUzMKuUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761303932997504603?= X-GMAIL-MSGID: =?utf-8?q?1761303932997504603?= From: Ye Bin SHOST_BLOCKED state to blocking io in block layer. This state use for test, Only running state and blocked state can be switched to each other. Signed-off-by: Ye Bin --- drivers/scsi/hosts.c | 11 +++++++++++ drivers/scsi/scsi_sysfs.c | 1 + include/scsi/scsi_host.h | 1 + 3 files changed, 13 insertions(+) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 9b6fbbe15d92..3b497fd4d329 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -90,6 +90,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) switch (oldstate) { case SHOST_CREATED: case SHOST_RECOVERY: + case SHOST_BLOCKED: break; default: goto illegal; @@ -99,6 +100,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) case SHOST_RECOVERY: switch (oldstate) { case SHOST_RUNNING: + case SHOST_BLOCKED: break; default: goto illegal; @@ -109,6 +111,7 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) switch (oldstate) { case SHOST_CREATED: case SHOST_RUNNING: + case SHOST_BLOCKED: case SHOST_CANCEL_RECOVERY: break; default: @@ -144,6 +147,14 @@ int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state) goto illegal; } break; + case SHOST_BLOCKED: + switch (oldstate) { + case SHOST_RUNNING: + break; + default: + goto illegal; + } + break; } shost->shost_state = state; return 0; diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index cc0ae5e3def3..b14f95ac594e 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -69,6 +69,7 @@ static const struct { { SHOST_RECOVERY, "recovery" }, { SHOST_CANCEL_RECOVERY, "cancel/recovery" }, { SHOST_DEL_RECOVERY, "deleted/recovery", }, + { SHOST_BLOCKED, "blocked", }, }; const char *scsi_host_state_name(enum scsi_host_state state) { diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 587cc767bb67..9e99317b11fa 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -527,6 +527,7 @@ enum scsi_host_state { SHOST_RECOVERY, SHOST_CANCEL_RECOVERY, SHOST_DEL_RECOVERY, + SHOST_BLOCKED, }; struct Scsi_Host {