4 * Copyright (C) 1992 Rick Sladkey
6 * nfs superblock handling functions
8 * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
9 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
11 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
12 * J.S.Peatfield@damtp.cam.ac.uk
14 * Split from inode.c by David Howells <dhowells@redhat.com>
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())
23 #include <linux/module.h>
24 #include <linux/init.h>
26 #include <linux/time.h>
27 #include <linux/kernel.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>
36 #include <linux/sunrpc/xprtsock.h>
37 #include <linux/sunrpc/xprtrdma.h>
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/seq_file.h>
43 #include <linux/mount.h>
44 #include <linux/namei.h>
45 #include <linux/nfs_idmap.h>
46 #include <linux/vfs.h>
47 #include <linux/inet.h>
48 #include <linux/in6.h>
49 #include <linux/slab.h>
51 #include <linux/netdevice.h>
52 #include <linux/nfs_xdr.h>
53 #include <linux/magic.h>
54 #include <linux/parser.h>
55 #include <linux/nsproxy.h>
56 #include <linux/rcupdate.h>
58 #include <asm/uaccess.h>
62 #include "delegation.h"
68 #define NFSDBG_FACILITY NFSDBG_VFS
69 #define NFS_TEXT_DATA 1
72 #define NFS_DEFAULT_VERSION 3
74 #define NFS_DEFAULT_VERSION 2
78 /* Mount options that take no arguments */
80 Opt_posix
, Opt_noposix
,
84 Opt_udp
, Opt_tcp
, Opt_rdma
,
86 Opt_rdirplus
, Opt_nordirplus
,
87 Opt_sharecache
, Opt_nosharecache
,
88 Opt_resvport
, Opt_noresvport
,
89 Opt_fscache
, Opt_nofscache
,
91 /* Mount options that take integer arguments */
93 Opt_rsize
, Opt_wsize
, Opt_bsize
,
94 Opt_timeo
, Opt_retrans
,
95 Opt_acregmin
, Opt_acregmax
,
96 Opt_acdirmin
, Opt_acdirmax
,
103 /* Mount options that take string arguments */
105 Opt_sec
, Opt_proto
, Opt_mountproto
, Opt_mounthost
,
106 Opt_addr
, Opt_mountaddr
, Opt_clientaddr
,
111 /* Special mount options */
112 Opt_userspace
, Opt_deprecated
, Opt_sloppy
,
117 static const match_table_t nfs_mount_option_tokens
= {
118 { Opt_userspace
, "bg" },
119 { Opt_userspace
, "fg" },
120 { Opt_userspace
, "retry=%s" },
122 { Opt_sloppy
, "sloppy" },
124 { Opt_soft
, "soft" },
125 { Opt_hard
, "hard" },
126 { Opt_deprecated
, "intr" },
127 { Opt_deprecated
, "nointr" },
128 { Opt_posix
, "posix" },
129 { Opt_noposix
, "noposix" },
131 { Opt_nocto
, "nocto" },
133 { Opt_noac
, "noac" },
134 { Opt_lock
, "lock" },
135 { Opt_nolock
, "nolock" },
138 { Opt_rdma
, "rdma" },
140 { Opt_noacl
, "noacl" },
141 { Opt_rdirplus
, "rdirplus" },
142 { Opt_nordirplus
, "nordirplus" },
143 { Opt_sharecache
, "sharecache" },
144 { Opt_nosharecache
, "nosharecache" },
145 { Opt_resvport
, "resvport" },
146 { Opt_noresvport
, "noresvport" },
147 { Opt_fscache
, "fsc" },
148 { Opt_nofscache
, "nofsc" },
150 { Opt_port
, "port=%s" },
151 { Opt_rsize
, "rsize=%s" },
152 { Opt_wsize
, "wsize=%s" },
153 { Opt_bsize
, "bsize=%s" },
154 { Opt_timeo
, "timeo=%s" },
155 { Opt_retrans
, "retrans=%s" },
156 { Opt_acregmin
, "acregmin=%s" },
157 { Opt_acregmax
, "acregmax=%s" },
158 { Opt_acdirmin
, "acdirmin=%s" },
159 { Opt_acdirmax
, "acdirmax=%s" },
160 { Opt_actimeo
, "actimeo=%s" },
161 { Opt_namelen
, "namlen=%s" },
162 { Opt_mountport
, "mountport=%s" },
163 { Opt_mountvers
, "mountvers=%s" },
164 { Opt_minorversion
, "minorversion=%s" },
166 { Opt_nfsvers
, "nfsvers=%s" },
167 { Opt_nfsvers
, "vers=%s" },
169 { Opt_sec
, "sec=%s" },
170 { Opt_proto
, "proto=%s" },
171 { Opt_mountproto
, "mountproto=%s" },
172 { Opt_addr
, "addr=%s" },
173 { Opt_clientaddr
, "clientaddr=%s" },
174 { Opt_mounthost
, "mounthost=%s" },
175 { Opt_mountaddr
, "mountaddr=%s" },
177 { Opt_lookupcache
, "lookupcache=%s" },
178 { Opt_fscache_uniq
, "fsc=%s" },
179 { Opt_local_lock
, "local_lock=%s" },
181 /* The following needs to be listed after all other options */
182 { Opt_nfsvers
, "v%s" },
188 Opt_xprt_udp
, Opt_xprt_udp6
, Opt_xprt_tcp
, Opt_xprt_tcp6
, Opt_xprt_rdma
,
193 static const match_table_t nfs_xprt_protocol_tokens
= {
194 { Opt_xprt_udp
, "udp" },
195 { Opt_xprt_udp6
, "udp6" },
196 { Opt_xprt_tcp
, "tcp" },
197 { Opt_xprt_tcp6
, "tcp6" },
198 { Opt_xprt_rdma
, "rdma" },
200 { Opt_xprt_err
, NULL
}
204 Opt_sec_none
, Opt_sec_sys
,
205 Opt_sec_krb5
, Opt_sec_krb5i
, Opt_sec_krb5p
,
206 Opt_sec_lkey
, Opt_sec_lkeyi
, Opt_sec_lkeyp
,
207 Opt_sec_spkm
, Opt_sec_spkmi
, Opt_sec_spkmp
,
212 static const match_table_t nfs_secflavor_tokens
= {
213 { Opt_sec_none
, "none" },
214 { Opt_sec_none
, "null" },
215 { Opt_sec_sys
, "sys" },
217 { Opt_sec_krb5
, "krb5" },
218 { Opt_sec_krb5i
, "krb5i" },
219 { Opt_sec_krb5p
, "krb5p" },
221 { Opt_sec_lkey
, "lkey" },
222 { Opt_sec_lkeyi
, "lkeyi" },
223 { Opt_sec_lkeyp
, "lkeyp" },
225 { Opt_sec_spkm
, "spkm3" },
226 { Opt_sec_spkmi
, "spkm3i" },
227 { Opt_sec_spkmp
, "spkm3p" },
229 { Opt_sec_err
, NULL
}
233 Opt_lookupcache_all
, Opt_lookupcache_positive
,
234 Opt_lookupcache_none
,
239 static match_table_t nfs_lookupcache_tokens
= {
240 { Opt_lookupcache_all
, "all" },
241 { Opt_lookupcache_positive
, "pos" },
242 { Opt_lookupcache_positive
, "positive" },
243 { Opt_lookupcache_none
, "none" },
245 { Opt_lookupcache_err
, NULL
}
249 Opt_local_lock_all
, Opt_local_lock_flock
, Opt_local_lock_posix
,
255 static match_table_t nfs_local_lock_tokens
= {
256 { Opt_local_lock_all
, "all" },
257 { Opt_local_lock_flock
, "flock" },
258 { Opt_local_lock_posix
, "posix" },
259 { Opt_local_lock_none
, "none" },
261 { Opt_local_lock_err
, NULL
}
265 Opt_vers_2
, Opt_vers_3
, Opt_vers_4
, Opt_vers_4_0
,
271 static match_table_t nfs_vers_tokens
= {
275 { Opt_vers_4_0
, "4.0" },
276 { Opt_vers_4_1
, "4.1" },
278 { Opt_vers_err
, NULL
}
281 struct nfs_mount_info
{
282 void (*fill_super
)(struct super_block
*, struct nfs_mount_info
*);
283 int (*set_security
)(struct super_block
*, struct dentry
*, struct nfs_mount_info
*);
284 struct nfs_parsed_mount_data
*parsed
;
285 struct nfs_clone_mount
*cloned
;
288 static void nfs_umount_begin(struct super_block
*);
289 static int nfs_statfs(struct dentry
*, struct kstatfs
*);
290 static int nfs_show_options(struct seq_file
*, struct dentry
*);
291 static int nfs_show_devname(struct seq_file
*, struct dentry
*);
292 static int nfs_show_path(struct seq_file
*, struct dentry
*);
293 static int nfs_show_stats(struct seq_file
*, struct dentry
*);
294 static struct dentry
*nfs_fs_mount_common(struct file_system_type
*,
295 struct nfs_server
*, int, const char *, struct nfs_fh
*,
296 struct nfs_mount_info
*);
297 static struct dentry
*nfs_fs_mount(struct file_system_type
*,
298 int, const char *, void *);
299 static struct dentry
*nfs_xdev_mount(struct file_system_type
*fs_type
,
300 int flags
, const char *dev_name
, void *raw_data
);
301 static void nfs_put_super(struct super_block
*);
302 static void nfs_kill_super(struct super_block
*);
303 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
305 static struct file_system_type nfs_fs_type
= {
306 .owner
= THIS_MODULE
,
308 .mount
= nfs_fs_mount
,
309 .kill_sb
= nfs_kill_super
,
310 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
313 struct file_system_type nfs_xdev_fs_type
= {
314 .owner
= THIS_MODULE
,
316 .mount
= nfs_xdev_mount
,
317 .kill_sb
= nfs_kill_super
,
318 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
321 static const struct super_operations nfs_sops
= {
322 .alloc_inode
= nfs_alloc_inode
,
323 .destroy_inode
= nfs_destroy_inode
,
324 .write_inode
= nfs_write_inode
,
325 .put_super
= nfs_put_super
,
326 .statfs
= nfs_statfs
,
327 .evict_inode
= nfs_evict_inode
,
328 .umount_begin
= nfs_umount_begin
,
329 .show_options
= nfs_show_options
,
330 .show_devname
= nfs_show_devname
,
331 .show_path
= nfs_show_path
,
332 .show_stats
= nfs_show_stats
,
333 .remount_fs
= nfs_remount
,
337 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*);
338 static int nfs4_validate_mount_data(void *options
,
339 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
340 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
341 struct nfs_parsed_mount_data
*data
);
342 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
343 int flags
, const char *dev_name
, void *raw_data
);
344 static struct dentry
*nfs4_remote_mount(struct file_system_type
*fs_type
,
345 int flags
, const char *dev_name
, void *raw_data
);
346 static struct dentry
*nfs4_xdev_mount(struct file_system_type
*fs_type
,
347 int flags
, const char *dev_name
, void *raw_data
);
348 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
349 int flags
, const char *dev_name
, void *raw_data
);
350 static struct dentry
*nfs4_remote_referral_mount(struct file_system_type
*fs_type
,
351 int flags
, const char *dev_name
, void *raw_data
);
352 static void nfs4_kill_super(struct super_block
*sb
);
354 static struct file_system_type nfs4_fs_type
= {
355 .owner
= THIS_MODULE
,
358 .kill_sb
= nfs4_kill_super
,
359 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
362 static struct file_system_type nfs4_remote_fs_type
= {
363 .owner
= THIS_MODULE
,
365 .mount
= nfs4_remote_mount
,
366 .kill_sb
= nfs4_kill_super
,
367 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
370 struct file_system_type nfs4_xdev_fs_type
= {
371 .owner
= THIS_MODULE
,
373 .mount
= nfs4_xdev_mount
,
374 .kill_sb
= nfs4_kill_super
,
375 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
378 static struct file_system_type nfs4_remote_referral_fs_type
= {
379 .owner
= THIS_MODULE
,
381 .mount
= nfs4_remote_referral_mount
,
382 .kill_sb
= nfs4_kill_super
,
383 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
386 struct file_system_type nfs4_referral_fs_type
= {
387 .owner
= THIS_MODULE
,
389 .mount
= nfs4_referral_mount
,
390 .kill_sb
= nfs4_kill_super
,
391 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
394 static const struct super_operations nfs4_sops
= {
395 .alloc_inode
= nfs_alloc_inode
,
396 .destroy_inode
= nfs_destroy_inode
,
397 .write_inode
= nfs_write_inode
,
398 .put_super
= nfs_put_super
,
399 .statfs
= nfs_statfs
,
400 .evict_inode
= nfs4_evict_inode
,
401 .umount_begin
= nfs_umount_begin
,
402 .show_options
= nfs_show_options
,
403 .show_devname
= nfs_show_devname
,
404 .show_path
= nfs_show_path
,
405 .show_stats
= nfs_show_stats
,
406 .remount_fs
= nfs_remount
,
410 static struct shrinker acl_shrinker
= {
411 .shrink
= nfs_access_cache_shrinker
,
412 .seeks
= DEFAULT_SEEKS
,
416 * Register the NFS filesystems
418 int __init
register_nfs_fs(void)
422 ret
= register_filesystem(&nfs_fs_type
);
426 ret
= nfs_register_sysctl();
430 ret
= register_filesystem(&nfs4_fs_type
);
434 register_shrinker(&acl_shrinker
);
439 nfs_unregister_sysctl();
442 unregister_filesystem(&nfs_fs_type
);
448 * Unregister the NFS filesystems
450 void __exit
unregister_nfs_fs(void)
452 unregister_shrinker(&acl_shrinker
);
454 unregister_filesystem(&nfs4_fs_type
);
456 nfs_unregister_sysctl();
457 unregister_filesystem(&nfs_fs_type
);
460 void nfs_sb_active(struct super_block
*sb
)
462 struct nfs_server
*server
= NFS_SB(sb
);
464 if (atomic_inc_return(&server
->active
) == 1)
465 atomic_inc(&sb
->s_active
);
468 void nfs_sb_deactive(struct super_block
*sb
)
470 struct nfs_server
*server
= NFS_SB(sb
);
472 if (atomic_dec_and_test(&server
->active
))
473 deactivate_super(sb
);
477 * Deliver file system statistics to userspace
479 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
481 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
482 unsigned char blockbits
;
483 unsigned long blockres
;
484 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
485 struct nfs_fsstat res
;
488 res
.fattr
= nfs_alloc_fattr();
489 if (res
.fattr
== NULL
)
492 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
493 if (unlikely(error
== -ESTALE
)) {
494 struct dentry
*pd_dentry
;
496 pd_dentry
= dget_parent(dentry
);
497 if (pd_dentry
!= NULL
) {
498 nfs_zap_caches(pd_dentry
->d_inode
);
502 nfs_free_fattr(res
.fattr
);
506 buf
->f_type
= NFS_SUPER_MAGIC
;
509 * Current versions of glibc do not correctly handle the
510 * case where f_frsize != f_bsize. Eventually we want to
511 * report the value of wtmult in this field.
513 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
516 * On most *nix systems, f_blocks, f_bfree, and f_bavail
517 * are reported in units of f_frsize. Linux hasn't had
518 * an f_frsize field in its statfs struct until recently,
519 * thus historically Linux's sys_statfs reports these
520 * fields in units of f_bsize.
522 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
523 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
524 blockres
= (1 << blockbits
) - 1;
525 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
526 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
527 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
529 buf
->f_files
= res
.tfiles
;
530 buf
->f_ffree
= res
.afiles
;
532 buf
->f_namelen
= server
->namelen
;
537 dprintk("%s: statfs error = %d\n", __func__
, -error
);
542 * Map the security flavour number to a name
544 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
546 static const struct {
547 rpc_authflavor_t flavour
;
550 { RPC_AUTH_NULL
, "null" },
551 { RPC_AUTH_UNIX
, "sys" },
552 { RPC_AUTH_GSS_KRB5
, "krb5" },
553 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
554 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
555 { RPC_AUTH_GSS_LKEY
, "lkey" },
556 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
557 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
558 { RPC_AUTH_GSS_SPKM
, "spkm" },
559 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
560 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
561 { UINT_MAX
, "unknown" }
565 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
566 if (sec_flavours
[i
].flavour
== flavour
)
569 return sec_flavours
[i
].str
;
572 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
575 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
577 seq_printf(m
, ",mountproto=");
578 switch (sap
->sa_family
) {
580 switch (nfss
->mountd_protocol
) {
582 seq_printf(m
, RPCBIND_NETID_UDP
);
585 seq_printf(m
, RPCBIND_NETID_TCP
);
589 seq_printf(m
, "auto");
593 switch (nfss
->mountd_protocol
) {
595 seq_printf(m
, RPCBIND_NETID_UDP6
);
598 seq_printf(m
, RPCBIND_NETID_TCP6
);
602 seq_printf(m
, "auto");
607 seq_printf(m
, "auto");
611 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
614 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
616 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
619 switch (sap
->sa_family
) {
621 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
622 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
626 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
627 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
632 seq_printf(m
, ",mountaddr=unspecified");
635 if (nfss
->mountd_version
|| showdefaults
)
636 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
637 if ((nfss
->mountd_port
&&
638 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
640 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
642 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
646 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
649 struct nfs_client
*clp
= nfss
->nfs_client
;
651 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
654 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
660 static void nfs_show_nfs_version(struct seq_file
*m
,
661 unsigned int version
,
662 unsigned int minorversion
)
664 seq_printf(m
, ",vers=%u", version
);
666 seq_printf(m
, ".%u", minorversion
);
670 * Describe the mount options in force on this server representation
672 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
675 static const struct proc_nfs_info
{
680 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
681 { NFS_MOUNT_POSIX
, ",posix", "" },
682 { NFS_MOUNT_NOCTO
, ",nocto", "" },
683 { NFS_MOUNT_NOAC
, ",noac", "" },
684 { NFS_MOUNT_NONLM
, ",nolock", "" },
685 { NFS_MOUNT_NOACL
, ",noacl", "" },
686 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
687 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
688 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
691 const struct proc_nfs_info
*nfs_infop
;
692 struct nfs_client
*clp
= nfss
->nfs_client
;
693 u32 version
= clp
->rpc_ops
->version
;
694 int local_flock
, local_fcntl
;
696 nfs_show_nfs_version(m
, version
, clp
->cl_minorversion
);
697 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
698 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
699 if (nfss
->bsize
!= 0)
700 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
701 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
702 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
703 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
704 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
705 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
706 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
707 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
708 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
709 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
710 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
711 if (nfss
->flags
& nfs_infop
->flag
)
712 seq_puts(m
, nfs_infop
->str
);
714 seq_puts(m
, nfs_infop
->nostr
);
717 seq_printf(m
, ",proto=%s",
718 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
721 if (nfss
->port
!= NFS_PORT
)
722 seq_printf(m
, ",port=%u", nfss
->port
);
725 seq_printf(m
, ",port=%u", nfss
->port
);
727 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
728 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
729 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
732 nfs_show_mountd_options(m
, nfss
, showdefaults
);
734 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
736 if (nfss
->options
& NFS_OPTION_FSCACHE
)
737 seq_printf(m
, ",fsc");
739 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
740 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
741 seq_printf(m
, ",lookupcache=none");
743 seq_printf(m
, ",lookupcache=pos");
746 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
747 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
749 if (!local_flock
&& !local_fcntl
)
750 seq_printf(m
, ",local_lock=none");
751 else if (local_flock
&& local_fcntl
)
752 seq_printf(m
, ",local_lock=all");
753 else if (local_flock
)
754 seq_printf(m
, ",local_lock=flock");
756 seq_printf(m
, ",local_lock=posix");
760 * Describe the mount options on this VFS mountpoint
762 static int nfs_show_options(struct seq_file
*m
, struct dentry
*root
)
764 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
766 nfs_show_mount_options(m
, nfss
, 0);
769 seq_printf(m
, ",addr=%s",
770 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
778 #ifdef CONFIG_NFS_V4_1
779 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
)
781 if (nfs4_has_session(server
->nfs_client
))
782 seq_printf(m
, ",sessions");
785 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
) {}
789 #ifdef CONFIG_NFS_V4_1
790 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
792 seq_printf(m
, ",pnfs=");
793 if (server
->pnfs_curr_ld
)
794 seq_printf(m
, "%s", server
->pnfs_curr_ld
->name
);
796 seq_printf(m
, "not configured");
799 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
801 if (nfss
->nfs_client
&& nfss
->nfs_client
->impl_id
) {
802 struct nfs41_impl_id
*impl_id
= nfss
->nfs_client
->impl_id
;
803 seq_printf(m
, "\n\timpl_id:\tname='%s',domain='%s',"
805 impl_id
->name
, impl_id
->domain
,
806 impl_id
->date
.seconds
, impl_id
->date
.nseconds
);
811 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
815 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
820 static int nfs_show_devname(struct seq_file
*m
, struct dentry
*root
)
822 char *page
= (char *) __get_free_page(GFP_KERNEL
);
823 char *devname
, *dummy
;
827 devname
= nfs_path(&dummy
, root
, page
, PAGE_SIZE
);
829 err
= PTR_ERR(devname
);
831 seq_escape(m
, devname
, " \t\n\\");
832 free_page((unsigned long)page
);
836 static int nfs_show_path(struct seq_file
*m
, struct dentry
*dentry
)
843 * Present statistical information for this VFS mountpoint
845 static int nfs_show_stats(struct seq_file
*m
, struct dentry
*root
)
848 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
849 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
850 struct nfs_iostats totals
= { };
852 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
855 * Display all mount option settings
857 seq_printf(m
, "\n\topts:\t");
858 seq_puts(m
, root
->d_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
859 seq_puts(m
, root
->d_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
860 seq_puts(m
, root
->d_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
861 seq_puts(m
, root
->d_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
862 nfs_show_mount_options(m
, nfss
, 1);
864 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
866 show_implementation_id(m
, nfss
);
868 seq_printf(m
, "\n\tcaps:\t");
869 seq_printf(m
, "caps=0x%x", nfss
->caps
);
870 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
871 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
872 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
873 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
876 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
877 seq_printf(m
, "\n\tnfsv4:\t");
878 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
879 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
880 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
881 show_sessions(m
, nfss
);
887 * Display security flavor in effect for this mount
889 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
891 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
894 * Display superblock I/O counters
896 for_each_possible_cpu(cpu
) {
897 struct nfs_iostats
*stats
;
900 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
902 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
903 totals
.events
[i
] += stats
->events
[i
];
904 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
905 totals
.bytes
[i
] += stats
->bytes
[i
];
906 #ifdef CONFIG_NFS_FSCACHE
907 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
908 totals
.fscache
[i
] += stats
->fscache
[i
];
914 seq_printf(m
, "\n\tevents:\t");
915 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
916 seq_printf(m
, "%lu ", totals
.events
[i
]);
917 seq_printf(m
, "\n\tbytes:\t");
918 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
919 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
920 #ifdef CONFIG_NFS_FSCACHE
921 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
922 seq_printf(m
, "\n\tfsc:\t");
923 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
924 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
929 rpc_print_iostats(m
, nfss
->client
);
935 * Begin unmount by attempting to remove all automounted mountpoints we added
936 * in response to xdev traversals and referrals
938 static void nfs_umount_begin(struct super_block
*sb
)
940 struct nfs_server
*server
;
941 struct rpc_clnt
*rpc
;
944 /* -EIO all pending I/O */
945 rpc
= server
->client_acl
;
947 rpc_killall_tasks(rpc
);
948 rpc
= server
->client
;
950 rpc_killall_tasks(rpc
);
953 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(void)
955 struct nfs_parsed_mount_data
*data
;
957 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
959 data
->acregmin
= NFS_DEF_ACREGMIN
;
960 data
->acregmax
= NFS_DEF_ACREGMAX
;
961 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
962 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
963 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
964 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
965 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
966 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
967 data
->auth_flavor_len
= 1;
968 data
->minorversion
= 0;
969 data
->need_mount
= true;
970 data
->net
= current
->nsproxy
->net_ns
;
971 security_init_mnt_opts(&data
->lsm_opts
);
976 static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data
*data
)
979 kfree(data
->client_address
);
980 kfree(data
->mount_server
.hostname
);
981 kfree(data
->nfs_server
.export_path
);
982 kfree(data
->nfs_server
.hostname
);
983 kfree(data
->fscache_uniq
);
984 security_free_mnt_opts(&data
->lsm_opts
);
990 * Sanity-check a server address provided by the mount command.
992 * Address family must be initialized, and address must not be
993 * the ANY address for that family.
995 static int nfs_verify_server_address(struct sockaddr
*addr
)
997 switch (addr
->sa_family
) {
999 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
1000 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
1003 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
1004 return !ipv6_addr_any(sa
);
1008 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
1013 * Select between a default port value and a user-specified port value.
1014 * If a zero value is set, then autobind will be used.
1016 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
1017 const unsigned short default_port
)
1019 if (*port
== NFS_UNSPEC_PORT
)
1020 *port
= default_port
;
1022 rpc_set_port(sap
, *port
);
1026 * Sanity check the NFS transport protocol.
1029 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
1031 switch (mnt
->nfs_server
.protocol
) {
1032 case XPRT_TRANSPORT_UDP
:
1033 case XPRT_TRANSPORT_TCP
:
1034 case XPRT_TRANSPORT_RDMA
:
1037 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1042 * For text based NFSv2/v3 mounts, the mount protocol transport default
1043 * settings should depend upon the specified NFS transport.
1045 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
1047 nfs_validate_transport_protocol(mnt
);
1049 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
1050 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
1052 switch (mnt
->nfs_server
.protocol
) {
1053 case XPRT_TRANSPORT_UDP
:
1054 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1056 case XPRT_TRANSPORT_TCP
:
1057 case XPRT_TRANSPORT_RDMA
:
1058 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1063 * Parse the value of the 'sec=' option.
1065 static int nfs_parse_security_flavors(char *value
,
1066 struct nfs_parsed_mount_data
*mnt
)
1068 substring_t args
[MAX_OPT_ARGS
];
1070 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
1072 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
1074 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
1077 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
1080 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
1083 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
1086 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
1089 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
1092 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
1095 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
1098 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
1101 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
1104 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
1110 mnt
->flags
|= NFS_MOUNT_SECFLAVOUR
;
1111 mnt
->auth_flavor_len
= 1;
1115 static int nfs_parse_version_string(char *string
,
1116 struct nfs_parsed_mount_data
*mnt
,
1119 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1120 switch (match_token(string
, nfs_vers_tokens
, args
)) {
1125 mnt
->flags
|= NFS_MOUNT_VER3
;
1129 /* Backward compatibility option. In future,
1130 * the mount program should always supply
1131 * a NFSv4 minor version number.
1137 mnt
->minorversion
= 0;
1141 mnt
->minorversion
= 1;
1149 static int nfs_get_option_str(substring_t args
[], char **option
)
1152 *option
= match_strdup(args
);
1156 static int nfs_get_option_ul(substring_t args
[], unsigned long *option
)
1161 string
= match_strdup(args
);
1164 rc
= strict_strtoul(string
, 10, option
);
1171 * Error-check and convert a string of mount options from user space into
1172 * a data structure. The whole mount string is processed; bad options are
1173 * skipped as they are encountered. If there were no errors, return 1;
1174 * otherwise return 0 (zero).
1176 static int nfs_parse_mount_options(char *raw
,
1177 struct nfs_parsed_mount_data
*mnt
)
1179 char *p
, *string
, *secdata
;
1180 int rc
, sloppy
= 0, invalid_option
= 0;
1181 unsigned short protofamily
= AF_UNSPEC
;
1182 unsigned short mountfamily
= AF_UNSPEC
;
1185 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
1188 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1190 secdata
= alloc_secdata();
1194 rc
= security_sb_copy_data(raw
, secdata
);
1196 goto out_security_failure
;
1198 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1200 goto out_security_failure
;
1202 free_secdata(secdata
);
1204 while ((p
= strsep(&raw
, ",")) != NULL
) {
1205 substring_t args
[MAX_OPT_ARGS
];
1206 unsigned long option
;
1212 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1214 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1218 * boolean options: foo/nofoo
1221 mnt
->flags
|= NFS_MOUNT_SOFT
;
1224 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1227 mnt
->flags
|= NFS_MOUNT_POSIX
;
1230 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1233 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1236 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1239 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1242 mnt
->flags
|= NFS_MOUNT_NOAC
;
1245 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1246 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1247 NFS_MOUNT_LOCAL_FCNTL
);
1250 mnt
->flags
|= NFS_MOUNT_NONLM
;
1251 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1252 NFS_MOUNT_LOCAL_FCNTL
);
1255 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1256 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1259 mnt
->flags
|= NFS_MOUNT_TCP
;
1260 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1263 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1264 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1265 xprt_load_transport(p
);
1268 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1271 mnt
->flags
|= NFS_MOUNT_NOACL
;
1274 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1276 case Opt_nordirplus
:
1277 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1279 case Opt_sharecache
:
1280 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1282 case Opt_nosharecache
:
1283 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1286 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1288 case Opt_noresvport
:
1289 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1292 mnt
->options
|= NFS_OPTION_FSCACHE
;
1293 kfree(mnt
->fscache_uniq
);
1294 mnt
->fscache_uniq
= NULL
;
1297 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1298 kfree(mnt
->fscache_uniq
);
1299 mnt
->fscache_uniq
= NULL
;
1303 * options that take numeric values
1306 if (nfs_get_option_ul(args
, &option
) ||
1308 goto out_invalid_value
;
1309 mnt
->nfs_server
.port
= option
;
1312 if (nfs_get_option_ul(args
, &option
))
1313 goto out_invalid_value
;
1314 mnt
->rsize
= option
;
1317 if (nfs_get_option_ul(args
, &option
))
1318 goto out_invalid_value
;
1319 mnt
->wsize
= option
;
1322 if (nfs_get_option_ul(args
, &option
))
1323 goto out_invalid_value
;
1324 mnt
->bsize
= option
;
1327 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1328 goto out_invalid_value
;
1329 mnt
->timeo
= option
;
1332 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1333 goto out_invalid_value
;
1334 mnt
->retrans
= option
;
1337 if (nfs_get_option_ul(args
, &option
))
1338 goto out_invalid_value
;
1339 mnt
->acregmin
= option
;
1342 if (nfs_get_option_ul(args
, &option
))
1343 goto out_invalid_value
;
1344 mnt
->acregmax
= option
;
1347 if (nfs_get_option_ul(args
, &option
))
1348 goto out_invalid_value
;
1349 mnt
->acdirmin
= option
;
1352 if (nfs_get_option_ul(args
, &option
))
1353 goto out_invalid_value
;
1354 mnt
->acdirmax
= option
;
1357 if (nfs_get_option_ul(args
, &option
))
1358 goto out_invalid_value
;
1359 mnt
->acregmin
= mnt
->acregmax
=
1360 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1363 if (nfs_get_option_ul(args
, &option
))
1364 goto out_invalid_value
;
1365 mnt
->namlen
= option
;
1368 if (nfs_get_option_ul(args
, &option
) ||
1370 goto out_invalid_value
;
1371 mnt
->mount_server
.port
= option
;
1374 if (nfs_get_option_ul(args
, &option
) ||
1375 option
< NFS_MNT_VERSION
||
1376 option
> NFS_MNT3_VERSION
)
1377 goto out_invalid_value
;
1378 mnt
->mount_server
.version
= option
;
1380 case Opt_minorversion
:
1381 if (nfs_get_option_ul(args
, &option
))
1382 goto out_invalid_value
;
1383 if (option
> NFS4_MAX_MINOR_VERSION
)
1384 goto out_invalid_value
;
1385 mnt
->minorversion
= option
;
1389 * options that take text values
1392 string
= match_strdup(args
);
1395 rc
= nfs_parse_version_string(string
, mnt
, args
);
1398 goto out_invalid_value
;
1401 string
= match_strdup(args
);
1404 rc
= nfs_parse_security_flavors(string
, mnt
);
1407 dfprintk(MOUNT
, "NFS: unrecognized "
1408 "security flavor\n");
1413 string
= match_strdup(args
);
1416 token
= match_token(string
,
1417 nfs_xprt_protocol_tokens
, args
);
1419 protofamily
= AF_INET
;
1422 protofamily
= AF_INET6
;
1424 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1425 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1428 protofamily
= AF_INET6
;
1430 mnt
->flags
|= NFS_MOUNT_TCP
;
1431 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1434 /* vector side protocols to TCP */
1435 mnt
->flags
|= NFS_MOUNT_TCP
;
1436 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1437 xprt_load_transport(string
);
1440 dfprintk(MOUNT
, "NFS: unrecognized "
1441 "transport protocol\n");
1447 case Opt_mountproto
:
1448 string
= match_strdup(args
);
1451 token
= match_token(string
,
1452 nfs_xprt_protocol_tokens
, args
);
1455 mountfamily
= AF_INET
;
1458 mountfamily
= AF_INET6
;
1460 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1463 mountfamily
= AF_INET6
;
1465 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1467 case Opt_xprt_rdma
: /* not used for side protocols */
1469 dfprintk(MOUNT
, "NFS: unrecognized "
1470 "transport protocol\n");
1475 string
= match_strdup(args
);
1478 mnt
->nfs_server
.addrlen
=
1479 rpc_pton(mnt
->net
, string
, strlen(string
),
1481 &mnt
->nfs_server
.address
,
1482 sizeof(mnt
->nfs_server
.address
));
1484 if (mnt
->nfs_server
.addrlen
== 0)
1485 goto out_invalid_address
;
1487 case Opt_clientaddr
:
1488 if (nfs_get_option_str(args
, &mnt
->client_address
))
1492 if (nfs_get_option_str(args
,
1493 &mnt
->mount_server
.hostname
))
1497 string
= match_strdup(args
);
1500 mnt
->mount_server
.addrlen
=
1501 rpc_pton(mnt
->net
, string
, strlen(string
),
1503 &mnt
->mount_server
.address
,
1504 sizeof(mnt
->mount_server
.address
));
1506 if (mnt
->mount_server
.addrlen
== 0)
1507 goto out_invalid_address
;
1509 case Opt_lookupcache
:
1510 string
= match_strdup(args
);
1513 token
= match_token(string
,
1514 nfs_lookupcache_tokens
, args
);
1517 case Opt_lookupcache_all
:
1518 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1520 case Opt_lookupcache_positive
:
1521 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1522 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1524 case Opt_lookupcache_none
:
1525 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1528 dfprintk(MOUNT
, "NFS: invalid "
1529 "lookupcache argument\n");
1533 case Opt_fscache_uniq
:
1534 if (nfs_get_option_str(args
, &mnt
->fscache_uniq
))
1536 mnt
->options
|= NFS_OPTION_FSCACHE
;
1538 case Opt_local_lock
:
1539 string
= match_strdup(args
);
1542 token
= match_token(string
, nfs_local_lock_tokens
,
1546 case Opt_local_lock_all
:
1547 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1548 NFS_MOUNT_LOCAL_FCNTL
);
1550 case Opt_local_lock_flock
:
1551 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1553 case Opt_local_lock_posix
:
1554 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1556 case Opt_local_lock_none
:
1557 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1558 NFS_MOUNT_LOCAL_FCNTL
);
1561 dfprintk(MOUNT
, "NFS: invalid "
1562 "local_lock argument\n");
1572 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1575 case Opt_deprecated
:
1576 dfprintk(MOUNT
, "NFS: ignoring mount option "
1582 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1587 if (!sloppy
&& invalid_option
)
1590 if (mnt
->minorversion
&& mnt
->version
!= 4)
1591 goto out_minorversion_mismatch
;
1594 * verify that any proto=/mountproto= options match the address
1595 * familiies in the addr=/mountaddr= options.
1597 if (protofamily
!= AF_UNSPEC
&&
1598 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1599 goto out_proto_mismatch
;
1601 if (mountfamily
!= AF_UNSPEC
) {
1602 if (mnt
->mount_server
.addrlen
) {
1603 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1604 goto out_mountproto_mismatch
;
1606 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1607 goto out_mountproto_mismatch
;
1613 out_mountproto_mismatch
:
1614 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1618 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1620 out_invalid_address
:
1621 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1624 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1626 out_minorversion_mismatch
:
1627 printk(KERN_INFO
"NFS: mount option vers=%u does not support "
1628 "minorversion=%u\n", mnt
->version
, mnt
->minorversion
);
1631 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1633 out_security_failure
:
1634 free_secdata(secdata
);
1635 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1640 * Match the requested auth flavors with the list returned by
1641 * the server. Returns zero and sets the mount's authentication
1642 * flavor on success; returns -EACCES if server does not support
1643 * the requested flavor.
1645 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1646 struct nfs_mount_request
*request
)
1648 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1651 * Certain releases of Linux's mountd return an empty
1652 * flavor list. To prevent behavioral regression with
1653 * these servers (ie. rejecting mounts that used to
1654 * succeed), revert to pre-2.6.32 behavior (no checking)
1655 * if the returned flavor list is empty.
1657 if (server_authlist_len
== 0)
1661 * We avoid sophisticated negotiating here, as there are
1662 * plenty of cases where we can get it wrong, providing
1663 * either too little or too much security.
1665 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1666 * flavor listed first. However, some servers list
1667 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1668 * preferred default, in args->auth_flavors[0] if user
1669 * didn't specify sec= mount option.
1671 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1672 for (j
= 0; j
< server_authlist_len
; j
++)
1673 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1674 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1675 request
->auth_flavs
[j
]);
1676 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1680 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1681 nfs_umount(request
);
1686 * Use the remote server's MOUNT service to request the NFS file handle
1687 * corresponding to the provided path.
1689 static int nfs_request_mount(struct nfs_parsed_mount_data
*args
,
1690 struct nfs_fh
*root_fh
)
1692 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1693 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1694 struct nfs_mount_request request
= {
1695 .sap
= (struct sockaddr
*)
1696 &args
->mount_server
.address
,
1697 .dirpath
= args
->nfs_server
.export_path
,
1698 .protocol
= args
->mount_server
.protocol
,
1700 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1701 .auth_flav_len
= &server_authlist_len
,
1702 .auth_flavs
= server_authlist
,
1707 if (args
->mount_server
.version
== 0) {
1708 switch (args
->version
) {
1710 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1713 args
->mount_server
.version
= NFS_MNT_VERSION
;
1716 request
.version
= args
->mount_server
.version
;
1718 if (args
->mount_server
.hostname
)
1719 request
.hostname
= args
->mount_server
.hostname
;
1721 request
.hostname
= args
->nfs_server
.hostname
;
1724 * Construct the mount server's address.
1726 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1727 memcpy(request
.sap
, &args
->nfs_server
.address
,
1728 args
->nfs_server
.addrlen
);
1729 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1731 request
.salen
= args
->mount_server
.addrlen
;
1732 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1735 * Now ask the mount server to map our export path
1738 status
= nfs_mount(&request
);
1740 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1741 request
.hostname
, status
);
1746 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1748 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1750 return nfs_walk_authlist(args
, &request
);
1753 static struct dentry
*nfs_try_mount(int flags
, const char *dev_name
,
1754 struct nfs_fh
*mntfh
,
1755 struct nfs_mount_info
*mount_info
)
1758 struct nfs_server
*server
;
1760 if (mount_info
->parsed
->need_mount
) {
1761 status
= nfs_request_mount(mount_info
->parsed
, mntfh
);
1763 return ERR_PTR(status
);
1766 /* Get a volume representation */
1767 server
= nfs_create_server(mount_info
->parsed
, mntfh
);
1769 return ERR_CAST(server
);
1771 return nfs_fs_mount_common(&nfs_fs_type
, server
, flags
, dev_name
, mntfh
, mount_info
);
1775 * Split "dev_name" into "hostname:export_path".
1777 * The leftmost colon demarks the split between the server's hostname
1778 * and the export path. If the hostname starts with a left square
1779 * bracket, then it may contain colons.
1781 * Note: caller frees hostname and export path, even on error.
1783 static int nfs_parse_devname(const char *dev_name
,
1784 char **hostname
, size_t maxnamlen
,
1785 char **export_path
, size_t maxpathlen
)
1790 /* Is the host name protected with square brakcets? */
1791 if (*dev_name
== '[') {
1792 end
= strchr(++dev_name
, ']');
1793 if (end
== NULL
|| end
[1] != ':')
1794 goto out_bad_devname
;
1796 len
= end
- dev_name
;
1801 end
= strchr(dev_name
, ':');
1803 goto out_bad_devname
;
1804 len
= end
- dev_name
;
1806 /* kill possible hostname list: not supported */
1807 comma
= strchr(dev_name
, ',');
1808 if (comma
!= NULL
&& comma
< end
)
1812 if (len
> maxnamlen
)
1815 /* N.B. caller will free nfs_server.hostname in all cases */
1816 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1817 if (*hostname
== NULL
)
1819 len
= strlen(++end
);
1820 if (len
> maxpathlen
)
1822 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1826 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1830 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1834 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1838 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1839 return -ENAMETOOLONG
;
1842 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1843 return -ENAMETOOLONG
;
1847 * Validate the NFS2/NFS3 mount data
1848 * - fills in the mount root filehandle
1850 * For option strings, user space handles the following behaviors:
1852 * + DNS: mapping server host name to IP address ("addr=" option)
1854 * + failure mode: how to behave if a mount request can't be handled
1855 * immediately ("fg/bg" option)
1857 * + retry: how often to retry a mount request ("retry=" option)
1859 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1860 * mountproto=tcp after mountproto=udp, and so on
1862 static int nfs23_validate_mount_data(void *options
,
1863 struct nfs_parsed_mount_data
*args
,
1864 struct nfs_fh
*mntfh
,
1865 const char *dev_name
)
1867 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1868 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1873 switch (data
->version
) {
1879 if (data
->flags
& NFS_MOUNT_VER3
)
1881 data
->root
.size
= NFS2_FHSIZE
;
1882 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1884 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1887 memset(data
->context
, 0, sizeof(data
->context
));
1889 if (data
->flags
& NFS_MOUNT_VER3
) {
1890 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1891 goto out_invalid_fh
;
1892 mntfh
->size
= data
->root
.size
;
1895 mntfh
->size
= NFS2_FHSIZE
;
1900 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1901 if (mntfh
->size
< sizeof(mntfh
->data
))
1902 memset(mntfh
->data
+ mntfh
->size
, 0,
1903 sizeof(mntfh
->data
) - mntfh
->size
);
1906 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1909 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1910 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1911 args
->rsize
= data
->rsize
;
1912 args
->wsize
= data
->wsize
;
1913 args
->timeo
= data
->timeo
;
1914 args
->retrans
= data
->retrans
;
1915 args
->acregmin
= data
->acregmin
;
1916 args
->acregmax
= data
->acregmax
;
1917 args
->acdirmin
= data
->acdirmin
;
1918 args
->acdirmax
= data
->acdirmax
;
1919 args
->need_mount
= false;
1921 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1922 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1923 if (!nfs_verify_server_address(sap
))
1924 goto out_no_address
;
1926 if (!(data
->flags
& NFS_MOUNT_TCP
))
1927 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1928 /* N.B. caller will free nfs_server.hostname in all cases */
1929 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1930 args
->namlen
= data
->namlen
;
1931 args
->bsize
= data
->bsize
;
1933 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1934 args
->auth_flavors
[0] = data
->pseudoflavor
;
1935 if (!args
->nfs_server
.hostname
)
1938 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1939 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1940 NFS_MOUNT_LOCAL_FCNTL
);
1942 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1943 NFS_MOUNT_LOCAL_FCNTL
);
1945 * The legacy version 6 binary mount data from userspace has a
1946 * field used only to transport selinux information into the
1947 * the kernel. To continue to support that functionality we
1948 * have a touch of selinux knowledge here in the NFS code. The
1949 * userspace code converted context=blah to just blah so we are
1950 * converting back to the full string selinux understands.
1952 if (data
->context
[0]){
1953 #ifdef CONFIG_SECURITY_SELINUX
1955 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1958 strcpy(opts_str
, "context=");
1959 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1960 strcat(opts_str
, &data
->context
[0]);
1961 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1972 return NFS_TEXT_DATA
;
1975 #ifndef CONFIG_NFS_V3
1976 if (args
->version
== 3)
1977 goto out_v3_not_compiled
;
1978 #endif /* !CONFIG_NFS_V3 */
1983 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1987 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1992 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1995 #ifndef CONFIG_NFS_V3
1996 out_v3_not_compiled
:
1997 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1998 return -EPROTONOSUPPORT
;
1999 #endif /* !CONFIG_NFS_V3 */
2002 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
2006 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2010 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
2014 #ifdef CONFIG_NFS_V4
2015 static int nfs_validate_mount_data(struct file_system_type
*fs_type
,
2017 struct nfs_parsed_mount_data
*args
,
2018 struct nfs_fh
*mntfh
,
2019 const char *dev_name
)
2021 if (fs_type
== &nfs_fs_type
)
2022 return nfs23_validate_mount_data(options
, args
, mntfh
, dev_name
);
2023 return nfs4_validate_mount_data(options
, args
, dev_name
);
2026 static int nfs_validate_mount_data(struct file_system_type
*fs_type
,
2028 struct nfs_parsed_mount_data
*args
,
2029 struct nfs_fh
*mntfh
,
2030 const char *dev_name
)
2032 return nfs23_validate_mount_data(options
, args
, mntfh
, dev_name
);
2036 static int nfs_validate_text_mount_data(void *options
,
2037 struct nfs_parsed_mount_data
*args
,
2038 const char *dev_name
)
2041 int max_namelen
= PAGE_SIZE
;
2042 int max_pathlen
= NFS_MAXPATHLEN
;
2043 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2045 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2048 if (!nfs_verify_server_address(sap
))
2049 goto out_no_address
;
2051 if (args
->version
== 4) {
2052 #ifdef CONFIG_NFS_V4
2054 max_namelen
= NFS4_MAXNAMLEN
;
2055 max_pathlen
= NFS4_MAXPATHLEN
;
2056 nfs_validate_transport_protocol(args
);
2057 nfs4_validate_mount_flags(args
);
2059 goto out_v4_not_compiled
;
2060 #endif /* CONFIG_NFS_V4 */
2062 nfs_set_mount_transport_protocol(args
);
2064 nfs_set_port(sap
, &args
->nfs_server
.port
, port
);
2066 if (args
->auth_flavor_len
> 1)
2069 return nfs_parse_devname(dev_name
,
2070 &args
->nfs_server
.hostname
,
2072 &args
->nfs_server
.export_path
,
2075 #ifndef CONFIG_NFS_V4
2076 out_v4_not_compiled
:
2077 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
2078 return -EPROTONOSUPPORT
;
2079 #endif /* !CONFIG_NFS_V4 */
2082 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2086 dfprintk(MOUNT
, "NFS: Too many RPC auth flavours specified\n");
2091 nfs_compare_remount_data(struct nfs_server
*nfss
,
2092 struct nfs_parsed_mount_data
*data
)
2094 if (data
->flags
!= nfss
->flags
||
2095 data
->rsize
!= nfss
->rsize
||
2096 data
->wsize
!= nfss
->wsize
||
2097 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
2098 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
2099 data
->acregmin
!= nfss
->acregmin
/ HZ
||
2100 data
->acregmax
!= nfss
->acregmax
/ HZ
||
2101 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
2102 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
2103 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
2104 data
->nfs_server
.port
!= nfss
->port
||
2105 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
2106 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
2107 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
2114 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
2117 struct nfs_server
*nfss
= sb
->s_fs_info
;
2118 struct nfs_parsed_mount_data
*data
;
2119 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
2120 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
2121 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
2124 * Userspace mount programs that send binary options generally send
2125 * them populated with default values. We have no way to know which
2126 * ones were explicitly specified. Fall back to legacy behavior and
2127 * just return success.
2129 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
2130 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
2131 options
->version
<= 6))))
2134 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
2138 /* fill out struct with values from existing mount */
2139 data
->flags
= nfss
->flags
;
2140 data
->rsize
= nfss
->rsize
;
2141 data
->wsize
= nfss
->wsize
;
2142 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2143 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
2144 data
->acregmin
= nfss
->acregmin
/ HZ
;
2145 data
->acregmax
= nfss
->acregmax
/ HZ
;
2146 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2147 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2148 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2149 data
->nfs_server
.port
= nfss
->port
;
2150 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2151 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2152 data
->nfs_server
.addrlen
);
2154 /* overwrite those values with any that were specified */
2155 error
= nfs_parse_mount_options((char *)options
, data
);
2160 * noac is a special case. It implies -o sync, but that's not
2161 * necessarily reflected in the mtab options. do_remount_sb
2162 * will clear MS_SYNCHRONOUS if -o sync wasn't specified in the
2163 * remount options, so we have to explicitly reset it.
2165 if (data
->flags
& NFS_MOUNT_NOAC
)
2166 *flags
|= MS_SYNCHRONOUS
;
2168 /* compare new mount options with old ones */
2169 error
= nfs_compare_remount_data(nfss
, data
);
2176 * Initialise the common bits of the superblock
2178 static inline void nfs_initialise_sb(struct super_block
*sb
)
2180 struct nfs_server
*server
= NFS_SB(sb
);
2182 sb
->s_magic
= NFS_SUPER_MAGIC
;
2184 /* We probably want something more informative here */
2185 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2186 "%u:%u", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2188 if (sb
->s_blocksize
== 0)
2189 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2190 &sb
->s_blocksize_bits
);
2192 sb
->s_bdi
= &server
->backing_dev_info
;
2194 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2198 * Finish setting up an NFS2/3 superblock
2200 static void nfs_fill_super(struct super_block
*sb
,
2201 struct nfs_mount_info
*mount_info
)
2203 struct nfs_parsed_mount_data
*data
= mount_info
->parsed
;
2204 struct nfs_server
*server
= NFS_SB(sb
);
2206 sb
->s_blocksize_bits
= 0;
2207 sb
->s_blocksize
= 0;
2209 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2211 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2212 /* The VFS shouldn't apply the umask to mode bits. We will do
2213 * so ourselves when necessary.
2215 sb
->s_flags
|= MS_POSIXACL
;
2216 sb
->s_time_gran
= 1;
2219 sb
->s_op
= &nfs_sops
;
2220 nfs_initialise_sb(sb
);
2224 * Finish setting up a cloned NFS2/3 superblock
2226 static void nfs_clone_super(struct super_block
*sb
,
2227 struct nfs_mount_info
*mount_info
)
2229 const struct super_block
*old_sb
= mount_info
->cloned
->sb
;
2230 struct nfs_server
*server
= NFS_SB(sb
);
2232 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2233 sb
->s_blocksize
= old_sb
->s_blocksize
;
2234 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2236 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2237 /* The VFS shouldn't apply the umask to mode bits. We will do
2238 * so ourselves when necessary.
2240 sb
->s_flags
|= MS_POSIXACL
;
2241 sb
->s_time_gran
= 1;
2244 sb
->s_op
= old_sb
->s_op
;
2245 nfs_initialise_sb(sb
);
2248 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2250 const struct nfs_server
*a
= s
->s_fs_info
;
2251 const struct rpc_clnt
*clnt_a
= a
->client
;
2252 const struct rpc_clnt
*clnt_b
= b
->client
;
2254 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2256 if (a
->nfs_client
!= b
->nfs_client
)
2258 if (a
->flags
!= b
->flags
)
2260 if (a
->wsize
!= b
->wsize
)
2262 if (a
->rsize
!= b
->rsize
)
2264 if (a
->acregmin
!= b
->acregmin
)
2266 if (a
->acregmax
!= b
->acregmax
)
2268 if (a
->acdirmin
!= b
->acdirmin
)
2270 if (a
->acdirmax
!= b
->acdirmax
)
2272 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2279 struct nfs_sb_mountdata
{
2280 struct nfs_server
*server
;
2284 static int nfs_set_super(struct super_block
*s
, void *data
)
2286 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2287 struct nfs_server
*server
= sb_mntdata
->server
;
2290 s
->s_flags
= sb_mntdata
->mntflags
;
2291 s
->s_fs_info
= server
;
2292 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
2293 ret
= set_anon_super(s
, server
);
2295 server
->s_dev
= s
->s_dev
;
2299 static int nfs_compare_super_address(struct nfs_server
*server1
,
2300 struct nfs_server
*server2
)
2302 struct sockaddr
*sap1
, *sap2
;
2304 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2305 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2307 if (sap1
->sa_family
!= sap2
->sa_family
)
2310 switch (sap1
->sa_family
) {
2312 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2313 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2314 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2316 if (sin1
->sin_port
!= sin2
->sin_port
)
2321 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2322 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2323 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2325 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2336 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2338 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2339 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2340 int mntflags
= sb_mntdata
->mntflags
;
2342 if (!nfs_compare_super_address(old
, server
))
2344 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2345 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2347 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2349 return nfs_compare_mount_options(sb
, server
, mntflags
);
2352 static void nfs_get_cache_cookie(struct super_block
*sb
,
2353 struct nfs_parsed_mount_data
*parsed
,
2354 struct nfs_clone_mount
*cloned
)
2359 if (parsed
&& parsed
->fscache_uniq
) {
2360 uniq
= parsed
->fscache_uniq
;
2361 ulen
= strlen(parsed
->fscache_uniq
);
2362 } else if (cloned
) {
2363 struct nfs_server
*mnt_s
= NFS_SB(cloned
->sb
);
2364 if (mnt_s
->fscache_key
) {
2365 uniq
= mnt_s
->fscache_key
->key
.uniquifier
;
2366 ulen
= mnt_s
->fscache_key
->key
.uniq_len
;
2370 nfs_fscache_get_super_cookie(sb
, uniq
, ulen
);
2373 static int nfs_bdi_register(struct nfs_server
*server
)
2375 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2378 static int nfs_set_sb_security(struct super_block
*s
, struct dentry
*mntroot
,
2379 struct nfs_mount_info
*mount_info
)
2381 return security_sb_set_mnt_opts(s
, &mount_info
->parsed
->lsm_opts
);
2384 static int nfs_clone_sb_security(struct super_block
*s
, struct dentry
*mntroot
,
2385 struct nfs_mount_info
*mount_info
)
2387 /* clone any lsm security options from the parent to the new sb */
2388 security_sb_clone_mnt_opts(mount_info
->cloned
->sb
, s
);
2389 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
)
2394 static struct dentry
*nfs_fs_mount_common(struct file_system_type
*fs_type
,
2395 struct nfs_server
*server
,
2396 int flags
, const char *dev_name
,
2397 struct nfs_fh
*mntfh
,
2398 struct nfs_mount_info
*mount_info
)
2400 struct super_block
*s
;
2401 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2402 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2403 struct nfs_sb_mountdata sb_mntdata
= {
2409 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2410 compare_super
= NULL
;
2412 /* -o noac implies -o sync */
2413 if (server
->flags
& NFS_MOUNT_NOAC
)
2414 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2416 /* Get a superblock - note that we may end up sharing one that already exists */
2417 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2419 mntroot
= ERR_CAST(s
);
2423 if (s
->s_fs_info
!= server
) {
2424 nfs_free_server(server
);
2427 error
= nfs_bdi_register(server
);
2429 mntroot
= ERR_PTR(error
);
2430 goto error_splat_bdi
;
2435 /* initial superblock/root creation */
2436 mount_info
->fill_super(s
, mount_info
);
2437 nfs_get_cache_cookie(s
, mount_info
->parsed
, mount_info
->cloned
);
2440 mntroot
= nfs_get_root(s
, mntfh
, dev_name
);
2441 if (IS_ERR(mntroot
))
2442 goto error_splat_super
;
2444 error
= mount_info
->set_security(s
, mntroot
, mount_info
);
2446 goto error_splat_root
;
2448 s
->s_flags
|= MS_ACTIVE
;
2454 nfs_free_server(server
);
2459 mntroot
= ERR_PTR(error
);
2461 if (server
&& !s
->s_root
)
2462 bdi_unregister(&server
->backing_dev_info
);
2464 deactivate_locked_super(s
);
2468 static struct dentry
*nfs_fs_mount(struct file_system_type
*fs_type
,
2469 int flags
, const char *dev_name
, void *raw_data
)
2471 struct nfs_mount_info mount_info
= {
2472 .fill_super
= nfs_fill_super
,
2473 .set_security
= nfs_set_sb_security
,
2475 struct nfs_fh
*mntfh
;
2476 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2479 mount_info
.parsed
= nfs_alloc_parsed_mount_data();
2480 mntfh
= nfs_alloc_fhandle();
2481 if (mount_info
.parsed
== NULL
|| mntfh
== NULL
)
2484 /* Validate the mount data */
2485 error
= nfs_validate_mount_data(fs_type
, raw_data
, mount_info
.parsed
, mntfh
, dev_name
);
2486 if (error
== NFS_TEXT_DATA
)
2487 error
= nfs_validate_text_mount_data(raw_data
, mount_info
.parsed
, dev_name
);
2489 mntroot
= ERR_PTR(error
);
2493 #ifdef CONFIG_NFS_V4
2494 if (mount_info
.parsed
->version
== 4)
2495 mntroot
= nfs4_try_mount(flags
, dev_name
, mount_info
.parsed
);
2497 #endif /* CONFIG_NFS_V4 */
2498 mntroot
= nfs_try_mount(flags
, dev_name
, mntfh
, &mount_info
);
2501 nfs_free_parsed_mount_data(mount_info
.parsed
);
2502 nfs_free_fhandle(mntfh
);
2507 * Ensure that we unregister the bdi before kill_anon_super
2508 * releases the device name
2510 static void nfs_put_super(struct super_block
*s
)
2512 struct nfs_server
*server
= NFS_SB(s
);
2514 bdi_unregister(&server
->backing_dev_info
);
2518 * Destroy an NFS2/3 superblock
2520 static void nfs_kill_super(struct super_block
*s
)
2522 struct nfs_server
*server
= NFS_SB(s
);
2525 nfs_fscache_release_super_cookie(s
);
2526 nfs_free_server(server
);
2530 * Clone an NFS2/3/4 server record on xdev traversal (FSID-change)
2532 static struct dentry
*
2533 nfs_xdev_mount_common(struct file_system_type
*fs_type
, int flags
,
2534 const char *dev_name
, struct nfs_mount_info
*mount_info
)
2536 struct nfs_clone_mount
*data
= mount_info
->cloned
;
2537 struct nfs_server
*server
;
2538 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2541 dprintk("--> nfs_xdev_mount_common()\n");
2543 /* create a new volume representation */
2544 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
, data
->authflavor
);
2545 if (IS_ERR(server
)) {
2546 error
= PTR_ERR(server
);
2550 mntroot
= nfs_fs_mount_common(fs_type
, server
, flags
, dev_name
, data
->fh
, mount_info
);
2551 dprintk("<-- nfs_xdev_mount_common() = 0\n");
2556 dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error
);
2561 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2563 static struct dentry
*
2564 nfs_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2565 const char *dev_name
, void *raw_data
)
2567 struct nfs_mount_info mount_info
= {
2568 .fill_super
= nfs_clone_super
,
2569 .set_security
= nfs_clone_sb_security
,
2572 return nfs_xdev_mount_common(&nfs_fs_type
, flags
, dev_name
, &mount_info
);
2575 #ifdef CONFIG_NFS_V4
2578 * Finish setting up a cloned NFS4 superblock
2580 static void nfs4_clone_super(struct super_block
*sb
,
2581 struct nfs_mount_info
*mount_info
)
2583 const struct super_block
*old_sb
= mount_info
->cloned
->sb
;
2584 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2585 sb
->s_blocksize
= old_sb
->s_blocksize
;
2586 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2587 sb
->s_time_gran
= 1;
2588 sb
->s_op
= old_sb
->s_op
;
2590 * The VFS shouldn't apply the umask to mode bits. We will do
2591 * so ourselves when necessary.
2593 sb
->s_flags
|= MS_POSIXACL
;
2594 sb
->s_xattr
= old_sb
->s_xattr
;
2595 nfs_initialise_sb(sb
);
2599 * Set up an NFS4 superblock
2601 static void nfs4_fill_super(struct super_block
*sb
,
2602 struct nfs_mount_info
*mount_info
)
2604 sb
->s_time_gran
= 1;
2605 sb
->s_op
= &nfs4_sops
;
2607 * The VFS shouldn't apply the umask to mode bits. We will do
2608 * so ourselves when necessary.
2610 sb
->s_flags
|= MS_POSIXACL
;
2611 sb
->s_xattr
= nfs4_xattr_handlers
;
2612 nfs_initialise_sb(sb
);
2615 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2617 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2618 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2622 * Validate NFSv4 mount options
2624 static int nfs4_validate_mount_data(void *options
,
2625 struct nfs_parsed_mount_data
*args
,
2626 const char *dev_name
)
2628 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2629 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2635 switch (data
->version
) {
2637 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2638 goto out_no_address
;
2639 if (data
->host_addrlen
== 0)
2640 goto out_no_address
;
2641 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2642 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2644 if (!nfs_verify_server_address(sap
))
2645 goto out_no_address
;
2647 if (data
->auth_flavourlen
) {
2648 if (data
->auth_flavourlen
> 1)
2649 goto out_inval_auth
;
2650 if (copy_from_user(&args
->auth_flavors
[0],
2651 data
->auth_flavours
,
2652 sizeof(args
->auth_flavors
[0])))
2656 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2659 args
->nfs_server
.hostname
= c
;
2661 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2664 args
->nfs_server
.export_path
= c
;
2665 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2667 c
= strndup_user(data
->client_addr
.data
, 16);
2670 args
->client_address
= c
;
2673 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2677 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2678 args
->rsize
= data
->rsize
;
2679 args
->wsize
= data
->wsize
;
2680 args
->timeo
= data
->timeo
;
2681 args
->retrans
= data
->retrans
;
2682 args
->acregmin
= data
->acregmin
;
2683 args
->acregmax
= data
->acregmax
;
2684 args
->acdirmin
= data
->acdirmin
;
2685 args
->acdirmax
= data
->acdirmax
;
2686 args
->nfs_server
.protocol
= data
->proto
;
2687 nfs_validate_transport_protocol(args
);
2691 return NFS_TEXT_DATA
;
2697 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2701 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2702 data
->auth_flavourlen
);
2706 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2711 * Get the superblock for the NFS4 root partition
2713 static struct dentry
*
2714 nfs4_remote_mount(struct file_system_type
*fs_type
, int flags
,
2715 const char *dev_name
, void *raw_data
)
2717 struct nfs_mount_info mount_info
= {
2718 .fill_super
= nfs4_fill_super
,
2719 .set_security
= nfs_set_sb_security
,
2722 struct nfs_server
*server
;
2723 struct nfs_fh
*mntfh
;
2724 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2726 mntfh
= nfs_alloc_fhandle();
2727 if (mount_info
.parsed
== NULL
|| mntfh
== NULL
)
2730 /* Get a volume representation */
2731 server
= nfs4_create_server(mount_info
.parsed
, mntfh
);
2732 if (IS_ERR(server
)) {
2733 mntroot
= ERR_CAST(server
);
2737 mntroot
= nfs_fs_mount_common(fs_type
, server
, flags
,
2738 dev_name
, mntfh
, &mount_info
);
2741 nfs_free_fhandle(mntfh
);
2745 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2746 int flags
, void *data
, const char *hostname
)
2748 struct vfsmount
*root_mnt
;
2752 len
= strlen(hostname
) + 5;
2753 root_devname
= kmalloc(len
, GFP_KERNEL
);
2754 if (root_devname
== NULL
)
2755 return ERR_PTR(-ENOMEM
);
2756 /* Does hostname needs to be enclosed in brackets? */
2757 if (strchr(hostname
, ':'))
2758 snprintf(root_devname
, len
, "[%s]:/", hostname
);
2760 snprintf(root_devname
, len
, "%s:/", hostname
);
2761 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2762 kfree(root_devname
);
2766 struct nfs_referral_count
{
2767 struct list_head list
;
2768 const struct task_struct
*task
;
2769 unsigned int referral_count
;
2772 static LIST_HEAD(nfs_referral_count_list
);
2773 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2775 static struct nfs_referral_count
*nfs_find_referral_count(void)
2777 struct nfs_referral_count
*p
;
2779 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2780 if (p
->task
== current
)
2786 #define NFS_MAX_NESTED_REFERRALS 2
2788 static int nfs_referral_loop_protect(void)
2790 struct nfs_referral_count
*p
, *new;
2793 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2796 new->task
= current
;
2797 new->referral_count
= 1;
2800 spin_lock(&nfs_referral_count_list_lock
);
2801 p
= nfs_find_referral_count();
2803 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2806 p
->referral_count
++;
2808 list_add(&new->list
, &nfs_referral_count_list
);
2811 spin_unlock(&nfs_referral_count_list_lock
);
2817 static void nfs_referral_loop_unprotect(void)
2819 struct nfs_referral_count
*p
;
2821 spin_lock(&nfs_referral_count_list_lock
);
2822 p
= nfs_find_referral_count();
2823 p
->referral_count
--;
2824 if (p
->referral_count
== 0)
2828 spin_unlock(&nfs_referral_count_list_lock
);
2832 static struct dentry
*nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2833 const char *export_path
)
2835 struct dentry
*dentry
;
2838 if (IS_ERR(root_mnt
))
2839 return ERR_CAST(root_mnt
);
2841 err
= nfs_referral_loop_protect();
2844 return ERR_PTR(err
);
2847 dentry
= mount_subtree(root_mnt
, export_path
);
2848 nfs_referral_loop_unprotect();
2853 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
2854 struct nfs_parsed_mount_data
*data
)
2857 struct vfsmount
*root_mnt
;
2860 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2862 export_path
= data
->nfs_server
.export_path
;
2863 data
->nfs_server
.export_path
= "/";
2864 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2865 data
->nfs_server
.hostname
);
2866 data
->nfs_server
.export_path
= export_path
;
2868 res
= nfs_follow_remote_path(root_mnt
, export_path
);
2870 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %ld%s\n",
2871 IS_ERR(res
) ? PTR_ERR(res
) : 0,
2872 IS_ERR(res
) ? " [error]" : "");
2877 * Get the superblock for an NFS4 mountpoint
2879 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
2880 int flags
, const char *dev_name
, void *raw_data
)
2882 struct nfs_parsed_mount_data
*data
;
2883 int error
= -ENOMEM
;
2884 struct dentry
*res
= ERR_PTR(-ENOMEM
);
2886 data
= nfs_alloc_parsed_mount_data();
2890 /* Validate the mount data */
2891 error
= nfs_validate_mount_data(fs_type
, raw_data
, data
, NULL
, dev_name
);
2892 if (error
== NFS_TEXT_DATA
)
2893 error
= nfs_validate_text_mount_data(raw_data
, data
, dev_name
);
2895 res
= ERR_PTR(error
);
2899 res
= nfs4_try_mount(flags
, dev_name
, data
);
2901 error
= PTR_ERR(res
);
2904 nfs_free_parsed_mount_data(data
);
2905 dprintk("<-- nfs4_mount() = %d%s\n", error
,
2906 error
!= 0 ? " [error]" : "");
2910 static void nfs4_kill_super(struct super_block
*sb
)
2912 struct nfs_server
*server
= NFS_SB(sb
);
2914 dprintk("--> %s\n", __func__
);
2915 nfs_super_return_all_delegations(sb
);
2916 kill_anon_super(sb
);
2917 nfs_fscache_release_super_cookie(sb
);
2918 nfs_free_server(server
);
2919 dprintk("<-- %s\n", __func__
);
2923 * Clone an NFS4 server record on xdev traversal (FSID-change)
2925 static struct dentry
*
2926 nfs4_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2927 const char *dev_name
, void *raw_data
)
2929 struct nfs_mount_info mount_info
= {
2930 .fill_super
= nfs4_clone_super
,
2931 .set_security
= nfs_clone_sb_security
,
2934 return nfs_xdev_mount_common(&nfs4_fs_type
, flags
, dev_name
, &mount_info
);
2937 static struct dentry
*
2938 nfs4_remote_referral_mount(struct file_system_type
*fs_type
, int flags
,
2939 const char *dev_name
, void *raw_data
)
2941 struct nfs_mount_info mount_info
= {
2942 .fill_super
= nfs4_fill_super
,
2943 .set_security
= nfs_clone_sb_security
,
2946 struct nfs_server
*server
;
2947 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2948 struct nfs_fh
*mntfh
;
2950 dprintk("--> nfs4_referral_get_sb()\n");
2952 mntfh
= nfs_alloc_fhandle();
2953 if (mount_info
.cloned
== NULL
|| mntfh
== NULL
)
2956 /* create a new volume representation */
2957 server
= nfs4_create_referral_server(mount_info
.cloned
, mntfh
);
2958 if (IS_ERR(server
)) {
2959 mntroot
= ERR_CAST(server
);
2963 mntroot
= nfs_fs_mount_common(&nfs4_fs_type
, server
, flags
, dev_name
, mntfh
, &mount_info
);
2965 nfs_free_fhandle(mntfh
);
2970 * Create an NFS4 server record on referral traversal
2972 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
2973 int flags
, const char *dev_name
, void *raw_data
)
2975 struct nfs_clone_mount
*data
= raw_data
;
2977 struct vfsmount
*root_mnt
;
2980 dprintk("--> nfs4_referral_mount()\n");
2982 export_path
= data
->mnt_path
;
2983 data
->mnt_path
= "/";
2985 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
2986 flags
, data
, data
->hostname
);
2987 data
->mnt_path
= export_path
;
2989 res
= nfs_follow_remote_path(root_mnt
, export_path
);
2990 dprintk("<-- nfs4_referral_mount() = %ld%s\n",
2991 IS_ERR(res
) ? PTR_ERR(res
) : 0,
2992 IS_ERR(res
) ? " [error]" : "");
2996 #endif /* CONFIG_NFS_V4 */