All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH rfc] nvme-fabrics: request transport module
Date: Sun, 24 Sep 2017 15:45:25 +0300	[thread overview]
Message-ID: <1506257125-15257-1-git-send-email-sagi@grimberg.me> (raw)

Help userspace to not make sure transport module is
loaded.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
This is useful for having systemd nvmf auto discovery service

 drivers/nvme/host/fabrics.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 6d68738f01ea..7d3381f05bf1 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -551,6 +551,27 @@ static const match_table_t opt_tokens = {
 	{ NVMF_OPT_ERR,			NULL			}
 };
 
+static int nvmf_request_transport(struct nvmf_ctrl_options *opts)
+{
+	char *mod_name;
+	int ret;
+
+	if (!strcmp(opts->transport, "rdma"))
+		mod_name = "nvme-rdma";
+	else if (!strcmp(opts->transport, "fc"))
+		mod_name = "nvme-fc";
+	else if (!strcmp(opts->transport, "loop"))
+		mod_name = "nvme-loop";
+	else
+		return -EINVAL;
+
+	ret = request_module(mod_name) < 0;
+	if (ret)
+		pr_warn("Unable to request_module %s %d\n", mod_name, ret);
+
+	return ret;
+}
+
 static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 		const char *buf)
 {
@@ -945,6 +966,10 @@ nvmf_create_ctrl(struct device *dev, const char *buf, size_t count)
 	if (ret)
 		goto out_free_opts;
 
+	ret = nvmf_request_transport(opts);
+	if (ret)
+		goto out_free_opts;
+
 	/*
 	 * Check the generic options first as we need a valid transport for
 	 * the lookup below.  Then clear the generic flags so that transport
-- 
2.7.4

             reply	other threads:[~2017-09-24 12:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24 12:45 Sagi Grimberg [this message]
2017-09-24 12:55 ` [PATCH rfc] nvme-fabrics: request transport module Christoph Hellwig
2017-09-24 13:03   ` Sagi Grimberg
2017-09-24 13:04     ` Christoph Hellwig

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=1506257125-15257-1-git-send-email-sagi@grimberg.me \
    --to=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.