Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Chaitanya Kulkarni <chaitanyak@nvidia.com>,
	"hare@kernel.org" <hare@kernel.org>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] nvmet: implement unique discovery NQN
Date: Tue, 12 Dec 2023 08:05:49 +0100	[thread overview]
Message-ID: <33904ceb-78a8-476e-9993-31d11b0fb54a@suse.de> (raw)
In-Reply-To: <8aea5054-9acc-4123-be68-6c51f0ab206e@nvidia.com>

On 12/12/23 06:20, Chaitanya Kulkarni wrote:
> On 12/11/23 00:10, hare@kernel.org wrote:
>> From: Hannes Reinecke <hare@suse.de>
>>
>> Add a configfs attribute 'discovery_nqn' in the 'nvmet' configfs
>> directory to specify the unique discovery NQN.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>>    drivers/nvme/target/configfs.c | 45 ++++++++++++++++++++++++++++++++++
>>    drivers/nvme/target/core.c     |  7 ++++++
>>    2 files changed, 52 insertions(+)
>>
>> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
>> index d937fe05129e..88911d0cd057 100644
>> --- a/drivers/nvme/target/configfs.c
>> +++ b/drivers/nvme/target/configfs.c
>> @@ -1587,6 +1587,11 @@ static struct config_group *nvmet_subsys_make(struct config_group *group,
>>    		return ERR_PTR(-EINVAL);
>>    	}
>>    
>> +	if (sysfs_streq(name, nvmet_disc_subsys->subsysnqn)) {
>> +		pr_err("can't create subsystem using unique discovery NQN\n");
>> +		return ERR_PTR(-EINVAL);
>> +	}
>> +
>>    	subsys = nvmet_subsys_alloc(name, NVME_NQN_NVME);
>>    	if (IS_ERR(subsys))
>>    		return ERR_CAST(subsys);
>> @@ -2131,7 +2136,47 @@ static const struct config_item_type nvmet_hosts_type = {
>>    
>>    static struct config_group nvmet_hosts_group;
>>    
>> +static ssize_t nvmet_root_discovery_nqn_show(struct config_item *item,
>> +					     char *page)
>> +{
>> +	return sprintf(page, "%s\n", nvmet_disc_subsys->subsysnqn);
>> +}
>> +
>> +static ssize_t nvmet_root_discovery_nqn_store(struct config_item *item,
>> +		const char *page, size_t count)
>> +{
>> +	size_t len;
>> +	struct list_head *entry;
>> +
>> +	len = strcspn(page, "\n");
>> +	if (!len || len > NVMF_NQN_FIELD_LEN - 1)
>> +		return -EINVAL;
>> +
>> +	down_write(&nvmet_config_sem);
>> +	list_for_each(entry, &nvmet_subsystems_group.cg_children) {
>> +		struct config_item *item = container_of(entry, struct config_item, ci_entry);
>> +		if (!strncmp(config_item_name(item), page, len)) {
>> +			pr_err("duplicate NQN %s\n", config_item_name(item));
>> +			up_write(&nvmet_config_sem);
>> +			return -EINVAL;
>> +		}
>> +	}
>> +	memset(nvmet_disc_subsys->subsysnqn, 0, NVMF_NQN_FIELD_LEN);
>> +	memcpy(nvmet_disc_subsys->subsysnqn, page, len);
>> +	up_write(&nvmet_config_sem);
>> +
>> +	return len;
>> +}
>> +
>>
> 
> please consider something like following, it removes long line
> re-structures the declaration totally untested :-
> 
> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
> index 88911d0cd057..05d67ddfe83e 100644
> --- a/drivers/nvme/target/configfs.c
> +++ b/drivers/nvme/target/configfs.c
> @@ -2145,8 +2145,8 @@ static ssize_t
> nvmet_root_discovery_nqn_show(struct config_item *item,
>    static ssize_t nvmet_root_discovery_nqn_store(struct config_item *item,
>                   const char *page, size_t count)
>    {
> -       size_t len;
>           struct list_head *entry;
> +       size_t len;
> 
>           len = strcspn(page, "\n");
>           if (!len || len > NVMF_NQN_FIELD_LEN - 1)
> @@ -2154,7 +2154,9 @@ static ssize_t
> nvmet_root_discovery_nqn_store(struct config_item *item,
> 
>           down_write(&nvmet_config_sem);
>           list_for_each(entry, &nvmet_subsystems_group.cg_children) {
> -               struct config_item *item = container_of(entry, struct
> config_item, ci_entry);
> +               struct config_item *item =
> +                       container_of(entry, struct config_item, ci_entry);
> +
>                   if (!strncmp(config_item_name(item), page, len)) {
>                           pr_err("duplicate NQN %s\n",
> config_item_name(item));
>                           up_write(&nvmet_config_sem);
> 
> -ck
> 
> 
Ok, will be resending.

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), GF: Ivo Totev, Andrew McDonald,
Werner Knoblich



      reply	other threads:[~2023-12-12  7:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11  8:10 [PATCH] nvmet: implement unique discovery NQN hare
2023-12-11 14:15 ` Sagi Grimberg
2023-12-11 14:57   ` Hannes Reinecke
2023-12-12  5:20 ` Chaitanya Kulkarni
2023-12-12  7:05   ` Hannes Reinecke [this message]

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=33904ceb-78a8-476e-9993-31d11b0fb54a@suse.de \
    --to=hare@suse.de \
    --cc=chaitanyak@nvidia.com \
    --cc=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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