* [PATCH rfc] nvme-fabrics: request transport module
@ 2017-09-24 12:45 Sagi Grimberg
2017-09-24 12:55 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2017-09-24 12:45 UTC (permalink / 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH rfc] nvme-fabrics: request transport module
2017-09-24 12:45 [PATCH rfc] nvme-fabrics: request transport module Sagi Grimberg
@ 2017-09-24 12:55 ` Christoph Hellwig
2017-09-24 13:03 ` Sagi Grimberg
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2017-09-24 12:55 UTC (permalink / raw)
> +
> + 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;
You can replace this whole function with:
request_module("nvme-%d", opts->transport);
Also if I remember correctly request_module returns an error if the
driver is built-in, thus most callers either don't check the return
value or just print a warning (I personally hate the warning, so I think
we should just do the simple request_module call).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rfc] nvme-fabrics: request transport module
2017-09-24 12:55 ` Christoph Hellwig
@ 2017-09-24 13:03 ` Sagi Grimberg
2017-09-24 13:04 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Sagi Grimberg @ 2017-09-24 13:03 UTC (permalink / raw)
>> +
>> + 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;
>
> You can replace this whole function with:
>
> request_module("nvme-%d", opts->transport);
Hahaha, how could I miss that?!
> Also if I remember correctly request_module returns an error if the
> driver is built-in, thus most callers either don't check the return
> value or just print a warning (I personally hate the warning, so I think
> we should just do the simple request_module call).
So skip the return value altogether? I don't mind that...
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rfc] nvme-fabrics: request transport module
2017-09-24 13:03 ` Sagi Grimberg
@ 2017-09-24 13:04 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-09-24 13:04 UTC (permalink / raw)
On Sun, Sep 24, 2017@04:03:55PM +0300, Sagi Grimberg wrote:
>> Also if I remember correctly request_module returns an error if the
>> driver is built-in, thus most callers either don't check the return
>> value or just print a warning (I personally hate the warning, so I think
>> we should just do the simple request_module call).
>
> So skip the return value altogether? I don't mind that...
Yes.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-24 13:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-24 12:45 [PATCH rfc] nvme-fabrics: request transport module Sagi Grimberg
2017-09-24 12:55 ` Christoph Hellwig
2017-09-24 13:03 ` Sagi Grimberg
2017-09-24 13:04 ` Christoph Hellwig
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.