public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Matias Bjørling" <mb@lightnvm.io>
To: Wenwei Tao <wwtao0320@163.com>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	ww.tao0320@gmail.com
Subject: Re: [RFC PATCH 2/2] lightnvm: Append device name to target name
Date: Mon, 23 May 2016 11:16:47 +0200	[thread overview]
Message-ID: <5742CA7F.4030000@lightnvm.io> (raw)
In-Reply-To: <1463994814-3388-2-git-send-email-wwtao0320@163.com>

On 05/23/2016 11:13 AM, Wenwei Tao wrote:
> From: Wenwei Tao <ww.tao0320@gmail.com>
>
> We may create targets with same name on different
> backend devices, this is not what we want, so append
> the device name to target name to make the new target
> name unique in the system.
>
> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> ---
>   drivers/lightnvm/gennvm.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
> index 39ff0af..ecb09cb 100644
> --- a/drivers/lightnvm/gennvm.c
> +++ b/drivers/lightnvm/gennvm.c
> @@ -43,9 +43,18 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>   	struct gendisk *tdisk;
>   	struct nvm_tgt_type *tt;
>   	struct nvm_target *t;
> +	char tgtname[DISK_NAME_LEN];
>   	void *targetdata;
>   	int ret = -ENOMEM;
>
> +	if (strlen(dev->name) + strlen(create->tgtname) + 1 > DISK_NAME_LEN) {
> +		pr_err("nvm: target name too long. %s:%s\n",
> +				dev->name, create->tgtname);
> +		return -EINVAL;
> +	}
> +
> +	sprintf(tgtname, "%s%s", dev->name, create->tgtname);
> +
>   	tt = nvm_find_target_type(create->tgttype, 1);
>   	if (!tt) {
>   		pr_err("nvm: target type %s not found\n", create->tgttype);
> @@ -53,7 +62,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>   	}
>
>   	mutex_lock(&gn->lock);
> -	t = gen_find_target(gn, create->tgtname);
> +	t = gen_find_target(gn, tgtname);
>   	if (t) {
>   		pr_err("nvm: target name already exists.\n");
>   		ret = -EINVAL;
> @@ -73,7 +82,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
>   	if (!tdisk)
>   		goto err_queue;
>
> -	sprintf(tdisk->disk_name, "%s", create->tgtname);
> +	sprintf(tdisk->disk_name, "%s", tgtname);
>   	tdisk->flags = GENHD_FL_EXT_DEVT;
>   	tdisk->major = 0;
>   	tdisk->first_minor = 0;
>

Hi Wenwei, what about the case where a target instance has multiple 
devices associated?

I am okay with having the user choosing a unique name for the target to 
be exposed.

  reply	other threads:[~2016-05-23  9:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-23  9:13 [PATCH v2 1/2] lightnvm: hold lock until finish the target creation Wenwei Tao
2016-05-23  9:13 ` [RFC PATCH 2/2] lightnvm: Append device name to target name Wenwei Tao
2016-05-23  9:16   ` Matias Bjørling [this message]
2016-05-23 11:05     ` Wenwei Tao
2016-05-23 12:24       ` Matias Bjørling
2016-05-23 13:31         ` Wenwei Tao
2016-05-24 14:17           ` Matias Bjørling
2016-05-24 14:38             ` Wenwei Tao

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=5742CA7F.4030000@lightnvm.io \
    --to=mb@lightnvm.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ww.tao0320@gmail.com \
    --cc=wwtao0320@163.com \
    /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