Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Guixin Liu <kanie@linux.alibaba.com>,
	Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-multipath: expose path_state via sysfs
Date: Mon, 22 Jun 2026 10:40:27 +0530	[thread overview]
Message-ID: <38c7c98a-03cf-4c35-90d5-d7557eaa8a4d@linux.ibm.com> (raw)
In-Reply-To: <20260617121543.2291455-1-kanie@linux.alibaba.com>

On 6/17/26 5:45 PM, Guixin Liu wrote:
> Add a read-only "path_state" sysfs attribute to each NVMe path namespace
> device (/sys/class/nvme/nvmeX/nvmeXcYnZ/path_state) that exposes whether
> the path is currently enabled or disabled.
> 
> The attribute reflects the result of nvme_path_is_disabled(), showing
> "disabled" when the controller is not live/deleting, the namespace has
> an ANA state change pending, or the namespace is not ready. Otherwise
> it shows "enabled".
> 
> This gives userspace visibility into the multipath path selection state
> without requiring users to piece together controller state and namespace
> flags manually.
> 
> Signed-off-by: Guixin Liu<kanie@linux.alibaba.com>
> ---
>   drivers/nvme/host/multipath.c | 10 ++++++++++
>   drivers/nvme/host/nvme.h      |  1 +
>   drivers/nvme/host/sysfs.c     |  4 +++-
>   3 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index 81fff2f20d23..65bd3dd188ee 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -1210,6 +1210,16 @@ static ssize_t in_flight_bytes_show(struct device *dev,
>   }
>   DEVICE_ATTR_RO(in_flight_bytes);
>   
> +static ssize_t path_state_show(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct nvme_ns *ns = nvme_get_ns_from_dev(dev);
> +
> +	return sysfs_emit(buf, "%s\n",
> +			  nvme_path_is_disabled(ns) ? "disabled" : "enabled");
> +}
> +DEVICE_ATTR_RO(path_state);
> +

Instead of only exposing disabled/enabled state, can we also expose the
reason why the path was not usable?

For instance, path_state attribute shall expose "enabled" when it's
available for I/O (this is straightforward):
- enabled

But in case path is not usable/available then expose "disabled" along
with the reason:
- disabled (ctrl_down)
- disabled (ana_pending)
- disabled (ns_not_ready)

Or any other combination depending on the ns->flags and ctrl->state.

That way, the userspace would know the exact reason when path is
not available/usable for I/O.

Thanks,
--Nilay


  parent reply	other threads:[~2026-06-22  5:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 12:15 [PATCH] nvme-multipath: expose path_state via sysfs Guixin Liu
2026-06-18 13:02 ` Daniel Wagner
2026-06-22  2:02   ` Guixin Liu
2026-06-22  7:50     ` Daniel Wagner
2026-06-22  9:07       ` Guixin Liu
2026-06-22  5:10 ` Nilay Shroff [this message]
2026-06-22  9:09   ` Guixin Liu

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=38c7c98a-03cf-4c35-90d5-d7557eaa8a4d@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kanie@linux.alibaba.com \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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