diff options
author | Tom Talpey <tmtalpey@gmail.com> | 2009-03-11 14:37:56 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-03-11 14:37:56 -0400 |
commit | 441e3e242903f9b190d5764bed73edb58f977413 (patch) | |
tree | 3898c80feadee3cdeb3c99cb7d62861127f1b4ef | |
parent | b38ab40ad58c1fc43ea590d6342f6a6763ac8fb6 (diff) |
SUNRPC: dynamically load RPC transport modules on-demand
Provide an api to attempt to load any necessary kernel RPC
client transport module automatically. By convention, the
desired module name is "xprt"+"transport name". For example,
when NFS mounting with "-o proto=rdma", attempt to load the
"xprtrdma" module.
Signed-off-by: Tom Talpey <tmtalpey@gmail.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | include/linux/sunrpc/xprt.h | 1 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 11fc71d50c1e..2b0d960603b9 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h | |||
@@ -235,6 +235,7 @@ static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 * | |||
235 | */ | 235 | */ |
236 | int xprt_register_transport(struct xprt_class *type); | 236 | int xprt_register_transport(struct xprt_class *type); |
237 | int xprt_unregister_transport(struct xprt_class *type); | 237 | int xprt_unregister_transport(struct xprt_class *type); |
238 | int xprt_load_transport(const char *); | ||
238 | void xprt_set_retrans_timeout_def(struct rpc_task *task); | 239 | void xprt_set_retrans_timeout_def(struct rpc_task *task); |
239 | void xprt_set_retrans_timeout_rtt(struct rpc_task *task); | 240 | void xprt_set_retrans_timeout_rtt(struct rpc_task *task); |
240 | void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status); | 241 | void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status); |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 62098d101a1f..d1afec640394 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -152,6 +152,37 @@ out: | |||
152 | EXPORT_SYMBOL_GPL(xprt_unregister_transport); | 152 | EXPORT_SYMBOL_GPL(xprt_unregister_transport); |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * xprt_load_transport - load a transport implementation | ||
156 | * @transport_name: transport to load | ||
157 | * | ||
158 | * Returns: | ||
159 | * 0: transport successfully loaded | ||
160 | * -ENOENT: transport module not available | ||
161 | */ | ||
162 | int xprt_load_transport(const char *transport_name) | ||
163 | { | ||
164 | struct xprt_class *t; | ||
165 | char module_name[sizeof t->name + 5]; | ||
166 | int result; | ||
167 | |||
168 | result = 0; | ||
169 | spin_lock(&xprt_list_lock); | ||
170 | list_for_each_entry(t, &xprt_list, list) { | ||
171 | if (strcmp(t->name, transport_name) == 0) { | ||
172 | spin_unlock(&xprt_list_lock); | ||
173 | goto out; | ||
174 | } | ||
175 | } | ||
176 | spin_unlock(&xprt_list_lock); | ||
177 | strcpy(module_name, "xprt"); | ||
178 | strncat(module_name, transport_name, sizeof t->name); | ||
179 | result = request_module(module_name); | ||
180 | out: | ||
181 | return result; | ||
182 | } | ||
183 | EXPORT_SYMBOL_GPL(xprt_load_transport); | ||
184 | |||
185 | /** | ||
155 | * xprt_reserve_xprt - serialize write access to transports | 186 | * xprt_reserve_xprt - serialize write access to transports |
156 | * @task: task that is requesting access to the transport | 187 | * @task: task that is requesting access to the transport |
157 | * | 188 | * |