linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Garry <john.garry@huawei.com>
To: Hannes Reinecke <hare@suse.de>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	Bart van Assche <bvanassche@acm.org>,
	Don Brace <don.brace@microchip.com>, <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 13/21] scsi: implement reserved command handling
Date: Wed, 8 Jul 2020 10:39:19 +0100	[thread overview]
Message-ID: <b03c1256-8255-5e7f-dda3-df036aaef812@huawei.com> (raw)
In-Reply-To: <20200703130122.111448-14-hare@suse.de>

On 03/07/2020 14:01, Hannes Reinecke wrote:
> Quite some drivers are using management commands internally, which
> typically use the same hardware tag pool (ie they are being allocated
> from the same hardware resources) as the 'normal' I/O commands.
> These commands are set aside before allocating the block-mq tag bitmap,
> so they'll never show up as busy in the tag map.
> The block-layer, OTOH, already has 'reserved_tags' to handle precisely
> this situation.
> So this patch adds a new field 'nr_reserved_cmds' to the SCSI host
> template to instruct the block layer to set aside a tag space for these
> management commands by using reserved tags.
> 

Apart from (a good few) comments:

Reviewed-by: John Garry <john.garry@huawei.com>

> Signed-off-by: Hannes Reinecke <hare@suse.de> > ---
>   drivers/scsi/hosts.c     |  3 +++
>   drivers/scsi/scsi_lib.c  | 10 +++++++++-
>   include/scsi/scsi_host.h | 22 +++++++++++++++++++++-
>   3 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index 7ec91c3a66ca..db91b045a4ce 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -466,6 +466,9 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
>   	if (sht->virt_boundary_mask)
>   		shost->virt_boundary_mask = sht->virt_boundary_mask;
>   
> +	if (sht->nr_reserved_cmds)
> +		shost->nr_reserved_cmds = sht->nr_reserved_cmds;
> +
>   	device_initialize(&shost->shost_gendev);
>   	dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
>   	shost->shost_gendev.bus = &scsi_bus_type;
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 1d5c1b9a1203..1362f4f17dfd 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1887,7 +1887,9 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
>   	else
>   		tag_set->ops = &scsi_mq_ops_no_commit;
>   	tag_set->nr_hw_queues = shost->nr_hw_queues ? : 1;
> -	tag_set->queue_depth = shost->can_queue;
> +	tag_set->queue_depth =
> +		shost->can_queue + shost->nr_reserved_cmds;

I think that this can fit on a single line without exceeding 80 characters

> +	tag_set->reserved_tags = shost->nr_reserved_cmds;
>   	tag_set->cmd_size = cmd_size;
>   	tag_set->numa_node = NUMA_NO_NODE;
>   	tag_set->flags = BLK_MQ_F_SHOULD_MERGE;
> @@ -1910,6 +1912,9 @@ void scsi_mq_destroy_tags(struct Scsi_Host *shost)
>    * @op_flags: request allocation flags
>    *
>    * Allocates a SCSI command for internal LLDD use.
> + * If 'nr_reserved_commands' is spectified by the host the

again, please check spellings

> + * command will be allocated from the reserved tag pool;
> + * otherwise the normal tag pool will be used.
>    */
>   struct scsi_cmnd *scsi_get_internal_cmd(struct scsi_device *sdev,
>   	enum dma_data_direction data_direction, int op_flags)
> @@ -1919,6 +1924,9 @@ struct scsi_cmnd *scsi_get_internal_cmd(struct scsi_device *sdev,
>   	blk_mq_req_flags_t flags = 0;
>   	unsigned int op = REQ_INTERNAL | op_flags;
>   
> +	if (sdev->host->nr_reserved_cmds)
> +		flags = BLK_MQ_REQ_RESERVED;

Previously I mentioned that '|=' is nicer - not sure if it was missed or 
dismissed, so mentioning it again just in case

> +
>   	op |= (data_direction == DMA_TO_DEVICE) ?
>   		REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN;
>   	rq = blk_mq_alloc_request(sdev->request_queue, op, flags);
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 4919a66565d6..c4d0d26c880e 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -342,10 +342,19 @@ struct scsi_host_template {
>   	/*
>   	 * This determines if we will use a non-interrupt driven
>   	 * or an interrupt driven scheme.  It is set to the maximum number
> -	 * of simultaneous commands a single hw queue in HBA will accept.
> +	 * of simultaneous commands a single hw queue in HBA will accept
> +	 * excluding internal commands.
>   	 */
>   	int can_queue;
>   
> +	/*
> +	 * This determines how many commands the HBA will set aside
> +	 * for internal commands. This number will be added to
> +	 * @can_queue to calcumate the maximum number of simultaneous

check spelling of calculate

> +	 * commands sent to the host.
> +	 */
> +	int nr_reserved_cmds;

We have can_queue file in the scsi_host sysfs folder - I wonder if it is 
also worth adding a file for this?

> +
>   	/*


  reply	other threads:[~2020-07-08  9:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 13:01 [PATCHv6 00/21] scsi: enable reserved commands for LLDDs Hannes Reinecke
2020-07-03 13:01 ` [PATCH 01/21] scsi: drop gdth driver Hannes Reinecke
2020-07-03 13:01 ` [PATCH 02/21] block: add flag for internal commands Hannes Reinecke
2020-07-08  9:27   ` John Garry
2020-07-09 20:02     ` Jens Axboe
2020-07-17 10:32       ` John Garry
2020-07-03 13:01 ` [PATCH 03/21] scsi: add scsi_{get,put}_internal_cmd() helper Hannes Reinecke
2020-07-07 13:54   ` John Garry
2020-11-16  8:56   ` John Garry
2020-11-16  9:03     ` Hannes Reinecke
2020-11-18 12:28       ` John Garry
2020-12-07 10:15       ` John Garry
2020-12-07 15:52         ` Hannes Reinecke
2020-07-03 13:01 ` [PATCH 04/21] fnic: use internal commands Hannes Reinecke
2020-07-03 13:01 ` [PATCH 05/21] fnic: use scsi_host_busy_iter() to traverse commands Hannes Reinecke
2020-07-03 13:01 ` [PATCH 06/21] fnic: check for started requests in fnic_wq_copy_cleanup_handler() Hannes Reinecke
2020-07-03 13:01 ` [PATCH 07/21] scsi: use real inquiry data when initialising devices Hannes Reinecke
2020-07-03 13:01 ` [PATCH 08/21] scsi: Use dummy inquiry data for the host device Hannes Reinecke
2020-07-03 13:01 ` [PATCH 09/21] scsi: revamp host device handling Hannes Reinecke
2020-07-03 13:01 ` [PATCH 10/21] snic: use reserved commands Hannes Reinecke
2020-07-08 11:08   ` John Garry
2020-07-08 11:18     ` Hannes Reinecke
2020-07-03 13:01 ` [PATCH 11/21] snic: use tagset iter for traversing commands Hannes Reinecke
2020-07-03 13:01 ` [PATCH 12/21] snic: check for started requests in snic_hba_reset_cmpl_handler() Hannes Reinecke
2020-07-03 13:01 ` [PATCH 13/21] scsi: implement reserved command handling Hannes Reinecke
2020-07-08  9:39   ` John Garry [this message]
2020-07-03 13:01 ` [PATCH 14/21] hpsa: move hpsa_hba_inquiry after scsi_add_host() Hannes Reinecke
2020-07-03 13:01 ` [PATCH 15/21] hpsa: use reserved commands Hannes Reinecke
2020-07-03 13:01 ` [PATCH 16/21] hpsa: use scsi_host_busy_iter() to traverse outstanding commands Hannes Reinecke
2020-07-03 13:01 ` [PATCH 17/21] hpsa: drop refcount field from CommandList Hannes Reinecke
2020-07-03 13:01 ` [PATCH 18/21] aacraid: move scsi_add_host() Hannes Reinecke
2020-07-03 13:01 ` [PATCH 19/21] aacraid: store target id in host_scribble Hannes Reinecke
2020-07-03 13:01 ` [PATCH 20/21] aacraid: use scsi_get_internal_cmd() Hannes Reinecke
2020-07-03 13:01 ` [PATCH 21/21] aacraid: use scsi_host_busy_iter() to traverse outstanding commands Hannes Reinecke
2020-10-27 15:27 ` [PATCHv6 00/21] scsi: enable reserved commands for LLDDs John Garry
2020-10-27 15:53   ` Hannes Reinecke
2020-10-27 16:59     ` John Garry
2020-10-27 17:07       ` Hannes Reinecke

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=b03c1256-8255-5e7f-dda3-df036aaef812@huawei.com \
    --to=john.garry@huawei.com \
    --cc=bvanassche@acm.org \
    --cc=don.brace@microchip.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --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;
as well as URLs for NNTP newsgroup(s).