[PATCH 2/7] nvmet: add 'host_traddr' callback for debugfs

Chaitanya Kulkarni chaitanyak at nvidia.com
Mon Apr 8 11:25:13 PDT 2024


On 3/26/24 05:03, Hannes Reinecke wrote:
> We want to display the transport address of the connected host
> in debugfs, but this is a property of the transport.
> So add a callback 'host_traddr' to allow the transport drivers
> to fill in the data.
>
> Signed-off-by: Hannes Reinecke <hare at kernel.org>
> Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>   drivers/nvme/target/core.c    |  8 ++++++++
>   drivers/nvme/target/debugfs.c | 19 +++++++++++++++++++
>   drivers/nvme/target/nvmet.h   |  4 ++++
>   3 files changed, 31 insertions(+)
>
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 7c82e33d9347..20b138ed571f 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -1530,6 +1530,14 @@ void nvmet_ctrl_fatal_error(struct nvmet_ctrl *ctrl)
>   }
>   EXPORT_SYMBOL_GPL(nvmet_ctrl_fatal_error);
>   
> +ssize_t nvmet_ctrl_host_traddr(struct nvmet_ctrl *ctrl,
> +		char *traddr, size_t traddr_len)
> +{
> +	if (!ctrl->ops->host_traddr)
> +		return -EOPNOTSUPP;
> +	return ctrl->ops->host_traddr(ctrl, traddr, traddr_len);
> +}
> +
>   static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port,
>   		const char *subsysnqn)
>   {
> diff --git a/drivers/nvme/target/debugfs.c b/drivers/nvme/target/debugfs.c
> index 45c0483c54fc..60cfb1ab266e 100644
> --- a/drivers/nvme/target/debugfs.c
> +++ b/drivers/nvme/target/debugfs.c
> @@ -115,6 +115,23 @@ static ssize_t nvmet_ctrl_state_write(struct file *file, const char __user *buf,
>   }
>   NVMET_DEBUGFS_RW_ATTR(nvmet_ctrl_state);
>   
> +static int nvmet_ctrl_host_traddr_show(struct seq_file *m, void *p)
> +{
> +	struct nvmet_ctrl *ctrl = (struct nvmet_ctrl *)m->private;

cast can be avoided above ...

-ck




More information about the Linux-nvme mailing list