Re: [PATCH] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands

From: Damien Le Moal

Date: Sun Apr 12 2026 - 03:06:57 EST


On 4/11/26 01:15, Igor Pylypiv wrote:
> Commit 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
> introduced ata_scsi_requeue_deferred_qc() to handle commands deferred
> during resets or NCQ failures. This deferral logic completed commands
> with DID_SOFT_ERROR to trigger a retry in the SCSI mid-layer.
>
> However, DID_SOFT_ERROR is subject to scsi_cmd_retry_allowed() checks.
> ATA PASS-THROUGH commands sent via SG_IO ioctl have scmd->allowed set
> to zero. This causes the mid-layer to fail the command immediately
> instead of retrying, even though the command was never actually issued
> to the hardware.
>
> Switch to DID_REQUEUE to ensure these commands are inserted back into
> the request queue regardless of retry limits.

I really thought that DID_SOFT_ERROR was not decrementing the retry counter.
Checking the code again, I was wrong. Good catch !

> Fixes: 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")
> Signed-off-by: Igor Pylypiv <ipylypiv@xxxxxxxxxx>

Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>


--
Damien Le Moal
Western Digital Research