Skip to contentSkip to conversation

scsi: core: move scsi_host_busy() out of host lock if it is for per-command

PATCH Applied Ming Lei 3 participants 3 messages Feb 3, 2024 – Feb 6, 2024 SCSI

lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 1/1 scsi: core: move scsi_host_busy() out of host lock if it is for per-command

Commit 4373534a9850 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler") is for fixing hard lockup issue triggered by EH.

The core idea is to move scsi_host_busy() out of host lock if it is called for per-command. However, the patch is merged as wrong and doesn't move scsi_host_busy() out of host lock, so fix it.

Fixes 4373534a9850 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler")
Cc Sathya Prakash Veerichetty <[email protected]>
Cc Bart Van Assche <[email protected]>
Cc Ewan D. Milne <[email protected]>
---
 drivers/scsi/scsi_error.c | 3 ++-
 drivers/scsi/scsi_lib.c   | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/scsi_error.c +2 -1
index 4f455884fdc4..612489afe8d2 100644
@@ -282,11 +282,12 @@ static void scsi_eh_inc_host_failed(struct rcu_head *head)
 {
 	struct scsi_cmnd *scmd = container_of(head, typeof(*scmd), rcu);
 	struct Scsi_Host *shost = scmd->device->host;
+	unsigned int busy = scsi_host_busy(shost);
 	unsigned long flags;
 
 	spin_lock_irqsave(shost->host_lock, flags);
 	shost->host_failed++;
-	scsi_eh_wakeup(shost, scsi_host_busy(shost));
+	scsi_eh_wakeup(shost, busy);
 	spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
drivers/scsi/scsi_lib.c +3 -1
index 1fb80eae9a63..df5ac03d5d6c 100644
@@ -278,9 +278,11 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 	rcu_read_lock();
 	__clear_bit(SCMD_STATE_INFLIGHT, &cmd->state);
 	if (unlikely(scsi_host_in_recovery(shost))) {
+		unsigned int busy = scsi_host_busy(shost);
+
 		spin_lock_irqsave(shost->host_lock, flags);
 		if (shost->host_failed || shost->host_eh_scheduled)
-			scsi_eh_wakeup(shost, scsi_host_busy(shost));
+			scsi_eh_wakeup(shost, busy);
 		spin_unlock_irqrestore(shost->host_lock, flags);
 	}
 	rcu_read_unlock();
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ming Lei

Commit 4373534a9850 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler") is for fixing hard lockup issue triggered by EH.

The core idea is to move scsi_host_busy() out of host lock if it is called for per-command. However, the patch is merged as wrong and

                                                ^^^^^^^^^^^^^^^

I'm not sure what this means?

Quoted 1 line

doesn't move scsi_host_busy() out of host lock, so fix it.

Anyway:

#2 lore raw
In reply to Ming Lei
Quoted 8 lines · Ming Lei

Commit 4373534a9850 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler") is for fixing hard lockup issue triggered by EH.

The core idea is to move scsi_host_busy() out of host lock if it is called for per-command. However, the patch is merged as wrong and doesn't move scsi_host_busy() out of host lock, so fix it.

[...]

Applied to 6.8/scsi-fixes, thanks!

[1/1] scsi: core: move scsi_host_busy() out of host lock if it is for per-command

      https://git.kernel.org/mkp/scsi/c/4e6c90119907
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering