Skip to contentSkip to conversation

ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush()

PATCH Applied [email protected] 2 participants 3 messages Oct 20 – Nov 2 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush()

From: Shao Mingyin <[email protected]>

ata_eh_maybe_retry_flush() validates link->active_tag with ata_tag_valid() before calling __ata_qc_from_tag(), which itself evaluates ata_tag_valid() on the same tag and returns NULL when the tag is invalid.

Since the NULL return value of __ata_qc_from_tag() is the single source of truth for tag validity, drop the redundant explicit ata_tag_valid() check and simply return early when qc is NULL. This mirrors the style already used in ata_eh_get_non_ncq_success_sense().

No functional change.

---
 drivers/ata/libata-eh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/libata-eh.c +2 -4
index c93c24b22d9c..bf3313175a97 100644
@@ -3571,11 +3571,9 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
 	unsigned int err_mask;
 	int rc = 0;
 
-	/* did flush fail for this device? */
-	if (!ata_tag_valid(link->active_tag))
-		return 0;
-
 	qc = __ata_qc_from_tag(ap, link->active_tag);
+	if (!qc)
+		return 0;
 	if (qc->dev != dev || (qc->tf.command != ATA_CMD_FLUSH_EXT &&
 			       qc->tf.command != ATA_CMD_FLUSH))
 		return 0;
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 39 lines · On Tue, Oct 20, 2026 at 04:01:01PM +0800, [email protected] wrote:

From: Shao Mingyin <[email protected]>

ata_eh_maybe_retry_flush() validates link->active_tag with ata_tag_valid() before calling __ata_qc_from_tag(), which itself evaluates ata_tag_valid() on the same tag and returns NULL when the tag is invalid.

Since the NULL return value of __ata_qc_from_tag() is the single source of truth for tag validity, drop the redundant explicit ata_tag_valid() check and simply return early when qc is NULL. This mirrors the style already used in ata_eh_get_non_ncq_success_sense().

No functional change.

---
 drivers/ata/libata-eh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/libata-eh.c +2 -4
index c93c24b22d9c..bf3313175a97 100644
@@ -3571,11 +3571,9 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
 	unsigned int err_mask;
 	int rc = 0;
 
-	/* did flush fail for this device? */
-	if (!ata_tag_valid(link->active_tag))
-		return 0;
-
 	qc = __ata_qc_from_tag(ap, link->active_tag);
+	if (!qc)
+		return 0;
 	if (qc->dev != dev || (qc->tf.command != ATA_CMD_FLUSH_EXT &&
 			       qc->tf.command != ATA_CMD_FLUSH))
 		return 0;
Signature · 1 line
2.27.0

We are in the middle of the merge window, and since this is not fixing an actual problem, I expect this to be queued on for-7.5 once 7.4-rc1 is out:

maintainer Applied
#2 lore raw
In reply to [email protected]
Quoted 10 lines · On Tue, 20 Oct 2026 16:01:01 +0800, [email protected] wrote:

ata_eh_maybe_retry_flush() validates link->active_tag with ata_tag_valid() before calling __ata_qc_from_tag(), which itself evaluates ata_tag_valid() on the same tag and returns NULL when the tag is invalid.

Since the NULL return value of __ata_qc_from_tag() is the single source of truth for tag validity, drop the redundant explicit ata_tag_valid() check and simply return early when qc is NULL. This mirrors the style already used in ata_eh_get_non_ncq_success_sense().

[...]

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

[1/1] ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush()

      https://git.kernel.org/libata/linux/c/267accfa

Kind regards,
Niklas