public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Hannes Reinecke <hare@suse.de>,
	John Garry <john.garry@huawei.com>,
	Bart Van Assche <bvanassche@acm.org>,
	axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com,
	brking@us.ibm.com, hch@lst.de
Cc: linux-block@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	chenxiang66@hisilicon.com
Subject: Re: [PATCH RFC v2 03/18] scsi: core: Implement reserved command handling
Date: Mon, 20 Jun 2022 18:02:30 +0900	[thread overview]
Message-ID: <9de5ed1b-e874-28ac-0532-cd5420892064@opensource.wdc.com> (raw)
In-Reply-To: <7b046321-fdb3-33f0-94a0-78a25cbbe02e@suse.de>

On 6/20/22 17:27, Hannes Reinecke wrote:
> On 6/16/22 10:41, Damien Le Moal wrote:
>> On 2022/06/16 17:24, John Garry wrote:
>>> On 16/06/2022 03:47, Damien Le Moal wrote:
>>>>>> so going backward several years... That internal tag for ATA does not
>>>>>> need to be reserved since this command is always used when the drive is
>>>>>> idle and no other NCQ commands are on-going.
>>>>>
>>>>> So do you mean that ATA_TAG_INTERNAL qc is used for other commands
>>>>> apart from internal commands?
>>>>
>>>> No. It is used only for internal commands. What I meant to say is that
>>>> currently, internal commands are issued only on device scan, device
>>>> revalidate and error handling. All of these phases are done with the
>>>> device under EH with the issuing path stopped and all commands
>>>> completed,
>>>
>>> If I want to allocate a request for an ATA internal command then could I
>>> use 1x from the regular tags? I didn't think that this was possible as I
>>> thought that all tags may be outstanding when EH kicks in. I need to
>>> double check it.
>>
>> When EH kicks in, the drive is in error mode and all commands are back to the
>> host. From there, you need to get the drive out of error mode with read log 10h
>> and then internal commands can be issued if needed. Then the aborted commands
>> that are not in error are restarted.
>>
>> For the non-error case (revalidate), ap->ops->qc_defer() will make sure that NCQ
>> and non-NCQ commands are never mixed. Since all internal commands are non-ncq,
>> when an internal command is issued, there are necessarily no other commands
>> ongoing, but 32 NCQ commands may be waiting, without any free tag. The internal
>> command being non-NCQ can still proceed since it does not need a real device tag.
>>
>> The joy of ATA...
>>
>>> Even if it were true, not using a reserved tag for ATA internal command
>>> makes things more tricky as this command requires special handling for
>>> scsi blk_mq_ops and there is no easy way to identify the command as
>>> reserved (to know special handling is required).
>>
>> Yes. Having the ATA_TAG_INTERNAL tag as a reserved tag is fine. But from the
>> above, you can see that this is not really needed at all to make things work.
>> The management of ATA_TAG_INTERNAL as a reserve tag is really about getting your
>> API to simplify the code.
>>
>> What I am thinking is that with your patches as is, it seems that we can never
>> actually reserve a real tag for ATA to do internal NCQ commands... We do not
>> really need that for now though, apart maybe for speeding up device revalidate.
>> Everytime that one runs, one can see a big spike in read/write IO latencies
>> because of the queue drain it causes.
>>
> Hmm. But doesn't that mean the we can reserve one tag, _and_ set the 
> queue depth to '32'?
> We'll need to fiddle with the tag map on completion (cf my previous 
> mail), but then we might need to do that anyway if we separate out 
> ATA_QCFLAG_INTERNAL ...

Reserving a tag is not enough. As explained, even if I can get a tag for a
qc, I need a proper req to safely issue an ncq command (because of the
potential need to delay and requeue even if we have a free tag !).

So reserving a tag/req to be able to do NCQ at the cost of max qd being 31
works for that. We could keep max qd at 32 by creating one more "fake" tag
and having a request for it, that is, having the fake tag visible to the
block layer as a reserved tag, as John's series is doing, but for the
reserved tags, we actually need to use an effective tag (qc->hw_tag) when
issuing the commands. And for that, we can reuse the tag of one of the
failed commands.

> 
> Cheers,
> 
> Hannes


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2022-06-20  9:02 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 10:29 [PATCH RFC v2 00/18] blk-mq/libata/scsi: SCSI driver tagging improvements John Garry
2022-06-09 10:29 ` [PATCH RFC v2 01/18] blk-mq: Add a flag for reserved requests John Garry
2022-06-14  6:43   ` Christoph Hellwig
2022-06-14  9:29     ` John Garry
2022-06-14 18:00   ` Bart Van Assche
2022-06-14 18:30     ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 02/18] scsi: core: Resurrect scsi_{get,free}_host_dev() John Garry
2022-06-14  6:44   ` Christoph Hellwig
2022-06-14  9:33     ` John Garry
2022-06-14 19:33   ` Bart Van Assche
2022-06-15 13:44     ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 03/18] scsi: core: Implement reserved command handling John Garry
2022-06-13  7:01   ` Damien Le Moal
2022-06-13  8:25     ` John Garry
2022-06-13  9:06       ` Damien Le Moal
2022-06-13  9:34         ` John Garry
2022-06-13  9:43           ` Damien Le Moal
2022-06-13 10:05             ` John Garry
2022-06-20  6:45         ` Hannes Reinecke
2022-06-20  7:06           ` Damien Le Moal
2022-06-14 18:20     ` Bart Van Assche
2022-06-14 23:43       ` Damien Le Moal
2022-06-15  7:35         ` John Garry
2022-06-16  2:47           ` Damien Le Moal
2022-06-16  8:24             ` John Garry
2022-06-16  8:41               ` Damien Le Moal
2022-06-20  8:27                 ` Hannes Reinecke
2022-06-20  9:02                   ` Damien Le Moal [this message]
2022-06-20  9:05                     ` Christoph Hellwig
2022-06-20 11:24                       ` Damien Le Moal
2022-06-20 11:56                         ` Hannes Reinecke
2022-06-20  8:02           ` Hannes Reinecke
2022-06-20  6:24     ` Hannes Reinecke
2022-06-20  6:28       ` Christoph Hellwig
2022-06-20  7:03         ` Hannes Reinecke
2022-06-20  7:14           ` Damien Le Moal
2022-06-09 10:29 ` [PATCH RFC v2 04/18] scsi: core: Add support to send reserved commands John Garry
2022-06-13  7:03   ` Damien Le Moal
2022-06-13  9:40     ` John Garry
2022-06-13  9:41       ` Damien Le Moal
2022-06-09 10:29 ` [PATCH RFC v2 05/18] scsi: core: Allocate SCSI host sdev when required John Garry
2022-06-09 10:29 ` [PATCH RFC v2 06/18] libata-scsi: Add ata_scsi_queue_internal() John Garry
2022-06-13  7:12   ` Damien Le Moal
2022-06-13  9:41     ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 07/18] libata-scsi: Add ata_internal_queuecommand() John Garry
2022-06-13  7:16   ` Damien Le Moal
2022-06-13  9:44     ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 08/18] libata: Queue ATA internal commands as requests John Garry
2022-06-13  7:22   ` Damien Le Moal
2022-06-13  8:13     ` John Garry
2022-06-09 10:29 ` [PATCH RFC v2 09/18] scsi: ipr: Support reserved commands John Garry
2022-06-09 10:29 ` [PATCH RFC v2 10/18] libata/scsi: libsas: Add sas_queuecommand_internal() John Garry
2022-06-09 10:29 ` [PATCH RFC v2 11/18] scsi: libsas: Don't attempt to find scsi host rphy in slave alloc John Garry
2022-06-09 10:29 ` [PATCH RFC v2 12/18] scsi: libsas drivers: Prepare for reserved commands John Garry
2022-06-09 10:29 ` [PATCH RFC v2 13/18] scsi: libsas: Allocate SCSI commands for tasks John Garry
2022-06-09 10:29 ` [PATCH RFC v2 14/18] scsi: libsas: Queue SMP commands as requests John Garry
2022-06-09 10:29 ` [PATCH RFC v2 15/18] scsi: libsas: Queue TMF " John Garry
2022-06-09 10:29 ` [PATCH RFC v2 16/18] scsi: core: Add scsi_alloc_request_hwq() John Garry
2022-06-09 10:29 ` [PATCH RFC v2 17/18] scsi: libsas: Queue internal abort commands as requests John Garry
2022-06-09 10:29 ` [PATCH RFC v2 18/18] scsi: libsas drivers: Remove private tag management John Garry

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=9de5ed1b-e874-28ac-0532-cd5420892064@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=axboe@kernel.dk \
    --cc=brking@us.ibm.com \
    --cc=bvanassche@acm.org \
    --cc=chenxiang66@hisilicon.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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