Skip to contentSkip to conversation

ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands

PATCH Applied Igor Pylypiv 3 participants 3 messages Apr 12 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands

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.

Fixes 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")

---

Changes from v1:
- Dropped the usage of set_host_byte() because it is logically a separate change from what this commit is fixing. set_host_byte() does not clear the status byte and the ML byte.

 drivers/ata/libata-scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-scsi.c +2 -2
index 3b65df914ebb..cd607911d724 100644
@@ -1692,7 +1692,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
 	/*
 	 * If we have a deferred qc when a reset occurs or NCQ commands fail,
 	 * do not try to be smart about what to do with this deferred command
-	 * and simply retry it by completing it with DID_SOFT_ERROR.
+	 * and simply requeue it by completing it with DID_REQUEUE.
 	 */
 	if (!qc)
 		return;
@@ -1701,7 +1701,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
 	ap->deferred_qc = NULL;
 	cancel_work(&ap->deferred_qc_work);
 	ata_qc_free(qc);
-	scmd->result = (DID_SOFT_ERROR << 16);
+	scmd->result = (DID_REQUEUE << 16);
 	scsi_done(scmd);
 }
 
Signature · 1 line
2.53.0.1213.gd9a14994de-goog
#1 lore raw
Quoted 31 lines · Igor Pylypiv

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.

Fixes 0ea84089dbf6 ("ata: libata-scsi: avoid Non-NCQ command starvation")

---

Changes from v1:
- Dropped the usage of set_host_byte() because it is logically a separate change from what this commit is fixing. set_host_byte() does not clear the status byte and the ML byte.

 drivers/ata/libata-scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/libata-scsi.c +0 -0
index 3b65df914ebb..cd607911d724 100644

[...]

drivers/ata/libata-scsi.c void ata_scsi_requeue_deferred_qc(struct ata_port *ap) · line 1704

Quoted 6 lines
drivers/ata/libata-scsi.c +1 -1
@@ -1701,7 +1701,7 @@ void ata_scsi_requeue_deferred_qc(struct ata_port *ap)
 	ap->deferred_qc = NULL;
 	cancel_work(&ap->deferred_qc_work);
 	ata_qc_free(qc);
-	scmd->result = (DID_SOFT_ERROR << 16);
+	scmd->result = (DID_REQUEUE << 16);

You could drop the useless parens, while at it...

drivers/ata/libata-scsi.c void ata_scsi_requeue_deferred_qc(struct ata_port *ap) · line 1707

Quoted 3 lines
drivers/ata/libata-scsi.c +0 -0
 	scsi_done(scmd);
 }
 

MBR, Sergey

maintainer Applied
#2 lore raw
In reply to Igor Pylypiv
Quoted 5 lines · Igor Pylypiv

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.

Quoted 7 lines

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.

[...]

Hello Igor,

Considering that Linus is expected for release 7.0 any minute now (it is already Sunday afternoon), it seems too late to send this as a PR for 7.0.

The fix will have to be backported to v7.0 stable instead.

Therefore, I rebased your patch on libata/for-next (without any parens - the comment from Sergey).

Applied to libata/linux.git (for-7.1), thanks!

[1/1] ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands

      https://git.kernel.org/libata/linux/c/8ebf408e

Kind regards,
Niklas