David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 1 | /* client.c: NFS client sharing and management code |
| 2 | * |
| 3 | * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 15 | #include <linux/sched.h> |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 16 | #include <linux/time.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/mm.h> |
| 19 | #include <linux/string.h> |
| 20 | #include <linux/stat.h> |
| 21 | #include <linux/errno.h> |
| 22 | #include <linux/unistd.h> |
| 23 | #include <linux/sunrpc/clnt.h> |
| 24 | #include <linux/sunrpc/stats.h> |
| 25 | #include <linux/sunrpc/metrics.h> |
\"Talpey, Thomas\ | 0896a72 | 2007-09-10 13:48:23 -0400 | [diff] [blame] | 26 | #include <linux/sunrpc/xprtsock.h> |
\"Talpey, Thomas\ | 2cf7ff7 | 2007-09-10 13:49:41 -0400 | [diff] [blame] | 27 | #include <linux/sunrpc/xprtrdma.h> |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 28 | #include <linux/nfs_fs.h> |
| 29 | #include <linux/nfs_mount.h> |
| 30 | #include <linux/nfs4_mount.h> |
| 31 | #include <linux/lockd/bind.h> |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 32 | #include <linux/seq_file.h> |
| 33 | #include <linux/mount.h> |
| 34 | #include <linux/nfs_idmap.h> |
| 35 | #include <linux/vfs.h> |
| 36 | #include <linux/inet.h> |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 37 | #include <linux/in6.h> |
| 38 | #include <net/ipv6.h> |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 39 | #include <linux/nfs_xdr.h> |
| 40 | |
| 41 | #include <asm/system.h> |
| 42 | |
| 43 | #include "nfs4_fs.h" |
| 44 | #include "callback.h" |
| 45 | #include "delegation.h" |
| 46 | #include "iostat.h" |
| 47 | #include "internal.h" |
David Howells | 1472728 | 2009-04-03 16:42:42 +0100 | [diff] [blame] | 48 | #include "fscache.h" |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 49 | |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 50 | static int nfs4_init_callback(struct nfs_client *); |
| 51 | static void nfs4_destroy_callback(struct nfs_client *); |
| 52 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 53 | #define NFSDBG_FACILITY NFSDBG_CLIENT |
| 54 | |
| 55 | static DEFINE_SPINLOCK(nfs_client_lock); |
| 56 | static LIST_HEAD(nfs_client_list); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 57 | static LIST_HEAD(nfs_volume_list); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 58 | static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq); |
| 59 | |
| 60 | /* |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 61 | * RPC cruft for NFS |
| 62 | */ |
| 63 | static struct rpc_version *nfs_version[5] = { |
| 64 | [2] = &nfs_version2, |
| 65 | #ifdef CONFIG_NFS_V3 |
| 66 | [3] = &nfs_version3, |
| 67 | #endif |
| 68 | #ifdef CONFIG_NFS_V4 |
| 69 | [4] = &nfs_version4, |
| 70 | #endif |
| 71 | }; |
| 72 | |
| 73 | struct rpc_program nfs_program = { |
| 74 | .name = "nfs", |
| 75 | .number = NFS_PROGRAM, |
| 76 | .nrvers = ARRAY_SIZE(nfs_version), |
| 77 | .version = nfs_version, |
| 78 | .stats = &nfs_rpcstat, |
| 79 | .pipe_dir_name = "/nfs", |
| 80 | }; |
| 81 | |
| 82 | struct rpc_stat nfs_rpcstat = { |
| 83 | .program = &nfs_program |
| 84 | }; |
| 85 | |
| 86 | |
| 87 | #ifdef CONFIG_NFS_V3_ACL |
| 88 | static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program }; |
| 89 | static struct rpc_version * nfsacl_version[] = { |
| 90 | [3] = &nfsacl_version3, |
| 91 | }; |
| 92 | |
| 93 | struct rpc_program nfsacl_program = { |
| 94 | .name = "nfsacl", |
| 95 | .number = NFS_ACL_PROGRAM, |
| 96 | .nrvers = ARRAY_SIZE(nfsacl_version), |
| 97 | .version = nfsacl_version, |
| 98 | .stats = &nfsacl_rpcstat, |
| 99 | }; |
| 100 | #endif /* CONFIG_NFS_V3_ACL */ |
| 101 | |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 102 | struct nfs_client_initdata { |
| 103 | const char *hostname; |
Chuck Lever | d7422c4 | 2007-12-10 14:58:51 -0500 | [diff] [blame] | 104 | const struct sockaddr *addr; |
Chuck Lever | 6e4cffd | 2007-12-10 14:58:15 -0500 | [diff] [blame] | 105 | size_t addrlen; |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 106 | const struct nfs_rpc_ops *rpc_ops; |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 107 | int proto; |
Benny Halevy | 5aae4a9 | 2009-04-01 09:21:50 -0400 | [diff] [blame] | 108 | u32 minorversion; |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 109 | }; |
| 110 | |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 111 | /* |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 112 | * Allocate a shared client record |
| 113 | * |
| 114 | * Since these are allocated/deallocated very rarely, we don't |
| 115 | * bother putting them in a slab cache... |
| 116 | */ |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 117 | static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 118 | { |
| 119 | struct nfs_client *clp; |
Trond Myklebust | 7c67db3 | 2008-04-07 20:50:11 -0400 | [diff] [blame] | 120 | struct rpc_cred *cred; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 121 | |
| 122 | if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) |
| 123 | goto error_0; |
| 124 | |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 125 | clp->rpc_ops = cl_init->rpc_ops; |
| 126 | |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 127 | if (nfs4_init_callback(clp) < 0) |
| 128 | goto error_2; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 129 | |
| 130 | atomic_set(&clp->cl_count, 1); |
| 131 | clp->cl_cons_state = NFS_CS_INITING; |
| 132 | |
Chuck Lever | 6e4cffd | 2007-12-10 14:58:15 -0500 | [diff] [blame] | 133 | memcpy(&clp->cl_addr, cl_init->addr, cl_init->addrlen); |
| 134 | clp->cl_addrlen = cl_init->addrlen; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 135 | |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 136 | if (cl_init->hostname) { |
| 137 | clp->cl_hostname = kstrdup(cl_init->hostname, GFP_KERNEL); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 138 | if (!clp->cl_hostname) |
| 139 | goto error_3; |
| 140 | } |
| 141 | |
| 142 | INIT_LIST_HEAD(&clp->cl_superblocks); |
| 143 | clp->cl_rpcclient = ERR_PTR(-EINVAL); |
| 144 | |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 145 | clp->cl_proto = cl_init->proto; |
| 146 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 147 | #ifdef CONFIG_NFS_V4 |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 148 | INIT_LIST_HEAD(&clp->cl_delegations); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 149 | spin_lock_init(&clp->cl_lock); |
David Howells | 65f27f3 | 2006-11-22 14:55:48 +0000 | [diff] [blame] | 150 | INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 151 | rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client"); |
| 152 | clp->cl_boot_time = CURRENT_TIME; |
| 153 | clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; |
Benny Halevy | 5aae4a9 | 2009-04-01 09:21:50 -0400 | [diff] [blame] | 154 | clp->cl_minorversion = cl_init->minorversion; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 155 | #endif |
Trond Myklebust | 7c67db3 | 2008-04-07 20:50:11 -0400 | [diff] [blame] | 156 | cred = rpc_lookup_machine_cred(); |
| 157 | if (!IS_ERR(cred)) |
| 158 | clp->cl_machine_cred = cred; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 159 | |
David Howells | 1472728 | 2009-04-03 16:42:42 +0100 | [diff] [blame] | 160 | nfs_fscache_get_client_cookie(clp); |
| 161 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 162 | return clp; |
| 163 | |
| 164 | error_3: |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 165 | nfs4_destroy_callback(clp); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 166 | error_2: |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 167 | kfree(clp); |
| 168 | error_0: |
| 169 | return NULL; |
| 170 | } |
| 171 | |
Trond Myklebust | 5dd3177 | 2006-08-24 01:03:05 -0400 | [diff] [blame] | 172 | static void nfs4_shutdown_client(struct nfs_client *clp) |
| 173 | { |
| 174 | #ifdef CONFIG_NFS_V4 |
| 175 | if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state)) |
| 176 | nfs4_kill_renewd(clp); |
Trond Myklebust | 9f958ab | 2007-07-02 13:58:33 -0400 | [diff] [blame] | 177 | BUG_ON(!RB_EMPTY_ROOT(&clp->cl_state_owners)); |
Trond Myklebust | 5dd3177 | 2006-08-24 01:03:05 -0400 | [diff] [blame] | 178 | if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state)) |
| 179 | nfs_idmap_delete(clp); |
Trond Myklebust | f6a1cc8 | 2008-02-22 17:06:55 -0500 | [diff] [blame] | 180 | |
| 181 | rpc_destroy_wait_queue(&clp->cl_rpcwaitq); |
Trond Myklebust | 5dd3177 | 2006-08-24 01:03:05 -0400 | [diff] [blame] | 182 | #endif |
| 183 | } |
| 184 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 185 | /* |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 186 | * Destroy the NFS4 callback service |
| 187 | */ |
| 188 | static void nfs4_destroy_callback(struct nfs_client *clp) |
| 189 | { |
| 190 | #ifdef CONFIG_NFS_V4 |
| 191 | if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) |
| 192 | nfs_callback_down(); |
| 193 | #endif /* CONFIG_NFS_V4 */ |
| 194 | } |
| 195 | |
| 196 | /* |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 197 | * Clears/puts all minor version specific parts from an nfs_client struct |
| 198 | * reverting it to minorversion 0. |
| 199 | */ |
| 200 | static void nfs4_clear_client_minor_version(struct nfs_client *clp) |
| 201 | { |
| 202 | #ifdef CONFIG_NFS_V4_1 |
| 203 | if (nfs4_has_session(clp)) { |
| 204 | nfs4_destroy_session(clp->cl_session); |
| 205 | clp->cl_session = NULL; |
| 206 | } |
Andy Adamson | cccef3b | 2009-04-01 09:22:03 -0400 | [diff] [blame] | 207 | |
| 208 | clp->cl_call_sync = _nfs4_call_sync; |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 209 | #endif /* CONFIG_NFS_V4_1 */ |
| 210 | } |
| 211 | |
| 212 | /* |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 213 | * Destroy a shared client record |
| 214 | */ |
| 215 | static void nfs_free_client(struct nfs_client *clp) |
| 216 | { |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 217 | dprintk("--> nfs_free_client(%u)\n", clp->rpc_ops->version); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 218 | |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 219 | nfs4_clear_client_minor_version(clp); |
Trond Myklebust | 5dd3177 | 2006-08-24 01:03:05 -0400 | [diff] [blame] | 220 | nfs4_shutdown_client(clp); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 221 | |
David Howells | 1472728 | 2009-04-03 16:42:42 +0100 | [diff] [blame] | 222 | nfs_fscache_release_client_cookie(clp); |
| 223 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 224 | /* -EIO all pending I/O */ |
| 225 | if (!IS_ERR(clp->cl_rpcclient)) |
| 226 | rpc_shutdown_client(clp->cl_rpcclient); |
| 227 | |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 228 | nfs4_destroy_callback(clp); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 229 | |
Trond Myklebust | 7c67db3 | 2008-04-07 20:50:11 -0400 | [diff] [blame] | 230 | if (clp->cl_machine_cred != NULL) |
| 231 | put_rpccred(clp->cl_machine_cred); |
| 232 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 233 | kfree(clp->cl_hostname); |
| 234 | kfree(clp); |
| 235 | |
| 236 | dprintk("<-- nfs_free_client()\n"); |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * Release a reference to a shared client record |
| 241 | */ |
| 242 | void nfs_put_client(struct nfs_client *clp) |
| 243 | { |
David Howells | 27ba851 | 2006-07-30 14:40:56 -0400 | [diff] [blame] | 244 | if (!clp) |
| 245 | return; |
| 246 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 247 | dprintk("--> nfs_put_client({%d})\n", atomic_read(&clp->cl_count)); |
| 248 | |
| 249 | if (atomic_dec_and_lock(&clp->cl_count, &nfs_client_lock)) { |
| 250 | list_del(&clp->cl_share_link); |
| 251 | spin_unlock(&nfs_client_lock); |
| 252 | |
| 253 | BUG_ON(!list_empty(&clp->cl_superblocks)); |
| 254 | |
| 255 | nfs_free_client(clp); |
| 256 | } |
| 257 | } |
| 258 | |
Trond Myklebust | 9082a5c | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 259 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 260 | /* |
| 261 | * Test if two ip6 socket addresses refer to the same socket by |
| 262 | * comparing relevant fields. The padding bytes specifically, are not |
| 263 | * compared. sin6_flowinfo is not compared because it only affects QoS |
| 264 | * and sin6_scope_id is only compared if the address is "link local" |
| 265 | * because "link local" addresses need only be unique to a specific |
| 266 | * link. Conversely, ordinary unicast addresses might have different |
| 267 | * sin6_scope_id. |
| 268 | * |
| 269 | * The caller should ensure both socket addresses are AF_INET6. |
| 270 | */ |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 271 | static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1, |
| 272 | const struct sockaddr *sa2) |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 273 | { |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 274 | const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1; |
| 275 | const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2; |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 276 | |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 277 | if (ipv6_addr_scope(&sin1->sin6_addr) == IPV6_ADDR_SCOPE_LINKLOCAL && |
| 278 | sin1->sin6_scope_id != sin2->sin6_scope_id) |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 279 | return 0; |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 280 | |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 281 | return ipv6_addr_equal(&sin1->sin6_addr, &sin1->sin6_addr); |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 282 | } |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 283 | #else /* !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) */ |
| 284 | static int nfs_sockaddr_match_ipaddr6(const struct sockaddr *sa1, |
| 285 | const struct sockaddr *sa2) |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 286 | { |
| 287 | return 0; |
| 288 | } |
Trond Myklebust | 9082a5c | 2008-12-23 15:21:53 -0500 | [diff] [blame] | 289 | #endif |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 290 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 291 | /* |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 292 | * Test if two ip4 socket addresses refer to the same socket, by |
| 293 | * comparing relevant fields. The padding bytes specifically, are |
| 294 | * not compared. |
| 295 | * |
| 296 | * The caller should ensure both socket addresses are AF_INET. |
| 297 | */ |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 298 | static int nfs_sockaddr_match_ipaddr4(const struct sockaddr *sa1, |
| 299 | const struct sockaddr *sa2) |
| 300 | { |
| 301 | const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1; |
| 302 | const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2; |
| 303 | |
| 304 | return sin1->sin_addr.s_addr == sin2->sin_addr.s_addr; |
| 305 | } |
| 306 | |
| 307 | static int nfs_sockaddr_cmp_ip6(const struct sockaddr *sa1, |
| 308 | const struct sockaddr *sa2) |
| 309 | { |
| 310 | const struct sockaddr_in6 *sin1 = (const struct sockaddr_in6 *)sa1; |
| 311 | const struct sockaddr_in6 *sin2 = (const struct sockaddr_in6 *)sa2; |
| 312 | |
| 313 | return nfs_sockaddr_match_ipaddr6(sa1, sa2) && |
| 314 | (sin1->sin6_port == sin2->sin6_port); |
| 315 | } |
| 316 | |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 317 | static int nfs_sockaddr_cmp_ip4(const struct sockaddr *sa1, |
| 318 | const struct sockaddr *sa2) |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 319 | { |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 320 | const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1; |
| 321 | const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2; |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 322 | |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 323 | return nfs_sockaddr_match_ipaddr4(sa1, sa2) && |
| 324 | (sin1->sin_port == sin2->sin_port); |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /* |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 328 | * Test if two socket addresses represent the same actual socket, |
Chuck Lever | 3c8c45d | 2009-03-18 20:48:14 -0400 | [diff] [blame] | 329 | * by comparing (only) relevant fields, excluding the port number. |
| 330 | */ |
| 331 | static int nfs_sockaddr_match_ipaddr(const struct sockaddr *sa1, |
| 332 | const struct sockaddr *sa2) |
| 333 | { |
| 334 | if (sa1->sa_family != sa2->sa_family) |
| 335 | return 0; |
| 336 | |
| 337 | switch (sa1->sa_family) { |
| 338 | case AF_INET: |
| 339 | return nfs_sockaddr_match_ipaddr4(sa1, sa2); |
| 340 | case AF_INET6: |
| 341 | return nfs_sockaddr_match_ipaddr6(sa1, sa2); |
| 342 | } |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | /* |
| 347 | * Test if two socket addresses represent the same actual socket, |
| 348 | * by comparing (only) relevant fields, including the port number. |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 349 | */ |
| 350 | static int nfs_sockaddr_cmp(const struct sockaddr *sa1, |
| 351 | const struct sockaddr *sa2) |
| 352 | { |
| 353 | if (sa1->sa_family != sa2->sa_family) |
| 354 | return 0; |
| 355 | |
| 356 | switch (sa1->sa_family) { |
| 357 | case AF_INET: |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 358 | return nfs_sockaddr_cmp_ip4(sa1, sa2); |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 359 | case AF_INET6: |
Trond Myklebust | 9f4c899 | 2009-03-12 14:51:32 -0400 | [diff] [blame] | 360 | return nfs_sockaddr_cmp_ip6(sa1, sa2); |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 361 | } |
| 362 | return 0; |
| 363 | } |
| 364 | |
| 365 | /* |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 366 | * Find a client by IP address and protocol version |
| 367 | * - returns NULL if no such client |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 368 | */ |
Chuck Lever | ff05264 | 2007-12-10 14:58:44 -0500 | [diff] [blame] | 369 | struct nfs_client *nfs_find_client(const struct sockaddr *addr, u32 nfsversion) |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 370 | { |
| 371 | struct nfs_client *clp; |
| 372 | |
| 373 | spin_lock(&nfs_client_lock); |
| 374 | list_for_each_entry(clp, &nfs_client_list, cl_share_link) { |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 375 | struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; |
| 376 | |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 377 | /* Don't match clients that failed to initialise properly */ |
Andy Adamson | 76db6d9 | 2009-04-01 09:22:38 -0400 | [diff] [blame] | 378 | if (!(clp->cl_cons_state == NFS_CS_READY || |
| 379 | clp->cl_cons_state == NFS_CS_SESSION_INITING)) |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 380 | continue; |
| 381 | |
| 382 | /* Different NFS versions cannot share the same nfs_client */ |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 383 | if (clp->rpc_ops->version != nfsversion) |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 384 | continue; |
| 385 | |
| 386 | /* Match only the IP address, not the port number */ |
Trond Myklebust | 3b0d3f9 | 2008-01-03 13:28:58 -0500 | [diff] [blame] | 387 | if (!nfs_sockaddr_match_ipaddr(addr, clap)) |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 388 | continue; |
| 389 | |
| 390 | atomic_inc(&clp->cl_count); |
| 391 | spin_unlock(&nfs_client_lock); |
| 392 | return clp; |
| 393 | } |
| 394 | spin_unlock(&nfs_client_lock); |
| 395 | return NULL; |
| 396 | } |
| 397 | |
| 398 | /* |
Trond Myklebust | 3fbd67a | 2008-01-26 01:06:40 -0500 | [diff] [blame] | 399 | * Find a client by IP address and protocol version |
| 400 | * - returns NULL if no such client |
| 401 | */ |
| 402 | struct nfs_client *nfs_find_client_next(struct nfs_client *clp) |
| 403 | { |
| 404 | struct sockaddr *sap = (struct sockaddr *)&clp->cl_addr; |
| 405 | u32 nfsvers = clp->rpc_ops->version; |
| 406 | |
| 407 | spin_lock(&nfs_client_lock); |
| 408 | list_for_each_entry_continue(clp, &nfs_client_list, cl_share_link) { |
| 409 | struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; |
| 410 | |
| 411 | /* Don't match clients that failed to initialise properly */ |
| 412 | if (clp->cl_cons_state != NFS_CS_READY) |
| 413 | continue; |
| 414 | |
| 415 | /* Different NFS versions cannot share the same nfs_client */ |
| 416 | if (clp->rpc_ops->version != nfsvers) |
| 417 | continue; |
| 418 | |
Trond Myklebust | 3fbd67a | 2008-01-26 01:06:40 -0500 | [diff] [blame] | 419 | /* Match only the IP address, not the port number */ |
| 420 | if (!nfs_sockaddr_match_ipaddr(sap, clap)) |
| 421 | continue; |
| 422 | |
| 423 | atomic_inc(&clp->cl_count); |
| 424 | spin_unlock(&nfs_client_lock); |
| 425 | return clp; |
| 426 | } |
| 427 | spin_unlock(&nfs_client_lock); |
| 428 | return NULL; |
| 429 | } |
| 430 | |
| 431 | /* |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 432 | * Find an nfs_client on the list that matches the initialisation data |
| 433 | * that is supplied. |
| 434 | */ |
| 435 | static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *data) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 436 | { |
| 437 | struct nfs_client *clp; |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 438 | const struct sockaddr *sap = data->addr; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 439 | |
| 440 | list_for_each_entry(clp, &nfs_client_list, cl_share_link) { |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 441 | const struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; |
Trond Myklebust | 13bbc06 | 2006-10-19 23:28:40 -0700 | [diff] [blame] | 442 | /* Don't match clients that failed to initialise properly */ |
| 443 | if (clp->cl_cons_state < 0) |
| 444 | continue; |
| 445 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 446 | /* Different NFS versions cannot share the same nfs_client */ |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 447 | if (clp->rpc_ops != data->rpc_ops) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 448 | continue; |
| 449 | |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 450 | if (clp->cl_proto != data->proto) |
| 451 | continue; |
Benny Halevy | 5aae4a9 | 2009-04-01 09:21:50 -0400 | [diff] [blame] | 452 | /* Match nfsv4 minorversion */ |
| 453 | if (clp->cl_minorversion != data->minorversion) |
| 454 | continue; |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 455 | /* Match the full socket address */ |
Ian Dall | d7371c4 | 2009-03-10 20:33:22 -0400 | [diff] [blame] | 456 | if (!nfs_sockaddr_cmp(sap, clap)) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 457 | continue; |
| 458 | |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 459 | atomic_inc(&clp->cl_count); |
| 460 | return clp; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 461 | } |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 462 | return NULL; |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /* |
| 466 | * Look up a client by IP address and protocol version |
| 467 | * - creates a new record if one doesn't yet exist |
| 468 | */ |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 469 | static struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 470 | { |
| 471 | struct nfs_client *clp, *new = NULL; |
| 472 | int error; |
| 473 | |
Chuck Lever | d7422c4 | 2007-12-10 14:58:51 -0500 | [diff] [blame] | 474 | dprintk("--> nfs_get_client(%s,v%u)\n", |
| 475 | cl_init->hostname ?: "", cl_init->rpc_ops->version); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 476 | |
| 477 | /* see if the client already exists */ |
| 478 | do { |
| 479 | spin_lock(&nfs_client_lock); |
| 480 | |
Trond Myklebust | c81468a | 2007-12-14 14:56:05 -0500 | [diff] [blame] | 481 | clp = nfs_match_client(cl_init); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 482 | if (clp) |
| 483 | goto found_client; |
| 484 | if (new) |
| 485 | goto install_client; |
| 486 | |
| 487 | spin_unlock(&nfs_client_lock); |
| 488 | |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 489 | new = nfs_alloc_client(cl_init); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 490 | } while (new); |
| 491 | |
| 492 | return ERR_PTR(-ENOMEM); |
| 493 | |
| 494 | /* install a new client and return with it unready */ |
| 495 | install_client: |
| 496 | clp = new; |
| 497 | list_add(&clp->cl_share_link, &nfs_client_list); |
| 498 | spin_unlock(&nfs_client_lock); |
| 499 | dprintk("--> nfs_get_client() = %p [new]\n", clp); |
| 500 | return clp; |
| 501 | |
| 502 | /* found an existing client |
| 503 | * - make sure it's ready before returning |
| 504 | */ |
| 505 | found_client: |
| 506 | spin_unlock(&nfs_client_lock); |
| 507 | |
| 508 | if (new) |
| 509 | nfs_free_client(new); |
| 510 | |
Matthew Wilcox | 150030b | 2007-12-06 16:24:39 -0500 | [diff] [blame] | 511 | error = wait_event_killable(nfs_client_active_wq, |
Andy Adamson | 76db6d9 | 2009-04-01 09:22:38 -0400 | [diff] [blame] | 512 | clp->cl_cons_state < NFS_CS_INITING); |
Trond Myklebust | 0bae89e | 2006-10-08 14:33:24 -0400 | [diff] [blame] | 513 | if (error < 0) { |
| 514 | nfs_put_client(clp); |
| 515 | return ERR_PTR(-ERESTARTSYS); |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | if (clp->cl_cons_state < NFS_CS_READY) { |
| 519 | error = clp->cl_cons_state; |
| 520 | nfs_put_client(clp); |
| 521 | return ERR_PTR(error); |
| 522 | } |
| 523 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 524 | BUG_ON(clp->cl_cons_state != NFS_CS_READY); |
| 525 | |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 526 | dprintk("--> nfs_get_client() = %p [share]\n", clp); |
| 527 | return clp; |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 | * Mark a server as ready or failed |
| 532 | */ |
Andy Adamson | 76db6d9 | 2009-04-01 09:22:38 -0400 | [diff] [blame] | 533 | void nfs_mark_client_ready(struct nfs_client *clp, int state) |
David Howells | 24c8dbb | 2006-08-22 20:06:10 -0400 | [diff] [blame] | 534 | { |
| 535 | clp->cl_cons_state = state; |
| 536 | wake_up_all(&nfs_client_active_wq); |
| 537 | } |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 538 | |
| 539 | /* |
Benny Halevy | 008f55d | 2009-04-01 09:22:50 -0400 | [diff] [blame] | 540 | * With sessions, the client is not marked ready until after a |
| 541 | * successful EXCHANGE_ID and CREATE_SESSION. |
| 542 | * |
| 543 | * Map errors cl_cons_state errors to EPROTONOSUPPORT to indicate |
| 544 | * other versions of NFS can be tried. |
| 545 | */ |
| 546 | int nfs4_check_client_ready(struct nfs_client *clp) |
| 547 | { |
| 548 | if (!nfs4_has_session(clp)) |
| 549 | return 0; |
| 550 | if (clp->cl_cons_state < NFS_CS_READY) |
| 551 | return -EPROTONOSUPPORT; |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | /* |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 556 | * Initialise the timeout values for a connection |
| 557 | */ |
| 558 | static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, |
| 559 | unsigned int timeo, unsigned int retrans) |
| 560 | { |
| 561 | to->to_initval = timeo * HZ / 10; |
| 562 | to->to_retries = retrans; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 563 | |
| 564 | switch (proto) { |
\"Talpey, Thomas\ | 0896a72 | 2007-09-10 13:48:23 -0400 | [diff] [blame] | 565 | case XPRT_TRANSPORT_TCP: |
\"Talpey, Thomas\ | 2cf7ff7 | 2007-09-10 13:49:41 -0400 | [diff] [blame] | 566 | case XPRT_TRANSPORT_RDMA: |
Trond Myklebust | 259875e | 2008-07-02 14:43:47 -0400 | [diff] [blame] | 567 | if (to->to_retries == 0) |
| 568 | to->to_retries = NFS_DEF_TCP_RETRANS; |
Trond Myklebust | 7a3e3e1 | 2007-12-20 16:03:57 -0500 | [diff] [blame] | 569 | if (to->to_initval == 0) |
Trond Myklebust | 259875e | 2008-07-02 14:43:47 -0400 | [diff] [blame] | 570 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 571 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
| 572 | to->to_initval = NFS_MAX_TCP_TIMEOUT; |
| 573 | to->to_increment = to->to_initval; |
| 574 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); |
Trond Myklebust | 7a3e3e1 | 2007-12-20 16:03:57 -0500 | [diff] [blame] | 575 | if (to->to_maxval > NFS_MAX_TCP_TIMEOUT) |
| 576 | to->to_maxval = NFS_MAX_TCP_TIMEOUT; |
| 577 | if (to->to_maxval < to->to_initval) |
| 578 | to->to_maxval = to->to_initval; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 579 | to->to_exponential = 0; |
| 580 | break; |
\"Talpey, Thomas\ | 0896a72 | 2007-09-10 13:48:23 -0400 | [diff] [blame] | 581 | case XPRT_TRANSPORT_UDP: |
Trond Myklebust | 259875e | 2008-07-02 14:43:47 -0400 | [diff] [blame] | 582 | if (to->to_retries == 0) |
| 583 | to->to_retries = NFS_DEF_UDP_RETRANS; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 584 | if (!to->to_initval) |
Trond Myklebust | 259875e | 2008-07-02 14:43:47 -0400 | [diff] [blame] | 585 | to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 586 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) |
| 587 | to->to_initval = NFS_MAX_UDP_TIMEOUT; |
| 588 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; |
| 589 | to->to_exponential = 1; |
| 590 | break; |
Trond Myklebust | 259875e | 2008-07-02 14:43:47 -0400 | [diff] [blame] | 591 | default: |
| 592 | BUG(); |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | |
| 596 | /* |
| 597 | * Create an RPC client handle |
| 598 | */ |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 599 | static int nfs_create_rpc_client(struct nfs_client *clp, |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 600 | const struct rpc_timeout *timeparms, |
| 601 | rpc_authflavor_t flavor, |
Chuck Lever | 4a01b8a | 2008-12-23 15:21:35 -0500 | [diff] [blame] | 602 | int discrtry, int noresvport) |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 603 | { |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 604 | struct rpc_clnt *clnt = NULL; |
Chuck Lever | 41877d2 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 605 | struct rpc_create_args args = { |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 606 | .protocol = clp->cl_proto, |
Chuck Lever | 41877d2 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 607 | .address = (struct sockaddr *)&clp->cl_addr, |
Chuck Lever | 6e4cffd | 2007-12-10 14:58:15 -0500 | [diff] [blame] | 608 | .addrsize = clp->cl_addrlen, |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 609 | .timeout = timeparms, |
Chuck Lever | 41877d2 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 610 | .servername = clp->cl_hostname, |
| 611 | .program = &nfs_program, |
| 612 | .version = clp->rpc_ops->version, |
| 613 | .authflavor = flavor, |
| 614 | }; |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 615 | |
Chuck Lever | 4a01b8a | 2008-12-23 15:21:35 -0500 | [diff] [blame] | 616 | if (discrtry) |
| 617 | args.flags |= RPC_CLNT_CREATE_DISCRTRY; |
| 618 | if (noresvport) |
| 619 | args.flags |= RPC_CLNT_CREATE_NONPRIVPORT; |
| 620 | |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 621 | if (!IS_ERR(clp->cl_rpcclient)) |
| 622 | return 0; |
| 623 | |
Chuck Lever | 41877d2 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 624 | clnt = rpc_create(&args); |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 625 | if (IS_ERR(clnt)) { |
| 626 | dprintk("%s: cannot create RPC client. Error = %ld\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 627 | __func__, PTR_ERR(clnt)); |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 628 | return PTR_ERR(clnt); |
| 629 | } |
| 630 | |
David Howells | 5006a76 | 2006-08-22 20:06:12 -0400 | [diff] [blame] | 631 | clp->cl_rpcclient = clnt; |
| 632 | return 0; |
| 633 | } |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 634 | |
| 635 | /* |
| 636 | * Version 2 or 3 client destruction |
| 637 | */ |
| 638 | static void nfs_destroy_server(struct nfs_server *server) |
| 639 | { |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 640 | if (!(server->flags & NFS_MOUNT_NONLM)) |
Chuck Lever | 9289e7f | 2008-01-11 17:09:52 -0500 | [diff] [blame] | 641 | nlmclnt_done(server->nlm_host); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | /* |
| 645 | * Version 2 or 3 lockd setup |
| 646 | */ |
| 647 | static int nfs_start_lockd(struct nfs_server *server) |
| 648 | { |
Chuck Lever | 9289e7f | 2008-01-11 17:09:52 -0500 | [diff] [blame] | 649 | struct nlm_host *host; |
| 650 | struct nfs_client *clp = server->nfs_client; |
Chuck Lever | 883bb16 | 2008-01-15 16:04:20 -0500 | [diff] [blame] | 651 | struct nlmclnt_initdata nlm_init = { |
| 652 | .hostname = clp->cl_hostname, |
| 653 | .address = (struct sockaddr *)&clp->cl_addr, |
| 654 | .addrlen = clp->cl_addrlen, |
| 655 | .protocol = server->flags & NFS_MOUNT_TCP ? |
| 656 | IPPROTO_TCP : IPPROTO_UDP, |
| 657 | .nfs_version = clp->rpc_ops->version, |
Chuck Lever | 0cb2659 | 2008-12-23 15:21:38 -0500 | [diff] [blame] | 658 | .noresvport = server->flags & NFS_MOUNT_NORESVPORT ? |
| 659 | 1 : 0, |
Chuck Lever | 883bb16 | 2008-01-15 16:04:20 -0500 | [diff] [blame] | 660 | }; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 661 | |
Chuck Lever | 883bb16 | 2008-01-15 16:04:20 -0500 | [diff] [blame] | 662 | if (nlm_init.nfs_version > 3) |
Chuck Lever | 9289e7f | 2008-01-11 17:09:52 -0500 | [diff] [blame] | 663 | return 0; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 664 | if (server->flags & NFS_MOUNT_NONLM) |
Chuck Lever | 9289e7f | 2008-01-11 17:09:52 -0500 | [diff] [blame] | 665 | return 0; |
| 666 | |
Chuck Lever | 883bb16 | 2008-01-15 16:04:20 -0500 | [diff] [blame] | 667 | host = nlmclnt_init(&nlm_init); |
Chuck Lever | 9289e7f | 2008-01-11 17:09:52 -0500 | [diff] [blame] | 668 | if (IS_ERR(host)) |
| 669 | return PTR_ERR(host); |
| 670 | |
| 671 | server->nlm_host = host; |
| 672 | server->destroy = nfs_destroy_server; |
| 673 | return 0; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | /* |
| 677 | * Initialise an NFSv3 ACL client connection |
| 678 | */ |
| 679 | #ifdef CONFIG_NFS_V3_ACL |
| 680 | static void nfs_init_server_aclclient(struct nfs_server *server) |
| 681 | { |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 682 | if (server->nfs_client->rpc_ops->version != 3) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 683 | goto out_noacl; |
| 684 | if (server->flags & NFS_MOUNT_NOACL) |
| 685 | goto out_noacl; |
| 686 | |
| 687 | server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3); |
| 688 | if (IS_ERR(server->client_acl)) |
| 689 | goto out_noacl; |
| 690 | |
| 691 | /* No errors! Assume that Sun nfsacls are supported */ |
| 692 | server->caps |= NFS_CAP_ACLS; |
| 693 | return; |
| 694 | |
| 695 | out_noacl: |
| 696 | server->caps &= ~NFS_CAP_ACLS; |
| 697 | } |
| 698 | #else |
| 699 | static inline void nfs_init_server_aclclient(struct nfs_server *server) |
| 700 | { |
| 701 | server->flags &= ~NFS_MOUNT_NOACL; |
| 702 | server->caps &= ~NFS_CAP_ACLS; |
| 703 | } |
| 704 | #endif |
| 705 | |
| 706 | /* |
| 707 | * Create a general RPC client |
| 708 | */ |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 709 | static int nfs_init_server_rpcclient(struct nfs_server *server, |
| 710 | const struct rpc_timeout *timeo, |
| 711 | rpc_authflavor_t pseudoflavour) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 712 | { |
| 713 | struct nfs_client *clp = server->nfs_client; |
| 714 | |
| 715 | server->client = rpc_clone_client(clp->cl_rpcclient); |
| 716 | if (IS_ERR(server->client)) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 717 | dprintk("%s: couldn't create rpc_client!\n", __func__); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 718 | return PTR_ERR(server->client); |
| 719 | } |
| 720 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 721 | memcpy(&server->client->cl_timeout_default, |
| 722 | timeo, |
| 723 | sizeof(server->client->cl_timeout_default)); |
| 724 | server->client->cl_timeout = &server->client->cl_timeout_default; |
| 725 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 726 | if (pseudoflavour != clp->cl_rpcclient->cl_auth->au_flavor) { |
| 727 | struct rpc_auth *auth; |
| 728 | |
| 729 | auth = rpcauth_create(pseudoflavour, server->client); |
| 730 | if (IS_ERR(auth)) { |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 731 | dprintk("%s: couldn't create credcache!\n", __func__); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 732 | return PTR_ERR(auth); |
| 733 | } |
| 734 | } |
| 735 | server->client->cl_softrtry = 0; |
| 736 | if (server->flags & NFS_MOUNT_SOFT) |
| 737 | server->client->cl_softrtry = 1; |
| 738 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 739 | return 0; |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | * Initialise an NFS2 or NFS3 client |
| 744 | */ |
\"Talpey, Thomas\ | 2283f8d | 2007-09-10 13:43:56 -0400 | [diff] [blame] | 745 | static int nfs_init_client(struct nfs_client *clp, |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 746 | const struct rpc_timeout *timeparms, |
\"Talpey, Thomas\ | 2283f8d | 2007-09-10 13:43:56 -0400 | [diff] [blame] | 747 | const struct nfs_parsed_mount_data *data) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 748 | { |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 749 | int error; |
| 750 | |
| 751 | if (clp->cl_cons_state == NFS_CS_READY) { |
| 752 | /* the client is already initialised */ |
| 753 | dprintk("<-- nfs_init_client() = 0 [already %p]\n", clp); |
| 754 | return 0; |
| 755 | } |
| 756 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 757 | /* |
| 758 | * Create a client RPC handle for doing FSSTAT with UNIX auth only |
| 759 | * - RFC 2623, sec 2.3.2 |
| 760 | */ |
Chuck Lever | d740351 | 2008-12-23 15:21:37 -0500 | [diff] [blame] | 761 | error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX, |
| 762 | 0, data->flags & NFS_MOUNT_NORESVPORT); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 763 | if (error < 0) |
| 764 | goto error; |
| 765 | nfs_mark_client_ready(clp, NFS_CS_READY); |
| 766 | return 0; |
| 767 | |
| 768 | error: |
| 769 | nfs_mark_client_ready(clp, error); |
| 770 | dprintk("<-- nfs_init_client() = xerror %d\n", error); |
| 771 | return error; |
| 772 | } |
| 773 | |
| 774 | /* |
| 775 | * Create a version 2 or 3 client |
| 776 | */ |
\"Talpey, Thomas\ | 2283f8d | 2007-09-10 13:43:56 -0400 | [diff] [blame] | 777 | static int nfs_init_server(struct nfs_server *server, |
| 778 | const struct nfs_parsed_mount_data *data) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 779 | { |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 780 | struct nfs_client_initdata cl_init = { |
| 781 | .hostname = data->nfs_server.hostname, |
Chuck Lever | d7422c4 | 2007-12-10 14:58:51 -0500 | [diff] [blame] | 782 | .addr = (const struct sockaddr *)&data->nfs_server.address, |
Chuck Lever | 4c56801 | 2007-12-10 14:59:28 -0500 | [diff] [blame] | 783 | .addrlen = data->nfs_server.addrlen, |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 784 | .rpc_ops = &nfs_v2_clientops, |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 785 | .proto = data->nfs_server.protocol, |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 786 | }; |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 787 | struct rpc_timeout timeparms; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 788 | struct nfs_client *clp; |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 789 | int error; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 790 | |
| 791 | dprintk("--> nfs_init_server()\n"); |
| 792 | |
| 793 | #ifdef CONFIG_NFS_V3 |
| 794 | if (data->flags & NFS_MOUNT_VER3) |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 795 | cl_init.rpc_ops = &nfs_v3_clientops; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 796 | #endif |
| 797 | |
| 798 | /* Allocate or find a client reference we can use */ |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 799 | clp = nfs_get_client(&cl_init); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 800 | if (IS_ERR(clp)) { |
| 801 | dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp)); |
| 802 | return PTR_ERR(clp); |
| 803 | } |
| 804 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 805 | nfs_init_timeout_values(&timeparms, data->nfs_server.protocol, |
| 806 | data->timeo, data->retrans); |
| 807 | error = nfs_init_client(clp, &timeparms, data); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 808 | if (error < 0) |
| 809 | goto error; |
| 810 | |
| 811 | server->nfs_client = clp; |
| 812 | |
| 813 | /* Initialise the client representation from the mount data */ |
Trond Myklebust | ff3525a | 2008-08-15 16:59:14 -0400 | [diff] [blame] | 814 | server->flags = data->flags; |
David Howells | b797cac | 2009-04-03 16:42:48 +0100 | [diff] [blame] | 815 | server->options = data->options; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 816 | |
| 817 | if (data->rsize) |
| 818 | server->rsize = nfs_block_size(data->rsize, NULL); |
| 819 | if (data->wsize) |
| 820 | server->wsize = nfs_block_size(data->wsize, NULL); |
| 821 | |
| 822 | server->acregmin = data->acregmin * HZ; |
| 823 | server->acregmax = data->acregmax * HZ; |
| 824 | server->acdirmin = data->acdirmin * HZ; |
| 825 | server->acdirmax = data->acdirmax * HZ; |
| 826 | |
| 827 | /* Start lockd here, before we might error out */ |
| 828 | error = nfs_start_lockd(server); |
| 829 | if (error < 0) |
| 830 | goto error; |
| 831 | |
Chuck Lever | f22d6d7 | 2008-03-14 14:10:22 -0400 | [diff] [blame] | 832 | server->port = data->nfs_server.port; |
| 833 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 834 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 835 | if (error < 0) |
| 836 | goto error; |
| 837 | |
Chuck Lever | 3f8400d | 2008-03-14 14:10:30 -0400 | [diff] [blame] | 838 | /* Preserve the values of mount_server-related mount options */ |
| 839 | if (data->mount_server.addrlen) { |
| 840 | memcpy(&server->mountd_address, &data->mount_server.address, |
| 841 | data->mount_server.addrlen); |
| 842 | server->mountd_addrlen = data->mount_server.addrlen; |
| 843 | } |
| 844 | server->mountd_version = data->mount_server.version; |
| 845 | server->mountd_port = data->mount_server.port; |
| 846 | server->mountd_protocol = data->mount_server.protocol; |
| 847 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 848 | server->namelen = data->namlen; |
| 849 | /* Create a client RPC handle for the NFSv3 ACL management interface */ |
| 850 | nfs_init_server_aclclient(server); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 851 | dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp); |
| 852 | return 0; |
| 853 | |
| 854 | error: |
| 855 | server->nfs_client = NULL; |
| 856 | nfs_put_client(clp); |
| 857 | dprintk("<-- nfs_init_server() = xerror %d\n", error); |
| 858 | return error; |
| 859 | } |
| 860 | |
| 861 | /* |
| 862 | * Load up the server record from information gained in an fsinfo record |
| 863 | */ |
| 864 | static void nfs_server_set_fsinfo(struct nfs_server *server, struct nfs_fsinfo *fsinfo) |
| 865 | { |
| 866 | unsigned long max_rpc_payload; |
| 867 | |
| 868 | /* Work out a lot of parameters */ |
| 869 | if (server->rsize == 0) |
| 870 | server->rsize = nfs_block_size(fsinfo->rtpref, NULL); |
| 871 | if (server->wsize == 0) |
| 872 | server->wsize = nfs_block_size(fsinfo->wtpref, NULL); |
| 873 | |
| 874 | if (fsinfo->rtmax >= 512 && server->rsize > fsinfo->rtmax) |
| 875 | server->rsize = nfs_block_size(fsinfo->rtmax, NULL); |
| 876 | if (fsinfo->wtmax >= 512 && server->wsize > fsinfo->wtmax) |
| 877 | server->wsize = nfs_block_size(fsinfo->wtmax, NULL); |
| 878 | |
| 879 | max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL); |
| 880 | if (server->rsize > max_rpc_payload) |
| 881 | server->rsize = max_rpc_payload; |
| 882 | if (server->rsize > NFS_MAX_FILE_IO_SIZE) |
| 883 | server->rsize = NFS_MAX_FILE_IO_SIZE; |
| 884 | server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
Peter Zijlstra | e0bf68d | 2007-10-16 23:25:46 -0700 | [diff] [blame] | 885 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 886 | server->backing_dev_info.ra_pages = server->rpages * NFS_MAX_READAHEAD; |
| 887 | |
| 888 | if (server->wsize > max_rpc_payload) |
| 889 | server->wsize = max_rpc_payload; |
| 890 | if (server->wsize > NFS_MAX_FILE_IO_SIZE) |
| 891 | server->wsize = NFS_MAX_FILE_IO_SIZE; |
| 892 | server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
| 893 | server->wtmult = nfs_block_bits(fsinfo->wtmult, NULL); |
| 894 | |
| 895 | server->dtsize = nfs_block_size(fsinfo->dtpref, NULL); |
| 896 | if (server->dtsize > PAGE_CACHE_SIZE) |
| 897 | server->dtsize = PAGE_CACHE_SIZE; |
| 898 | if (server->dtsize > server->rsize) |
| 899 | server->dtsize = server->rsize; |
| 900 | |
| 901 | if (server->flags & NFS_MOUNT_NOAC) { |
| 902 | server->acregmin = server->acregmax = 0; |
| 903 | server->acdirmin = server->acdirmax = 0; |
| 904 | } |
| 905 | |
| 906 | server->maxfilesize = fsinfo->maxfilesize; |
| 907 | |
| 908 | /* We're airborne Set socket buffersize */ |
| 909 | rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100); |
| 910 | } |
| 911 | |
| 912 | /* |
| 913 | * Probe filesystem information, including the FSID on v2/v3 |
| 914 | */ |
| 915 | static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr) |
| 916 | { |
| 917 | struct nfs_fsinfo fsinfo; |
| 918 | struct nfs_client *clp = server->nfs_client; |
| 919 | int error; |
| 920 | |
| 921 | dprintk("--> nfs_probe_fsinfo()\n"); |
| 922 | |
| 923 | if (clp->rpc_ops->set_capabilities != NULL) { |
| 924 | error = clp->rpc_ops->set_capabilities(server, mntfh); |
| 925 | if (error < 0) |
| 926 | goto out_error; |
| 927 | } |
| 928 | |
| 929 | fsinfo.fattr = fattr; |
| 930 | nfs_fattr_init(fattr); |
| 931 | error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo); |
| 932 | if (error < 0) |
| 933 | goto out_error; |
| 934 | |
| 935 | nfs_server_set_fsinfo(server, &fsinfo); |
Peter Zijlstra | e0bf68d | 2007-10-16 23:25:46 -0700 | [diff] [blame] | 936 | error = bdi_init(&server->backing_dev_info); |
| 937 | if (error) |
| 938 | goto out_error; |
| 939 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 940 | |
| 941 | /* Get some general file system info */ |
| 942 | if (server->namelen == 0) { |
| 943 | struct nfs_pathconf pathinfo; |
| 944 | |
| 945 | pathinfo.fattr = fattr; |
| 946 | nfs_fattr_init(fattr); |
| 947 | |
| 948 | if (clp->rpc_ops->pathconf(server, mntfh, &pathinfo) >= 0) |
| 949 | server->namelen = pathinfo.max_namelen; |
| 950 | } |
| 951 | |
| 952 | dprintk("<-- nfs_probe_fsinfo() = 0\n"); |
| 953 | return 0; |
| 954 | |
| 955 | out_error: |
| 956 | dprintk("nfs_probe_fsinfo: error = %d\n", -error); |
| 957 | return error; |
| 958 | } |
| 959 | |
| 960 | /* |
| 961 | * Copy useful information when duplicating a server record |
| 962 | */ |
| 963 | static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source) |
| 964 | { |
| 965 | target->flags = source->flags; |
| 966 | target->acregmin = source->acregmin; |
| 967 | target->acregmax = source->acregmax; |
| 968 | target->acdirmin = source->acdirmin; |
| 969 | target->acdirmax = source->acdirmax; |
| 970 | target->caps = source->caps; |
| 971 | } |
| 972 | |
| 973 | /* |
| 974 | * Allocate and initialise a server record |
| 975 | */ |
| 976 | static struct nfs_server *nfs_alloc_server(void) |
| 977 | { |
| 978 | struct nfs_server *server; |
| 979 | |
| 980 | server = kzalloc(sizeof(struct nfs_server), GFP_KERNEL); |
| 981 | if (!server) |
| 982 | return NULL; |
| 983 | |
| 984 | server->client = server->client_acl = ERR_PTR(-EINVAL); |
| 985 | |
| 986 | /* Zero out the NFS state stuff */ |
| 987 | INIT_LIST_HEAD(&server->client_link); |
| 988 | INIT_LIST_HEAD(&server->master_link); |
| 989 | |
Steve Dickson | ef818a2 | 2007-11-08 04:05:04 -0500 | [diff] [blame] | 990 | atomic_set(&server->active, 0); |
| 991 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 992 | server->io_stats = nfs_alloc_iostats(); |
| 993 | if (!server->io_stats) { |
| 994 | kfree(server); |
| 995 | return NULL; |
| 996 | } |
| 997 | |
| 998 | return server; |
| 999 | } |
| 1000 | |
| 1001 | /* |
| 1002 | * Free up a server record |
| 1003 | */ |
| 1004 | void nfs_free_server(struct nfs_server *server) |
| 1005 | { |
| 1006 | dprintk("--> nfs_free_server()\n"); |
| 1007 | |
| 1008 | spin_lock(&nfs_client_lock); |
| 1009 | list_del(&server->client_link); |
| 1010 | list_del(&server->master_link); |
| 1011 | spin_unlock(&nfs_client_lock); |
| 1012 | |
| 1013 | if (server->destroy != NULL) |
| 1014 | server->destroy(server); |
Trond Myklebust | 5cef338 | 2007-12-11 22:01:56 -0500 | [diff] [blame] | 1015 | |
| 1016 | if (!IS_ERR(server->client_acl)) |
| 1017 | rpc_shutdown_client(server->client_acl); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1018 | if (!IS_ERR(server->client)) |
| 1019 | rpc_shutdown_client(server->client); |
| 1020 | |
| 1021 | nfs_put_client(server->nfs_client); |
| 1022 | |
| 1023 | nfs_free_iostats(server->io_stats); |
Peter Zijlstra | e0bf68d | 2007-10-16 23:25:46 -0700 | [diff] [blame] | 1024 | bdi_destroy(&server->backing_dev_info); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1025 | kfree(server); |
| 1026 | nfs_release_automount_timer(); |
| 1027 | dprintk("<-- nfs_free_server()\n"); |
| 1028 | } |
| 1029 | |
| 1030 | /* |
| 1031 | * Create a version 2 or 3 volume record |
| 1032 | * - keyed on server and FSID |
| 1033 | */ |
\"Talpey, Thomas\ | 2283f8d | 2007-09-10 13:43:56 -0400 | [diff] [blame] | 1034 | struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1035 | struct nfs_fh *mntfh) |
| 1036 | { |
| 1037 | struct nfs_server *server; |
| 1038 | struct nfs_fattr fattr; |
| 1039 | int error; |
| 1040 | |
| 1041 | server = nfs_alloc_server(); |
| 1042 | if (!server) |
| 1043 | return ERR_PTR(-ENOMEM); |
| 1044 | |
| 1045 | /* Get a client representation */ |
| 1046 | error = nfs_init_server(server, data); |
| 1047 | if (error < 0) |
| 1048 | goto error; |
| 1049 | |
| 1050 | BUG_ON(!server->nfs_client); |
| 1051 | BUG_ON(!server->nfs_client->rpc_ops); |
| 1052 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 1053 | |
| 1054 | /* Probe the root fh to retrieve its FSID */ |
| 1055 | error = nfs_probe_fsinfo(server, mntfh, &fattr); |
| 1056 | if (error < 0) |
| 1057 | goto error; |
Trond Myklebust | 54af3bb | 2007-09-28 12:27:41 -0400 | [diff] [blame] | 1058 | if (server->nfs_client->rpc_ops->version == 3) { |
| 1059 | if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) |
| 1060 | server->namelen = NFS3_MAXNAMLEN; |
| 1061 | if (!(data->flags & NFS_MOUNT_NORDIRPLUS)) |
| 1062 | server->caps |= NFS_CAP_READDIRPLUS; |
| 1063 | } else { |
| 1064 | if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) |
| 1065 | server->namelen = NFS2_MAXNAMLEN; |
| 1066 | } |
| 1067 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1068 | if (!(fattr.valid & NFS_ATTR_FATTR)) { |
| 1069 | error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr); |
| 1070 | if (error < 0) { |
| 1071 | dprintk("nfs_create_server: getattr error = %d\n", -error); |
| 1072 | goto error; |
| 1073 | } |
| 1074 | } |
| 1075 | memcpy(&server->fsid, &fattr.fsid, sizeof(server->fsid)); |
| 1076 | |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1077 | dprintk("Server FSID: %llx:%llx\n", |
| 1078 | (unsigned long long) server->fsid.major, |
| 1079 | (unsigned long long) server->fsid.minor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1080 | |
| 1081 | BUG_ON(!server->nfs_client); |
| 1082 | BUG_ON(!server->nfs_client->rpc_ops); |
| 1083 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 1084 | |
| 1085 | spin_lock(&nfs_client_lock); |
| 1086 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); |
| 1087 | list_add_tail(&server->master_link, &nfs_volume_list); |
| 1088 | spin_unlock(&nfs_client_lock); |
| 1089 | |
| 1090 | server->mount_time = jiffies; |
| 1091 | return server; |
| 1092 | |
| 1093 | error: |
| 1094 | nfs_free_server(server); |
| 1095 | return ERR_PTR(error); |
| 1096 | } |
| 1097 | |
| 1098 | #ifdef CONFIG_NFS_V4 |
| 1099 | /* |
Benny Halevy | 9bdaa86 | 2009-04-01 09:22:55 -0400 | [diff] [blame^] | 1100 | * Initialize the NFS4 callback service |
| 1101 | */ |
| 1102 | static int nfs4_init_callback(struct nfs_client *clp) |
| 1103 | { |
| 1104 | int error; |
| 1105 | |
| 1106 | if (clp->rpc_ops->version == 4) { |
| 1107 | error = nfs_callback_up(); |
| 1108 | if (error < 0) { |
| 1109 | dprintk("%s: failed to start callback. Error = %d\n", |
| 1110 | __func__, error); |
| 1111 | return error; |
| 1112 | } |
| 1113 | __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state); |
| 1114 | } |
| 1115 | return 0; |
| 1116 | } |
| 1117 | |
| 1118 | /* |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1119 | * Initialize the minor version specific parts of an NFS4 client record |
| 1120 | */ |
| 1121 | static int nfs4_init_client_minor_version(struct nfs_client *clp) |
| 1122 | { |
Andy Adamson | cccef3b | 2009-04-01 09:22:03 -0400 | [diff] [blame] | 1123 | clp->cl_call_sync = _nfs4_call_sync; |
| 1124 | |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1125 | #if defined(CONFIG_NFS_V4_1) |
| 1126 | if (clp->cl_minorversion) { |
| 1127 | struct nfs4_session *session = NULL; |
| 1128 | /* |
| 1129 | * Create the session and mark it expired. |
| 1130 | * When a SEQUENCE operation encounters the expired session |
| 1131 | * it will do session recovery to initialize it. |
| 1132 | */ |
| 1133 | session = nfs4_alloc_session(clp); |
| 1134 | if (!session) |
| 1135 | return -ENOMEM; |
| 1136 | |
| 1137 | clp->cl_session = session; |
Andy Adamson | cccef3b | 2009-04-01 09:22:03 -0400 | [diff] [blame] | 1138 | clp->cl_call_sync = _nfs4_call_sync_session; |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1139 | } |
| 1140 | #endif /* CONFIG_NFS_V4_1 */ |
| 1141 | |
| 1142 | return 0; |
| 1143 | } |
| 1144 | |
| 1145 | /* |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1146 | * Initialise an NFS4 client record |
| 1147 | */ |
| 1148 | static int nfs4_init_client(struct nfs_client *clp, |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1149 | const struct rpc_timeout *timeparms, |
J. Bruce Fields | 7d9ac06 | 2006-10-19 23:28:39 -0700 | [diff] [blame] | 1150 | const char *ip_addr, |
Chuck Lever | d740351 | 2008-12-23 15:21:37 -0500 | [diff] [blame] | 1151 | rpc_authflavor_t authflavour, |
| 1152 | int flags) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1153 | { |
| 1154 | int error; |
| 1155 | |
| 1156 | if (clp->cl_cons_state == NFS_CS_READY) { |
| 1157 | /* the client is initialised already */ |
| 1158 | dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp); |
| 1159 | return 0; |
| 1160 | } |
| 1161 | |
| 1162 | /* Check NFS protocol revision and initialize RPC op vector */ |
| 1163 | clp->rpc_ops = &nfs_v4_clientops; |
| 1164 | |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 1165 | error = nfs_create_rpc_client(clp, timeparms, authflavour, |
Chuck Lever | d740351 | 2008-12-23 15:21:37 -0500 | [diff] [blame] | 1166 | 1, flags & NFS_MOUNT_NORESVPORT); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1167 | if (error < 0) |
| 1168 | goto error; |
J. Bruce Fields | 7d9ac06 | 2006-10-19 23:28:39 -0700 | [diff] [blame] | 1169 | memcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1170 | |
| 1171 | error = nfs_idmap_new(clp); |
| 1172 | if (error < 0) { |
| 1173 | dprintk("%s: failed to create idmapper. Error = %d\n", |
Harvey Harrison | 3110ff8 | 2008-05-02 13:42:44 -0700 | [diff] [blame] | 1174 | __func__, error); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1175 | goto error; |
| 1176 | } |
Trond Myklebust | 9c5bf38 | 2006-08-22 20:06:14 -0400 | [diff] [blame] | 1177 | __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1178 | |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1179 | error = nfs4_init_client_minor_version(clp); |
| 1180 | if (error < 0) |
| 1181 | goto error; |
| 1182 | |
Andy Adamson | 76db6d9 | 2009-04-01 09:22:38 -0400 | [diff] [blame] | 1183 | if (!nfs4_has_session(clp)) |
| 1184 | nfs_mark_client_ready(clp, NFS_CS_READY); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1185 | return 0; |
| 1186 | |
| 1187 | error: |
| 1188 | nfs_mark_client_ready(clp, error); |
| 1189 | dprintk("<-- nfs4_init_client() = xerror %d\n", error); |
| 1190 | return error; |
| 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | * Set up an NFS4 client |
| 1195 | */ |
| 1196 | static int nfs4_set_client(struct nfs_server *server, |
Chuck Lever | dcecae0 | 2007-12-10 14:58:59 -0500 | [diff] [blame] | 1197 | const char *hostname, |
| 1198 | const struct sockaddr *addr, |
| 1199 | const size_t addrlen, |
J. Bruce Fields | 7d9ac06 | 2006-10-19 23:28:39 -0700 | [diff] [blame] | 1200 | const char *ip_addr, |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1201 | rpc_authflavor_t authflavour, |
Benny Halevy | 94a417f | 2009-04-01 09:21:49 -0400 | [diff] [blame] | 1202 | int proto, const struct rpc_timeout *timeparms, |
| 1203 | u32 minorversion) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1204 | { |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 1205 | struct nfs_client_initdata cl_init = { |
| 1206 | .hostname = hostname, |
Chuck Lever | dcecae0 | 2007-12-10 14:58:59 -0500 | [diff] [blame] | 1207 | .addr = addr, |
| 1208 | .addrlen = addrlen, |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 1209 | .rpc_ops = &nfs_v4_clientops, |
Trond Myklebust | 59dca3b | 2008-01-03 16:29:06 -0500 | [diff] [blame] | 1210 | .proto = proto, |
Benny Halevy | 5aae4a9 | 2009-04-01 09:21:50 -0400 | [diff] [blame] | 1211 | .minorversion = minorversion, |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 1212 | }; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1213 | struct nfs_client *clp; |
| 1214 | int error; |
| 1215 | |
| 1216 | dprintk("--> nfs4_set_client()\n"); |
| 1217 | |
| 1218 | /* Allocate or find a client reference we can use */ |
Trond Myklebust | 3a49802 | 2007-12-14 14:56:04 -0500 | [diff] [blame] | 1219 | clp = nfs_get_client(&cl_init); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1220 | if (IS_ERR(clp)) { |
| 1221 | error = PTR_ERR(clp); |
| 1222 | goto error; |
| 1223 | } |
Chuck Lever | d740351 | 2008-12-23 15:21:37 -0500 | [diff] [blame] | 1224 | error = nfs4_init_client(clp, timeparms, ip_addr, authflavour, |
| 1225 | server->flags); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1226 | if (error < 0) |
| 1227 | goto error_put; |
| 1228 | |
| 1229 | server->nfs_client = clp; |
| 1230 | dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp); |
| 1231 | return 0; |
| 1232 | |
| 1233 | error_put: |
| 1234 | nfs_put_client(clp); |
| 1235 | error: |
| 1236 | dprintk("<-- nfs4_set_client() = xerror %d\n", error); |
| 1237 | return error; |
| 1238 | } |
| 1239 | |
| 1240 | /* |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1241 | * Initialize a session. |
| 1242 | * Note: save the mount rsize and wsize for create_server negotiation. |
| 1243 | */ |
| 1244 | static void nfs4_init_session(struct nfs_client *clp, |
| 1245 | unsigned int wsize, unsigned int rsize) |
| 1246 | { |
| 1247 | #if defined(CONFIG_NFS_V4_1) |
| 1248 | if (nfs4_has_session(clp)) { |
| 1249 | clp->cl_session->fc_attrs.max_rqst_sz = wsize; |
| 1250 | clp->cl_session->fc_attrs.max_resp_sz = rsize; |
| 1251 | } |
| 1252 | #endif /* CONFIG_NFS_V4_1 */ |
| 1253 | } |
| 1254 | |
| 1255 | /* |
Andy Adamson | 96b09e0 | 2009-04-01 09:22:33 -0400 | [diff] [blame] | 1256 | * Session has been established, and the client marked ready. |
| 1257 | * Set the mount rsize and wsize with negotiated fore channel |
| 1258 | * attributes which will be bound checked in nfs_server_set_fsinfo. |
| 1259 | */ |
| 1260 | static void nfs4_session_set_rwsize(struct nfs_server *server) |
| 1261 | { |
| 1262 | #ifdef CONFIG_NFS_V4_1 |
| 1263 | if (!nfs4_has_session(server->nfs_client)) |
| 1264 | return; |
| 1265 | server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz; |
| 1266 | server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz; |
| 1267 | #endif /* CONFIG_NFS_V4_1 */ |
| 1268 | } |
| 1269 | |
| 1270 | /* |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1271 | * Create a version 4 volume record |
| 1272 | */ |
| 1273 | static int nfs4_init_server(struct nfs_server *server, |
\"Talpey, Thomas\ | 91ea40b | 2007-09-10 13:44:33 -0400 | [diff] [blame] | 1274 | const struct nfs_parsed_mount_data *data) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1275 | { |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1276 | struct rpc_timeout timeparms; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1277 | int error; |
| 1278 | |
| 1279 | dprintk("--> nfs4_init_server()\n"); |
| 1280 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1281 | nfs_init_timeout_values(&timeparms, data->nfs_server.protocol, |
| 1282 | data->timeo, data->retrans); |
| 1283 | |
Chuck Lever | 542fcc3 | 2008-12-23 15:21:36 -0500 | [diff] [blame] | 1284 | /* Initialise the client representation from the mount data */ |
| 1285 | server->flags = data->flags; |
| 1286 | server->caps |= NFS_CAP_ATOMIC_OPEN; |
David Howells | b797cac | 2009-04-03 16:42:48 +0100 | [diff] [blame] | 1287 | server->options = data->options; |
Chuck Lever | 542fcc3 | 2008-12-23 15:21:36 -0500 | [diff] [blame] | 1288 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1289 | /* Get a client record */ |
| 1290 | error = nfs4_set_client(server, |
| 1291 | data->nfs_server.hostname, |
| 1292 | (const struct sockaddr *)&data->nfs_server.address, |
| 1293 | data->nfs_server.addrlen, |
| 1294 | data->client_address, |
| 1295 | data->auth_flavors[0], |
| 1296 | data->nfs_server.protocol, |
Benny Halevy | 94a417f | 2009-04-01 09:21:49 -0400 | [diff] [blame] | 1297 | &timeparms, |
| 1298 | data->minorversion); |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1299 | if (error < 0) |
| 1300 | goto error; |
| 1301 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1302 | if (data->rsize) |
| 1303 | server->rsize = nfs_block_size(data->rsize, NULL); |
| 1304 | if (data->wsize) |
| 1305 | server->wsize = nfs_block_size(data->wsize, NULL); |
| 1306 | |
| 1307 | server->acregmin = data->acregmin * HZ; |
| 1308 | server->acregmax = data->acregmax * HZ; |
| 1309 | server->acdirmin = data->acdirmin * HZ; |
| 1310 | server->acdirmax = data->acdirmax * HZ; |
| 1311 | |
Chuck Lever | f22d6d7 | 2008-03-14 14:10:22 -0400 | [diff] [blame] | 1312 | server->port = data->nfs_server.port; |
| 1313 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1314 | error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1315 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1316 | error: |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1317 | /* Done */ |
| 1318 | dprintk("<-- nfs4_init_server() = %d\n", error); |
| 1319 | return error; |
| 1320 | } |
| 1321 | |
| 1322 | /* |
| 1323 | * Create a version 4 volume record |
| 1324 | * - keyed on server and FSID |
| 1325 | */ |
\"Talpey, Thomas\ | 91ea40b | 2007-09-10 13:44:33 -0400 | [diff] [blame] | 1326 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1327 | struct nfs_fh *mntfh) |
| 1328 | { |
| 1329 | struct nfs_fattr fattr; |
| 1330 | struct nfs_server *server; |
| 1331 | int error; |
| 1332 | |
| 1333 | dprintk("--> nfs4_create_server()\n"); |
| 1334 | |
| 1335 | server = nfs_alloc_server(); |
| 1336 | if (!server) |
| 1337 | return ERR_PTR(-ENOMEM); |
| 1338 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1339 | /* set up the general RPC client */ |
\"Talpey, Thomas\ | 91ea40b | 2007-09-10 13:44:33 -0400 | [diff] [blame] | 1340 | error = nfs4_init_server(server, data); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1341 | if (error < 0) |
| 1342 | goto error; |
| 1343 | |
| 1344 | BUG_ON(!server->nfs_client); |
| 1345 | BUG_ON(!server->nfs_client->rpc_ops); |
| 1346 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 1347 | |
Andy Adamson | 557134a | 2009-04-01 09:21:53 -0400 | [diff] [blame] | 1348 | nfs4_init_session(server->nfs_client, server->wsize, server->rsize); |
| 1349 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1350 | /* Probe the root fh to retrieve its FSID */ |
\"Talpey, Thomas\ | 91ea40b | 2007-09-10 13:44:33 -0400 | [diff] [blame] | 1351 | error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1352 | if (error < 0) |
| 1353 | goto error; |
| 1354 | |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1355 | dprintk("Server FSID: %llx:%llx\n", |
| 1356 | (unsigned long long) server->fsid.major, |
| 1357 | (unsigned long long) server->fsid.minor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1358 | dprintk("Mount FH: %d\n", mntfh->size); |
| 1359 | |
Andy Adamson | 96b09e0 | 2009-04-01 09:22:33 -0400 | [diff] [blame] | 1360 | nfs4_session_set_rwsize(server); |
| 1361 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1362 | error = nfs_probe_fsinfo(server, mntfh, &fattr); |
| 1363 | if (error < 0) |
| 1364 | goto error; |
| 1365 | |
Trond Myklebust | 54af3bb | 2007-09-28 12:27:41 -0400 | [diff] [blame] | 1366 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) |
| 1367 | server->namelen = NFS4_MAXNAMLEN; |
| 1368 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1369 | BUG_ON(!server->nfs_client); |
| 1370 | BUG_ON(!server->nfs_client->rpc_ops); |
| 1371 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 1372 | |
| 1373 | spin_lock(&nfs_client_lock); |
| 1374 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); |
| 1375 | list_add_tail(&server->master_link, &nfs_volume_list); |
| 1376 | spin_unlock(&nfs_client_lock); |
| 1377 | |
| 1378 | server->mount_time = jiffies; |
| 1379 | dprintk("<-- nfs4_create_server() = %p\n", server); |
| 1380 | return server; |
| 1381 | |
| 1382 | error: |
| 1383 | nfs_free_server(server); |
| 1384 | dprintk("<-- nfs4_create_server() = error %d\n", error); |
| 1385 | return ERR_PTR(error); |
| 1386 | } |
| 1387 | |
| 1388 | /* |
| 1389 | * Create an NFS4 referral server record |
| 1390 | */ |
| 1391 | struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data, |
Trond Myklebust | f2d0d85 | 2007-02-02 14:46:09 -0800 | [diff] [blame] | 1392 | struct nfs_fh *mntfh) |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1393 | { |
| 1394 | struct nfs_client *parent_client; |
| 1395 | struct nfs_server *server, *parent_server; |
| 1396 | struct nfs_fattr fattr; |
| 1397 | int error; |
| 1398 | |
| 1399 | dprintk("--> nfs4_create_referral_server()\n"); |
| 1400 | |
| 1401 | server = nfs_alloc_server(); |
| 1402 | if (!server) |
| 1403 | return ERR_PTR(-ENOMEM); |
| 1404 | |
| 1405 | parent_server = NFS_SB(data->sb); |
| 1406 | parent_client = parent_server->nfs_client; |
| 1407 | |
Chuck Lever | 542fcc3 | 2008-12-23 15:21:36 -0500 | [diff] [blame] | 1408 | /* Initialise the client representation from the parent server */ |
| 1409 | nfs_server_copy_userdata(server, parent_server); |
| 1410 | server->caps |= NFS_CAP_ATOMIC_OPEN; |
| 1411 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1412 | /* Get a client representation. |
| 1413 | * Note: NFSv4 always uses TCP, */ |
Chuck Lever | dcecae0 | 2007-12-10 14:58:59 -0500 | [diff] [blame] | 1414 | error = nfs4_set_client(server, data->hostname, |
Chuck Lever | 6677d09 | 2007-12-10 14:59:06 -0500 | [diff] [blame] | 1415 | data->addr, |
| 1416 | data->addrlen, |
Chuck Lever | dcecae0 | 2007-12-10 14:58:59 -0500 | [diff] [blame] | 1417 | parent_client->cl_ipaddr, |
| 1418 | data->authflavor, |
| 1419 | parent_server->client->cl_xprt->prot, |
Benny Halevy | 94a417f | 2009-04-01 09:21:49 -0400 | [diff] [blame] | 1420 | parent_server->client->cl_timeout, |
| 1421 | parent_client->cl_minorversion); |
andros@citi.umich.edu | 297de4f | 2006-08-29 12:19:41 -0400 | [diff] [blame] | 1422 | if (error < 0) |
| 1423 | goto error; |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1424 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1425 | error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1426 | if (error < 0) |
| 1427 | goto error; |
| 1428 | |
| 1429 | BUG_ON(!server->nfs_client); |
| 1430 | BUG_ON(!server->nfs_client->rpc_ops); |
| 1431 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
| 1432 | |
Trond Myklebust | f2d0d85 | 2007-02-02 14:46:09 -0800 | [diff] [blame] | 1433 | /* Probe the root fh to retrieve its FSID and filehandle */ |
| 1434 | error = nfs4_path_walk(server, mntfh, data->mnt_path); |
| 1435 | if (error < 0) |
| 1436 | goto error; |
| 1437 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1438 | /* probe the filesystem info for this server filesystem */ |
Trond Myklebust | f2d0d85 | 2007-02-02 14:46:09 -0800 | [diff] [blame] | 1439 | error = nfs_probe_fsinfo(server, mntfh, &fattr); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1440 | if (error < 0) |
| 1441 | goto error; |
| 1442 | |
Trond Myklebust | 54af3bb | 2007-09-28 12:27:41 -0400 | [diff] [blame] | 1443 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) |
| 1444 | server->namelen = NFS4_MAXNAMLEN; |
| 1445 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1446 | dprintk("Referral FSID: %llx:%llx\n", |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1447 | (unsigned long long) server->fsid.major, |
| 1448 | (unsigned long long) server->fsid.minor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1449 | |
| 1450 | spin_lock(&nfs_client_lock); |
| 1451 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); |
| 1452 | list_add_tail(&server->master_link, &nfs_volume_list); |
| 1453 | spin_unlock(&nfs_client_lock); |
| 1454 | |
| 1455 | server->mount_time = jiffies; |
| 1456 | |
| 1457 | dprintk("<-- nfs_create_referral_server() = %p\n", server); |
| 1458 | return server; |
| 1459 | |
| 1460 | error: |
| 1461 | nfs_free_server(server); |
| 1462 | dprintk("<-- nfs4_create_referral_server() = error %d\n", error); |
| 1463 | return ERR_PTR(error); |
| 1464 | } |
| 1465 | |
| 1466 | #endif /* CONFIG_NFS_V4 */ |
| 1467 | |
| 1468 | /* |
| 1469 | * Clone an NFS2, NFS3 or NFS4 server record |
| 1470 | */ |
| 1471 | struct nfs_server *nfs_clone_server(struct nfs_server *source, |
| 1472 | struct nfs_fh *fh, |
| 1473 | struct nfs_fattr *fattr) |
| 1474 | { |
| 1475 | struct nfs_server *server; |
| 1476 | struct nfs_fattr fattr_fsinfo; |
| 1477 | int error; |
| 1478 | |
| 1479 | dprintk("--> nfs_clone_server(,%llx:%llx,)\n", |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1480 | (unsigned long long) fattr->fsid.major, |
| 1481 | (unsigned long long) fattr->fsid.minor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1482 | |
| 1483 | server = nfs_alloc_server(); |
| 1484 | if (!server) |
| 1485 | return ERR_PTR(-ENOMEM); |
| 1486 | |
| 1487 | /* Copy data from the source */ |
| 1488 | server->nfs_client = source->nfs_client; |
| 1489 | atomic_inc(&server->nfs_client->cl_count); |
| 1490 | nfs_server_copy_userdata(server, source); |
| 1491 | |
| 1492 | server->fsid = fattr->fsid; |
| 1493 | |
Trond Myklebust | 3317023 | 2007-12-20 16:03:59 -0500 | [diff] [blame] | 1494 | error = nfs_init_server_rpcclient(server, |
| 1495 | source->client->cl_timeout, |
| 1496 | source->client->cl_auth->au_flavor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1497 | if (error < 0) |
| 1498 | goto out_free_server; |
| 1499 | if (!IS_ERR(source->client_acl)) |
| 1500 | nfs_init_server_aclclient(server); |
| 1501 | |
| 1502 | /* probe the filesystem info for this server filesystem */ |
| 1503 | error = nfs_probe_fsinfo(server, fh, &fattr_fsinfo); |
| 1504 | if (error < 0) |
| 1505 | goto out_free_server; |
| 1506 | |
Trond Myklebust | 54af3bb | 2007-09-28 12:27:41 -0400 | [diff] [blame] | 1507 | if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN) |
| 1508 | server->namelen = NFS4_MAXNAMLEN; |
| 1509 | |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1510 | dprintk("Cloned FSID: %llx:%llx\n", |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1511 | (unsigned long long) server->fsid.major, |
| 1512 | (unsigned long long) server->fsid.minor); |
David Howells | 54ceac4 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1513 | |
| 1514 | error = nfs_start_lockd(server); |
| 1515 | if (error < 0) |
| 1516 | goto out_free_server; |
| 1517 | |
| 1518 | spin_lock(&nfs_client_lock); |
| 1519 | list_add_tail(&server->client_link, &server->nfs_client->cl_superblocks); |
| 1520 | list_add_tail(&server->master_link, &nfs_volume_list); |
| 1521 | spin_unlock(&nfs_client_lock); |
| 1522 | |
| 1523 | server->mount_time = jiffies; |
| 1524 | |
| 1525 | dprintk("<-- nfs_clone_server() = %p\n", server); |
| 1526 | return server; |
| 1527 | |
| 1528 | out_free_server: |
| 1529 | nfs_free_server(server); |
| 1530 | dprintk("<-- nfs_clone_server() = error %d\n", error); |
| 1531 | return ERR_PTR(error); |
| 1532 | } |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1533 | |
| 1534 | #ifdef CONFIG_PROC_FS |
| 1535 | static struct proc_dir_entry *proc_fs_nfs; |
| 1536 | |
| 1537 | static int nfs_server_list_open(struct inode *inode, struct file *file); |
| 1538 | static void *nfs_server_list_start(struct seq_file *p, loff_t *pos); |
| 1539 | static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos); |
| 1540 | static void nfs_server_list_stop(struct seq_file *p, void *v); |
| 1541 | static int nfs_server_list_show(struct seq_file *m, void *v); |
| 1542 | |
| 1543 | static struct seq_operations nfs_server_list_ops = { |
| 1544 | .start = nfs_server_list_start, |
| 1545 | .next = nfs_server_list_next, |
| 1546 | .stop = nfs_server_list_stop, |
| 1547 | .show = nfs_server_list_show, |
| 1548 | }; |
| 1549 | |
Arjan van de Ven | 00977a5 | 2007-02-12 00:55:34 -0800 | [diff] [blame] | 1550 | static const struct file_operations nfs_server_list_fops = { |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1551 | .open = nfs_server_list_open, |
| 1552 | .read = seq_read, |
| 1553 | .llseek = seq_lseek, |
| 1554 | .release = seq_release, |
Denis V. Lunev | 34b3723 | 2008-04-29 01:02:07 -0700 | [diff] [blame] | 1555 | .owner = THIS_MODULE, |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1556 | }; |
| 1557 | |
| 1558 | static int nfs_volume_list_open(struct inode *inode, struct file *file); |
| 1559 | static void *nfs_volume_list_start(struct seq_file *p, loff_t *pos); |
| 1560 | static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos); |
| 1561 | static void nfs_volume_list_stop(struct seq_file *p, void *v); |
| 1562 | static int nfs_volume_list_show(struct seq_file *m, void *v); |
| 1563 | |
| 1564 | static struct seq_operations nfs_volume_list_ops = { |
| 1565 | .start = nfs_volume_list_start, |
| 1566 | .next = nfs_volume_list_next, |
| 1567 | .stop = nfs_volume_list_stop, |
| 1568 | .show = nfs_volume_list_show, |
| 1569 | }; |
| 1570 | |
Arjan van de Ven | 00977a5 | 2007-02-12 00:55:34 -0800 | [diff] [blame] | 1571 | static const struct file_operations nfs_volume_list_fops = { |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1572 | .open = nfs_volume_list_open, |
| 1573 | .read = seq_read, |
| 1574 | .llseek = seq_lseek, |
| 1575 | .release = seq_release, |
Denis V. Lunev | 34b3723 | 2008-04-29 01:02:07 -0700 | [diff] [blame] | 1576 | .owner = THIS_MODULE, |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1577 | }; |
| 1578 | |
| 1579 | /* |
| 1580 | * open "/proc/fs/nfsfs/servers" which provides a summary of servers with which |
| 1581 | * we're dealing |
| 1582 | */ |
| 1583 | static int nfs_server_list_open(struct inode *inode, struct file *file) |
| 1584 | { |
| 1585 | struct seq_file *m; |
| 1586 | int ret; |
| 1587 | |
| 1588 | ret = seq_open(file, &nfs_server_list_ops); |
| 1589 | if (ret < 0) |
| 1590 | return ret; |
| 1591 | |
| 1592 | m = file->private_data; |
| 1593 | m->private = PDE(inode)->data; |
| 1594 | |
| 1595 | return 0; |
| 1596 | } |
| 1597 | |
| 1598 | /* |
| 1599 | * set up the iterator to start reading from the server list and return the first item |
| 1600 | */ |
| 1601 | static void *nfs_server_list_start(struct seq_file *m, loff_t *_pos) |
| 1602 | { |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1603 | /* lock the list against modification */ |
| 1604 | spin_lock(&nfs_client_lock); |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1605 | return seq_list_start_head(&nfs_client_list, *_pos); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1606 | } |
| 1607 | |
| 1608 | /* |
| 1609 | * move to next server |
| 1610 | */ |
| 1611 | static void *nfs_server_list_next(struct seq_file *p, void *v, loff_t *pos) |
| 1612 | { |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1613 | return seq_list_next(v, &nfs_client_list, pos); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | /* |
| 1617 | * clean up after reading from the transports list |
| 1618 | */ |
| 1619 | static void nfs_server_list_stop(struct seq_file *p, void *v) |
| 1620 | { |
| 1621 | spin_unlock(&nfs_client_lock); |
| 1622 | } |
| 1623 | |
| 1624 | /* |
| 1625 | * display a header line followed by a load of call lines |
| 1626 | */ |
| 1627 | static int nfs_server_list_show(struct seq_file *m, void *v) |
| 1628 | { |
| 1629 | struct nfs_client *clp; |
| 1630 | |
| 1631 | /* display header on line 1 */ |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1632 | if (v == &nfs_client_list) { |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1633 | seq_puts(m, "NV SERVER PORT USE HOSTNAME\n"); |
| 1634 | return 0; |
| 1635 | } |
| 1636 | |
| 1637 | /* display one transport per line on subsequent lines */ |
| 1638 | clp = list_entry(v, struct nfs_client, cl_share_link); |
| 1639 | |
Chuck Lever | 5d8515c | 2007-12-10 14:57:16 -0500 | [diff] [blame] | 1640 | seq_printf(m, "v%u %s %s %3d %s\n", |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 1641 | clp->rpc_ops->version, |
Chuck Lever | 5d8515c | 2007-12-10 14:57:16 -0500 | [diff] [blame] | 1642 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR), |
| 1643 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT), |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1644 | atomic_read(&clp->cl_count), |
| 1645 | clp->cl_hostname); |
| 1646 | |
| 1647 | return 0; |
| 1648 | } |
| 1649 | |
| 1650 | /* |
| 1651 | * open "/proc/fs/nfsfs/volumes" which provides a summary of extant volumes |
| 1652 | */ |
| 1653 | static int nfs_volume_list_open(struct inode *inode, struct file *file) |
| 1654 | { |
| 1655 | struct seq_file *m; |
| 1656 | int ret; |
| 1657 | |
| 1658 | ret = seq_open(file, &nfs_volume_list_ops); |
| 1659 | if (ret < 0) |
| 1660 | return ret; |
| 1661 | |
| 1662 | m = file->private_data; |
| 1663 | m->private = PDE(inode)->data; |
| 1664 | |
| 1665 | return 0; |
| 1666 | } |
| 1667 | |
| 1668 | /* |
| 1669 | * set up the iterator to start reading from the volume list and return the first item |
| 1670 | */ |
| 1671 | static void *nfs_volume_list_start(struct seq_file *m, loff_t *_pos) |
| 1672 | { |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1673 | /* lock the list against modification */ |
| 1674 | spin_lock(&nfs_client_lock); |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1675 | return seq_list_start_head(&nfs_volume_list, *_pos); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1676 | } |
| 1677 | |
| 1678 | /* |
| 1679 | * move to next volume |
| 1680 | */ |
| 1681 | static void *nfs_volume_list_next(struct seq_file *p, void *v, loff_t *pos) |
| 1682 | { |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1683 | return seq_list_next(v, &nfs_volume_list, pos); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1684 | } |
| 1685 | |
| 1686 | /* |
| 1687 | * clean up after reading from the transports list |
| 1688 | */ |
| 1689 | static void nfs_volume_list_stop(struct seq_file *p, void *v) |
| 1690 | { |
| 1691 | spin_unlock(&nfs_client_lock); |
| 1692 | } |
| 1693 | |
| 1694 | /* |
| 1695 | * display a header line followed by a load of call lines |
| 1696 | */ |
| 1697 | static int nfs_volume_list_show(struct seq_file *m, void *v) |
| 1698 | { |
| 1699 | struct nfs_server *server; |
| 1700 | struct nfs_client *clp; |
| 1701 | char dev[8], fsid[17]; |
| 1702 | |
| 1703 | /* display header on line 1 */ |
Pavel Emelianov | 259902e | 2007-07-15 23:39:56 -0700 | [diff] [blame] | 1704 | if (v == &nfs_volume_list) { |
David Howells | 5d1acff | 2009-04-03 16:42:47 +0100 | [diff] [blame] | 1705 | seq_puts(m, "NV SERVER PORT DEV FSID FSC\n"); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1706 | return 0; |
| 1707 | } |
| 1708 | /* display one transport per line on subsequent lines */ |
| 1709 | server = list_entry(v, struct nfs_server, master_link); |
| 1710 | clp = server->nfs_client; |
| 1711 | |
| 1712 | snprintf(dev, 8, "%u:%u", |
| 1713 | MAJOR(server->s_dev), MINOR(server->s_dev)); |
| 1714 | |
| 1715 | snprintf(fsid, 17, "%llx:%llx", |
David Howells | 6daabf1 | 2006-08-24 15:44:16 -0400 | [diff] [blame] | 1716 | (unsigned long long) server->fsid.major, |
| 1717 | (unsigned long long) server->fsid.minor); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1718 | |
David Howells | 5d1acff | 2009-04-03 16:42:47 +0100 | [diff] [blame] | 1719 | seq_printf(m, "v%u %s %s %-7s %-17s %s\n", |
Trond Myklebust | 40c55319 | 2007-12-14 14:56:07 -0500 | [diff] [blame] | 1720 | clp->rpc_ops->version, |
Chuck Lever | 5d8515c | 2007-12-10 14:57:16 -0500 | [diff] [blame] | 1721 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_ADDR), |
| 1722 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_HEX_PORT), |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1723 | dev, |
David Howells | 5d1acff | 2009-04-03 16:42:47 +0100 | [diff] [blame] | 1724 | fsid, |
| 1725 | nfs_server_fscache_state(server)); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1726 | |
| 1727 | return 0; |
| 1728 | } |
| 1729 | |
| 1730 | /* |
| 1731 | * initialise the /proc/fs/nfsfs/ directory |
| 1732 | */ |
| 1733 | int __init nfs_fs_proc_init(void) |
| 1734 | { |
| 1735 | struct proc_dir_entry *p; |
| 1736 | |
Alexey Dobriyan | 36a5aeb | 2008-04-29 01:01:42 -0700 | [diff] [blame] | 1737 | proc_fs_nfs = proc_mkdir("fs/nfsfs", NULL); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1738 | if (!proc_fs_nfs) |
| 1739 | goto error_0; |
| 1740 | |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1741 | /* a file of servers with which we're dealing */ |
Denis V. Lunev | 34b3723 | 2008-04-29 01:02:07 -0700 | [diff] [blame] | 1742 | p = proc_create("servers", S_IFREG|S_IRUGO, |
| 1743 | proc_fs_nfs, &nfs_server_list_fops); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1744 | if (!p) |
| 1745 | goto error_1; |
| 1746 | |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1747 | /* a file of volumes that we have mounted */ |
Denis V. Lunev | 34b3723 | 2008-04-29 01:02:07 -0700 | [diff] [blame] | 1748 | p = proc_create("volumes", S_IFREG|S_IRUGO, |
| 1749 | proc_fs_nfs, &nfs_volume_list_fops); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1750 | if (!p) |
| 1751 | goto error_2; |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1752 | return 0; |
| 1753 | |
| 1754 | error_2: |
| 1755 | remove_proc_entry("servers", proc_fs_nfs); |
| 1756 | error_1: |
Alexey Dobriyan | 36a5aeb | 2008-04-29 01:01:42 -0700 | [diff] [blame] | 1757 | remove_proc_entry("fs/nfsfs", NULL); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1758 | error_0: |
| 1759 | return -ENOMEM; |
| 1760 | } |
| 1761 | |
| 1762 | /* |
| 1763 | * clean up the /proc/fs/nfsfs/ directory |
| 1764 | */ |
| 1765 | void nfs_fs_proc_exit(void) |
| 1766 | { |
| 1767 | remove_proc_entry("volumes", proc_fs_nfs); |
| 1768 | remove_proc_entry("servers", proc_fs_nfs); |
Alexey Dobriyan | 36a5aeb | 2008-04-29 01:01:42 -0700 | [diff] [blame] | 1769 | remove_proc_entry("fs/nfsfs", NULL); |
David Howells | 6aaca56 | 2006-08-22 20:06:13 -0400 | [diff] [blame] | 1770 | } |
| 1771 | |
| 1772 | #endif /* CONFIG_PROC_FS */ |