linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: hch@lst.de, linux-nvme@lists.infradead.org
Subject: Re: [PATCH V3 1/3] nvmet: make ctrl-id configurable
Date: Thu, 12 Dec 2019 10:26:08 +0100	[thread overview]
Message-ID: <20191212092608.GH2399@lst.de> (raw)
In-Reply-To: <20191127094034.12334-2-chaitanya.kulkarni@wdc.com>

On Wed, Nov 27, 2019 at 01:40:32AM -0800, Chaitanya Kulkarni wrote:
> +	int ret = -EINVAL;
> +	u16 cntlid_min;
> +
> +	if (sscanf(page, "%hu\n", &cntlid_min) != 1)
> +		return ret;
> +
> +	if (cntlid_min == 0) {
> +		pr_info("specified cntlid_min = 0 is not allowed\n");
> +		return ret;
> +	}
> +
> +	down_write(&nvmet_config_sem);
> +	if (cntlid_min >= to_subsys(item)->cntlid_max) {
> +		pr_info("specified cntlid_min is >= current cntlid_max\n");
> +		goto out;

I'm not sure we need the pr_info calls here.  The error conditions
are pretty clear when we get an -EINVAL from the write.

> +	}
> +
> +	ret = 0;
> +	to_subsys(item)->cntlid_min = cntlid_min;
> +out:
> +	up_write(&nvmet_config_sem);
> +
> +	return ret ? ret : cnt;

The tail of the function could be simplified by avoid the ret variable.
the ret variable:

	down_write(&nvmet_config_sem);
	if (cntlid_min >= to_subsys(item)->cntlid_max)
		goto out_unlock;
	to_subsys(item)->cntlid_min = cntlid_min;
	up_write(&nvmet_config_sem);
	return cnt;

out_unlock:
	up_write(&nvmet_config_sem);
	return -EINVAL;


> +	if (cntlid_max == 0) {
> +		pr_info("specified cntlid_max = 0 is not allowed\n");
> +		return ret;
> +	}
> +
> +	down_write(&nvmet_config_sem);
> +	if (cntlid_max <= to_subsys(item)->cntlid_min) {
> +		pr_info("specified cntlid_max is <= current cntlid_min\n");
> +		goto out;
> +	}
> +
> +	ret = 0;
> +	to_subsys(item)->cntlid_max = cntlid_max;
> +out:
> +	up_write(&nvmet_config_sem);
> +
> +	return ret ? ret : cnt;

Same comments here.

>  	}
> -
> +	subsys->cntlid_min = NVME_CNTLID_MIN;
> +	subsys->cntlid_max = NVME_CNTLID_MAX;
>  	kref_init(&subsys->ref);
>  
>  	mutex_init(&subsys->lock);
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index 46df45e837c9..6492d12e626a 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -211,6 +211,8 @@ struct nvmet_subsys {
>  	struct list_head	namespaces;
>  	unsigned int		nr_namespaces;
>  	unsigned int		max_nsid;
> +	u16			cntlid_min;
> +	u16			cntlid_max;
>  
>  	struct list_head	ctrls;
>  
> -- 
> 2.22.1
---end quoted text---

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

  parent reply	other threads:[~2019-12-12  9:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  9:40 [PATCH 0/3] nvmet: make model/ctrl-id configurable, configfs fix Chaitanya Kulkarni
2019-11-27  9:40 ` [PATCH V3 1/3] nvmet: make ctrl-id configurable Chaitanya Kulkarni
2019-12-12  0:45   ` Sagi Grimberg
2019-12-12  9:22     ` Christoph Hellwig
2019-12-12  9:26   ` Christoph Hellwig [this message]
2019-12-16 20:40     ` Chaitanya Kulkarni
2019-11-27  9:40 ` [PATCH V4 2/3] nvmet: make ctrl model configurable Chaitanya Kulkarni
2019-12-12  0:45   ` Sagi Grimberg
2019-12-12  9:28   ` Christoph Hellwig
2019-12-12  9:46     ` Christoph Hellwig
2019-12-17  4:53     ` Chaitanya Kulkarni
2019-11-27  9:40 ` [PATCH V2 3/3] nvmet: check sscanf value for subsys serial attr Chaitanya Kulkarni
2019-12-12  0:46   ` Sagi Grimberg
2019-12-12  9:29   ` Christoph Hellwig
2019-12-11  5:35 ` [PATCH 0/3] nvmet: make model/ctrl-id configurable, configfs fix 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=20191212092608.GH2399@lst.de \
    --to=hch@lst.de \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=linux-nvme@lists.infradead.org \
    --subject='Re: [PATCH V3 1/3] nvmet: make ctrl-id configurable' \
    /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

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).