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: 668512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BCD7C76196 for ; Tue, 28 Mar 2023 14:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232457AbjC1Ofa (ORCPT ); Tue, 28 Mar 2023 10:35:30 -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: <20230328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I42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUFD73DUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 */