mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush()
@ 2026-10-20  8:01 shao.mingyin
  2026-10-20  9:22 ` Niklas Cassel
  0 siblings, 1 reply; 2+ messages in thread
From: shao.mingyin @ 2026-10-20  8:01 UTC (permalink / raw)
  To: linux-ide, dlemoal, cassel; +Cc: linux-kernel, yang.tao172, zhang.yue5

From: Shao Mingyin <shao.mingyin@zte.com.cn>

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.

Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Yang Tao <yang.tao172@zte.com.cn>
---
 drivers/ata/libata-eh.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index c93c24b22d9c..bf3313175a97 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -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;
-- 
2.27.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush()
  2026-10-20  8:01 [PATCH] ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush() shao.mingyin
@ 2026-10-20  9:22 ` Niklas Cassel
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Cassel @ 2026-10-20  9:22 UTC (permalink / raw)
  To: shao.mingyin; +Cc: linux-ide, dlemoal, linux-kernel, yang.tao172, zhang.yue5

On Tue, Oct 20, 2026 at 04:01:01PM +0800, shao.mingyin@zte.com.cn wrote:
> From: Shao Mingyin <shao.mingyin@zte.com.cn>
> 
> 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.
> 
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> Signed-off-by: Yang Tao <yang.tao172@zte.com.cn>
> ---
>  drivers/ata/libata-eh.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index c93c24b22d9c..bf3313175a97 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -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;
> -- 
> 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:

Reviewed-by: Niklas Cassel <cassel@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-20  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20  8:01 [PATCH] ata: libata-eh: drop redundant ata_tag_valid() check in ata_eh_maybe_retry_flush() shao.mingyin
2026-10-20  9:22 ` Niklas Cassel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®