public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Ye Bin <yebin@huaweicloud.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ye Bin <yebin10@huawei.com>
Subject: [PATCH v2 1/3] scsi: forbid to set scsi host state by sysfs
Date: Tue, 28 Mar 2023 22:34:40 +0800	[thread overview]
Message-ID: <20230328143442.2684167-2-yebin@huaweicloud.com> (raw)
In-Reply-To: <20230328143442.2684167-1-yebin@huaweicloud.com>

From: Ye Bin <yebin10@huawei.com>

Actually, set scsi host state by sysfs may lead to functional issues.
So forbid to set scsi host state.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 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)
-- 
2.31.1


  reply	other threads:[~2023-03-28 14:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 14:34 [PATCH v2 0/3] limit set the host state by sysfs Ye Bin
2023-03-28 14:34 ` Ye Bin [this message]
2023-03-28 14:34 ` [PATCH v2 2/3] scsi: introduce 'blocked' sysfs api Ye Bin
2023-03-28 16:06   ` Mike Christie
2023-03-28 14:34 ` [PATCH v2 3/3] scsi: blocking IO when host is set blocked Ye Bin
2023-03-28 15:56   ` Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230328143442.2684167-2-yebin@huaweicloud.com \
    --to=yebin@huaweicloud.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yebin10@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox