diff options
Diffstat (limited to 'fs/nfs/nfs3client.c')
| -rw-r--r-- | fs/nfs/nfs3client.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c index 8c1b437c5403..9e9fa347a948 100644 --- a/fs/nfs/nfs3client.c +++ b/fs/nfs/nfs3client.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/nfs_fs.h> | 1 | #include <linux/nfs_fs.h> |
| 2 | #include <linux/nfs_mount.h> | 2 | #include <linux/nfs_mount.h> |
| 3 | #include <linux/sunrpc/addr.h> | ||
| 3 | #include "internal.h" | 4 | #include "internal.h" |
| 4 | #include "nfs3_fs.h" | 5 | #include "nfs3_fs.h" |
| 5 | 6 | ||
| @@ -64,3 +65,43 @@ struct nfs_server *nfs3_clone_server(struct nfs_server *source, | |||
| 64 | nfs_init_server_aclclient(server); | 65 | nfs_init_server_aclclient(server); |
| 65 | return server; | 66 | return server; |
| 66 | } | 67 | } |
| 68 | |||
| 69 | /* | ||
| 70 | * Set up a pNFS Data Server client over NFSv3. | ||
| 71 | * | ||
| 72 | * Return any existing nfs_client that matches server address,port,version | ||
| 73 | * and minorversion. | ||
| 74 | * | ||
| 75 | * For a new nfs_client, use a soft mount (default), a low retrans and a | ||
| 76 | * low timeout interval so that if a connection is lost, we retry through | ||
| 77 | * the MDS. | ||
| 78 | */ | ||
| 79 | struct nfs_client *nfs3_set_ds_client(struct nfs_client *mds_clp, | ||
| 80 | const struct sockaddr *ds_addr, int ds_addrlen, | ||
| 81 | int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans, | ||
| 82 | rpc_authflavor_t au_flavor) | ||
| 83 | { | ||
| 84 | struct nfs_client_initdata cl_init = { | ||
| 85 | .addr = ds_addr, | ||
| 86 | .addrlen = ds_addrlen, | ||
| 87 | .nfs_mod = &nfs_v3, | ||
| 88 | .proto = ds_proto, | ||
| 89 | .net = mds_clp->cl_net, | ||
| 90 | }; | ||
| 91 | struct rpc_timeout ds_timeout; | ||
| 92 | struct nfs_client *clp; | ||
| 93 | char buf[INET6_ADDRSTRLEN + 1]; | ||
| 94 | |||
| 95 | /* fake a hostname because lockd wants it */ | ||
| 96 | if (rpc_ntop(ds_addr, buf, sizeof(buf)) <= 0) | ||
| 97 | return ERR_PTR(-EINVAL); | ||
| 98 | cl_init.hostname = buf; | ||
| 99 | |||
| 100 | /* Use the MDS nfs_client cl_ipaddr. */ | ||
| 101 | nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans); | ||
| 102 | clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr, | ||
| 103 | au_flavor); | ||
| 104 | |||
| 105 | return clp; | ||
| 106 | } | ||
| 107 | EXPORT_SYMBOL_GPL(nfs3_set_ds_client); | ||
