Skip to content

Commit 4cd82a5

Browse files
t-8chmartinetd
authored andcommitted
net/9p: autoload transport modules
Automatically load transport modules based on the trans= parameter passed to mount. This removes the requirement for the user to know which module to use. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Dominique Martinet <[email protected]>
1 parent 27eb4c3 commit 4cd82a5

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

include/net/9p/transport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#ifndef NET_9P_TRANSPORT_H
1212
#define NET_9P_TRANSPORT_H
1313

14+
#include <linux/module.h>
15+
1416
#define P9_DEF_MIN_RESVPORT (665U)
1517
#define P9_DEF_MAX_RESVPORT (1023U)
1618

@@ -55,4 +57,8 @@ void v9fs_unregister_trans(struct p9_trans_module *m);
5557
struct p9_trans_module *v9fs_get_trans_by_name(char *s);
5658
struct p9_trans_module *v9fs_get_default_trans(void);
5759
void v9fs_put_trans(struct p9_trans_module *m);
60+
61+
#define MODULE_ALIAS_9P(transport) \
62+
MODULE_ALIAS("9p-" transport)
63+
5864
#endif /* NET_9P_TRANSPORT_H */

net/9p/mod.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1313

1414
#include <linux/module.h>
15+
#include <linux/kmod.h>
1516
#include <linux/errno.h>
1617
#include <linux/sched.h>
1718
#include <linux/moduleparam.h>
@@ -87,12 +88,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m)
8788
}
8889
EXPORT_SYMBOL(v9fs_unregister_trans);
8990

90-
/**
91-
* v9fs_get_trans_by_name - get transport with the matching name
92-
* @s: string identifying transport
93-
*
94-
*/
95-
struct p9_trans_module *v9fs_get_trans_by_name(char *s)
91+
static struct p9_trans_module *_p9_get_trans_by_name(char *s)
9692
{
9793
struct p9_trans_module *t, *found = NULL;
9894

@@ -106,6 +102,28 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s)
106102
}
107103

108104
spin_unlock(&v9fs_trans_lock);
105+
106+
return found;
107+
}
108+
109+
/**
110+
* v9fs_get_trans_by_name - get transport with the matching name
111+
* @s: string identifying transport
112+
*
113+
*/
114+
struct p9_trans_module *v9fs_get_trans_by_name(char *s)
115+
{
116+
struct p9_trans_module *found = NULL;
117+
118+
found = _p9_get_trans_by_name(s);
119+
120+
#ifdef CONFIG_MODULES
121+
if (!found) {
122+
request_module("9p-%s", s);
123+
found = _p9_get_trans_by_name(s);
124+
}
125+
#endif
126+
109127
return found;
110128
}
111129
EXPORT_SYMBOL(v9fs_get_trans_by_name);

net/9p/trans_rdma.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ static void __exit p9_trans_rdma_exit(void)
767767

768768
module_init(p9_trans_rdma_init);
769769
module_exit(p9_trans_rdma_exit);
770+
MODULE_ALIAS_9P("rdma");
770771

771772
MODULE_AUTHOR("Tom Tucker <[email protected]>");
772773
MODULE_DESCRIPTION("RDMA Transport for 9P");

net/9p/trans_virtio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ static void __exit p9_virtio_cleanup(void)
794794

795795
module_init(p9_virtio_init);
796796
module_exit(p9_virtio_cleanup);
797+
MODULE_ALIAS_9P("virtio");
797798

798799
MODULE_DEVICE_TABLE(virtio, id_table);
799800
MODULE_AUTHOR("Eric Van Hensbergen <[email protected]>");

net/9p/trans_xen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ static int p9_trans_xen_init(void)
552552
return rc;
553553
}
554554
module_init(p9_trans_xen_init);
555+
MODULE_ALIAS_9P("xen");
555556

556557
static void p9_trans_xen_exit(void)
557558
{

0 commit comments

Comments
 (0)