linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Max Gurtovoy <maxg@mellanox.com>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	<linux-nvme@lists.infradead.org>
Subject: Re: [PATCH] nvmet: make ctrl-id configurable
Date: Mon, 4 Nov 2019 11:36:03 +0200	[thread overview]
Message-ID: <409804f3-158b-cc3e-9b04-6499bfe1638d@mellanox.com> (raw)
In-Reply-To: <20191103181343.3011-1-chaitanya.kulkarni@wdc.com>


On 11/3/2019 8:13 PM, Chaitanya Kulkarni wrote:
> This patch adds a new target subsys attribute which allows user to
> optionally specify target controller which then used in the
> nvmet_execute_identify_ctrl() to fill up the nvme_id_ctrl structure.

hi,

can you explain why we should give the user the ability to control this ?

In this case you will have multiple controllers with the same id, and 
I'm not sure that we want that.

Did you try to connect to it with -D (duplication) flag ?

>
> When new attribute is not specified target will fall back to original
> cntlid calculation method.
>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
> Hi Mark,
>
> This patch allows user to set the contoller ID through configfs
> which is target susbsy attribute.
>
> Can you please take a look and provide feedback ? so that we can get
> it to upstream ? I'm planning to send this on Sunday.
>
> -Regards,
> Chaitanya
> ---
>   drivers/nvme/target/configfs.c | 23 +++++++++++++++++++++++
>   drivers/nvme/target/core.c     | 23 +++++++++++++++--------
>   drivers/nvme/target/nvmet.h    |  1 +
>   3 files changed, 39 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index 98613a45bd3b..83391e54ed12 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -862,10 +862,33 @@ static ssize_t nvmet_subsys_attr_serial_store(struct config_item *item,
>   }
>   CONFIGFS_ATTR(nvmet_subsys_, attr_serial);
>   
> +static ssize_t nvmet_subsys_attr_id_show(struct config_item *item,
> +					     char *page)
> +{
> +	struct nvmet_subsys *subsys = to_subsys(item);
> +
> +	return snprintf(page, PAGE_SIZE, "%d\n", subsys->id);
> +}
> +
> +static ssize_t nvmet_subsys_attr_id_store(struct config_item *item,
> +					  const char *page, size_t count)
> +{
> +	struct nvmet_subsys *subsys = to_subsys(item);
> +
> +	down_write(&nvmet_config_sem);
> +	/* should this be %x ? */
> +	sscanf(page, "%hu\n", &subsys->id);
> +	up_write(&nvmet_config_sem);
> +
> +	return count;
> +}
> +CONFIGFS_ATTR(nvmet_subsys_, attr_id);
> +
>   static struct configfs_attribute *nvmet_subsys_attrs[] = {
>   	&nvmet_subsys_attr_attr_allow_any_host,
>   	&nvmet_subsys_attr_attr_version,
>   	&nvmet_subsys_attr_attr_serial,
> +	&nvmet_subsys_attr_attr_id,
>   	NULL,
>   };
>   
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 28438b833c1b..2396215a23c9 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -1267,13 +1267,18 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn,
>   	if (!ctrl->sqs)
>   		goto out_free_cqs;
>   
> -	ret = ida_simple_get(&cntlid_ida,
> -			     NVME_CNTLID_MIN, NVME_CNTLID_MAX,
> -			     GFP_KERNEL);
> -	if (ret < 0) {
> -		status = NVME_SC_CONNECT_CTRL_BUSY | NVME_SC_DNR;
> -		goto out_free_sqs;
> -	}
> +	if (!subsys->id) {
> +		ret = ida_simple_get(&cntlid_ida,
> +				NVME_CNTLID_MIN, NVME_CNTLID_MAX,
> +				GFP_KERNEL);
> +		if (ret < 0) {
> +			status = NVME_SC_CONNECT_CTRL_BUSY | NVME_SC_DNR;
> +			goto out_free_sqs;
> +		}
> +		ctrl->cntlid = ret;
> +	} else
> +		ret = subsys->id;
> +
>   	ctrl->cntlid = ret;
>   
>   	ctrl->ops = req->ops;
> @@ -1330,7 +1335,8 @@ static void nvmet_ctrl_free(struct kref *ref)
>   	flush_work(&ctrl->async_event_work);
>   	cancel_work_sync(&ctrl->fatal_err_work);
>   
> -	ida_simple_remove(&cntlid_ida, ctrl->cntlid);
> +	if (!subsys->id)
> +		ida_simple_remove(&cntlid_ida, ctrl->cntlid);
>   
>   	kfree(ctrl->sqs);
>   	kfree(ctrl->cqs);
> @@ -1416,6 +1422,7 @@ struct nvmet_subsys *nvmet_subsys_alloc(const char *subsysnqn,
>   		kfree(subsys);
>   		return ERR_PTR(-ENOMEM);
>   	}
> +	subsys->id = 0;
>   
>   	kref_init(&subsys->ref);
>   
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index 46df45e837c9..a3d3471bdf2d 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -211,6 +211,7 @@ struct nvmet_subsys {
>   	struct list_head	namespaces;
>   	unsigned int		nr_namespaces;
>   	unsigned int		max_nsid;
> +	u16			id;
>   
>   	struct list_head	ctrls;
>   

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2019-11-04  9:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-03 18:13 [PATCH] nvmet: make ctrl-id configurable Chaitanya Kulkarni
2019-11-03 18:15 ` Chaitanya Kulkarni
2019-11-04  9:36 ` Max Gurtovoy [this message]
2019-11-04 10:45   ` Mark Ruijter
2019-11-04 14:04     ` Max Gurtovoy
2019-11-04 16:36       ` Mark Ruijter
2019-11-05 22:38         ` James Smart
2019-11-06 16:51           ` Sagi Grimberg
2019-11-08 16:15             ` Mark Ruijter
2019-11-12 19:01               ` Sagi Grimberg
2019-11-12 21:19                 ` Mark Ruijter
2019-11-13  0:44                   ` James Smart
2019-11-13 23:40                 ` Chaitanya Kulkarni
2019-11-14 15:55                   ` Mark Ruijter
2019-11-20 18:51                   ` Christoph Hellwig
2019-11-05 21:15     ` Chaitanya Kulkarni

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=409804f3-158b-cc3e-9b04-6499bfe1638d@mellanox.com \
    --to=maxg@mellanox.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=linux-nvme@lists.infradead.org \
    /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).