Skip to content

Commit 4e6c901

Browse files
Ming Leimartinkpetersen
authored andcommitted
scsi: core: Move scsi_host_busy() out of host lock if it is for per-command
Commit 4373534 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler") intended to fix a hard lockup issue triggered by EH. The core idea was to move scsi_host_busy() out of the host lock when processing individual commands for EH. However, a suggested style change inadvertently caused scsi_host_busy() to remain under the host lock. Fix this by calling scsi_host_busy() outside the lock. Fixes: 4373534 ("scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler") Cc: Sathya Prakash Veerichetty <safhya.prakash@broadcom.com> Cc: Bart Van Assche <bvanassche@acm.org> Cc: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20240203024521.2006455-1-ming.lei@redhat.com Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent f4469f3 commit 4e6c901

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

drivers/scsi/scsi_error.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,12 @@ static void scsi_eh_inc_host_failed(struct rcu_head *head)
282282
{
283283
struct scsi_cmnd *scmd = container_of(head, typeof(*scmd), rcu);
284284
struct Scsi_Host *shost = scmd->device->host;
285+
unsigned int busy = scsi_host_busy(shost);
285286
unsigned long flags;
286287

287288
spin_lock_irqsave(shost->host_lock, flags);
288289
shost->host_failed++;
289-
scsi_eh_wakeup(shost, scsi_host_busy(shost));
290+
scsi_eh_wakeup(shost, busy);
290291
spin_unlock_irqrestore(shost->host_lock, flags);
291292
}
292293

drivers/scsi/scsi_lib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,11 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
278278
rcu_read_lock();
279279
__clear_bit(SCMD_STATE_INFLIGHT, &cmd->state);
280280
if (unlikely(scsi_host_in_recovery(shost))) {
281+
unsigned int busy = scsi_host_busy(shost);
282+
281283
spin_lock_irqsave(shost->host_lock, flags);
282284
if (shost->host_failed || shost->host_eh_scheduled)
283-
scsi_eh_wakeup(shost, scsi_host_busy(shost));
285+
scsi_eh_wakeup(shost, busy);
284286
spin_unlock_irqrestore(shost->host_lock, flags);
285287
}
286288
rcu_read_unlock();

0 commit comments

Comments
 (0)