All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Mike Christie <michael.christie@oracle.com>,
	chaitanyak@nvidia.com, kbusch@kernel.org, hch@lst.de,
	sagi@grimberg.me, joao.m.martins@oracle.com,
	linux-nvme@lists.infradead.org, kvm@vger.kernel.org,
	kwankhede@nvidia.com, alex.williamson@redhat.com,
	mlevitsk@redhat.com
Subject: Re: [PATCH RFC 04/11] nvmet: Add function to get nvmet_fabrics_ops from trtype
Date: Thu, 13 Mar 2025 18:03:13 +0900	[thread overview]
Message-ID: <f7e7c4e0-1997-4edd-a0b6-137f5abca3c0@kernel.org> (raw)
In-Reply-To: <20250313052222.178524-5-michael.christie@oracle.com>

On 3/13/25 14:18, Mike Christie wrote:
> In the next patches we allow users to create static controllers if the
> driver supports it. To get this info we need the nvmet_fabrics_ops
> a little sooner then port enablement so this creates a function to go
> from trtype to nvmet_fabrics_ops.
> 
> Signed-off-by: Mike Christie <michael.christie@oracle.com>
> ---
>  drivers/nvme/target/core.c  | 41 +++++++++++++++++++++++--------------
>  drivers/nvme/target/nvmet.h |  1 +
>  2 files changed, 27 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index 4de534eafd89..06967c00e9a2 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -306,6 +306,30 @@ void nvmet_unregister_transport(const struct nvmet_fabrics_ops *ops)
>  }
>  EXPORT_SYMBOL_GPL(nvmet_unregister_transport);
>  
> +const struct nvmet_fabrics_ops *nvmet_get_ops_by_transport(int trtype)
> +{
> +	const struct nvmet_fabrics_ops *ops;
> +
> +	lockdep_assert_held(&nvmet_config_sem);
> +
> +	ops = nvmet_transports[trtype];
> +	if (!ops) {
> +		up_write(&nvmet_config_sem);
> +		request_module("nvmet-transport-%d", trtype);
> +		down_write(&nvmet_config_sem);
> +		ops = nvmet_transports[trtype];
> +		if (!ops) {
> +			pr_err("transport type %d not supported\n", trtype);
> +			return NULL;
> +		}
> +	}
> +
> +	if (!try_module_get(ops->owner))
> +		return NULL;
> +
> +	return ops;
> +}
> +
>  void nvmet_port_del_ctrls(struct nvmet_port *port, struct nvmet_subsys *subsys)
>  {
>  	struct nvmet_ctrl *ctrl;
> @@ -325,22 +349,9 @@ int nvmet_enable_port(struct nvmet_port *port)
>  
>  	lockdep_assert_held(&nvmet_config_sem);
>  
> -	ops = nvmet_transports[port->disc_addr.trtype];
> -	if (!ops) {
> -		up_write(&nvmet_config_sem);
> -		request_module("nvmet-transport-%d", port->disc_addr.trtype);
> -		down_write(&nvmet_config_sem);
> -		ops = nvmet_transports[port->disc_addr.trtype];
> -		if (!ops) {
> -			pr_err("transport type %d not supported\n",
> -				port->disc_addr.trtype);
> -			return -EINVAL;
> -		}
> -	}
> -
> -	if (!try_module_get(ops->owner))
> +	ops = nvmet_get_ops_by_transport(port->disc_addr.trtype);
> +	if (!ops)
>  		return -EINVAL;
> -

whiteline change.

>  	/*
>  	 * If the user requested PI support and the transport isn't pi capable,
>  	 * don't enable the port.
> diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
> index ec3d10eb316a..052ea4a105fc 100644
> --- a/drivers/nvme/target/nvmet.h
> +++ b/drivers/nvme/target/nvmet.h
> @@ -622,6 +622,7 @@ void nvmet_port_send_ana_event(struct nvmet_port *port);
>  
>  int nvmet_register_transport(const struct nvmet_fabrics_ops *ops);
>  void nvmet_unregister_transport(const struct nvmet_fabrics_ops *ops);
> +const struct nvmet_fabrics_ops *nvmet_get_ops_by_transport(int trtype);
>  
>  void nvmet_port_del_ctrls(struct nvmet_port *port,
>  			  struct nvmet_subsys *subsys);


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2025-03-13  9:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13  5:18 [PATCH RFC 00/11] nvmet: Add NVMe target mdev/vfio driver Mike Christie
2025-03-13  5:18 ` [PATCH RFC 01/11] nvmet: Remove duplicate uuid_copy Mike Christie
2025-03-13  6:36   ` Christoph Hellwig
2025-03-13  8:59   ` Damien Le Moal
2025-03-13 17:20   ` Keith Busch
2025-03-13  5:18 ` [PATCH RFC 02/11] nvmet: Export nvmet_add_async_event and add definitions Mike Christie
2025-03-13  6:36   ` Christoph Hellwig
2025-03-13 17:50     ` Mike Christie
2025-03-13  5:18 ` [PATCH RFC 03/11] nvmet: Add nvmet_fabrics_ops flag to indicate SGLs not supported Mike Christie
2025-03-13  6:37   ` Christoph Hellwig
2025-03-13  9:02   ` Damien Le Moal
2025-03-13  9:13     ` Christoph Hellwig
2025-03-13  9:16       ` Damien Le Moal
2025-03-13 17:19         ` Mike Christie
2025-03-13  5:18 ` [PATCH RFC 04/11] nvmet: Add function to get nvmet_fabrics_ops from trtype Mike Christie
2025-03-13  9:03   ` Damien Le Moal [this message]
2025-03-13  5:18 ` [PATCH RFC 05/11] nvmet: Add function to print trtype Mike Christie
2025-03-13  5:18 ` [PATCH RFC 06/11] nvmet: Allow nvmet_alloc_ctrl users to specify the cntlid Mike Christie
2025-03-13  5:18 ` [PATCH RFC 07/11] nvmet: Add static controller support to configfs Mike Christie
2025-03-13  5:18 ` [PATCH RFC 08/11] nvmet: Add shadow doorbell support Mike Christie
2025-03-13  5:18 ` [PATCH RFC 09/11] nvmet: Add helpers to find and get static controllers Mike Christie
2025-03-13  5:18 ` [PATCH RFC 10/11] nvmet: Add addr fam and trtype for mdev pci driver Mike Christie
2025-03-13  6:42   ` Christoph Hellwig
2025-03-13 17:56     ` Mike Christie
2025-03-13  5:18 ` [PATCH RFC 11/11] nvmet: Add nvmet-mdev-pci driver Mike Christie
2025-03-14  7:32   ` kernel test robot
2025-03-13  5:32 ` [PATCH RFC 00/11] nvmet: Add NVMe target mdev/vfio driver Damien Le Moal
2025-03-13  6:47 ` Christoph Hellwig
2025-03-13 17:17   ` Mike Christie
2025-03-14  8:31     ` 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=f7e7c4e0-1997-4edd-a0b6-137f5abca3c0@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=chaitanyak@nvidia.com \
    --cc=hch@lst.de \
    --cc=joao.m.martins@oracle.com \
    --cc=kbusch@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=michael.christie@oracle.com \
    --cc=mlevitsk@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.