scsi: libsas: terminate deferred commands on time out
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 9 Jul 2026 07:02:23 +0000 (16:02 +0900)
committerDamien Le Moal <dlemoal@kernel.org>
Wed, 29 Jul 2026 01:52:04 +0000 (10:52 +0900)
commitde202d2251bc181c6019b1ad3c0ba8133e5ec68d
tree3a9c64d62cb2764bfb20fb883345d81a5c9e0f59
parente7468b3f9b404ac7c1329ef07c146c3356dfbd01
scsi: libsas: terminate deferred commands on time out

If a command times out while we have deferred non-NCQ commands waiting to
be issued, the SCSI EH task is not immediately woken up as the waiting
deferred commands are never issued nor completed, thus leaving the SCSI
host in a busy state (shost->host_failed != scsi_host_busy(shost)) which
prevents the SCSI EH task from being woken up. Eventually, when the
deferred commands also time out, the SCSI EH task is woken up and the
timeout processing occurs.

Avoid this unnecessary additional SCSI EH wake up time with the same
method as implemented in libata-scsi, using the eh_timed_out SCSI host
template operation. The function sas_eh_timed_out() implements this
operation and executes the function ata_scsi_retry_deferred_qc()
for SATA devices.

Co-developed-by: Igor Pylypiv <ipylypiv@google.com>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Fixes: 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Tested-by: Igor Pylypiv <ipylypiv@google.com>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ata/libata-scsi.c
drivers/scsi/libsas/sas_scsi_host.c
include/linux/libata.h
include/scsi/libsas.h