[PATCH v3 1/3] nvmet: Expose max queues to sysfs
Hannes Reinecke
hare at suse.de
Mon Aug 29 02:06:06 PDT 2022
On 8/29/22 10:38, Daniel Wagner wrote:
> Allow to set the max queues the target supports. This is useful for
> testing the reconnect attempt of the host with changing numbers of
> supported queues.
>
> Signed-off-by: Daniel Wagner <dwagner at suse.de>
> ---
> drivers/nvme/target/configfs.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index 2bcd60758919..a415c2987393 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -1281,6 +1281,33 @@ static ssize_t nvmet_subsys_attr_pi_enable_store(struct config_item *item,
> CONFIGFS_ATTR(nvmet_subsys_, attr_pi_enable);
> #endif
>
> +static ssize_t nvmet_subsys_attr_qid_max_show(struct config_item *item,
> + char *page)
> +{
> + return snprintf(page, PAGE_SIZE, "%u\n", to_subsys(item)->max_qid);
> +}
> +
> +static ssize_t nvmet_subsys_attr_qid_max_store(struct config_item *item,
> + const char *page, size_t cnt)
> +{
> + u16 qid_max;
> +
> + if (nvmet_is_port_enabled(port, __func__))
> + return -EACCES;
> +
> + if (sscanf(page, "%hu\n", &qid_max) != 1)
> + return -EINVAL;
> +
> + if (qid_max < 1 || qid_max > NVMET_NR_QUEUES)
> + return -EINVAL;
> +
> + down_write(&nvmet_config_sem);
> + to_subsys(item)->max_qid = qid_max;
> + up_write(&nvmet_config_sem);
> + return cnt;
> +}
> +CONFIGFS_ATTR(nvmet_subsys_, attr_qid_max);
> +
> static struct configfs_attribute *nvmet_subsys_attrs[] = {
> &nvmet_subsys_attr_attr_allow_any_host,
> &nvmet_subsys_attr_attr_version,
> @@ -1291,6 +1318,7 @@ static struct configfs_attribute *nvmet_subsys_attrs[] = {
> #ifdef CONFIG_BLK_DEV_INTEGRITY
> &nvmet_subsys_attr_attr_pi_enable,
> #endif
> + &nvmet_subsys_attr_attr_qid_max,
> NULL,
> };
>
Minor nit: I would add the new field prior to the 'ifdef' stuff; as it
stands the layout of the resulting structure changes depending on the
configuration, which tends to cause all sorts of issues for distributions.
But otherwise:
Reviewed-by: Hannes Reinecke <hare at suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
More information about the Linux-nvme
mailing list