diff mbox series

[v2,3/3] scsi: blocking IO when host is set blocked

Message ID 20230328143442.2684167-4-yebin@huaweicloud.com (mailing list archive)
State Changes Requested
Headers show
Series limit set the host state by sysfs | expand

Commit Message

Ye Bin March 28, 2023, 2:34 p.m. UTC
From: Ye Bin <yebin10@huawei.com>

As previous patch introduce 'blocked' sysfs api to set 'host_blockio'.
If 'host_blockio' is true will blocking IO.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/scsi/scsi_lib.c  | 2 ++
 include/scsi/scsi_host.h | 5 +++++
 2 files changed, 7 insertions(+)

Comments

Mike Christie March 28, 2023, 3:56 p.m. UTC | #1
On 3/28/23 9:34 AM, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
> 
> As previous patch introduce 'blocked' sysfs api to set 'host_blockio'.
> If 'host_blockio' is true will blocking IO.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
>  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;

You can just put this check in scsi_host_queue_ready with the
host_self_blocked check.
diff mbox series

Patch

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 *);