Util-Linux Archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org, util-linux@vger.kernel.org,
	Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Subject: Re: [PATCH] nvme: add namespace paths links
Date: Tue, 5 Apr 2022 07:42:05 +0200	[thread overview]
Message-ID: <20220405054205.GA23466@lst.de> (raw)
In-Reply-To: <20220401092855.90652-1-hare@suse.de>

On Fri, Apr 01, 2022 at 11:28:55AM +0200, Hannes Reinecke 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.

I think having some form of links would be useful.  Quite a while ago
Thadeu looked into adding some form of relationship for lsblk and
friends.  Maybe it would be good to sync up and make sure whatever
links we are adding would be useful for all users?

> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  drivers/nvme/host/core.c      | 3 +++
>  drivers/nvme/host/multipath.c | 8 ++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f204c6f78b5b..df4d89aa061f 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4054,6 +4054,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);
>  	blk_cleanup_queue(ns->queue);
>  
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 7fc58e1f6b09..dc9a4018f90d 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -801,6 +801,8 @@ static int nvme_lookup_ana_group_desc(struct nvme_ctrl *ctrl,
>  
>  void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
>  {
> +	int ret;
> +
>  	if (nvme_ctrl_use_ana(ns->ctrl)) {
>  		struct nvme_ana_group_desc desc = {
>  			.grpid = id->anagrpid,
> @@ -831,6 +833,12 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id)
>  	if (blk_queue_is_zoned(ns->queue) && ns->head->disk)
>  		ns->head->disk->queue->nr_zones = ns->queue->nr_zones;
>  #endif
> +	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)
> -- 
> 2.29.2
---end quoted text---

       reply	other threads:[~2022-04-05  5:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220401092855.90652-1-hare@suse.de>
2022-04-05  5:42 ` Christoph Hellwig [this message]
2022-04-05  5:46   ` [PATCH] nvme: add namespace paths links Hannes Reinecke
2022-04-05  5:48     ` Christoph Hellwig
2022-04-05  8:34       ` Sagi Grimberg
2022-04-05  9:51         ` Hannes Reinecke
2022-04-05 10:22           ` Sagi Grimberg
2022-04-25 13:54       ` Karel Zak
2022-07-29 11:43         ` Hannes Reinecke

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=20220405054205.GA23466@lst.de \
    --to=hch@lst.de \
    --cc=cascardo@canonical.com \
    --cc=hare@suse.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=util-linux@vger.kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).