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: MRuijter@onestopsystems.com, hch@lst.de, linux-nvme@lists.infradead.org
Subject: Re: [PATCH V2] nvmet: make ctrl model configurable
Date: Wed, 20 Nov 2019 19:41:18 +0100	[thread overview]
Message-ID: <20191120184118.GA12060@lst.de> (raw)
In-Reply-To: <20191113215846.22399-1-chaitanya.kulkarni@wdc.com>

On Wed, Nov 13, 2019 at 01:58:45PM -0800, Chaitanya Kulkarni wrote:
> From: Mark Ruijter <MRuijter@onestopsystems.com>
> 
> This patch adds a new target subsys attribute which allows user to
> optionally specify model name which then used in the
> nvmet_execute_identify_ctrl() to fill up the nvme_id_ctrl structure.
> 
> The default value for the model is set to "Linux" for backward
> compatibility.
> 
> Signed-off-by: Mark Ruijter <MRuijter@onestopsystems.com>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
> Changes from V1:-
> 
> 1. Don't allocate memory for default subsys model,
> 2. Use helper to get the default model string from ctrl->subsys in the
>    nvmet_execute_identify_ctrl() and nvmet_subsys_attr_model()_show.
>    Later is needed so that nvmetcli can display default value Linux
>    when the model is not set from the user.
> 3. Get rid of the extra variable c in the nvmet_subsys_attr_model_store()
>    and replace for with while loop without loosing the code redability.
> ---
>  drivers/nvme/target/admin-cmd.c |  9 +++++--
>  drivers/nvme/target/configfs.c  | 44 +++++++++++++++++++++++++++++++++
>  drivers/nvme/target/core.c      |  2 ++
>  drivers/nvme/target/nvmet.h     |  4 +++
>  4 files changed, 57 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 56c21b501185..81374507099f 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -312,12 +312,17 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req)
>  	nvmet_req_complete(req, NVME_SC_INVALID_FIELD | NVME_SC_DNR);
>  }
>  
> +const char *nvmet_subsys_model(struct nvmet_subsys *subsys)
> +{
> +	return subsys->model ? subsys->model : NVMET_DEFAULT_CTRL_MODEL;

Nit: I always prefer good old if statements except when passing
arguments or a few commonly used idioms as it just reads much more
easily.

> +	/* Only 20h (space) until 7eh (~) is allowed */
> +	while (pos < len && (page[pos] >= 0x20 && page[pos] <= 0x7e) && ++pos)

No nee for the inner braces here, but I wonder If this whole thing
could be reshuffled somehow to be a bit more readable.  Something like:

/* See Section 1.5 of NVMe 1.4 */
static bool nvmet_is_ascii(const char c)
{
	return c >= 0x20 && c <= 0x7e;
}

	for (pos = 0; pos < len; pos++) {
		if (!nvmet_is_ascii(page[pos]))
			goto out_unlock;
	}

> +	tmp = kstrndup(page, len, GFP_KERNEL);
> +	if (!tmp) {

Maybe name tmp model?

> +const char *nvmet_subsys_model(struct nvmet_subsys *subsys);

Maybe just call this nvmet_model_number to match the field name?

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

      parent reply	other threads:[~2019-11-20 18:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 21:58 [PATCH V2] nvmet: make ctrl model configurable Chaitanya Kulkarni
2019-11-13 21:58 ` [PATCH] nvmetcli: allow setting of the subsystem model Chaitanya Kulkarni
2019-11-20  4:38   ` Chaitanya Kulkarni
2019-11-20  4:38 ` [PATCH V2] nvmet: make ctrl model configurable Chaitanya Kulkarni
2019-11-20 18:41 ` Christoph Hellwig [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=20191120184118.GA12060@lst.de \
    --to=hch@lst.de \
    --cc=MRuijter@onestopsystems.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).