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