[PATCH] nvme: add namespace paths links

Hannes Reinecke hare at suse.de
Mon Dec 4 03:19:21 PST 2023


On 12/4/23 11:25, Sagi Grimberg wrote:
> 
> 
> On 9/12/23 17:04, Hannes Reinecke wrote:
>> On 9/12/23 14:55, Sagi Grimberg wrote:
>>>
>>>>>> It is really annoying to always have to loop through the entire
>>>>>> /sys/block directory just to find the namespace path links for
>>>>>> a single namespace in libnvme/nvme-cli.
>>>>>> So provide links to the namespace paths for efficient lookup.
>>>>>>
>>>>>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>>>>>> ---
>>>>>>   drivers/nvme/host/core.c      |  3 +++
>>>>>>   drivers/nvme/host/multipath.c | 10 ++++++++++
>>>>>>   2 files changed, 13 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>>>>>> index 37b6fa746662..88933838e067 100644
>>>>>> --- a/drivers/nvme/host/core.c
>>>>>> +++ b/drivers/nvme/host/core.c
>>>>>> @@ -3681,6 +3681,9 @@ static void nvme_ns_remove(struct nvme_ns *ns)
>>>>>>       if (!nvme_ns_head_multipath(ns->head))
>>>>>>           nvme_cdev_del(&ns->cdev, &ns->cdev_device);
>>>>>> +    else
>>>>>> +        sysfs_remove_link(&disk_to_dev(ns->head->disk)->kobj,
>>>>>> +                  ns->disk->disk_name);
>>>>>>       del_gendisk(ns->disk);
>>>>>>       down_write(&ns->ctrl->namespaces_rwsem);
>>>>>> diff --git a/drivers/nvme/host/multipath.c 
>>>>>> b/drivers/nvme/host/multipath.c
>>>>>> index 0a88d7bdc5e3..9dd0be645dad 100644
>>>>>> --- a/drivers/nvme/host/multipath.c
>>>>>> +++ b/drivers/nvme/host/multipath.c
>>>>>> @@ -875,6 +875,16 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, 
>>>>>> __le32 anagrpid)
>>>>>>       if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
>>>>>>           ns->head->disk->nr_zones = ns->disk->nr_zones;
>>>>>>   #endif
>>>>>> +    if (ns->head->disk) {
>>>>>
>>>>> Why are the two conditions not identical?
>>>>>
>>>> Which two?
>>>
>>> ns->head->disk and nvme_ns_head_multipath()
>>>
>> How can we have one without the other? I thought that both are 
>> mutually dependent .. but yeah, we should be using 
>> 'nvme_ns_head_multipath()' here.
>>
>>>>
>>>>>> +        int ret;
>>>>>> +
>>>>>> +        ret = sysfs_create_link(&disk_to_dev(ns->head->disk)->kobj,
>>>>>> +                    &disk_to_dev(ns->disk)->kobj,
>>>>>> +                    ns->disk->disk_name);
>>>>>> +        if (ret)
>>>>>> +            dev_warn(ns->ctrl->device,
>>>>>> +                 "failed to create namespace path link\n");
>>>>>> +    }
>>>>>>   }
>>>>>>   void nvme_mpath_shutdown_disk(struct nvme_ns_head *head)
>>>>>
>>>>> What will these links be used for?
>>>>
>>>> Mapping for nvme-cli, as explained in the description.
>>>> Clearly it doesn't do it _now_, but once the patch is in we can
>>>> simplify nvme-cli to take advantage of it.
>>>
>>> you mean for nvme list -v ?
>>>
>>> Don't really mind having it, but would want to hear from others as
>>> well.
>>
>> Ok.
> 
> Hey Hannes,
> Has this gone anywhere?

Sadly, no. Everyone said "Yeah, good idea, but let's wait for the 
others." I _dearly_ would love to have it as it will simplify the
logic in nvme-cli/libnvme drastically.
Shall I repost?

Cheers,

Hannes




More information about the Linux-nvme mailing list