Skip to content

Commit 019641d

Browse files
t-8chmartinetd
authored andcommitted
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.net Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> [Dominique: constify v9fs_get_trans_by_name argument as per patch1v2] Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
1 parent 99aa673 commit 019641d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/net/9p/transport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct p9_trans_module {
5454

5555
void v9fs_register_trans(struct p9_trans_module *m);
5656
void v9fs_unregister_trans(struct p9_trans_module *m);
57-
struct p9_trans_module *v9fs_get_trans_by_name(char *s);
57+
struct p9_trans_module *v9fs_get_trans_by_name(const char *s);
5858
struct p9_trans_module *v9fs_get_default_trans(void);
5959
void v9fs_put_trans(struct p9_trans_module *m);
6060

net/9p/mod.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
8383
}
8484
EXPORT_SYMBOL(v9fs_unregister_trans);
8585

86-
static struct p9_trans_module *_p9_get_trans_by_name(char *s)
86+
static struct p9_trans_module *_p9_get_trans_by_name(const char *s)
8787
{
8888
struct p9_trans_module *t, *found = NULL;
8989

@@ -106,7 +106,7 @@ static struct p9_trans_module *_p9_get_trans_by_name(char *s)
106106
* @s: string identifying transport
107107
*
108108
*/
109-
struct p9_trans_module *v9fs_get_trans_by_name(char *s)
109+
struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
110110
{
111111
struct p9_trans_module *found = NULL;
112112

@@ -123,6 +123,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
123123
}
124124
EXPORT_SYMBOL(v9fs_get_trans_by_name);
125125

126+
static const char * const v9fs_default_transports[] = {
127+
"virtio", "tcp", "fd", "unix", "xen", "rdma",
128+
};
129+
126130
/**
127131
* v9fs_get_default_trans - get the default transport
128132
*
@@ -131,6 +135,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name);
131135
struct p9_trans_module *v9fs_get_default_trans(void)
132136
{
133137
struct p9_trans_module *t, *found = NULL;
138+
int i;
134139

135140
spin_lock(&v9fs_trans_lock);
136141

@@ -148,6 +153,10 @@ struct p9_trans_module *v9fs_get_default_trans(void)
148153
}
149154

150155
spin_unlock(&v9fs_trans_lock);
156+
157+
for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
158+
found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
159+
151160
return found;
152161
}
153162
EXPORT_SYMBOL(v9fs_get_default_trans);

0 commit comments

Comments
 (0)