[PATCH v6 1/2] nvme: add per-queue sysfs directories

Nilay Shroff nilay at linux.ibm.com
Fri Oct 30 07:46:21 PDT 2026


On 10/24/26 4:34 AM, Saravanan D wrote:
> Per I/O queue transport state, such as the nvme-tcp io_cpu, has
> nowhere to live in sysfs, since the core has no directory for
> individual queues.
> 
> Add helpers that create the controller's queues directory and add or
> remove one directory per queue
> 
>    /sys/class/nvme/nvmeX/queues/<qid>/
> 
> carrying attributes provided by the transport. The transport creates
> the queues directory from its controller setup path, adds a queue's
> directory when it sets the queue up and removes it when it frees the
> queue, so the directories follow the queues across reconnects and
> changes in the queue count. The core allocates each queue directory
> and its release frees only that allocation. Removal waits for running
> attribute callbacks, so the transport may tear the queue down once it
> returns.
> 
> The queues directory holds a reference on the controller device, so
> nvme_uninit_ctrl() deletes it after the transport has removed the
> queue directories.
> 
> Suggested-by: Sagi Grimberg <sagi at grimberg.me>
> Link: https://lore.kernel.org/linux-nvme/13c160d0-0657-47ce-9a16-58d348267ab0@grimberg.me/
> Assisted-by: Claude:claude-opus-5-5 [Claude Code]
> Signed-off-by: Saravanan D <saravanand at crusoe.ai>
> ---
>   drivers/nvme/host/core.c  |  6 +++
>   drivers/nvme/host/nvme.h  | 23 ++++++++++
>   drivers/nvme/host/sysfs.c | 88 +++++++++++++++++++++++++++++++++++++++
>   3 files changed, 117 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 531f9bb14bab..41e1c9d0ee58 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -5153,6 +5153,12 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
>   {
>   	nvme_stop_keep_alive(ctrl);
>   	nvme_hwmon_exit(ctrl);
> +	/* transports remove their queue directories before this point */
> +	if (ctrl->queues_kobj) {
> +		kobject_del(ctrl->queues_kobj);
> +		kobject_put(ctrl->queues_kobj);
> +		ctrl->queues_kobj = NULL;
> +	}

Can we have a helper something like nvme_queue_dir_destroy()
and then call it here?

Thanks,
--Nilay




More information about the Linux-nvme mailing list