From: Bart Van Assche <bvanassche@acm.org>
To: Ye Bin <yebin@huaweicloud.com>,
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: Re: [PATCH 3/5] scsi: limit to set the host state
Date: Mon, 27 Mar 2023 14:25:34 -0700 [thread overview]
Message-ID: <50fa480e-4c0e-70f2-5185-1d83df9f9e13@acm.org> (raw)
In-Reply-To: <20230325011734.507453-4-yebin@huaweicloud.com>
On 3/24/23 18:17, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> Now, we can set the host state with any value. Actually, it doesn't
> make sense. As previous patch introduce SHOST_BLOCKED state, set this
> state, it will blocking IO. So this patch limit to set the host with
> running/blocked state.
>
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
> drivers/scsi/scsi_sysfs.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index b14f95ac594e..42c5936c7711 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -203,6 +203,7 @@ store_shost_state(struct device *dev, struct device_attribute *attr,
> int i;
> struct Scsi_Host *shost = class_to_shost(dev);
> enum scsi_host_state state = 0;
> + enum scsi_host_state old_state;
> unsigned long flags;
>
> for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
> @@ -216,8 +217,13 @@ store_shost_state(struct device *dev, struct device_attribute *attr,
> if (!state)
> return -EINVAL;
>
> + if (state != SHOST_RUNNING && state != SHOST_BLOCKED)
> + return -EINVAL;
> +
> spin_lock_irqsave(shost->host_lock, flags);
> - if (scsi_host_set_state(shost, state)) {
> + old_state = shost->shost_state;
> + if ((old_state != SHOST_RUNNING && old_state != SHOST_BLOCKED) ||
> + scsi_host_set_state(shost, state)) {
> spin_unlock_irqrestore(shost->host_lock, flags);
> return -EINVAL;
> }
Please make sure that the "state != SHOST_RUNNING && state !=
SHOST_BLOCKED" check occurs only once and also that there is one
spin_lock_irqsave() call in this function and only one
spin_unlock_irqrestore() call.
Thanks,
Bart.
next prev parent reply other threads:[~2023-03-27 21:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-25 1:17 [PATCH 0/5] limit set the host state by sysfs Ye Bin
2023-03-25 1:17 ` [PATCH 1/5] scsi: fix switch host state race between by sysfs and others Ye Bin
2023-03-27 21:26 ` Bart Van Assche
2023-03-25 1:17 ` [PATCH 2/5] scsi: introduce SHOST_BLOCKED state to support blocking IO Ye Bin
2023-03-27 21:34 ` Bart Van Assche
2023-03-25 1:17 ` [PATCH 3/5] scsi: limit to set the host state Ye Bin
2023-03-27 21:25 ` Bart Van Assche [this message]
2023-03-25 1:17 ` [PATCH 4/5] scsi: blocking IO when host is blocked Ye Bin
2023-03-27 21:37 ` Bart Van Assche
2023-03-25 1:17 ` [PATCH 5/5] scsi: run queue after set host state from blocked to running Ye Bin
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=50fa480e-4c0e-70f2-5185-1d83df9f9e13@acm.org \
--to=bvanassche@acm.org \
--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 \
--cc=yebin@huaweicloud.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
all inboxes | Powered by JetHome®