linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Max Gurtovoy <mgurtovoy@nvidia.com>
To: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
	"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>,
	"sagi@grimberg.me" <sagi@grimberg.me>,
	"kbusch@kernel.org" <kbusch@kernel.org>,
	"hch@lst.de" <hch@lst.de>
Cc: "oren@nvidia.com" <oren@nvidia.com>,
	"ngottlieb@nvidia.com" <ngottlieb@nvidia.com>
Subject: Re: [PATCH 4/4] nvmet: make ver stable once connection established
Date: Thu, 22 Apr 2021 11:43:37 +0300	[thread overview]
Message-ID: <be2f8d6b-eb56-5efc-1853-5279329f733f@nvidia.com> (raw)
In-Reply-To: <BYAPR04MB496522B82F4480CADD4FF34286489@BYAPR04MB4965.namprd04.prod.outlook.com>


On 4/20/2021 8:47 PM, Chaitanya Kulkarni wrote:
> On 4/20/21 02:09, Max Gurtovoy wrote:
>> From: Noam Gottlieb <ngottlieb@nvidia.com>
>>
>> Once some host has connected to the nvmf target, make sure that the
>> version number is stable and cannot be changed.
>>
>> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
>> Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>
>> ---
>>   drivers/nvme/target/configfs.c | 36 +++++++++++++++++++++++++++++-----
>>   1 file changed, 31 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
>> index 61a9a52da30d..2c7aebd4d529 100644
>> --- a/drivers/nvme/target/configfs.c
>> +++ b/drivers/nvme/target/configfs.c
>> @@ -1007,13 +1007,26 @@ static ssize_t nvmet_subsys_attr_version_show(struct config_item *item,
>>   			NVME_MINOR(subsys->ver));
>>   }
>>   
>> -static ssize_t nvmet_subsys_attr_version_store(struct config_item *item,
>> -					       const char *page, size_t count)
>> +static ssize_t
>> +nvmet_subsys_attr_version_store_locked(struct nvmet_subsys *subsys,
>> +		const char *page, size_t count)
>>   {
> Seems like we lost the indentation in above line which was there previously.

We added a new line since the line was > 80 chars.

And we follow the conventions.


>
>> -	struct nvmet_subsys *subsys = to_subsys(item);
>>   	int major, minor, tertiary = 0;
>>   	int ret;
>>   
>> +	if (subsys->subsys_discovered) {
>> +		if (NVME_TERTIARY(subsys->ver))
>> +			pr_err("Can't set version number. %llu.%llu.%llu is already assigned\n",
>> +			       NVME_MAJOR(subsys->ver),
>> +			       NVME_MINOR(subsys->ver),
>> +			       NVME_TERTIARY(subsys->ver));
>> +		else
>> +			pr_err("Can't set version number. %llu.%llu is already assigned\n",
>> +			       NVME_MAJOR(subsys->ver),
>> +			       NVME_MINOR(subsys->ver));
>> +		return -EINVAL;
>> +	}
>> +
> Can you create a helper to for about error reporting so we can avoid
> extra long lines whenever itis possible something like :-
>
>          if (subsys->subsys_discovered)
>              return nvmet_subsys_discover_err(subsys);

We will create helper in the future in case this code will be re-used.

There is no need to create it now.

Long lines avoided by new lines.


>
>>   	/* passthru subsystems use the underlying controller's version */
>>   	if (nvmet_passthru_ctrl(subsys))
>>   		return -EINVAL;
>> @@ -1022,12 +1035,25 @@ static ssize_t nvmet_subsys_attr_version_store(struct config_item *item,
>>   	if (ret != 2 && ret != 3)
>>   		return -EINVAL;
>>   
>> -	down_write(&nvmet_config_sem);
>>   	subsys->ver = NVME_VS(major, minor, tertiary);
>> -	up_write(&nvmet_config_sem);
>>   
>>   	return count;
>>   }
>> +
>> +static ssize_t nvmet_subsys_attr_version_store(struct config_item *item,
>> +					       const char *page, size_t count)
>> +{
>> +	struct nvmet_subsys *subsys = to_subsys(item);
>> +	int ret;
>> +
> nit:- ret variable type should be ssize_t
> nvmet_subsys_attr_version_store_locke().

Ok. good catch.

Thanks.


>
>> +	down_write(&nvmet_config_sem);
>> +	mutex_lock(&subsys->lock);
>> +	ret = nvmet_subsys_attr_version_store_locked(subsys, page, count);
>> +	mutex_unlock(&subsys->lock);
>> +	up_write(&nvmet_config_sem);
>> +
>> +	return ret;
>> +}
>>   CONFIGFS_ATTR(nvmet_subsys_, attr_version);
>>   
>>   /* See Section 1.5 of NVMe 1.4 */

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

  reply	other threads:[~2021-04-22  8:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  9:09 [PATCH 1/4] nvmet: change sn size and check validity Max Gurtovoy
2021-04-20  9:09 ` [PATCH 2/4] nvmet: make sn stable once connection was established Max Gurtovoy
2021-04-20  9:09 ` [PATCH 3/4] nvmet: allow mn change if subsys not discovered Max Gurtovoy
2021-04-20  9:09 ` [PATCH 4/4] nvmet: make ver stable once connection established Max Gurtovoy
2021-04-20 17:47   ` Chaitanya Kulkarni
2021-04-22  8:43     ` Max Gurtovoy [this message]
2021-04-22 19:01       ` Chaitanya Kulkarni
2021-04-20 17:35 ` [PATCH 1/4] nvmet: change sn size and check validity Chaitanya Kulkarni
2021-04-22  8:50   ` Max Gurtovoy
2021-04-22 19:11     ` Chaitanya Kulkarni
2021-04-23 15:51 ` Keith Busch
2021-04-26 13:15   ` Max Gurtovoy
2021-04-29 10:47     ` Max Gurtovoy
2021-06-07  9:23 [PATCH v2 " Max Gurtovoy
2021-06-07  9:23 ` [PATCH 4/4] nvmet: make ver stable once connection established Max Gurtovoy

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=be2f8d6b-eb56-5efc-1853-5279329f733f@nvidia.com \
    --to=mgurtovoy@nvidia.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=ngottlieb@nvidia.com \
    --cc=oren@nvidia.com \
    --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;
as well as URLs for NNTP newsgroup(s).