[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ztjs4vMNJsJ6_ZtS@google.com>
Date: Wed, 4 Sep 2024 23:27:30 +0000
From: Igor Pylypiv <ipylypiv@...gle.com>
To: Damien Le Moal <dlemoal@...nel.org>, Niklas Cassel <cassel@...nel.org>
Cc: "Martin K. Petersen" <martin.petersen@...cle.com>,
Hannes Reinecke <hare@...e.de>, linux-ide@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ata: libata-eh: Clear scsicmd->result when setting
SAM_STAT_CHECK_CONDITION
On Wed, Sep 04, 2024 at 10:37:27PM +0000, Igor Pylypiv wrote:
> commit 24aeebbf8ea9 ("scsi: ata: libata: Change ata_eh_request_sense() to
> not set CHECK_CONDITION") changed the way how SAM_STAT_CHECK_CONDITION is
> set. Assignment "scmd->result = SAM_STAT_CHECK_CONDITION;" was replaced by
> set_status_byte() which does not clear the scsicmd->result.
>
> By not clearing the scsicmd->result we end up in a state where both
> the DID_TIME_OUT host byte and the SAM_STAT_CHECK_CONDITION status
> bytes are set.
>
> The DID_TIME_OUT host byte is getting set a part of error handling:
>
> ata_qc_complete()
> ata_qc_schedule_eh()
> blk_abort_request()
> WRITE_ONCE(req->deadline, jiffies);
>
> blk_mq_timeout_work()
> blk_mq_check_expired()
> blk_mq_rq_timed_out()
> req->q->mq_ops->timeout() / scsi_timeout()
> set_host_byte(scmd, DID_TIME_OUT);
>
> Having the host byte set to DID_TIME_OUT for a command that didn't timeout
> is confusing. Let's bring the old behavior back by setting scmd->result to
> SAM_STAT_CHECK_CONDITION.
>
> Fixes: 24aeebbf8ea9 ("scsi: ata: libata: Change ata_eh_request_sense() to not set CHECK_CONDITION")
> Signed-off-by: Igor Pylypiv <ipylypiv@...gle.com>
> ---
> drivers/ata/libata-eh.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 214b935c2ced..4927b40e782f 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -1605,7 +1605,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc)
> */
> if (!(qc->flags & ATA_QCFLAG_SENSE_VALID) &&
> (stat & ATA_SENSE) && ata_eh_request_sense(qc))
> - set_status_byte(qc->scsicmd, SAM_STAT_CHECK_CONDITION);
> + qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
Just realized that this needs a comment "/* Clear the host byte. */" to
prevent someone from changing it back to set_status_byte() in the future.
I'll add the comment in v2.
> if (err & ATA_ICRC)
> qc->err_mask |= AC_ERR_ATA_BUS;
> if (err & (ATA_UNC | ATA_AMNF))
> --
> 2.46.0.469.g59c65b2a67-goog
>
Powered by blists - more mailing lists