[4/5] scsi: blocking IO when host is blocked
Commit Message
From: Ye Bin <yebin10@huawei.com>
Unlike recovery state may block other process, blocking IO only
when host is blocked.
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
drivers/scsi/scsi_lib.c | 4 ++++
include/scsi/scsi_host.h | 5 +++++
2 files changed, 9 insertions(+)
Comments
On 3/24/23 18:17, Ye Bin wrote:
> + if (unlikely(scsi_host_blocked(shost)))
> + goto out_dec_target_busy;
I this check would be moved earlier then the atomic_inc() and
atomic_dec() of scsi_target(sdev)->target_busy could be skipped.
Thanks,
Bart.
@@ -1731,6 +1731,10 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
ret = BLK_STS_OFFLINE;
goto out_dec_target_busy;
}
+
+ if (unlikely(scsi_host_blocked(shost)))
+ goto out_dec_target_busy;
+
if (!scsi_host_queue_ready(q, shost, sdev, cmd))
goto out_dec_target_busy;
@@ -745,6 +745,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->shost_state == SHOST_BLOCKED;
+}
+
extern int scsi_queue_work(struct Scsi_Host *, struct work_struct *);
extern void scsi_flush_work(struct Scsi_Host *);