Re: [PATCH RFC v3 03/22] scsi: core: Implement reserved command handling

Hannes Reinecke
2022-10-27T07:51:10Z

On 10/27/22 03:18, Damien Le Moal wrote:
> On 10/25/22 19:17, John Garry wrote:
>> From: Hannes Reinecke <hare@suse.de>
>>
>> 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.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> #jpg: Set tag_set->queue_depth = shost->can_queue, and not
>> = shost->can_queue + shost->nr_reserved_cmds;
>> Signed-off-by: John Garry <john.garry@huawei.com>
>> ---
>> drivers/scsi/hosts.c | 3 +++
>> drivers/scsi/scsi_lib.c | 2 ++
>> include/scsi/scsi_host.h | 15 ++++++++++++++-
>> 3 files changed, 19 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
>> index 12346e2297fd..db89afc37bc9 100644
>> --- a/drivers/scsi/hosts.c
>> +++ b/drivers/scsi/hosts.c
>> @@ -489,6 +489,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;
>> +
>
> Nit: the if is not really necessary I think. But it does not hurt.
>
Yes, we do.
Not all HBAs are able to figure out the number of reserved commands
upfront; some modify that based on the PCI device used etc.
So I'd keep it for now.

Cheers,

Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman