]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/nfs/super.c
NFS: Use common device name parsing logic for NFSv4 and NFSv2/v3
[mirror_ubuntu-bionic-kernel.git] / fs / nfs / super.c
CommitLineData
f7b422b1
DH
1/*
2 * linux/fs/nfs/super.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs superblock handling functions
7 *
8 * Modularised by Alan Cox <Alan.Cox@linux.org>, while hacking some
9 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
10 *
11 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
12 * J.S.Peatfield@damtp.cam.ac.uk
13 *
14 * Split from inode.c by David Howells <dhowells@redhat.com>
15 *
54ceac45
DH
16 * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a
17 * particular server are held in the same superblock
18 * - NFS superblocks can have several effective roots to the dentry tree
19 * - directory type roots are spliced into the tree when a path from one root reaches the root
20 * of another (see nfs_lookup())
f7b422b1
DH
21 */
22
f7b422b1
DH
23#include <linux/module.h>
24#include <linux/init.h>
25
26#include <linux/time.h>
27#include <linux/kernel.h>
28#include <linux/mm.h>
29#include <linux/string.h>
30#include <linux/stat.h>
31#include <linux/errno.h>
32#include <linux/unistd.h>
33#include <linux/sunrpc/clnt.h>
34#include <linux/sunrpc/stats.h>
35#include <linux/sunrpc/metrics.h>
0896a725 36#include <linux/sunrpc/xprtsock.h>
2cf7ff7a 37#include <linux/sunrpc/xprtrdma.h>
f7b422b1
DH
38#include <linux/nfs_fs.h>
39#include <linux/nfs_mount.h>
40#include <linux/nfs4_mount.h>
41#include <linux/lockd/bind.h>
42#include <linux/smp_lock.h>
43#include <linux/seq_file.h>
44#include <linux/mount.h>
45#include <linux/nfs_idmap.h>
46#include <linux/vfs.h>
47#include <linux/inet.h>
fd00a8ff
CL
48#include <linux/in6.h>
49#include <net/ipv6.h>
f7b422b1 50#include <linux/nfs_xdr.h>
b5d5dfbd 51#include <linux/magic.h>
bf0fd768 52#include <linux/parser.h>
f7b422b1
DH
53
54#include <asm/system.h>
55#include <asm/uaccess.h>
56
57#include "nfs4_fs.h"
58#include "callback.h"
59#include "delegation.h"
60#include "iostat.h"
61#include "internal.h"
62
63#define NFSDBG_FACILITY NFSDBG_VFS
64
bf0fd768
CL
65enum {
66 /* Mount options that take no arguments */
67 Opt_soft, Opt_hard,
bf0fd768
CL
68 Opt_posix, Opt_noposix,
69 Opt_cto, Opt_nocto,
70 Opt_ac, Opt_noac,
71 Opt_lock, Opt_nolock,
72 Opt_v2, Opt_v3,
2cf7ff7a 73 Opt_udp, Opt_tcp, Opt_rdma,
bf0fd768
CL
74 Opt_acl, Opt_noacl,
75 Opt_rdirplus, Opt_nordirplus,
75180df2 76 Opt_sharecache, Opt_nosharecache,
bf0fd768
CL
77
78 /* Mount options that take integer arguments */
79 Opt_port,
80 Opt_rsize, Opt_wsize, Opt_bsize,
81 Opt_timeo, Opt_retrans,
82 Opt_acregmin, Opt_acregmax,
83 Opt_acdirmin, Opt_acdirmax,
84 Opt_actimeo,
85 Opt_namelen,
86 Opt_mountport,
e887cbcf 87 Opt_mountvers,
ad879cef 88 Opt_nfsvers,
bf0fd768
CL
89
90 /* Mount options that take string arguments */
33832034 91 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
0ac83779 92 Opt_addr, Opt_mountaddr, Opt_clientaddr,
bf0fd768
CL
93
94 /* Mount options that are ignored */
95 Opt_userspace, Opt_deprecated,
96
97 Opt_err
98};
99
100static match_table_t nfs_mount_option_tokens = {
101 { Opt_userspace, "bg" },
102 { Opt_userspace, "fg" },
ecbb3845
CL
103 { Opt_userspace, "retry=%s" },
104
bf0fd768
CL
105 { Opt_soft, "soft" },
106 { Opt_hard, "hard" },
d33e4dfe
CL
107 { Opt_deprecated, "intr" },
108 { Opt_deprecated, "nointr" },
bf0fd768
CL
109 { Opt_posix, "posix" },
110 { Opt_noposix, "noposix" },
111 { Opt_cto, "cto" },
112 { Opt_nocto, "nocto" },
113 { Opt_ac, "ac" },
114 { Opt_noac, "noac" },
115 { Opt_lock, "lock" },
116 { Opt_nolock, "nolock" },
117 { Opt_v2, "v2" },
118 { Opt_v3, "v3" },
119 { Opt_udp, "udp" },
120 { Opt_tcp, "tcp" },
2cf7ff7a 121 { Opt_rdma, "rdma" },
bf0fd768
CL
122 { Opt_acl, "acl" },
123 { Opt_noacl, "noacl" },
124 { Opt_rdirplus, "rdirplus" },
125 { Opt_nordirplus, "nordirplus" },
75180df2
TM
126 { Opt_sharecache, "sharecache" },
127 { Opt_nosharecache, "nosharecache" },
bf0fd768
CL
128
129 { Opt_port, "port=%u" },
130 { Opt_rsize, "rsize=%u" },
131 { Opt_wsize, "wsize=%u" },
132 { Opt_bsize, "bsize=%u" },
133 { Opt_timeo, "timeo=%u" },
134 { Opt_retrans, "retrans=%u" },
135 { Opt_acregmin, "acregmin=%u" },
136 { Opt_acregmax, "acregmax=%u" },
137 { Opt_acdirmin, "acdirmin=%u" },
138 { Opt_acdirmax, "acdirmax=%u" },
139 { Opt_actimeo, "actimeo=%u" },
bf0fd768
CL
140 { Opt_namelen, "namlen=%u" },
141 { Opt_mountport, "mountport=%u" },
bf0fd768 142 { Opt_mountvers, "mountvers=%u" },
bf0fd768
CL
143 { Opt_nfsvers, "nfsvers=%u" },
144 { Opt_nfsvers, "vers=%u" },
145
146 { Opt_sec, "sec=%s" },
147 { Opt_proto, "proto=%s" },
148 { Opt_mountproto, "mountproto=%s" },
149 { Opt_addr, "addr=%s" },
150 { Opt_clientaddr, "clientaddr=%s" },
33832034 151 { Opt_mounthost, "mounthost=%s" },
0ac83779 152 { Opt_mountaddr, "mountaddr=%s" },
bf0fd768
CL
153
154 { Opt_err, NULL }
155};
156
157enum {
2cf7ff7a 158 Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma,
bf0fd768
CL
159
160 Opt_xprt_err
161};
162
163static match_table_t nfs_xprt_protocol_tokens = {
164 { Opt_xprt_udp, "udp" },
165 { Opt_xprt_tcp, "tcp" },
2cf7ff7a 166 { Opt_xprt_rdma, "rdma" },
bf0fd768
CL
167
168 { Opt_xprt_err, NULL }
169};
170
171enum {
172 Opt_sec_none, Opt_sec_sys,
173 Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p,
174 Opt_sec_lkey, Opt_sec_lkeyi, Opt_sec_lkeyp,
175 Opt_sec_spkm, Opt_sec_spkmi, Opt_sec_spkmp,
176
177 Opt_sec_err
178};
179
180static match_table_t nfs_secflavor_tokens = {
181 { Opt_sec_none, "none" },
182 { Opt_sec_none, "null" },
183 { Opt_sec_sys, "sys" },
184
185 { Opt_sec_krb5, "krb5" },
186 { Opt_sec_krb5i, "krb5i" },
187 { Opt_sec_krb5p, "krb5p" },
188
189 { Opt_sec_lkey, "lkey" },
190 { Opt_sec_lkeyi, "lkeyi" },
191 { Opt_sec_lkeyp, "lkeyp" },
192
8d042218
OK
193 { Opt_sec_spkm, "spkm3" },
194 { Opt_sec_spkmi, "spkm3i" },
195 { Opt_sec_spkmp, "spkm3p" },
196
bf0fd768
CL
197 { Opt_sec_err, NULL }
198};
199
200
42faad99 201static void nfs_umount_begin(struct super_block *);
816724e6 202static int nfs_statfs(struct dentry *, struct kstatfs *);
f7b422b1
DH
203static int nfs_show_options(struct seq_file *, struct vfsmount *);
204static int nfs_show_stats(struct seq_file *, struct vfsmount *);
816724e6 205static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *);
54ceac45 206static int nfs_xdev_get_sb(struct file_system_type *fs_type,
816724e6 207 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
f7b422b1 208static void nfs_kill_super(struct super_block *);
ef818a28 209static void nfs_put_super(struct super_block *);
48b605f8 210static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
f7b422b1
DH
211
212static struct file_system_type nfs_fs_type = {
213 .owner = THIS_MODULE,
214 .name = "nfs",
215 .get_sb = nfs_get_sb,
216 .kill_sb = nfs_kill_super,
349457cc 217 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
218};
219
54ceac45 220struct file_system_type nfs_xdev_fs_type = {
f7b422b1
DH
221 .owner = THIS_MODULE,
222 .name = "nfs",
54ceac45 223 .get_sb = nfs_xdev_get_sb,
f7b422b1 224 .kill_sb = nfs_kill_super,
349457cc 225 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
226};
227
ee9b6d61 228static const struct super_operations nfs_sops = {
f7b422b1
DH
229 .alloc_inode = nfs_alloc_inode,
230 .destroy_inode = nfs_destroy_inode,
231 .write_inode = nfs_write_inode,
ef818a28 232 .put_super = nfs_put_super,
f7b422b1
DH
233 .statfs = nfs_statfs,
234 .clear_inode = nfs_clear_inode,
235 .umount_begin = nfs_umount_begin,
236 .show_options = nfs_show_options,
237 .show_stats = nfs_show_stats,
48b605f8 238 .remount_fs = nfs_remount,
f7b422b1
DH
239};
240
241#ifdef CONFIG_NFS_V4
816724e6
TM
242static int nfs4_get_sb(struct file_system_type *fs_type,
243 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
54ceac45
DH
244static int nfs4_xdev_get_sb(struct file_system_type *fs_type,
245 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
246static int nfs4_referral_get_sb(struct file_system_type *fs_type,
247 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
f7b422b1
DH
248static void nfs4_kill_super(struct super_block *sb);
249
250static struct file_system_type nfs4_fs_type = {
251 .owner = THIS_MODULE,
252 .name = "nfs4",
253 .get_sb = nfs4_get_sb,
254 .kill_sb = nfs4_kill_super,
349457cc 255 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
256};
257
54ceac45 258struct file_system_type nfs4_xdev_fs_type = {
f7b422b1
DH
259 .owner = THIS_MODULE,
260 .name = "nfs4",
54ceac45 261 .get_sb = nfs4_xdev_get_sb,
f7b422b1 262 .kill_sb = nfs4_kill_super,
349457cc 263 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
264};
265
54ceac45 266struct file_system_type nfs4_referral_fs_type = {
f7b422b1
DH
267 .owner = THIS_MODULE,
268 .name = "nfs4",
54ceac45 269 .get_sb = nfs4_referral_get_sb,
f7b422b1 270 .kill_sb = nfs4_kill_super,
349457cc 271 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
f7b422b1
DH
272};
273
ee9b6d61 274static const struct super_operations nfs4_sops = {
f7b422b1
DH
275 .alloc_inode = nfs_alloc_inode,
276 .destroy_inode = nfs_destroy_inode,
277 .write_inode = nfs_write_inode,
278 .statfs = nfs_statfs,
279 .clear_inode = nfs4_clear_inode,
280 .umount_begin = nfs_umount_begin,
281 .show_options = nfs_show_options,
282 .show_stats = nfs_show_stats,
48b605f8 283 .remount_fs = nfs_remount,
f7b422b1
DH
284};
285#endif
286
8e1f936b
RR
287static struct shrinker acl_shrinker = {
288 .shrink = nfs_access_cache_shrinker,
289 .seeks = DEFAULT_SEEKS,
290};
979df72e 291
f7b422b1
DH
292/*
293 * Register the NFS filesystems
294 */
295int __init register_nfs_fs(void)
296{
297 int ret;
298
299 ret = register_filesystem(&nfs_fs_type);
300 if (ret < 0)
301 goto error_0;
302
f7b422b1
DH
303 ret = nfs_register_sysctl();
304 if (ret < 0)
305 goto error_1;
89a09141 306#ifdef CONFIG_NFS_V4
f7b422b1
DH
307 ret = register_filesystem(&nfs4_fs_type);
308 if (ret < 0)
309 goto error_2;
310#endif
8e1f936b 311 register_shrinker(&acl_shrinker);
f7b422b1
DH
312 return 0;
313
314#ifdef CONFIG_NFS_V4
315error_2:
316 nfs_unregister_sysctl();
89a09141 317#endif
f7b422b1
DH
318error_1:
319 unregister_filesystem(&nfs_fs_type);
f7b422b1
DH
320error_0:
321 return ret;
322}
323
324/*
325 * Unregister the NFS filesystems
326 */
327void __exit unregister_nfs_fs(void)
328{
8e1f936b 329 unregister_shrinker(&acl_shrinker);
f7b422b1
DH
330#ifdef CONFIG_NFS_V4
331 unregister_filesystem(&nfs4_fs_type);
f7b422b1 332#endif
49af7ee1 333 nfs_unregister_sysctl();
f7b422b1
DH
334 unregister_filesystem(&nfs_fs_type);
335}
336
ef818a28
SD
337void nfs_sb_active(struct nfs_server *server)
338{
339 atomic_inc(&server->active);
340}
341
342void nfs_sb_deactive(struct nfs_server *server)
343{
344 if (atomic_dec_and_test(&server->active))
345 wake_up(&server->active_wq);
346}
347
348static void nfs_put_super(struct super_block *sb)
349{
350 struct nfs_server *server = NFS_SB(sb);
351 /*
352 * Make sure there are no outstanding ops to this server.
353 * If so, wait for them to finish before allowing the
354 * unmount to continue.
355 */
356 wait_event(server->active_wq, atomic_read(&server->active) == 0);
357}
358
f7b422b1
DH
359/*
360 * Deliver file system statistics to userspace
361 */
816724e6 362static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
f7b422b1 363{
0c7d90cf 364 struct nfs_server *server = NFS_SB(dentry->d_sb);
f7b422b1
DH
365 unsigned char blockbits;
366 unsigned long blockres;
0c7d90cf 367 struct nfs_fh *fh = NFS_FH(dentry->d_inode);
f7b422b1
DH
368 struct nfs_fattr fattr;
369 struct nfs_fsstat res = {
370 .fattr = &fattr,
371 };
372 int error;
373
374 lock_kernel();
375
8fa5c000 376 error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
f7b422b1
DH
377 if (error < 0)
378 goto out_err;
1a0ba9ae 379 buf->f_type = NFS_SUPER_MAGIC;
f7b422b1
DH
380
381 /*
382 * Current versions of glibc do not correctly handle the
383 * case where f_frsize != f_bsize. Eventually we want to
384 * report the value of wtmult in this field.
385 */
0c7d90cf 386 buf->f_frsize = dentry->d_sb->s_blocksize;
f7b422b1
DH
387
388 /*
389 * On most *nix systems, f_blocks, f_bfree, and f_bavail
390 * are reported in units of f_frsize. Linux hasn't had
391 * an f_frsize field in its statfs struct until recently,
392 * thus historically Linux's sys_statfs reports these
393 * fields in units of f_bsize.
394 */
0c7d90cf
DH
395 buf->f_bsize = dentry->d_sb->s_blocksize;
396 blockbits = dentry->d_sb->s_blocksize_bits;
f7b422b1
DH
397 blockres = (1 << blockbits) - 1;
398 buf->f_blocks = (res.tbytes + blockres) >> blockbits;
399 buf->f_bfree = (res.fbytes + blockres) >> blockbits;
400 buf->f_bavail = (res.abytes + blockres) >> blockbits;
401
402 buf->f_files = res.tfiles;
403 buf->f_ffree = res.afiles;
404
405 buf->f_namelen = server->namelen;
1a0ba9ae 406
f7b422b1
DH
407 unlock_kernel();
408 return 0;
409
410 out_err:
3110ff80 411 dprintk("%s: statfs error = %d\n", __func__, -error);
1a0ba9ae
AA
412 unlock_kernel();
413 return error;
f7b422b1
DH
414}
415
7d4e2747
DH
416/*
417 * Map the security flavour number to a name
418 */
81039f1f
TM
419static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
420{
7d4e2747 421 static const struct {
81039f1f
TM
422 rpc_authflavor_t flavour;
423 const char *str;
424 } sec_flavours[] = {
425 { RPC_AUTH_NULL, "null" },
426 { RPC_AUTH_UNIX, "sys" },
427 { RPC_AUTH_GSS_KRB5, "krb5" },
428 { RPC_AUTH_GSS_KRB5I, "krb5i" },
429 { RPC_AUTH_GSS_KRB5P, "krb5p" },
430 { RPC_AUTH_GSS_LKEY, "lkey" },
431 { RPC_AUTH_GSS_LKEYI, "lkeyi" },
432 { RPC_AUTH_GSS_LKEYP, "lkeyp" },
433 { RPC_AUTH_GSS_SPKM, "spkm" },
434 { RPC_AUTH_GSS_SPKMI, "spkmi" },
435 { RPC_AUTH_GSS_SPKMP, "spkmp" },
4d81cd16 436 { UINT_MAX, "unknown" }
81039f1f
TM
437 };
438 int i;
439
4d81cd16 440 for (i = 0; sec_flavours[i].flavour != UINT_MAX; i++) {
81039f1f
TM
441 if (sec_flavours[i].flavour == flavour)
442 break;
443 }
444 return sec_flavours[i].str;
445}
446
82d101d5
CL
447static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
448 int showdefaults)
449{
450 struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address;
451
452 switch (sap->sa_family) {
453 case AF_INET: {
454 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
455 seq_printf(m, ",mountaddr=" NIPQUAD_FMT,
456 NIPQUAD(sin->sin_addr.s_addr));
457 break;
458 }
459 case AF_INET6: {
460 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
461 seq_printf(m, ",mountaddr=" NIP6_FMT,
462 NIP6(sin6->sin6_addr));
463 break;
464 }
465 default:
466 if (showdefaults)
467 seq_printf(m, ",mountaddr=unspecified");
468 }
469
470 if (nfss->mountd_version || showdefaults)
471 seq_printf(m, ",mountvers=%u", nfss->mountd_version);
472 if (nfss->mountd_port || showdefaults)
473 seq_printf(m, ",mountport=%u", nfss->mountd_port);
474
475 switch (nfss->mountd_protocol) {
476 case IPPROTO_UDP:
477 seq_printf(m, ",mountproto=udp");
478 break;
479 case IPPROTO_TCP:
480 seq_printf(m, ",mountproto=tcp");
481 break;
482 default:
483 if (showdefaults)
484 seq_printf(m, ",mountproto=auto");
485 }
486}
487
f7b422b1
DH
488/*
489 * Describe the mount options in force on this server representation
490 */
82d101d5
CL
491static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
492 int showdefaults)
f7b422b1 493{
509de811 494 static const struct proc_nfs_info {
f7b422b1 495 int flag;
509de811
DH
496 const char *str;
497 const char *nostr;
f7b422b1
DH
498 } nfs_info[] = {
499 { NFS_MOUNT_SOFT, ",soft", ",hard" },
82d101d5
CL
500 { NFS_MOUNT_INTR, ",intr", ",nointr" },
501 { NFS_MOUNT_POSIX, ",posix", "" },
f7b422b1
DH
502 { NFS_MOUNT_NOCTO, ",nocto", "" },
503 { NFS_MOUNT_NOAC, ",noac", "" },
504 { NFS_MOUNT_NONLM, ",nolock", "" },
505 { NFS_MOUNT_NOACL, ",noacl", "" },
74dd34e6 506 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
75180df2 507 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
f7b422b1
DH
508 { 0, NULL, NULL }
509 };
509de811 510 const struct proc_nfs_info *nfs_infop;
8fa5c000 511 struct nfs_client *clp = nfss->nfs_client;
82d101d5 512 u32 version = clp->rpc_ops->version;
f7b422b1 513
82d101d5 514 seq_printf(m, ",vers=%u", version);
2d767432
CL
515 seq_printf(m, ",rsize=%u", nfss->rsize);
516 seq_printf(m, ",wsize=%u", nfss->wsize);
82d101d5
CL
517 if (nfss->bsize != 0)
518 seq_printf(m, ",bsize=%u", nfss->bsize);
519 seq_printf(m, ",namlen=%u", nfss->namelen);
f7b422b1 520 if (nfss->acregmin != 3*HZ || showdefaults)
2d767432 521 seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
f7b422b1 522 if (nfss->acregmax != 60*HZ || showdefaults)
2d767432 523 seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
f7b422b1 524 if (nfss->acdirmin != 30*HZ || showdefaults)
2d767432 525 seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
f7b422b1 526 if (nfss->acdirmax != 60*HZ || showdefaults)
2d767432 527 seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
f7b422b1
DH
528 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
529 if (nfss->flags & nfs_infop->flag)
530 seq_puts(m, nfs_infop->str);
531 else
532 seq_puts(m, nfs_infop->nostr);
533 }
56928edd
TT
534 seq_printf(m, ",proto=%s",
535 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
82d101d5
CL
536 if (version == 4) {
537 if (nfss->port != NFS_PORT)
538 seq_printf(m, ",port=%u", nfss->port);
539 } else
540 if (nfss->port)
541 seq_printf(m, ",port=%u", nfss->port);
542
33170233
TM
543 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
544 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
81039f1f 545 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
82d101d5
CL
546
547 if (version != 4)
548 nfs_show_mountd_options(m, nfss, showdefaults);
549
550#ifdef CONFIG_NFS_V4
551 if (clp->rpc_ops->version == 4)
552 seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
553#endif
f7b422b1
DH
554}
555
556/*
557 * Describe the mount options on this VFS mountpoint
558 */
559static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
560{
561 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
562
563 nfs_show_mount_options(m, nfss, 0);
564
5d8515ca
CL
565 seq_printf(m, ",addr=%s",
566 rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient,
567 RPC_DISPLAY_ADDR));
f7b422b1
DH
568
569 return 0;
570}
571
572/*
573 * Present statistical information for this VFS mountpoint
574 */
575static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
576{
577 int i, cpu;
578 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
579 struct rpc_auth *auth = nfss->client->cl_auth;
580 struct nfs_iostats totals = { };
581
582 seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS);
583
584 /*
585 * Display all mount option settings
586 */
587 seq_printf(m, "\n\topts:\t");
588 seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw");
589 seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : "");
590 seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : "");
591 seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : "");
592 nfs_show_mount_options(m, nfss, 1);
593
594 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ);
595
596 seq_printf(m, "\n\tcaps:\t");
597 seq_printf(m, "caps=0x%x", nfss->caps);
2d767432
CL
598 seq_printf(m, ",wtmult=%u", nfss->wtmult);
599 seq_printf(m, ",dtsize=%u", nfss->dtsize);
600 seq_printf(m, ",bsize=%u", nfss->bsize);
601 seq_printf(m, ",namlen=%u", nfss->namelen);
f7b422b1
DH
602
603#ifdef CONFIG_NFS_V4
40c55319 604 if (nfss->nfs_client->rpc_ops->version == 4) {
f7b422b1
DH
605 seq_printf(m, "\n\tnfsv4:\t");
606 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
607 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
608 seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
609 }
610#endif
611
612 /*
613 * Display security flavor in effect for this mount
614 */
2d767432 615 seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
f7b422b1 616 if (auth->au_flavor)
2d767432 617 seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
f7b422b1
DH
618
619 /*
620 * Display superblock I/O counters
621 */
622 for_each_possible_cpu(cpu) {
623 struct nfs_iostats *stats;
624
625 preempt_disable();
626 stats = per_cpu_ptr(nfss->io_stats, cpu);
627
628 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
629 totals.events[i] += stats->events[i];
630 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
631 totals.bytes[i] += stats->bytes[i];
632
633 preempt_enable();
634 }
635
636 seq_printf(m, "\n\tevents:\t");
637 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
638 seq_printf(m, "%lu ", totals.events[i]);
639 seq_printf(m, "\n\tbytes:\t");
640 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
641 seq_printf(m, "%Lu ", totals.bytes[i]);
642 seq_printf(m, "\n");
643
644 rpc_print_iostats(m, nfss->client);
645
646 return 0;
647}
648
649/*
650 * Begin unmount by attempting to remove all automounted mountpoints we added
54ceac45 651 * in response to xdev traversals and referrals
f7b422b1 652 */
42faad99 653static void nfs_umount_begin(struct super_block *sb)
f7b422b1 654{
42faad99 655 struct nfs_server *server = NFS_SB(sb);
fc6ae3cf
TM
656 struct rpc_clnt *rpc;
657
fc6ae3cf
TM
658 /* -EIO all pending I/O */
659 rpc = server->client_acl;
660 if (!IS_ERR(rpc))
661 rpc_killall_tasks(rpc);
662 rpc = server->client;
663 if (!IS_ERR(rpc))
664 rpc_killall_tasks(rpc);
f7b422b1
DH
665}
666
04dcd6e3
CL
667/*
668 * Set the port number in an address. Be agnostic about the address family.
669 */
670static void nfs_set_port(struct sockaddr *sap, unsigned short port)
671{
672 switch (sap->sa_family) {
673 case AF_INET: {
674 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
675 ap->sin_port = htons(port);
676 break;
677 }
678 case AF_INET6: {
679 struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
680 ap->sin6_port = htons(port);
681 break;
682 }
683 }
684}
685
fc50d58f 686/*
cdcd7f9a
CL
687 * Sanity-check a server address provided by the mount command.
688 *
689 * Address family must be initialized, and address must not be
690 * the ANY address for that family.
fc50d58f
CL
691 */
692static int nfs_verify_server_address(struct sockaddr *addr)
693{
694 switch (addr->sa_family) {
695 case AF_INET: {
cdcd7f9a 696 struct sockaddr_in *sa = (struct sockaddr_in *)addr;
e6f1cebf 697 return sa->sin_addr.s_addr != htonl(INADDR_ANY);
cdcd7f9a
CL
698 }
699 case AF_INET6: {
700 struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
701 return !ipv6_addr_any(sa);
fc50d58f
CL
702 }
703 }
704
705 return 0;
706}
707
9412b927
CL
708/*
709 * Parse string addresses passed in via a mount option,
710 * and construct a sockaddr based on the result.
711 *
712 * If address parsing fails, set the sockaddr's address
713 * family to AF_UNSPEC to force nfs_verify_server_address()
714 * to punt the mount.
715 */
716static void nfs_parse_server_address(char *value,
4c568017
CL
717 struct sockaddr *sap,
718 size_t *len)
9412b927 719{
3c7c7e48
CL
720 if (strchr(value, ':')) {
721 struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
722 u8 *addr = (u8 *)&ap->sin6_addr.in6_u;
9412b927 723
3c7c7e48
CL
724 ap->sin6_family = AF_INET6;
725 *len = sizeof(*ap);
726 if (in6_pton(value, -1, addr, '\0', NULL))
727 return;
728 } else {
729 struct sockaddr_in *ap = (struct sockaddr_in *)sap;
730 u8 *addr = (u8 *)&ap->sin_addr.s_addr;
731
732 ap->sin_family = AF_INET;
733 *len = sizeof(*ap);
734 if (in4_pton(value, -1, addr, '\0', NULL))
735 return;
736 }
9412b927
CL
737
738 sap->sa_family = AF_UNSPEC;
4c568017 739 *len = 0;
9412b927
CL
740}
741
bf0fd768
CL
742/*
743 * Error-check and convert a string of mount options from user space into
744 * a data structure
745 */
746static int nfs_parse_mount_options(char *raw,
747 struct nfs_parsed_mount_data *mnt)
748{
f9c3a380 749 char *p, *string, *secdata;
f9c3a380 750 int rc;
bf0fd768
CL
751
752 if (!raw) {
753 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
754 return 1;
755 }
756 dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
757
f9c3a380
EP
758 secdata = alloc_secdata();
759 if (!secdata)
760 goto out_nomem;
761
762 rc = security_sb_copy_data(raw, secdata);
763 if (rc)
764 goto out_security_failure;
765
766 rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
767 if (rc)
768 goto out_security_failure;
769
770 free_secdata(secdata);
771
bf0fd768
CL
772 while ((p = strsep(&raw, ",")) != NULL) {
773 substring_t args[MAX_OPT_ARGS];
774 int option, token;
775
776 if (!*p)
777 continue;
778
779 dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p);
780
781 token = match_token(p, nfs_mount_option_tokens, args);
782 switch (token) {
783 case Opt_soft:
784 mnt->flags |= NFS_MOUNT_SOFT;
785 break;
786 case Opt_hard:
787 mnt->flags &= ~NFS_MOUNT_SOFT;
788 break;
bf0fd768
CL
789 case Opt_posix:
790 mnt->flags |= NFS_MOUNT_POSIX;
791 break;
792 case Opt_noposix:
793 mnt->flags &= ~NFS_MOUNT_POSIX;
794 break;
795 case Opt_cto:
796 mnt->flags &= ~NFS_MOUNT_NOCTO;
797 break;
798 case Opt_nocto:
799 mnt->flags |= NFS_MOUNT_NOCTO;
800 break;
801 case Opt_ac:
802 mnt->flags &= ~NFS_MOUNT_NOAC;
803 break;
804 case Opt_noac:
805 mnt->flags |= NFS_MOUNT_NOAC;
806 break;
807 case Opt_lock:
808 mnt->flags &= ~NFS_MOUNT_NONLM;
809 break;
810 case Opt_nolock:
811 mnt->flags |= NFS_MOUNT_NONLM;
812 break;
813 case Opt_v2:
814 mnt->flags &= ~NFS_MOUNT_VER3;
815 break;
816 case Opt_v3:
817 mnt->flags |= NFS_MOUNT_VER3;
818 break;
819 case Opt_udp:
820 mnt->flags &= ~NFS_MOUNT_TCP;
0896a725 821 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768
CL
822 mnt->timeo = 7;
823 mnt->retrans = 5;
824 break;
825 case Opt_tcp:
826 mnt->flags |= NFS_MOUNT_TCP;
0896a725 827 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768
CL
828 mnt->timeo = 600;
829 mnt->retrans = 2;
830 break;
2cf7ff7a
TT
831 case Opt_rdma:
832 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
833 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
834 mnt->timeo = 600;
835 mnt->retrans = 2;
836 break;
bf0fd768
CL
837 case Opt_acl:
838 mnt->flags &= ~NFS_MOUNT_NOACL;
839 break;
840 case Opt_noacl:
841 mnt->flags |= NFS_MOUNT_NOACL;
842 break;
843 case Opt_rdirplus:
844 mnt->flags &= ~NFS_MOUNT_NORDIRPLUS;
845 break;
846 case Opt_nordirplus:
847 mnt->flags |= NFS_MOUNT_NORDIRPLUS;
848 break;
75180df2
TM
849 case Opt_sharecache:
850 mnt->flags &= ~NFS_MOUNT_UNSHARED;
851 break;
852 case Opt_nosharecache:
853 mnt->flags |= NFS_MOUNT_UNSHARED;
854 break;
bf0fd768
CL
855
856 case Opt_port:
857 if (match_int(args, &option))
858 return 0;
859 if (option < 0 || option > 65535)
860 return 0;
f22d6d79 861 mnt->nfs_server.port = option;
bf0fd768
CL
862 break;
863 case Opt_rsize:
864 if (match_int(args, &mnt->rsize))
865 return 0;
866 break;
867 case Opt_wsize:
868 if (match_int(args, &mnt->wsize))
869 return 0;
870 break;
871 case Opt_bsize:
872 if (match_int(args, &option))
873 return 0;
874 if (option < 0)
875 return 0;
876 mnt->bsize = option;
877 break;
878 case Opt_timeo:
879 if (match_int(args, &mnt->timeo))
880 return 0;
881 break;
882 case Opt_retrans:
883 if (match_int(args, &mnt->retrans))
884 return 0;
885 break;
886 case Opt_acregmin:
887 if (match_int(args, &mnt->acregmin))
888 return 0;
889 break;
890 case Opt_acregmax:
891 if (match_int(args, &mnt->acregmax))
892 return 0;
893 break;
894 case Opt_acdirmin:
895 if (match_int(args, &mnt->acdirmin))
896 return 0;
897 break;
898 case Opt_acdirmax:
899 if (match_int(args, &mnt->acdirmax))
900 return 0;
901 break;
902 case Opt_actimeo:
903 if (match_int(args, &option))
904 return 0;
905 if (option < 0)
906 return 0;
907 mnt->acregmin =
908 mnt->acregmax =
909 mnt->acdirmin =
910 mnt->acdirmax = option;
911 break;
912 case Opt_namelen:
913 if (match_int(args, &mnt->namlen))
914 return 0;
915 break;
916 case Opt_mountport:
917 if (match_int(args, &option))
918 return 0;
919 if (option < 0 || option > 65535)
920 return 0;
921 mnt->mount_server.port = option;
922 break;
bf0fd768
CL
923 case Opt_mountvers:
924 if (match_int(args, &option))
925 return 0;
926 if (option < 0)
927 return 0;
928 mnt->mount_server.version = option;
929 break;
bf0fd768
CL
930 case Opt_nfsvers:
931 if (match_int(args, &option))
932 return 0;
933 switch (option) {
934 case 2:
935 mnt->flags &= ~NFS_MOUNT_VER3;
936 break;
937 case 3:
938 mnt->flags |= NFS_MOUNT_VER3;
939 break;
940 default:
941 goto out_unrec_vers;
942 }
943 break;
944
945 case Opt_sec:
946 string = match_strdup(args);
947 if (string == NULL)
948 goto out_nomem;
949 token = match_token(string, nfs_secflavor_tokens, args);
950 kfree(string);
951
952 /*
953 * The flags setting is for v2/v3. The flavor_len
954 * setting is for v4. v2/v3 also need to know the
955 * difference between NULL and UNIX.
956 */
957 switch (token) {
958 case Opt_sec_none:
959 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
960 mnt->auth_flavor_len = 0;
961 mnt->auth_flavors[0] = RPC_AUTH_NULL;
962 break;
963 case Opt_sec_sys:
964 mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
965 mnt->auth_flavor_len = 0;
966 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
967 break;
968 case Opt_sec_krb5:
969 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
970 mnt->auth_flavor_len = 1;
971 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
972 break;
973 case Opt_sec_krb5i:
974 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
975 mnt->auth_flavor_len = 1;
976 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
977 break;
978 case Opt_sec_krb5p:
979 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
980 mnt->auth_flavor_len = 1;
981 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
982 break;
983 case Opt_sec_lkey:
984 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
985 mnt->auth_flavor_len = 1;
986 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
987 break;
988 case Opt_sec_lkeyi:
989 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
990 mnt->auth_flavor_len = 1;
991 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
992 break;
993 case Opt_sec_lkeyp:
994 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
995 mnt->auth_flavor_len = 1;
996 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
997 break;
998 case Opt_sec_spkm:
999 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1000 mnt->auth_flavor_len = 1;
1001 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
1002 break;
1003 case Opt_sec_spkmi:
1004 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1005 mnt->auth_flavor_len = 1;
1006 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
1007 break;
1008 case Opt_sec_spkmp:
1009 mnt->flags |= NFS_MOUNT_SECFLAVOUR;
1010 mnt->auth_flavor_len = 1;
1011 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
1012 break;
1013 default:
1014 goto out_unrec_sec;
1015 }
1016 break;
1017 case Opt_proto:
1018 string = match_strdup(args);
1019 if (string == NULL)
1020 goto out_nomem;
1021 token = match_token(string,
1022 nfs_xprt_protocol_tokens, args);
1023 kfree(string);
1024
1025 switch (token) {
fdb66ff4 1026 case Opt_xprt_udp:
bf0fd768 1027 mnt->flags &= ~NFS_MOUNT_TCP;
0896a725 1028 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768
CL
1029 mnt->timeo = 7;
1030 mnt->retrans = 5;
1031 break;
fdb66ff4 1032 case Opt_xprt_tcp:
bf0fd768 1033 mnt->flags |= NFS_MOUNT_TCP;
0896a725 1034 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768
CL
1035 mnt->timeo = 600;
1036 mnt->retrans = 2;
1037 break;
2cf7ff7a
TT
1038 case Opt_xprt_rdma:
1039 /* vector side protocols to TCP */
1040 mnt->flags |= NFS_MOUNT_TCP;
1041 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1042 mnt->timeo = 600;
1043 mnt->retrans = 2;
1044 break;
bf0fd768
CL
1045 default:
1046 goto out_unrec_xprt;
1047 }
1048 break;
1049 case Opt_mountproto:
1050 string = match_strdup(args);
1051 if (string == NULL)
1052 goto out_nomem;
1053 token = match_token(string,
1054 nfs_xprt_protocol_tokens, args);
1055 kfree(string);
1056
1057 switch (token) {
fdb66ff4 1058 case Opt_xprt_udp:
0896a725 1059 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
bf0fd768 1060 break;
fdb66ff4 1061 case Opt_xprt_tcp:
0896a725 1062 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
bf0fd768 1063 break;
2cf7ff7a 1064 case Opt_xprt_rdma: /* not used for side protocols */
bf0fd768
CL
1065 default:
1066 goto out_unrec_xprt;
1067 }
1068 break;
1069 case Opt_addr:
1070 string = match_strdup(args);
1071 if (string == NULL)
1072 goto out_nomem;
9412b927 1073 nfs_parse_server_address(string, (struct sockaddr *)
4c568017
CL
1074 &mnt->nfs_server.address,
1075 &mnt->nfs_server.addrlen);
bf0fd768
CL
1076 kfree(string);
1077 break;
1078 case Opt_clientaddr:
1079 string = match_strdup(args);
1080 if (string == NULL)
1081 goto out_nomem;
fc601477 1082 kfree(mnt->client_address);
bf0fd768
CL
1083 mnt->client_address = string;
1084 break;
33832034
CL
1085 case Opt_mounthost:
1086 string = match_strdup(args);
1087 if (string == NULL)
1088 goto out_nomem;
fc601477 1089 kfree(mnt->mount_server.hostname);
33832034
CL
1090 mnt->mount_server.hostname = string;
1091 break;
0ac83779 1092 case Opt_mountaddr:
bf0fd768
CL
1093 string = match_strdup(args);
1094 if (string == NULL)
1095 goto out_nomem;
9412b927 1096 nfs_parse_server_address(string, (struct sockaddr *)
4c568017
CL
1097 &mnt->mount_server.address,
1098 &mnt->mount_server.addrlen);
bf0fd768
CL
1099 kfree(string);
1100 break;
1101
1102 case Opt_userspace:
1103 case Opt_deprecated:
d33e4dfe
CL
1104 dfprintk(MOUNT, "NFS: ignoring mount option "
1105 "'%s'\n", p);
bf0fd768
CL
1106 break;
1107
1108 default:
1109 goto out_unknown;
1110 }
1111 }
1112
f22d6d79
CL
1113 nfs_set_port((struct sockaddr *)&mnt->nfs_server.address,
1114 mnt->nfs_server.port);
04dcd6e3 1115
bf0fd768
CL
1116 return 1;
1117
1118out_nomem:
1119 printk(KERN_INFO "NFS: not enough memory to parse option\n");
1120 return 0;
f9c3a380
EP
1121out_security_failure:
1122 free_secdata(secdata);
1123 printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
1124 return 0;
bf0fd768
CL
1125out_unrec_vers:
1126 printk(KERN_INFO "NFS: unrecognized NFS version number\n");
1127 return 0;
1128
1129out_unrec_xprt:
1130 printk(KERN_INFO "NFS: unrecognized transport protocol\n");
1131 return 0;
1132
1133out_unrec_sec:
1134 printk(KERN_INFO "NFS: unrecognized security flavor\n");
1135 return 0;
1136
1137out_unknown:
1138 printk(KERN_INFO "NFS: unknown mount option: %s\n", p);
1139 return 0;
1140}
1141
0076d7b7
CL
1142/*
1143 * Use the remote server's MOUNT service to request the NFS file handle
1144 * corresponding to the provided path.
1145 */
1146static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1147 struct nfs_fh *root_fh)
1148{
4c568017 1149 struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address;
33832034 1150 char *hostname;
4c568017 1151 int status;
0076d7b7
CL
1152
1153 if (args->mount_server.version == 0) {
1154 if (args->flags & NFS_MOUNT_VER3)
1155 args->mount_server.version = NFS_MNT3_VERSION;
1156 else
1157 args->mount_server.version = NFS_MNT_VERSION;
1158 }
1159
33832034
CL
1160 if (args->mount_server.hostname)
1161 hostname = args->mount_server.hostname;
1162 else
1163 hostname = args->nfs_server.hostname;
1164
0076d7b7
CL
1165 /*
1166 * Construct the mount server's address.
1167 */
4c568017
CL
1168 if (args->mount_server.address.ss_family == AF_UNSPEC) {
1169 memcpy(sap, &args->nfs_server.address,
1170 args->nfs_server.addrlen);
1171 args->mount_server.addrlen = args->nfs_server.addrlen;
1172 }
1173
aad70007
JL
1174 /*
1175 * autobind will be used if mount_server.port == 0
1176 */
4c568017 1177 nfs_set_port(sap, args->mount_server.port);
0076d7b7
CL
1178
1179 /*
1180 * Now ask the mount server to map our export path
1181 * to a file handle.
1182 */
4c568017
CL
1183 status = nfs_mount(sap,
1184 args->mount_server.addrlen,
33832034 1185 hostname,
0076d7b7
CL
1186 args->nfs_server.export_path,
1187 args->mount_server.version,
1188 args->mount_server.protocol,
1189 root_fh);
efd8340b
CL
1190 if (status == 0)
1191 return 0;
0076d7b7 1192
396cee97 1193 dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
33832034 1194 hostname, status);
0076d7b7
CL
1195 return status;
1196}
1197
dc045898
CL
1198/*
1199 * Split "dev_name" into "hostname:export_path".
1200 *
1201 * Note: caller frees hostname and export path, even on error.
1202 */
1203static int nfs_parse_devname(const char *dev_name,
1204 char **hostname, size_t maxnamlen,
1205 char **export_path, size_t maxpathlen)
1206{
1207 size_t len;
1208 char *colon, *comma;
1209
1210 colon = strchr(dev_name, ':');
1211 if (colon == NULL)
1212 goto out_bad_devname;
1213
1214 len = colon - dev_name;
1215 if (len > maxnamlen)
1216 goto out_hostname;
1217
1218 /* N.B. caller will free nfs_server.hostname in all cases */
1219 *hostname = kstrndup(dev_name, len, GFP_KERNEL);
1220 if (!*hostname)
1221 goto out_nomem;
1222
1223 /* kill possible hostname list: not supported */
1224 comma = strchr(*hostname, ',');
1225 if (comma != NULL) {
1226 if (comma == *hostname)
1227 goto out_bad_devname;
1228 *comma = '\0';
1229 }
1230
1231 colon++;
1232 len = strlen(colon);
1233 if (len > maxpathlen)
1234 goto out_path;
1235 *export_path = kstrndup(colon, len, GFP_KERNEL);
1236 if (!*export_path)
1237 goto out_nomem;
1238
1239 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path);
1240 return 0;
1241
1242out_bad_devname:
1243 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1244 return -EINVAL;
1245
1246out_nomem:
1247 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1248 return -ENOMEM;
1249
1250out_hostname:
1251 dfprintk(MOUNT, "NFS: server hostname too long\n");
1252 return -ENAMETOOLONG;
1253
1254out_path:
1255 dfprintk(MOUNT, "NFS: export pathname too long\n");
1256 return -ENAMETOOLONG;
1257}
1258
f7b422b1 1259/*
54ceac45
DH
1260 * Validate the NFS2/NFS3 mount data
1261 * - fills in the mount root filehandle
136d558c
CL
1262 *
1263 * For option strings, user space handles the following behaviors:
1264 *
1265 * + DNS: mapping server host name to IP address ("addr=" option)
1266 *
1267 * + failure mode: how to behave if a mount request can't be handled
1268 * immediately ("fg/bg" option)
1269 *
1270 * + retry: how often to retry a mount request ("retry=" option)
1271 *
1272 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1273 * mountproto=tcp after mountproto=udp, and so on
f7b422b1 1274 */
2283f8d6
TT
1275static int nfs_validate_mount_data(void *options,
1276 struct nfs_parsed_mount_data *args,
136d558c
CL
1277 struct nfs_fh *mntfh,
1278 const char *dev_name)
f7b422b1 1279{
2283f8d6 1280 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
136d558c 1281
5df36e78
CL
1282 if (data == NULL)
1283 goto out_no_data;
f7b422b1 1284
2283f8d6
TT
1285 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1286 args->rsize = NFS_MAX_FILE_IO_SIZE;
1287 args->wsize = NFS_MAX_FILE_IO_SIZE;
1288 args->timeo = 600;
1289 args->retrans = 2;
1290 args->acregmin = 3;
1291 args->acregmax = 60;
1292 args->acdirmin = 30;
1293 args->acdirmax = 60;
f22d6d79 1294 args->mount_server.port = 0; /* autobind unless user sets port */
0896a725 1295 args->mount_server.protocol = XPRT_TRANSPORT_UDP;
f22d6d79 1296 args->nfs_server.port = 0; /* autobind unless user sets port */
0896a725 1297 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
2283f8d6 1298
54ceac45 1299 switch (data->version) {
5df36e78
CL
1300 case 1:
1301 data->namlen = 0;
1302 case 2:
1303 data->bsize = 0;
1304 case 3:
1305 if (data->flags & NFS_MOUNT_VER3)
1306 goto out_no_v3;
1307 data->root.size = NFS2_FHSIZE;
1308 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1309 case 4:
1310 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1311 goto out_no_sec;
1312 case 5:
1313 memset(data->context, 0, sizeof(data->context));
1314 case 6:
b7e24457
TM
1315 if (data->flags & NFS_MOUNT_VER3) {
1316 if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
1317 goto out_invalid_fh;
5df36e78 1318 mntfh->size = data->root.size;
b7e24457 1319 } else
5df36e78
CL
1320 mntfh->size = NFS2_FHSIZE;
1321
5df36e78
CL
1322
1323 memcpy(mntfh->data, data->root.data, mntfh->size);
1324 if (mntfh->size < sizeof(mntfh->data))
1325 memset(mntfh->data + mntfh->size, 0,
1326 sizeof(mntfh->data) - mntfh->size);
6e88e061 1327
2283f8d6
TT
1328 /*
1329 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1330 * can deal with.
1331 */
1332 args->flags = data->flags;
1333 args->rsize = data->rsize;
1334 args->wsize = data->wsize;
2283f8d6
TT
1335 args->timeo = data->timeo;
1336 args->retrans = data->retrans;
1337 args->acregmin = data->acregmin;
1338 args->acregmax = data->acregmax;
1339 args->acdirmin = data->acdirmin;
1340 args->acdirmax = data->acdirmax;
4c568017
CL
1341
1342 memcpy(&args->nfs_server.address, &data->addr,
1343 sizeof(data->addr));
1344 args->nfs_server.addrlen = sizeof(data->addr);
1345 if (!nfs_verify_server_address((struct sockaddr *)
1346 &args->nfs_server.address))
1347 goto out_no_address;
1348
2283f8d6 1349 if (!(data->flags & NFS_MOUNT_TCP))
0896a725 1350 args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
2283f8d6
TT
1351 /* N.B. caller will free nfs_server.hostname in all cases */
1352 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1353 args->namlen = data->namlen;
1354 args->bsize = data->bsize;
1355 args->auth_flavors[0] = data->pseudoflavor;
63649bd7
CG
1356 if (!args->nfs_server.hostname)
1357 goto out_nomem;
f9c3a380
EP
1358
1359 /*
1360 * The legacy version 6 binary mount data from userspace has a
1361 * field used only to transport selinux information into the
1362 * the kernel. To continue to support that functionality we
1363 * have a touch of selinux knowledge here in the NFS code. The
1364 * userspace code converted context=blah to just blah so we are
1365 * converting back to the full string selinux understands.
1366 */
1367 if (data->context[0]){
1368#ifdef CONFIG_SECURITY_SELINUX
1369 int rc;
1370 char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
1371 if (!opts_str)
1372 return -ENOMEM;
1373 strcpy(opts_str, "context=");
1374 data->context[NFS_MAX_CONTEXT_LEN] = '\0';
1375 strcat(opts_str, &data->context[0]);
1376 rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
1377 kfree(opts_str);
1378 if (rc)
1379 return rc;
1380#else
1381 return -EINVAL;
1382#endif
1383 }
1384
5df36e78 1385 break;
136d558c 1386 default: {
136d558c 1387 int status;
136d558c 1388
2283f8d6
TT
1389 if (nfs_parse_mount_options((char *)options, args) == 0)
1390 return -EINVAL;
136d558c 1391
6e88e061
CL
1392 if (!nfs_verify_server_address((struct sockaddr *)
1393 &args->nfs_server.address))
1394 goto out_no_address;
1395
dc045898
CL
1396 status = nfs_parse_devname(dev_name,
1397 &args->nfs_server.hostname,
1398 PAGE_SIZE,
1399 &args->nfs_server.export_path,
1400 NFS_MAXPATHLEN);
1401 if (!status)
1402 status = nfs_try_mount(args, mntfh);
136d558c 1403
dc045898
CL
1404 kfree(args->nfs_server.export_path);
1405 args->nfs_server.export_path = NULL;
136d558c 1406
136d558c 1407 if (status)
fdc6e2c8 1408 return status;
136d558c 1409
136d558c
CL
1410 break;
1411 }
f7b422b1 1412 }
54ceac45 1413
2283f8d6
TT
1414 if (!(args->flags & NFS_MOUNT_SECFLAVOUR))
1415 args->auth_flavors[0] = RPC_AUTH_UNIX;
36b15c54 1416
54ceac45 1417#ifndef CONFIG_NFS_V3
2283f8d6 1418 if (args->flags & NFS_MOUNT_VER3)
5df36e78
CL
1419 goto out_v3_not_compiled;
1420#endif /* !CONFIG_NFS_V3 */
f7b422b1 1421
5df36e78 1422 return 0;
f7b422b1 1423
5df36e78
CL
1424out_no_data:
1425 dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n");
1426 return -EINVAL;
54ceac45 1427
5df36e78
CL
1428out_no_v3:
1429 dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n",
1430 data->version);
1431 return -EINVAL;
f7b422b1 1432
5df36e78
CL
1433out_no_sec:
1434 dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1435 return -EINVAL;
1436
5df36e78
CL
1437#ifndef CONFIG_NFS_V3
1438out_v3_not_compiled:
1439 dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n");
1440 return -EPROTONOSUPPORT;
1441#endif /* !CONFIG_NFS_V3 */
1442
63649bd7
CG
1443out_nomem:
1444 dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
1445 return -ENOMEM;
1446
5df36e78
CL
1447out_no_address:
1448 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
1449 return -EINVAL;
1450
1451out_invalid_fh:
1452 dfprintk(MOUNT, "NFS: invalid root filehandle\n");
1453 return -EINVAL;
f7b422b1
DH
1454}
1455
48b605f8
JL
1456static int
1457nfs_compare_remount_data(struct nfs_server *nfss,
1458 struct nfs_parsed_mount_data *data)
1459{
1460 if (data->flags != nfss->flags ||
1461 data->rsize != nfss->rsize ||
1462 data->wsize != nfss->wsize ||
1463 data->retrans != nfss->client->cl_timeout->to_retries ||
1464 data->auth_flavors[0] != nfss->client->cl_auth->au_flavor ||
1465 data->acregmin != nfss->acregmin / HZ ||
1466 data->acregmax != nfss->acregmax / HZ ||
1467 data->acdirmin != nfss->acdirmin / HZ ||
1468 data->acdirmax != nfss->acdirmax / HZ ||
1469 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
1470 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
1471 memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1472 data->nfs_server.addrlen) != 0)
1473 return -EINVAL;
1474
1475 return 0;
1476}
1477
1478static int
1479nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1480{
1481 int error;
1482 struct nfs_server *nfss = sb->s_fs_info;
1483 struct nfs_parsed_mount_data *data;
1484 struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data;
1485 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
cd100725 1486 u32 nfsvers = nfss->nfs_client->rpc_ops->version;
48b605f8
JL
1487
1488 /*
1489 * Userspace mount programs that send binary options generally send
1490 * them populated with default values. We have no way to know which
1491 * ones were explicitly specified. Fall back to legacy behavior and
1492 * just return success.
1493 */
cd100725
TM
1494 if ((nfsvers == 4 && options4->version == 1) ||
1495 (nfsvers <= 3 && options->version >= 1 &&
48b605f8
JL
1496 options->version <= 6))
1497 return 0;
1498
1499 data = kzalloc(sizeof(*data), GFP_KERNEL);
1500 if (data == NULL)
1501 return -ENOMEM;
1502
1503 /* fill out struct with values from existing mount */
1504 data->flags = nfss->flags;
1505 data->rsize = nfss->rsize;
1506 data->wsize = nfss->wsize;
1507 data->retrans = nfss->client->cl_timeout->to_retries;
1508 data->auth_flavors[0] = nfss->client->cl_auth->au_flavor;
1509 data->acregmin = nfss->acregmin / HZ;
1510 data->acregmax = nfss->acregmax / HZ;
1511 data->acdirmin = nfss->acdirmin / HZ;
1512 data->acdirmax = nfss->acdirmax / HZ;
1513 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
1514 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
1515 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1516 data->nfs_server.addrlen);
1517
1518 /* overwrite those values with any that were specified */
1519 error = nfs_parse_mount_options((char *)options, data);
1520 if (error < 0)
1521 goto out;
1522
1523 /* compare new mount options with old ones */
1524 error = nfs_compare_remount_data(nfss, data);
1525out:
1526 kfree(data);
1527 return error;
1528}
1529
f7b422b1 1530/*
54ceac45 1531 * Initialise the common bits of the superblock
f7b422b1 1532 */
54ceac45 1533static inline void nfs_initialise_sb(struct super_block *sb)
f7b422b1 1534{
54ceac45 1535 struct nfs_server *server = NFS_SB(sb);
5006a76c 1536
54ceac45 1537 sb->s_magic = NFS_SUPER_MAGIC;
f7b422b1 1538
54ceac45
DH
1539 /* We probably want something more informative here */
1540 snprintf(sb->s_id, sizeof(sb->s_id),
1541 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
5006a76c 1542
54ceac45
DH
1543 if (sb->s_blocksize == 0)
1544 sb->s_blocksize = nfs_block_bits(server->wsize,
1545 &sb->s_blocksize_bits);
f7b422b1 1546
54ceac45
DH
1547 if (server->flags & NFS_MOUNT_NOAC)
1548 sb->s_flags |= MS_SYNCHRONOUS;
f7b422b1 1549
54ceac45 1550 nfs_super_set_maxbytes(sb, server->maxfilesize);
f7b422b1
DH
1551}
1552
1553/*
54ceac45 1554 * Finish setting up an NFS2/3 superblock
f7b422b1 1555 */
2283f8d6
TT
1556static void nfs_fill_super(struct super_block *sb,
1557 struct nfs_parsed_mount_data *data)
f7b422b1
DH
1558{
1559 struct nfs_server *server = NFS_SB(sb);
5006a76c 1560
54ceac45
DH
1561 sb->s_blocksize_bits = 0;
1562 sb->s_blocksize = 0;
1563 if (data->bsize)
1564 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
f7b422b1 1565
54ceac45
DH
1566 if (server->flags & NFS_MOUNT_VER3) {
1567 /* The VFS shouldn't apply the umask to mode bits. We will do
1568 * so ourselves when necessary.
1569 */
1570 sb->s_flags |= MS_POSIXACL;
1571 sb->s_time_gran = 1;
816724e6 1572 }
54ceac45
DH
1573
1574 sb->s_op = &nfs_sops;
1575 nfs_initialise_sb(sb);
f7b422b1
DH
1576}
1577
1578/*
54ceac45 1579 * Finish setting up a cloned NFS2/3 superblock
f7b422b1 1580 */
54ceac45
DH
1581static void nfs_clone_super(struct super_block *sb,
1582 const struct super_block *old_sb)
f7b422b1 1583{
54ceac45
DH
1584 struct nfs_server *server = NFS_SB(sb);
1585
1586 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
1587 sb->s_blocksize = old_sb->s_blocksize;
1588 sb->s_maxbytes = old_sb->s_maxbytes;
f7b422b1 1589
f7b422b1 1590 if (server->flags & NFS_MOUNT_VER3) {
54ceac45
DH
1591 /* The VFS shouldn't apply the umask to mode bits. We will do
1592 * so ourselves when necessary.
f7b422b1
DH
1593 */
1594 sb->s_flags |= MS_POSIXACL;
f7b422b1 1595 sb->s_time_gran = 1;
f7b422b1
DH
1596 }
1597
54ceac45
DH
1598 sb->s_op = old_sb->s_op;
1599 nfs_initialise_sb(sb);
f7b422b1
DH
1600}
1601
275a5d24
TM
1602#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
1603
1604static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
1605{
1606 const struct nfs_server *a = s->s_fs_info;
1607 const struct rpc_clnt *clnt_a = a->client;
1608 const struct rpc_clnt *clnt_b = b->client;
1609
1610 if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK))
1611 goto Ebusy;
1612 if (a->nfs_client != b->nfs_client)
1613 goto Ebusy;
1614 if (a->flags != b->flags)
1615 goto Ebusy;
1616 if (a->wsize != b->wsize)
1617 goto Ebusy;
1618 if (a->rsize != b->rsize)
1619 goto Ebusy;
1620 if (a->acregmin != b->acregmin)
1621 goto Ebusy;
1622 if (a->acregmax != b->acregmax)
1623 goto Ebusy;
1624 if (a->acdirmin != b->acdirmin)
1625 goto Ebusy;
1626 if (a->acdirmax != b->acdirmax)
1627 goto Ebusy;
1628 if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
1629 goto Ebusy;
e89a5a43 1630 return 1;
275a5d24 1631Ebusy:
e89a5a43
TM
1632 return 0;
1633}
1634
1635struct nfs_sb_mountdata {
1636 struct nfs_server *server;
1637 int mntflags;
1638};
1639
1640static int nfs_set_super(struct super_block *s, void *data)
1641{
1642 struct nfs_sb_mountdata *sb_mntdata = data;
1643 struct nfs_server *server = sb_mntdata->server;
1644 int ret;
1645
1646 s->s_flags = sb_mntdata->mntflags;
1647 s->s_fs_info = server;
1648 ret = set_anon_super(s, server);
1649 if (ret == 0)
1650 server->s_dev = s->s_dev;
1651 return ret;
1652}
1653
fd00a8ff
CL
1654static int nfs_compare_super_address(struct nfs_server *server1,
1655 struct nfs_server *server2)
1656{
1657 struct sockaddr *sap1, *sap2;
1658
1659 sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr;
1660 sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr;
1661
1662 if (sap1->sa_family != sap2->sa_family)
1663 return 0;
1664
1665 switch (sap1->sa_family) {
1666 case AF_INET: {
1667 struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1;
1668 struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2;
1669 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
1670 return 0;
1671 if (sin1->sin_port != sin2->sin_port)
1672 return 0;
1673 break;
1674 }
1675 case AF_INET6: {
1676 struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1;
1677 struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2;
1678 if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
1679 return 0;
1680 if (sin1->sin6_port != sin2->sin6_port)
1681 return 0;
1682 break;
1683 }
1684 default:
1685 return 0;
1686 }
1687
1688 return 1;
1689}
1690
e89a5a43
TM
1691static int nfs_compare_super(struct super_block *sb, void *data)
1692{
1693 struct nfs_sb_mountdata *sb_mntdata = data;
1694 struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
1695 int mntflags = sb_mntdata->mntflags;
1696
fd00a8ff 1697 if (!nfs_compare_super_address(old, server))
e89a5a43
TM
1698 return 0;
1699 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
1700 if (old->flags & NFS_MOUNT_UNSHARED)
1701 return 0;
1702 if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
1703 return 0;
1704 return nfs_compare_mount_options(sb, server, mntflags);
275a5d24
TM
1705}
1706
fa799759
MS
1707static int nfs_bdi_register(struct nfs_server *server)
1708{
1709 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
1710}
1711
816724e6
TM
1712static int nfs_get_sb(struct file_system_type *fs_type,
1713 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
f7b422b1 1714{
f7b422b1
DH
1715 struct nfs_server *server = NULL;
1716 struct super_block *s;
33852a1f
TM
1717 struct nfs_parsed_mount_data *data;
1718 struct nfs_fh *mntfh;
54ceac45 1719 struct dentry *mntroot;
75180df2 1720 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
1721 struct nfs_sb_mountdata sb_mntdata = {
1722 .mntflags = flags,
1723 };
33852a1f
TM
1724 int error = -ENOMEM;
1725
1726 data = kzalloc(sizeof(*data), GFP_KERNEL);
1727 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
1728 if (data == NULL || mntfh == NULL)
1729 goto out_free_fh;
f7b422b1 1730
33852a1f 1731 security_init_mnt_opts(&data->lsm_opts);
f9c3a380 1732
54ceac45 1733 /* Validate the mount data */
33852a1f 1734 error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
54ceac45 1735 if (error < 0)
0655960f 1736 goto out;
f7b422b1 1737
54ceac45 1738 /* Get a volume representation */
33852a1f 1739 server = nfs_create_server(data, mntfh);
54ceac45
DH
1740 if (IS_ERR(server)) {
1741 error = PTR_ERR(server);
0655960f 1742 goto out;
f7b422b1 1743 }
e89a5a43 1744 sb_mntdata.server = server;
f7b422b1 1745
75180df2
TM
1746 if (server->flags & NFS_MOUNT_UNSHARED)
1747 compare_super = NULL;
1748
54ceac45 1749 /* Get a superblock - note that we may end up sharing one that already exists */
e89a5a43 1750 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
816724e6
TM
1751 if (IS_ERR(s)) {
1752 error = PTR_ERR(s);
54ceac45 1753 goto out_err_nosb;
816724e6
TM
1754 }
1755
54ceac45
DH
1756 if (s->s_fs_info != server) {
1757 nfs_free_server(server);
1758 server = NULL;
fa799759
MS
1759 } else {
1760 error = nfs_bdi_register(server);
1761 if (error)
1762 goto error_splat_super;
54ceac45 1763 }
f7b422b1 1764
54ceac45
DH
1765 if (!s->s_root) {
1766 /* initial superblock/root creation */
33852a1f 1767 nfs_fill_super(s, data);
54ceac45 1768 }
f7b422b1 1769
33852a1f 1770 mntroot = nfs_get_root(s, mntfh);
54ceac45
DH
1771 if (IS_ERR(mntroot)) {
1772 error = PTR_ERR(mntroot);
1773 goto error_splat_super;
f7b422b1 1774 }
816724e6 1775
33852a1f 1776 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
f9c3a380
EP
1777 if (error)
1778 goto error_splat_root;
1779
54ceac45
DH
1780 s->s_flags |= MS_ACTIVE;
1781 mnt->mnt_sb = s;
1782 mnt->mnt_root = mntroot;
0655960f
CL
1783 error = 0;
1784
1785out:
33852a1f
TM
1786 kfree(data->nfs_server.hostname);
1787 kfree(data->mount_server.hostname);
1788 security_free_mnt_opts(&data->lsm_opts);
1789out_free_fh:
1790 kfree(mntfh);
1791 kfree(data);
0655960f 1792 return error;
816724e6 1793
54ceac45
DH
1794out_err_nosb:
1795 nfs_free_server(server);
0655960f 1796 goto out;
54ceac45 1797
f9c3a380
EP
1798error_splat_root:
1799 dput(mntroot);
54ceac45
DH
1800error_splat_super:
1801 up_write(&s->s_umount);
1802 deactivate_super(s);
0655960f 1803 goto out;
f7b422b1
DH
1804}
1805
54ceac45
DH
1806/*
1807 * Destroy an NFS2/3 superblock
1808 */
f7b422b1
DH
1809static void nfs_kill_super(struct super_block *s)
1810{
1811 struct nfs_server *server = NFS_SB(s);
1812
fa799759 1813 bdi_unregister(&server->backing_dev_info);
f7b422b1 1814 kill_anon_super(s);
54ceac45 1815 nfs_free_server(server);
f7b422b1
DH
1816}
1817
54ceac45
DH
1818/*
1819 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
1820 */
1821static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
1822 const char *dev_name, void *raw_data,
1823 struct vfsmount *mnt)
f7b422b1
DH
1824{
1825 struct nfs_clone_mount *data = raw_data;
54ceac45
DH
1826 struct super_block *s;
1827 struct nfs_server *server;
1828 struct dentry *mntroot;
75180df2 1829 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
1830 struct nfs_sb_mountdata sb_mntdata = {
1831 .mntflags = flags,
1832 };
54ceac45 1833 int error;
f7b422b1 1834
54ceac45 1835 dprintk("--> nfs_xdev_get_sb()\n");
f7b422b1 1836
54ceac45
DH
1837 /* create a new volume representation */
1838 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
1839 if (IS_ERR(server)) {
1840 error = PTR_ERR(server);
1841 goto out_err_noserver;
1842 }
e89a5a43 1843 sb_mntdata.server = server;
8fa5c000 1844
75180df2
TM
1845 if (server->flags & NFS_MOUNT_UNSHARED)
1846 compare_super = NULL;
1847
54ceac45 1848 /* Get a superblock - note that we may end up sharing one that already exists */
e89a5a43 1849 s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
54ceac45
DH
1850 if (IS_ERR(s)) {
1851 error = PTR_ERR(s);
1852 goto out_err_nosb;
1853 }
5006a76c 1854
54ceac45
DH
1855 if (s->s_fs_info != server) {
1856 nfs_free_server(server);
1857 server = NULL;
fa799759
MS
1858 } else {
1859 error = nfs_bdi_register(server);
1860 if (error)
1861 goto error_splat_super;
f7b422b1 1862 }
24c8dbbb 1863
54ceac45
DH
1864 if (!s->s_root) {
1865 /* initial superblock/root creation */
54ceac45
DH
1866 nfs_clone_super(s, data->sb);
1867 }
f7b422b1 1868
54ceac45
DH
1869 mntroot = nfs_get_root(s, data->fh);
1870 if (IS_ERR(mntroot)) {
1871 error = PTR_ERR(mntroot);
1872 goto error_splat_super;
f7b422b1 1873 }
e9cc6c23 1874 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
4c1fe2f7
NB
1875 dput(mntroot);
1876 error = -ESTALE;
1877 goto error_splat_super;
1878 }
f7b422b1 1879
54ceac45
DH
1880 s->s_flags |= MS_ACTIVE;
1881 mnt->mnt_sb = s;
1882 mnt->mnt_root = mntroot;
f7b422b1 1883
f9c3a380
EP
1884 /* clone any lsm security options from the parent to the new sb */
1885 security_sb_clone_mnt_opts(data->sb, s);
1886
54ceac45
DH
1887 dprintk("<-- nfs_xdev_get_sb() = 0\n");
1888 return 0;
24c8dbbb 1889
54ceac45
DH
1890out_err_nosb:
1891 nfs_free_server(server);
1892out_err_noserver:
1893 dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error);
1894 return error;
f7b422b1 1895
54ceac45
DH
1896error_splat_super:
1897 up_write(&s->s_umount);
1898 deactivate_super(s);
1899 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
1900 return error;
f7b422b1
DH
1901}
1902
54ceac45
DH
1903#ifdef CONFIG_NFS_V4
1904
f7b422b1 1905/*
54ceac45 1906 * Finish setting up a cloned NFS4 superblock
f7b422b1 1907 */
54ceac45
DH
1908static void nfs4_clone_super(struct super_block *sb,
1909 const struct super_block *old_sb)
f7b422b1 1910{
54ceac45
DH
1911 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
1912 sb->s_blocksize = old_sb->s_blocksize;
1913 sb->s_maxbytes = old_sb->s_maxbytes;
f7b422b1 1914 sb->s_time_gran = 1;
54ceac45
DH
1915 sb->s_op = old_sb->s_op;
1916 nfs_initialise_sb(sb);
f7b422b1
DH
1917}
1918
54ceac45
DH
1919/*
1920 * Set up an NFS4 superblock
1921 */
1922static void nfs4_fill_super(struct super_block *sb)
f7b422b1 1923{
54ceac45
DH
1924 sb->s_time_gran = 1;
1925 sb->s_op = &nfs4_sops;
1926 nfs_initialise_sb(sb);
f7b422b1
DH
1927}
1928
f0768ebd
CL
1929/*
1930 * Validate NFSv4 mount options
1931 */
91ea40b9
TT
1932static int nfs4_validate_mount_data(void *options,
1933 struct nfs_parsed_mount_data *args,
1934 const char *dev_name)
f0768ebd 1935{
4c568017 1936 struct sockaddr_in *ap;
91ea40b9 1937 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
f0768ebd
CL
1938 char *c;
1939
1940 if (data == NULL)
1941 goto out_no_data;
1942
91ea40b9
TT
1943 args->rsize = NFS_MAX_FILE_IO_SIZE;
1944 args->wsize = NFS_MAX_FILE_IO_SIZE;
1945 args->timeo = 600;
1946 args->retrans = 2;
1947 args->acregmin = 3;
1948 args->acregmax = 60;
1949 args->acdirmin = 30;
1950 args->acdirmax = 60;
f22d6d79 1951 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
0896a725 1952 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
91ea40b9 1953
f0768ebd
CL
1954 switch (data->version) {
1955 case 1:
4c568017
CL
1956 ap = (struct sockaddr_in *)&args->nfs_server.address;
1957 if (data->host_addrlen > sizeof(args->nfs_server.address))
1958 goto out_no_address;
1959 if (data->host_addrlen == 0)
f0768ebd 1960 goto out_no_address;
4c568017
CL
1961 args->nfs_server.addrlen = data->host_addrlen;
1962 if (copy_from_user(ap, data->host_addr, data->host_addrlen))
f0768ebd 1963 return -EFAULT;
91ea40b9
TT
1964 if (!nfs_verify_server_address((struct sockaddr *)
1965 &args->nfs_server.address))
f0768ebd
CL
1966 goto out_no_address;
1967
1968 switch (data->auth_flavourlen) {
1969 case 0:
91ea40b9 1970 args->auth_flavors[0] = RPC_AUTH_UNIX;
f0768ebd
CL
1971 break;
1972 case 1:
20c71f5e 1973 if (copy_from_user(&args->auth_flavors[0],
91ea40b9 1974 data->auth_flavours,
20c71f5e 1975 sizeof(args->auth_flavors[0])))
f0768ebd
CL
1976 return -EFAULT;
1977 break;
1978 default:
1979 goto out_inval_auth;
1980 }
1981
1982 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
1983 if (IS_ERR(c))
1984 return PTR_ERR(c);
91ea40b9 1985 args->nfs_server.hostname = c;
f0768ebd
CL
1986
1987 c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
1988 if (IS_ERR(c))
1989 return PTR_ERR(c);
91ea40b9
TT
1990 args->nfs_server.export_path = c;
1991 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
f0768ebd
CL
1992
1993 c = strndup_user(data->client_addr.data, 16);
1994 if (IS_ERR(c))
1995 return PTR_ERR(c);
91ea40b9
TT
1996 args->client_address = c;
1997
1998 /*
1999 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2000 * can deal with.
2001 */
2002
2003 args->flags = data->flags & NFS4_MOUNT_FLAGMASK;
2004 args->rsize = data->rsize;
2005 args->wsize = data->wsize;
2006 args->timeo = data->timeo;
2007 args->retrans = data->retrans;
2008 args->acregmin = data->acregmin;
2009 args->acregmax = data->acregmax;
2010 args->acdirmin = data->acdirmin;
2011 args->acdirmax = data->acdirmax;
2012 args->nfs_server.protocol = data->proto;
f0768ebd
CL
2013
2014 break;
80071225 2015 default: {
dc045898 2016 int status;
91ea40b9
TT
2017
2018 if (nfs_parse_mount_options((char *)options, args) == 0)
80071225
CL
2019 return -EINVAL;
2020
2021 if (!nfs_verify_server_address((struct sockaddr *)
91ea40b9 2022 &args->nfs_server.address))
80071225 2023 return -EINVAL;
80071225 2024
91ea40b9 2025 switch (args->auth_flavor_len) {
80071225 2026 case 0:
91ea40b9 2027 args->auth_flavors[0] = RPC_AUTH_UNIX;
80071225
CL
2028 break;
2029 case 1:
80071225
CL
2030 break;
2031 default:
2032 goto out_inval_auth;
2033 }
2034
91ea40b9 2035 if (args->client_address == NULL)
0a87cf12
JL
2036 goto out_no_client_address;
2037
dc045898
CL
2038 status = nfs_parse_devname(dev_name,
2039 &args->nfs_server.hostname,
2040 NFS4_MAXNAMLEN,
2041 &args->nfs_server.export_path,
2042 NFS4_MAXPATHLEN);
2043 if (status < 0)
2044 return status;
2045
80071225
CL
2046 break;
2047 }
f0768ebd
CL
2048 }
2049
2050 return 0;
2051
2052out_no_data:
2053 dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
2054 return -EINVAL;
2055
2056out_inval_auth:
2057 dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
2058 data->auth_flavourlen);
2059 return -EINVAL;
2060
2061out_no_address:
2062 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
2063 return -EINVAL;
0a87cf12
JL
2064
2065out_no_client_address:
2066 dfprintk(MOUNT, "NFS4: mount program didn't pass callback address\n");
2067 return -EINVAL;
f0768ebd
CL
2068}
2069
54ceac45
DH
2070/*
2071 * Get the superblock for an NFS4 mountpoint
2072 */
816724e6
TM
2073static int nfs4_get_sb(struct file_system_type *fs_type,
2074 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
f7b422b1 2075{
33852a1f 2076 struct nfs_parsed_mount_data *data;
54ceac45
DH
2077 struct super_block *s;
2078 struct nfs_server *server;
33852a1f 2079 struct nfs_fh *mntfh;
54ceac45 2080 struct dentry *mntroot;
75180df2 2081 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
2082 struct nfs_sb_mountdata sb_mntdata = {
2083 .mntflags = flags,
2084 };
33852a1f
TM
2085 int error = -ENOMEM;
2086
2087 data = kzalloc(sizeof(*data), GFP_KERNEL);
2088 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2089 if (data == NULL || mntfh == NULL)
2090 goto out_free_fh;
f7b422b1 2091
33852a1f 2092 security_init_mnt_opts(&data->lsm_opts);
f9c3a380 2093
f0768ebd 2094 /* Validate the mount data */
33852a1f 2095 error = nfs4_validate_mount_data(raw_data, data, dev_name);
f0768ebd
CL
2096 if (error < 0)
2097 goto out;
f7b422b1 2098
54ceac45 2099 /* Get a volume representation */
33852a1f 2100 server = nfs4_create_server(data, mntfh);
54ceac45
DH
2101 if (IS_ERR(server)) {
2102 error = PTR_ERR(server);
29eb981a 2103 goto out;
f7b422b1 2104 }
e89a5a43 2105 sb_mntdata.server = server;
f7b422b1 2106
75180df2
TM
2107 if (server->flags & NFS4_MOUNT_UNSHARED)
2108 compare_super = NULL;
2109
54ceac45 2110 /* Get a superblock - note that we may end up sharing one that already exists */
e89a5a43 2111 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
816724e6
TM
2112 if (IS_ERR(s)) {
2113 error = PTR_ERR(s);
f7b422b1 2114 goto out_free;
816724e6
TM
2115 }
2116
5dd3177a
TM
2117 if (s->s_fs_info != server) {
2118 nfs_free_server(server);
2119 server = NULL;
fa799759
MS
2120 } else {
2121 error = nfs_bdi_register(server);
2122 if (error)
2123 goto error_splat_super;
5dd3177a
TM
2124 }
2125
54ceac45
DH
2126 if (!s->s_root) {
2127 /* initial superblock/root creation */
54ceac45 2128 nfs4_fill_super(s);
54ceac45 2129 }
f7b422b1 2130
33852a1f 2131 mntroot = nfs4_get_root(s, mntfh);
54ceac45
DH
2132 if (IS_ERR(mntroot)) {
2133 error = PTR_ERR(mntroot);
2134 goto error_splat_super;
f7b422b1 2135 }
54ceac45 2136
33852a1f 2137 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
46c8ac74
EP
2138 if (error)
2139 goto error_splat_root;
2140
f7b422b1 2141 s->s_flags |= MS_ACTIVE;
54ceac45
DH
2142 mnt->mnt_sb = s;
2143 mnt->mnt_root = mntroot;
29eb981a
CL
2144 error = 0;
2145
2146out:
33852a1f
TM
2147 kfree(data->client_address);
2148 kfree(data->nfs_server.export_path);
2149 kfree(data->nfs_server.hostname);
2150 security_free_mnt_opts(&data->lsm_opts);
2151out_free_fh:
2152 kfree(mntfh);
2153 kfree(data);
29eb981a 2154 return error;
54ceac45 2155
f7b422b1 2156out_free:
54ceac45 2157 nfs_free_server(server);
29eb981a 2158 goto out;
54ceac45 2159
46c8ac74
EP
2160error_splat_root:
2161 dput(mntroot);
54ceac45
DH
2162error_splat_super:
2163 up_write(&s->s_umount);
2164 deactivate_super(s);
29eb981a 2165 goto out;
f7b422b1
DH
2166}
2167
2168static void nfs4_kill_super(struct super_block *sb)
2169{
2170 struct nfs_server *server = NFS_SB(sb);
2171
2172 nfs_return_all_delegations(sb);
2173 kill_anon_super(sb);
2174
2175 nfs4_renewd_prepare_shutdown(server);
54ceac45 2176 nfs_free_server(server);
f7b422b1
DH
2177}
2178
2179/*
54ceac45 2180 * Clone an NFS4 server record on xdev traversal (FSID-change)
f7b422b1 2181 */
54ceac45
DH
2182static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2183 const char *dev_name, void *raw_data,
2184 struct vfsmount *mnt)
f7b422b1 2185{
54ceac45
DH
2186 struct nfs_clone_mount *data = raw_data;
2187 struct super_block *s;
2188 struct nfs_server *server;
2189 struct dentry *mntroot;
75180df2 2190 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
2191 struct nfs_sb_mountdata sb_mntdata = {
2192 .mntflags = flags,
2193 };
54ceac45 2194 int error;
f7b422b1 2195
54ceac45 2196 dprintk("--> nfs4_xdev_get_sb()\n");
f7b422b1 2197
54ceac45
DH
2198 /* create a new volume representation */
2199 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
2200 if (IS_ERR(server)) {
2201 error = PTR_ERR(server);
2202 goto out_err_noserver;
f7b422b1 2203 }
e89a5a43 2204 sb_mntdata.server = server;
f7b422b1 2205
75180df2
TM
2206 if (server->flags & NFS4_MOUNT_UNSHARED)
2207 compare_super = NULL;
2208
54ceac45 2209 /* Get a superblock - note that we may end up sharing one that already exists */
e89a5a43 2210 s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
54ceac45
DH
2211 if (IS_ERR(s)) {
2212 error = PTR_ERR(s);
2213 goto out_err_nosb;
f7b422b1 2214 }
f7b422b1 2215
54ceac45
DH
2216 if (s->s_fs_info != server) {
2217 nfs_free_server(server);
2218 server = NULL;
fa799759
MS
2219 } else {
2220 error = nfs_bdi_register(server);
2221 if (error)
2222 goto error_splat_super;
54ceac45 2223 }
f7b422b1 2224
54ceac45
DH
2225 if (!s->s_root) {
2226 /* initial superblock/root creation */
54ceac45
DH
2227 nfs4_clone_super(s, data->sb);
2228 }
f7b422b1 2229
54ceac45
DH
2230 mntroot = nfs4_get_root(s, data->fh);
2231 if (IS_ERR(mntroot)) {
2232 error = PTR_ERR(mntroot);
2233 goto error_splat_super;
2234 }
e9cc6c23
TM
2235 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2236 dput(mntroot);
2237 error = -ESTALE;
2238 goto error_splat_super;
2239 }
f7b422b1 2240
54ceac45
DH
2241 s->s_flags |= MS_ACTIVE;
2242 mnt->mnt_sb = s;
2243 mnt->mnt_root = mntroot;
2244
46c8ac74
EP
2245 security_sb_clone_mnt_opts(data->sb, s);
2246
54ceac45
DH
2247 dprintk("<-- nfs4_xdev_get_sb() = 0\n");
2248 return 0;
2249
2250out_err_nosb:
2251 nfs_free_server(server);
2252out_err_noserver:
2253 dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error);
2254 return error;
2255
2256error_splat_super:
2257 up_write(&s->s_umount);
2258 deactivate_super(s);
2259 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
2260 return error;
f7b422b1
DH
2261}
2262
54ceac45
DH
2263/*
2264 * Create an NFS4 server record on referral traversal
2265 */
2266static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
2267 const char *dev_name, void *raw_data,
2268 struct vfsmount *mnt)
f7b422b1
DH
2269{
2270 struct nfs_clone_mount *data = raw_data;
54ceac45
DH
2271 struct super_block *s;
2272 struct nfs_server *server;
2273 struct dentry *mntroot;
2274 struct nfs_fh mntfh;
75180df2 2275 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
e89a5a43
TM
2276 struct nfs_sb_mountdata sb_mntdata = {
2277 .mntflags = flags,
2278 };
54ceac45
DH
2279 int error;
2280
2281 dprintk("--> nfs4_referral_get_sb()\n");
2282
2283 /* create a new volume representation */
2284 server = nfs4_create_referral_server(data, &mntfh);
2285 if (IS_ERR(server)) {
2286 error = PTR_ERR(server);
2287 goto out_err_noserver;
2288 }
e89a5a43 2289 sb_mntdata.server = server;
54ceac45 2290
75180df2
TM
2291 if (server->flags & NFS4_MOUNT_UNSHARED)
2292 compare_super = NULL;
2293
54ceac45 2294 /* Get a superblock - note that we may end up sharing one that already exists */
e89a5a43 2295 s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
54ceac45
DH
2296 if (IS_ERR(s)) {
2297 error = PTR_ERR(s);
2298 goto out_err_nosb;
2299 }
2300
2301 if (s->s_fs_info != server) {
2302 nfs_free_server(server);
2303 server = NULL;
fa799759
MS
2304 } else {
2305 error = nfs_bdi_register(server);
2306 if (error)
2307 goto error_splat_super;
54ceac45
DH
2308 }
2309
2310 if (!s->s_root) {
2311 /* initial superblock/root creation */
54ceac45
DH
2312 nfs4_fill_super(s);
2313 }
2314
f2d0d85e 2315 mntroot = nfs4_get_root(s, &mntfh);
54ceac45
DH
2316 if (IS_ERR(mntroot)) {
2317 error = PTR_ERR(mntroot);
2318 goto error_splat_super;
2319 }
e9cc6c23
TM
2320 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2321 dput(mntroot);
2322 error = -ESTALE;
2323 goto error_splat_super;
2324 }
54ceac45
DH
2325
2326 s->s_flags |= MS_ACTIVE;
2327 mnt->mnt_sb = s;
2328 mnt->mnt_root = mntroot;
2329
46c8ac74
EP
2330 security_sb_clone_mnt_opts(data->sb, s);
2331
54ceac45
DH
2332 dprintk("<-- nfs4_referral_get_sb() = 0\n");
2333 return 0;
2334
2335out_err_nosb:
2336 nfs_free_server(server);
2337out_err_noserver:
2338 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error);
2339 return error;
2340
2341error_splat_super:
2342 up_write(&s->s_umount);
2343 deactivate_super(s);
2344 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
2345 return error;
f7b422b1
DH
2346}
2347
54ceac45 2348#endif /* CONFIG_NFS_V4 */