Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1406219
| Path | csiph.com!feeder.erje.net!1.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Wenwei Tao <ww.tao0320@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH 2/2] lightnvm: Append device name to target name |
| Date | Tue, 24 May 2016 16:40:03 +0200 |
| Message-ID | <rClF1-4qa-47@gated-at.bofh.it> (permalink) |
| References | <rBUbM-3YT-15@gated-at.bofh.it> <rBUbM-3YT-17@gated-at.bofh.it> <rBUbM-3YT-13@gated-at.bofh.it> <rBVUe-53H-19@gated-at.bofh.it> <rBX9E-5Jd-43@gated-at.bofh.it> <rBYp4-6vy-27@gated-at.bofh.it> <rCllE-4jI-3@gated-at.bofh.it> |
| X-Original-To | Matias Bjørling <mb@lightnvm.io> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=KLpF77V9wUGTQQDqAm7eVu5YNli2GtsNgDTQAGnQCOo=; b=FAmm5MNjKAIFFTW1KkWQSSyOwQjaKQwnKFGO2qyZDhzxTWc1FSMyThwEk6a/c3nmQV UGrOMfWfK0dD26/RIw0rdLRUOEaiN3J+rvupXelG5TALWPsWRQvkOopWlRzQDU18CLfO haQ3CtMmAp2a0FZFlc9M5LkO186dmhF1Mg4YVi7uq/MKOo6TZBUsQGDSDQqdwK1XlMFl kxADoeVNGu92HMuFjRovx7KnUqBAJodpaH+3DdoA6B1WHvwdwtW4KrQXxv7c4+z9l2q2 3WMkFgSANfagqbuBnp+uf/+IVoCl1UBmOadAgGLGbkjxinUOfZAs1IFpzBvYMUt8BYxD pzjg== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=KLpF77V9wUGTQQDqAm7eVu5YNli2GtsNgDTQAGnQCOo=; b=TJRtRRqwxVM6tJPvRo0NCbKrCx/PFwxk4HWpHIroJCUfYV0jH3qzPncqaFy2qR+WKL Z1TdOsyQz+Vg/v7aAvRcSd5i+SnyrHwlB/2LUuKzpb/tBTtRZJSvSL7r9ALZwVnc4Ios Y/tNWTU8s3fJ/bkbeXttviYpzfHH4cCg8rtVNoSVSgEVyUhgpEfan0zaEI/GEloyRbQi fisxcy3Otxo3HtnNPghfEFDPPB2+vRKh4OnmhDuQMIJgEpAxPD0QvnekheaBRr3FwuO2 0AY1t5RQCjvmdeWrWaIsc0hu8WzUZrAwzykZt/Dlg41YlZob+K7YhztseqRynYbPmY8B +H/A== |
| X-Gm-Message-State | ALyK8tITXDCRcT7MUR6FQ5mpRCHquNc1TzgHxQ8TjcwxoWwKFdre6u/TFMpnrYGB55DsWIl8ymbKuCmq6nUvtw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.223.171 with SMTP id qv11mr7158179igc.34.1464100689093; Tue, 24 May 2016 07:38:09 -0700 (PDT) |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8BIT |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 129 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Wenwei Tao <wwtao0320@163.com>, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org |
| X-Original-Date | Tue, 24 May 2016 22:38:09 +0800 |
| X-Original-Message-ID | <CACygaLBMt-p0seDRE4r3ZOoAbccyfgGy4fndY1bLv8Sk-ic9Zg@mail.gmail.com> |
| X-Original-References | <1463994814-3388-1-git-send-email-wwtao0320@163.com> <1463994814-3388-2-git-send-email-wwtao0320@163.com> <5742CA7F.4030000@lightnvm.io> <CACygaLCjhH=JKMJ=cML=LUb4=jvwqq_9P2ay-YGr376aLgZiVg@mail.gmail.com> <5742F686.7050408@lightnvm.io> <CACygaLCVipKvso0=w57V+ML6HXsC9rjfspYy6JT6Z5Me0uswPw@mail.gmail.com> <57446273.70509@lightnvm.io> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1406219 |
Show key headers only | View raw
It's fine to allow the user to define a device name as long as hold
the global lock and link the targets into a global list but that may
against the idea to move the target management into media mgr.
2016-05-24 22:17 GMT+08:00 Matias Bjørling <mb@lightnvm.io>:
> On 05/23/2016 03:31 PM, Wenwei Tao wrote:
>>
>> Eh.. my lock patch can only prevent concurrent creation of the same
>> name target on the same backend device, not the concurrent creation of
>> same name target on different backend devices, since target management
>> is protect by per device's gn->lock not
>> the global nvm_lock now.
>>
>> 2016-05-23 20:24 GMT+08:00 Matias Bjørling <mb@lightnvm.io>:
>>>
>>> On 05/23/2016 01:05 PM, Wenwei Tao wrote:
>>>>
>>>>
>>>> 2016-05-23 17:16 GMT+08:00 Matias Bjørling <mb@lightnvm.io>:
>>>>>
>>>>>
>>>>> 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?
>>>>>
>>>> You mean a target may be build on multiple backend devices ?
>>>
>>>
>>>
>>> Yes. Over time, we want a single target to manage many devices.
>>>
>>>>
>>>>> I am okay with having the user choosing a unique name for the target to
>>>>> be
>>>>> exposed.
>>>>
>>>>
>>>> You mean user should check the name before create the target?
>>>
>>>
>>>
>>> Sure. It is him that decides the name of the device. Your lock patch
>>> fixes
>>> the panic that could happen. I am happy with that.
>>>
>>>
>>>> Before move target mgmt into media mgr, that would be okay(after apply
>>>> lightnvm: hold lock until finish the target creation), since all
>>>> targets are in the global list.
>>>> Now consider below case:
>>>> There are two users A and B. A want to create target test0 upon
>>>> device0 B want to create test0 upon device1,
>>>> before creation they both check whether test0 is exist (e.g. by list
>>>> /dev/test0) , they all find test0 is not exist now, and they continue
>>>> their
>>>> creation. Both of them use disk name test0 to call add_disk, that
>>>> would cause panic.
>>>>
>>>
>
> You are right. The right way is properly to not allow the user to define a
> device name, and instead rely on generic naming and UUID.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Matias Bjørling <mb@lightnvm.io> - 2016-05-23 11:20 +0200
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Wenwei Tao <ww.tao0320@gmail.com> - 2016-05-23 13:10 +0200
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Matias Bjørling <mb@lightnvm.io> - 2016-05-23 14:30 +0200
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Wenwei Tao <ww.tao0320@gmail.com> - 2016-05-23 15:50 +0200
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Matias Bjørling <mb@lightnvm.io> - 2016-05-24 16:20 +0200
Re: [RFC PATCH 2/2] lightnvm: Append device name to target name Wenwei Tao <ww.tao0320@gmail.com> - 2016-05-24 16:40 +0200
csiph-web