Commit 019641d1 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Dominique Martinet

net/p9: load default transports

Now that all transports are split into modules it may happen that no
transports are registered when v9fs_get_default_trans() is called.
When that is the case try to load more transports from modules.

Link: https://lkml.kernel.org/r/20211103193823.111007-5-linux@weissschuh.netSigned-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
[Dominique: constify v9fs_get_trans_by_name argument as per patch1v2]
Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
parent 99aa673e
...@@ -54,7 +54,7 @@ struct p9_trans_module { ...@@ -54,7 +54,7 @@ struct p9_trans_module {
void v9fs_register_trans(struct p9_trans_module *m); void v9fs_register_trans(struct p9_trans_module *m);
void v9fs_unregister_trans(struct p9_trans_module *m); void v9fs_unregister_trans(struct p9_trans_module *m);
struct p9_trans_module *v9fs_get_trans_by_name(char *s); struct p9_trans_module *v9fs_get_trans_by_name(const char *s);
struct p9_trans_module *v9fs_get_default_trans(void); struct p9_trans_module *v9fs_get_default_trans(void);
void v9fs_put_trans(struct p9_trans_module *m); void v9fs_put_trans(struct p9_trans_module *m);
......
...@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m) ...@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
} }
EXPORT_SYMBOL(v9fs_unregister_trans); EXPORT_SYMBOL(v9fs_unregister_trans);
static struct p9_trans_module *_p9_get_trans_by_name(char *s) static struct p9_trans_module *_p9_get_trans_by_name(const char *s)
{ {
struct p9_trans_module *t, *found = NULL; struct p9_trans_module *t, *found = NULL;
...@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s) ...@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s)
* @s: string identifying transport * @s: string identifying transport
* *
*/ */
struct p9_trans_module *v9fs_get_trans_by_name(char *s) struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
{ {
struct p9_trans_module *found = NULL; struct p9_trans_module *found = NULL;
...@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s) ...@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
} }
EXPORT_SYMBOL(v9fs_get_trans_by_name); EXPORT_SYMBOL(v9fs_get_trans_by_name);
static const char * const v9fs_default_transports[] = {
"virtio", "tcp", "fd", "unix", "xen", "rdma",
};
/** /**
* v9fs_get_default_trans - get the default transport * v9fs_get_default_trans - get the default transport
* *
...@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name); ...@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name);
struct p9_trans_module *v9fs_get_default_trans(void) struct p9_trans_module *v9fs_get_default_trans(void)
{ {
struct p9_trans_module *t, *found = NULL; struct p9_trans_module *t, *found = NULL;
int i;
spin_lock(&v9fs_trans_lock); spin_lock(&v9fs_trans_lock);
...@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void) ...@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void)
} }
spin_unlock(&v9fs_trans_lock); spin_unlock(&v9fs_trans_lock);
for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
return found; return found;
} }
EXPORT_SYMBOL(v9fs_get_default_trans); EXPORT_SYMBOL(v9fs_get_default_trans);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment