From patchwork Tue Mar 28 14:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 76112 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2273635vqo; Tue, 28 Mar 2023 07:44:56 -0700 (PDT) X-Google-Smtp-Source: AKy350aVRRn2+ai5RpS9vBaW2hcC9HXnItUH4oV3DmRKaO3oDd65lXRowaaR/S1mR4nPgn5fowbe X-Received: by 2002:a17:902:d4c6:b0:1a1:cc5a:b07 with SMTP id o6-20020a170902d4c600b001a1cc5a0b07mr19036751plg.37.1680014695817; Tue, 28 Mar 2023 07:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680014695; cv=none; d=google.com; s=arc-20160816; b=Ht0Vi87AB7NJsi1DYEiJKZ7WAifc/6WyCgxUTAfEJAKzKdOdwDtoe/5GSrZLz6bUhq JbNcs+K+sql6CfQ7OKpc8LI2Ap/5KnOSwtMk0QUrHJoi8ZpDftO42ksIfp6T396+C3fx ucXzWmaYeMaOu5VqZ/xy67sPJXzJK+qYgiUWuAFzGa6qgTPsyurPIPzXfX0oD9IohCwr 8T10WPgVlGEY1jtT+8itEufnNY+QgsQRlY4f4h6ma/UfLM2nSuI6j42P90BwRZV0L3IJ 2uHJhKZEFBDGRbkkWnZKgFpIs37iyyUnYsip9563l5XkGd7uAX8tsL87uxG8PzzHw4mG lWCQ== 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=kgmmkbtE2kNCr1yvn5zlY/6+Jvlf9UahTl/t6PUvG8g=; b=zzjDYZchdqCM+UJHQn2jK/rzJA/MNj3fxeIMbOsaahIoHn+fWVY/SFBNtzjYopz74l wSokUhdNInMpR3/DJCjpOM+pF4rGsPhs/BP+pp+lb47QnhcepVvAocOxG4JAzsgxzGYD GM4Obocx+uUXyQ2WXr1STzA4CNwxo+O1hwE3JR1leEduUgj51Dj4ja3suqT1zY3ZUXxC 5LYsdGnTIho4WDCwfIF9Uisl7l8KtyQhmT8yCbkb2Vy0tNfOQbRZCNXJCQxftYsNiAcM O4EO8JPiE44CT/DMV9D/HUI7FlhIuZY/tRtOY+S5Dvj6fg0s0cyiTYL3YCNFO4ZNj7jT f+aw== 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 bv7-20020a632e07000000b0050f89421524si21495592pgb.319.2023.03.28.07.44.42; Tue, 28 Mar 2023 07:44:55 -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 S232667AbjC1Ofb (ORCPT + 99 others); Tue, 28 Mar 2023 10:35:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232278AbjC1OfV (ORCPT ); Tue, 28 Mar 2023 10:35:21 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57E6CC0D; Tue, 28 Mar 2023 07:35:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PmBzd13tZz4f3rNB; Tue, 28 Mar 2023 22:35:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R8X+yJkk4bgFg--.7384S5; Tue, 28 Mar 2023 22:35:10 +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 v2 1/3] scsi: forbid to set scsi host state by sysfs Date: Tue, 28 Mar 2023 22:34:40 +0800 Message-Id: <20230328143442.2684167-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230328143442.2684167-1-yebin@huaweicloud.com> References: <20230328143442.2684167-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R8X+yJkk4bgFg--.7384S5 X-Coremail-Antispam: 1UD129KBjvJXoW7CFW3XF4UZFWkJF1kZw47urg_yoW8AF17pr ZxJa4ag3yUGFs7WFsruws8W3sxKr18Gr9rt398twn7CF18AF9xKanrJay8Za4rJFW8Wrn7 JF4DJr15Cay8tF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_Jrv_JF4l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUCVW8JwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUOWlkDUUUU 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?1761623089382604030?= X-GMAIL-MSGID: =?utf-8?q?1761623089382604030?= From: Ye Bin Actually, set scsi host state by sysfs may lead to functional issues. So forbid to set scsi host state. Signed-off-by: Ye Bin --- drivers/scsi/scsi_sysfs.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index ee28f73af4d4..903aa9de46e5 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -195,30 +195,6 @@ store_scan(struct device *dev, struct device_attribute *attr, }; static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan); -static ssize_t -store_shost_state(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int i; - struct Scsi_Host *shost = class_to_shost(dev); - enum scsi_host_state state = 0; - - for (i = 0; i < ARRAY_SIZE(shost_states); i++) { - const int len = strlen(shost_states[i].name); - if (strncmp(shost_states[i].name, buf, len) == 0 && - buf[len] == '\n') { - state = shost_states[i].value; - break; - } - } - if (!state) - return -EINVAL; - - if (scsi_host_set_state(shost, state)) - return -EINVAL; - return count; -} - static ssize_t show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) { @@ -233,7 +209,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ static struct device_attribute dev_attr_hstate = - __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); + __ATTR(state, S_IRUGO, show_shost_state, NULL); static ssize_t show_shost_mode(unsigned int mode, char *buf) From patchwork Tue Mar 28 14:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 76115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2274970vqo; Tue, 28 Mar 2023 07:46:41 -0700 (PDT) X-Google-Smtp-Source: AKy350YM3rsRAAdB1BRNXd1fmryxDJIP1hYY2Vy5Q0xJBgetm3q6n4pbkKQyo67MS6q9rhC821t2 X-Received: by 2002:aa7:96f2:0:b0:625:cf03:e8cb with SMTP id i18-20020aa796f2000000b00625cf03e8cbmr16093013pfq.4.1680014800970; Tue, 28 Mar 2023 07:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680014800; cv=none; d=google.com; s=arc-20160816; b=TbvkSjNtYaFEySgeGRi5tQtik2Eel+7SkD6vYyziT19tQMcpGGBOKPiSYADXBRwvEC fZyBWbYlDLFWA7/8xltLYA8JYbHt3NjssbFaMtZXMkwmDlnejHmi9hsu9wov/HHBVhdX zPHQbdjjzNyc0oV7p2sHpzviM3mlRnWCmrlZyzO3aMbt1Z06aRyabo3F50AhK3Fa37aw xDQ+Xh8jrIyTODKg/8MeRT3UNiCiS7mdSpNH9EmncoeR84qlmQ+rO6jk9svCg7k5PqBL lPQA370Pt1og9rJ/djScplxe4FMo3rGGan/3ySVsGZLdsf65ntarfA6DNBjVQVanrCWH kg0w== 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=5OLBwOQ3QQLIUIuUB+gsPb/RudP25gD2RewRaRyDBYQ=; b=Ajfsojg28AgsKSyJD5qPzrVM5MnfXso32+SCWFIOTCK6uux3kiQvri5bnWuYF/su/a 7HdHaj7LbpDUHiEveJOy9cZq39NmUhycGLHGx5INCIwaLYXwY1U547idcLf/QYrsDQuI +SaPDCBapp53poC/Ww6Zz80WkcRNO+8keYdc7s5uN+1BgIDjV6bq4BmA3m0rODJV0i3s SIlcZ0q7xTuFIGoO3kASi84VtfWDmSc+S0siIhRPoFvzs6Vpf7ih6GMufF0mkFvJCgxv 97adbHoES+MHyeyms6OqM4nc9Z2KKUXpXO+k8+4tSId2qieuEhAAaNEoyyNl9+0w4vlc bauA== 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 a11-20020a65640b000000b0050be087ee08si28636397pgv.365.2023.03.28.07.46.27; Tue, 28 Mar 2023 07:46:40 -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 S233014AbjC1Ofe (ORCPT + 99 others); Tue, 28 Mar 2023 10:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233066AbjC1Of0 (ORCPT ); Tue, 28 Mar 2023 10:35:26 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD40FD311; Tue, 28 Mar 2023 07:35:19 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PmBzl2ZVtz4f3pCS; Tue, 28 Mar 2023 22:35:15 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R8X+yJkk4bgFg--.7384S6; Tue, 28 Mar 2023 22:35:16 +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 v2 2/3] scsi: introduce 'blocked' sysfs api Date: Tue, 28 Mar 2023 22:34:41 +0800 Message-Id: <20230328143442.2684167-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230328143442.2684167-1-yebin@huaweicloud.com> References: <20230328143442.2684167-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R8X+yJkk4bgFg--.7384S6 X-Coremail-Antispam: 1UD129KBjvJXoW7uw1kKw4DXF4UCFWUAw4Utwb_yoW5Jr1fpa 98Ga45KrWUGr1Ig3ZI9r45Wa43Ww48G347Jay7Ww1rZFWrJF9rtaykGa45XFyrJr4fWrsF qF4qqry5CFW8ZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUCVW8JwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUFD73DUUUU 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?1761623200362019054?= X-GMAIL-MSGID: =?utf-8?q?1761623200362019054?= From: Ye Bin Introduce 'blocked' sysfs api to control scsi host blocking IO. Use this founction for test. Perhaps we can use this to do some fault recovery or firmware upgrades, as long as the driver support is good, it may be insensitive to the upper layer. Signed-off-by: Ye Bin --- drivers/scsi/scsi_sysfs.c | 32 ++++++++++++++++++++++++++++++++ include/scsi/scsi_host.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 903aa9de46e5..cad1981ab528 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -345,6 +345,37 @@ store_shost_eh_deadline(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(eh_deadline, S_IRUGO | S_IWUSR, show_shost_eh_deadline, store_shost_eh_deadline); +static ssize_t +store_shost_blocked(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int err; + bool blocked; + struct Scsi_Host *shost = class_to_shost(dev); + + err = kstrtobool(buf, &blocked); + if (err) + return err; + + if (shost->host_blockio != blocked) { + shost->host_blockio = blocked; + if (!blocked) + scsi_run_host_queues(shost); + } + + return count; +} + +static ssize_t +show_shost_blocked(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct Scsi_Host *shost = class_to_shost(dev); + + return snprintf(buf, 20, "%d\n", shost->host_blockio); +} +static DEVICE_ATTR(blocked, S_IRUGO | S_IWUSR, + show_shost_blocked, store_shost_blocked); + shost_rd_attr(unique_id, "%u\n"); shost_rd_attr(cmd_per_lun, "%hd\n"); shost_rd_attr(can_queue, "%d\n"); @@ -397,6 +428,7 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { &dev_attr_host_reset.attr, &dev_attr_eh_deadline.attr, &dev_attr_nr_hw_queues.attr, + &dev_attr_blocked.attr, NULL }; diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 587cc767bb67..3e916dbac1cb 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -659,6 +659,9 @@ struct Scsi_Host { /* The transport requires the LUN bits NOT to be stored in CDB[1] */ unsigned no_scsi2_lun_in_cdb:1; + /* True host will blocking IO */ + unsigned host_blockio:1; + /* * Optional work queue to be utilized by the transport */ From patchwork Tue Mar 28 14:34:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 76114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2273717vqo; Tue, 28 Mar 2023 07:45:02 -0700 (PDT) X-Google-Smtp-Source: AKy350aWLW+FBCdCJZ4nzWUIpfEo47UHjWYOG2RzBVtLWDC7drccDAeTV0pWDSuS9+bc7YXhkwDA X-Received: by 2002:a17:902:e842:b0:19a:6acc:1de2 with SMTP id t2-20020a170902e84200b0019a6acc1de2mr20176967plg.35.1680014702113; Tue, 28 Mar 2023 07:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680014702; cv=none; d=google.com; s=arc-20160816; b=NUS5N4baW19RJ6hYG5vAKGA/5agsIWCPjeKhdv+mRrxSveFK+lGyX/cMGQj5sIW88M 3DbgFyDC2fatU266lKoCpl6V1FKh/f1GoPf1Eh1y05y0m2buwKT7qYitZEL4Kd/tSbvD 4TfQfeq+7J+Qgbv5Q1s5Dk6ICSwrXbTE0Vhs9jOOWWfamK1TsesDcocjTfqsqLLHw7IY 25+n5ZsH7Az4rNPHRjGMsFD7tQchHCtamCt8GTGTCwrUeMWzauOPzjH8LzeiDHtramRo q9Y8ne+QvZiilvGBZFANBc6VF4qHIpGB3nAA6LcAlT+fqyNdwaGmB8oE2etcS38/DyJ0 eP9A== 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=W/c5rDKGeISnado+zR0vxorbxcCUpcN5cXj1vsTsxe0=; b=pebnnHum/rq+sg1h/ywnT2MWpsfCo/ytfTWPR7H+rZbTyxVbB9dd9hvQMZeNePHFZa Wh9Km7PV/BGe/6g+caUN9DDDqKJdf3VUZnnMvHpSoHYGDD1xC+MlPldkta75HC+ZJsSD 5vEXdLEzf6JyWFsSWLccxyYKkBR7wtk/tTnISuhEz6QqjenEsFkMzHB5B0LjyCiM179t qieplI3u6QH62IJ1mtrbW3mW6EPNFCOmKNyRiwB3nJuxn/7a4O6TKC5kSSmOmWQxgNj5 9NVH4jecT9A29ZPEvColoo2nRdMbFVtg1C36exUSHfsm9yIndJOPVQTz+QCgbwgUyb8O gaRA== 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 q7-20020a170902dac700b001a217b21186si10366692plx.579.2023.03.28.07.44.50; Tue, 28 Mar 2023 07:45:02 -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 S233176AbjC1Ofp (ORCPT + 99 others); Tue, 28 Mar 2023 10:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjC1Of1 (ORCPT ); Tue, 28 Mar 2023 10:35:27 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B7AD32A; Tue, 28 Mar 2023 07:35:20 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PmBzm2Q7Xz4f3pCZ; Tue, 28 Mar 2023 22:35:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R8X+yJkk4bgFg--.7384S7; Tue, 28 Mar 2023 22:35:17 +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 v2 3/3] scsi: blocking IO when host is set blocked Date: Tue, 28 Mar 2023 22:34:42 +0800 Message-Id: <20230328143442.2684167-4-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230328143442.2684167-1-yebin@huaweicloud.com> References: <20230328143442.2684167-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgDn4R8X+yJkk4bgFg--.7384S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ur1ftw13JFyxZr18Jry7Jrb_yoW8Gry7pF Z0q34jkr48GF4xua98GF15XrySgaykGryDXFyxWwnxXFyUt34jqws8GFyjvFyrJr45Kr4D XF4DtFyYkr18XrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU7T5lUUUUU 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?1761623096757281338?= X-GMAIL-MSGID: =?utf-8?q?1761623096757281338?= From: Ye Bin As previous patch introduce 'blocked' sysfs api to set 'host_blockio'. If 'host_blockio' is true will blocking IO. Signed-off-by: Ye Bin --- drivers/scsi/scsi_lib.c | 2 ++ include/scsi/scsi_host.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b7c569a42aa4..20d618300a46 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1724,6 +1724,8 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, } ret = BLK_STS_RESOURCE; + if (unlikely(scsi_host_blocked(shost))) + goto out_put_budget; if (!scsi_target_queue_ready(shost, sdev)) goto out_put_budget; if (unlikely(scsi_host_in_recovery(shost))) { diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 3e916dbac1cb..9fc30d0c48de 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -747,6 +747,11 @@ static inline int scsi_host_in_recovery(struct Scsi_Host *shost) shost->tmf_in_progress; } +static inline int scsi_host_blocked(struct Scsi_Host *shost) +{ + return shost->host_blockio; +} + extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *); extern void scsi_flush_work(struct Scsi_Host *);