From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: linux-ide@vger.kernel.org, Igor Pylypiv <ipylypiv@google.com>,
Xingui Yang <yangxingui@huawei.com>,
John Garry <john.g.garry@oracle.com>
Subject: Re: [PATCH v3 2/2] ata: libata-scsi: avoid passthrough command starvation
Date: Wed, 31 Dec 2025 12:39:38 +0100 [thread overview]
Message-ID: <aVULegmRVY2O-TUC@ryzen> (raw)
In-Reply-To: <20251220002140.148854-3-dlemoal@kernel.org>
On Sat, Dec 20, 2025 at 09:21:40AM +0900, Damien Le Moal wrote:
> @@ -1702,6 +1779,17 @@ static int ata_scsi_defer(struct ata_port *ap, struct ata_queued_cmd *qc)
> if (!ret)
> return 0;
>
> + /*
> + * We must defer this qc: if this is not an NCQ command, keep this qc
> + * as a deferred one and wait for all on-going NCQ commands to complete
> + * before issuing it with the deferred qc work.
> + */
> + if (!ata_is_ncq(qc->tf.protocol)) {
> + ap->deferred_qc = qc;
> + return SCSI_MLQUEUE_DEVICE_BUSY;
Here you save the qc, and you return SCSI_MLQUEUE_DEVICE_BUSY;
SCSI_MLQUEUE_DEVICE_BUSY will cause the block layer to reinsert the request
in the queue, so you will get the same request sent to ata_scsi_translate()
again, even though you have save it. A little ugly IMO.
It seems like you are relying on the ata_scsi_qc_new() call will give you
the same *qc as the one you have stored...
> + }
> +
> + /* Use the SCSI layer to requeue and defer the command. */
> ata_qc_free(qc);
>
> switch (ret) {
> @@ -1777,8 +1865,11 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,
> goto done;
>
> rc = ata_scsi_defer(ap, qc);
> - if (rc)
> + if (rc) {
> + if (qc == ap->deferred_qc)
> + return 0;
...and then you have this code here, to do nothing in that case.
But, are we guaranteed that we will always get the same qc?
Have you tried this both with and without mq-deadline?
And on both ahci and libsas HBAs?
Because AFAICT, for AHCI with mq-deadline, I don't think that rq->tag will
be kept, so you will probably get another *qc.
This is apparently because when using mq-deadline, q->elevator is non-NULL:
https://github.com/torvalds/linux/blob/v6.19-rc3/block/blk-mq.c#L742-L745
Thus RQF_SCHED_TAGS will be set.
When RQF_SCHED_TAGS is set, the rq->tag is not kept during requeue:
https://github.com/torvalds/linux/blob/v6.19-rc3/block/blk-mq.c#L427-L433
Perhaps it does work (only) for libsas HBAs though, because:
https://github.com/torvalds/linux/blob/v6.19-rc3/drivers/ata/libata-scsi.c#L752-L762
in that case, it seems like the tag is taken from scsi_cmd->budget_token
rather than from rq->tag.
> return rc;
> + }
>
> ata_qc_issue(qc);
>
next prev parent reply other threads:[~2025-12-31 11:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-20 0:21 [PATCH v3 0/2] Prevent non-NCQ command starvation Damien Le Moal
2025-12-20 0:21 ` [PATCH v3 1/2] ata: libata-scsi: refactor ata_scsi_translate() Damien Le Moal
2025-12-22 21:19 ` Igor Pylypiv
2025-12-30 13:40 ` Niklas Cassel
2025-12-20 0:21 ` [PATCH v3 2/2] ata: libata-scsi: avoid passthrough command starvation Damien Le Moal
2025-12-22 21:28 ` Igor Pylypiv
2025-12-28 2:25 ` Damien Le Moal
2025-12-23 11:17 ` yangxingui
2025-12-31 11:17 ` Niklas Cassel
2026-01-02 0:47 ` Damien Le Moal
2026-01-02 10:24 ` Niklas Cassel
2026-01-02 11:00 ` Damien Le Moal
2025-12-31 11:39 ` Niklas Cassel [this message]
2026-01-02 1:10 ` Damien Le Moal
2026-01-02 9:46 ` Niklas Cassel
2026-01-02 11:01 ` Damien Le Moal
2025-12-31 10:04 ` [PATCH v3 0/2] Prevent non-NCQ " Niklas Cassel
2026-01-02 1:14 ` Damien Le Moal
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=aVULegmRVY2O-TUC@ryzen \
--to=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=ipylypiv@google.com \
--cc=john.g.garry@oracle.com \
--cc=linux-ide@vger.kernel.org \
--cc=yangxingui@huawei.com \
/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