All of lore.kernel.org
 help / color / mirror / Atom feed
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: Fri, 2 Jan 2026 10:46:31 +0100	[thread overview]
Message-ID: <aVeT9_ZK1NtUXMCT@ryzen> (raw)
In-Reply-To: <0b9fb4a6-db2d-488d-a486-74c67709b3a2@kernel.org>

On Fri, Jan 02, 2026 at 10:10:44AM +0900, Damien Le Moal wrote:
> On 12/31/25 20:39, Niklas Cassel wrote:
> > 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.
> 
> No it will not cause a requeue in this case because this change:
> 
>  	rc = ata_scsi_defer(ap, qc);
> -	if (rc)
> +	if (rc) {
> +		if (qc == ap->deferred_qc)
> +			return 0;
> 
> ensures that we return "0", thus telling the scsi and block layer that the
> command/request was accepted, but we do *not* call ata_qc_issue() for that qc.
> It is deferred and will be issued by the deferred qc work once the queue drains.

I see how I got confused.

In the case where we store the deferred QC, you overload the return value.
But the original return value did not make sense (SCSI_MLQUEUE_DEVICE_BUSY),
as it means ask upper layer to requeue. I suggest that you let ata_scsi_defer()
return some other value in this case.

ATA_DEFER_ACTION_CMD_STORED or something.

Then at the call site:

	rc = ata_scsi_defer(ap, qc);
	if (rc) {
		if (rc == ATA_DEFER_ACTION_CMD_STORED)
			return 0;
		return rc;
	}


Kind regards,
Niklas

  reply	other threads:[~2026-01-02  9:46 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
2026-01-02  1:10     ` Damien Le Moal
2026-01-02  9:46       ` Niklas Cassel [this message]
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=aVeT9_ZK1NtUXMCT@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.