From: Damien Le Moal <dlemoal@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, cassel@kernel.org
Subject: Re: [PATCH v2 1/2] ata: libata-scsi: terminate deferred commands on time out
Date: Fri, 10 Jul 2026 16:25:38 +0900 [thread overview]
Message-ID: <724b4a01-e396-4cc0-be2a-9860f42d803f@kernel.org> (raw)
In-Reply-To: <20260710002431.3148D1F000E9@smtp.kernel.org>
On 7/10/26 09:24, sashiko-bot@kernel.org wrote:
>> @@ -1694,16 +1695,19 @@ 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 requeue it by completing it with DID_REQUEUE.
>> + * and simply requeue it by completing it with DID_REQUEUE. The
>> + * exception here is if the deferred qc timed out, in which case, we
>> + * leave it as is as ata_scsi_cmd_error_handler() will take care of it.
>> */
>> ata_for_each_link(link, ap, PMP_FIRST) {
>> struct ata_queued_cmd *qc = link->deferred_qc;
>>
>> - if (qc) {
>> - link->deferred_qc = NULL;
>> - cancel_work(&link->deferred_qc_work);
>> - ata_scsi_qc_done(qc, true, DID_REQUEUE << 16);
>> - }
>> + if (!qc || qc->scsicmd == timed_out_scmd)
>> + continue;
>> +
>> + link->deferred_qc = NULL;
>> + cancel_work(&link->deferred_qc_work);
>> + ata_scsi_qc_done(qc, true, DID_REQUEUE << 16);
>
> [Severity: Critical]
> This is a pre-existing issue, but won't the explicit invocation of this
> requeue logic on every command timeout make a regression more likely?
Maybe. But that race exists since eons ago. And command timeouts are rare, so I
do not consider this to be "critical" at all.
>> +static enum scsi_timeout_action
>> +ata_scsi_port_eh_timed_out(struct ata_port *ap, struct scsi_cmnd *scmd)
>> +{
>> + unsigned long flags;
>> +
>> + /*
>> + * We had a timeout, either for an NCQ command or for one deferred
>> + * queued command. If we have deferred QCs and we do not release them
>> + * immediately, we will have shost->host_failed != scsi_host_busy()
>> + * until the deferred QCs also timeout. This unnecessarilly increases
>> + * the time it takes for scsi EH to start. Terminate all deferred QCs
>> + * to avoid that.
>> + */
>> + spin_lock_irqsave(ap->lock, flags);
>> + ata_scsi_requeue_deferred_qc(ap, scmd);
>> + spin_unlock_irqrestore(ap->lock, flags);
>
> [Severity: High]
> Does this function need to set ATA_PFLAG_EH_PENDING?
>
> Because this flag is not set, ata_port_eh_scheduled() will evaluate to
> false. This allows the block layer to immediately retry the requeued
> commands, which __ata_scsi_queuecmd() will accept and re-defer, keeping
> the host busy.
No it will not because this is called with SCSI EH already waiting to run, so
newly incoming commands are not passed down by the scsi layer.
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-07-10 7:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 0:06 [PATCH v2 0/2] fixup handling of timeouts with deferred QCs Damien Le Moal
2026-07-10 0:06 ` [PATCH v2 1/2] ata: libata-scsi: terminate deferred commands on time out Damien Le Moal
2026-07-10 0:24 ` sashiko-bot
2026-07-10 7:25 ` Damien Le Moal [this message]
2026-07-10 8:06 ` Niklas Cassel
2026-07-10 8:29 ` Damien Le Moal
2026-07-10 8:48 ` Niklas Cassel
2026-07-10 8:39 ` Niklas Cassel
2026-07-10 7:32 ` Niklas Cassel
2026-07-10 0:06 ` [PATCH v2 2/2] scsi: libsas: " Damien Le Moal
2026-07-10 1:53 ` Jason Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=724b4a01-e396-4cc0-be2a-9860f42d803f@kernel.org \
--to=dlemoal@kernel.org \
--cc=cassel@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox