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/mnt_namespace.h>
45 #include <linux/namei.h>
46 #include <linux/nfs_idmap.h>
47 #include <linux/vfs.h>
48 #include <linux/inet.h>
49 #include <linux/in6.h>
50 #include <linux/slab.h>
52 #include <linux/netdevice.h>
53 #include <linux/nfs_xdr.h>
54 #include <linux/magic.h>
55 #include <linux/parser.h>
57 #include <asm/system.h>
58 #include <asm/uaccess.h>
62 #include "delegation.h"
67 #define NFSDBG_FACILITY NFSDBG_VFS
70 #define NFS_DEFAULT_VERSION 3
72 #define NFS_DEFAULT_VERSION 2
76 /* Mount options that take no arguments */
78 Opt_posix
, Opt_noposix
,
82 Opt_v2
, Opt_v3
, Opt_v4
,
83 Opt_udp
, Opt_tcp
, Opt_rdma
,
85 Opt_rdirplus
, Opt_nordirplus
,
86 Opt_sharecache
, Opt_nosharecache
,
87 Opt_resvport
, Opt_noresvport
,
88 Opt_fscache
, Opt_nofscache
,
90 /* Mount options that take integer arguments */
92 Opt_rsize
, Opt_wsize
, Opt_bsize
,
93 Opt_timeo
, Opt_retrans
,
94 Opt_acregmin
, Opt_acregmax
,
95 Opt_acdirmin
, Opt_acdirmax
,
103 /* Mount options that take string arguments */
104 Opt_sec
, Opt_proto
, Opt_mountproto
, Opt_mounthost
,
105 Opt_addr
, Opt_mountaddr
, Opt_clientaddr
,
110 /* Special mount options */
111 Opt_userspace
, Opt_deprecated
, Opt_sloppy
,
116 static const match_table_t nfs_mount_option_tokens
= {
117 { Opt_userspace
, "bg" },
118 { Opt_userspace
, "fg" },
119 { Opt_userspace
, "retry=%s" },
121 { Opt_sloppy
, "sloppy" },
123 { Opt_soft
, "soft" },
124 { Opt_hard
, "hard" },
125 { Opt_deprecated
, "intr" },
126 { Opt_deprecated
, "nointr" },
127 { Opt_posix
, "posix" },
128 { Opt_noposix
, "noposix" },
130 { Opt_nocto
, "nocto" },
132 { Opt_noac
, "noac" },
133 { Opt_lock
, "lock" },
134 { Opt_nolock
, "nolock" },
140 { Opt_rdma
, "rdma" },
142 { Opt_noacl
, "noacl" },
143 { Opt_rdirplus
, "rdirplus" },
144 { Opt_nordirplus
, "nordirplus" },
145 { Opt_sharecache
, "sharecache" },
146 { Opt_nosharecache
, "nosharecache" },
147 { Opt_resvport
, "resvport" },
148 { Opt_noresvport
, "noresvport" },
149 { Opt_fscache
, "fsc" },
150 { Opt_nofscache
, "nofsc" },
152 { Opt_port
, "port=%s" },
153 { Opt_rsize
, "rsize=%s" },
154 { Opt_wsize
, "wsize=%s" },
155 { Opt_bsize
, "bsize=%s" },
156 { Opt_timeo
, "timeo=%s" },
157 { Opt_retrans
, "retrans=%s" },
158 { Opt_acregmin
, "acregmin=%s" },
159 { Opt_acregmax
, "acregmax=%s" },
160 { Opt_acdirmin
, "acdirmin=%s" },
161 { Opt_acdirmax
, "acdirmax=%s" },
162 { Opt_actimeo
, "actimeo=%s" },
163 { Opt_namelen
, "namlen=%s" },
164 { Opt_mountport
, "mountport=%s" },
165 { Opt_mountvers
, "mountvers=%s" },
166 { Opt_nfsvers
, "nfsvers=%s" },
167 { Opt_nfsvers
, "vers=%s" },
168 { Opt_minorversion
, "minorversion=%s" },
170 { Opt_sec
, "sec=%s" },
171 { Opt_proto
, "proto=%s" },
172 { Opt_mountproto
, "mountproto=%s" },
173 { Opt_addr
, "addr=%s" },
174 { Opt_clientaddr
, "clientaddr=%s" },
175 { Opt_mounthost
, "mounthost=%s" },
176 { Opt_mountaddr
, "mountaddr=%s" },
178 { Opt_lookupcache
, "lookupcache=%s" },
179 { Opt_fscache_uniq
, "fsc=%s" },
180 { Opt_local_lock
, "local_lock=%s" },
186 Opt_xprt_udp
, Opt_xprt_udp6
, Opt_xprt_tcp
, Opt_xprt_tcp6
, Opt_xprt_rdma
,
191 static const match_table_t nfs_xprt_protocol_tokens
= {
192 { Opt_xprt_udp
, "udp" },
193 { Opt_xprt_udp6
, "udp6" },
194 { Opt_xprt_tcp
, "tcp" },
195 { Opt_xprt_tcp6
, "tcp6" },
196 { Opt_xprt_rdma
, "rdma" },
198 { Opt_xprt_err
, NULL
}
202 Opt_sec_none
, Opt_sec_sys
,
203 Opt_sec_krb5
, Opt_sec_krb5i
, Opt_sec_krb5p
,
204 Opt_sec_lkey
, Opt_sec_lkeyi
, Opt_sec_lkeyp
,
205 Opt_sec_spkm
, Opt_sec_spkmi
, Opt_sec_spkmp
,
210 static const match_table_t nfs_secflavor_tokens
= {
211 { Opt_sec_none
, "none" },
212 { Opt_sec_none
, "null" },
213 { Opt_sec_sys
, "sys" },
215 { Opt_sec_krb5
, "krb5" },
216 { Opt_sec_krb5i
, "krb5i" },
217 { Opt_sec_krb5p
, "krb5p" },
219 { Opt_sec_lkey
, "lkey" },
220 { Opt_sec_lkeyi
, "lkeyi" },
221 { Opt_sec_lkeyp
, "lkeyp" },
223 { Opt_sec_spkm
, "spkm3" },
224 { Opt_sec_spkmi
, "spkm3i" },
225 { Opt_sec_spkmp
, "spkm3p" },
227 { Opt_sec_err
, NULL
}
231 Opt_lookupcache_all
, Opt_lookupcache_positive
,
232 Opt_lookupcache_none
,
237 static match_table_t nfs_lookupcache_tokens
= {
238 { Opt_lookupcache_all
, "all" },
239 { Opt_lookupcache_positive
, "pos" },
240 { Opt_lookupcache_positive
, "positive" },
241 { Opt_lookupcache_none
, "none" },
243 { Opt_lookupcache_err
, NULL
}
247 Opt_local_lock_all
, Opt_local_lock_flock
, Opt_local_lock_posix
,
253 static match_table_t nfs_local_lock_tokens
= {
254 { Opt_local_lock_all
, "all" },
255 { Opt_local_lock_flock
, "flock" },
256 { Opt_local_lock_posix
, "posix" },
257 { Opt_local_lock_none
, "none" },
259 { Opt_local_lock_err
, NULL
}
263 static void nfs_umount_begin(struct super_block
*);
264 static int nfs_statfs(struct dentry
*, struct kstatfs
*);
265 static int nfs_show_options(struct seq_file
*, struct vfsmount
*);
266 static int nfs_show_devname(struct seq_file
*, struct vfsmount
*);
267 static int nfs_show_path(struct seq_file
*, struct vfsmount
*);
268 static int nfs_show_stats(struct seq_file
*, struct vfsmount
*);
269 static struct dentry
*nfs_fs_mount(struct file_system_type
*,
270 int, const char *, void *);
271 static struct dentry
*nfs_xdev_mount(struct file_system_type
*fs_type
,
272 int flags
, const char *dev_name
, void *raw_data
);
273 static void nfs_put_super(struct super_block
*);
274 static void nfs_kill_super(struct super_block
*);
275 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
277 static struct file_system_type nfs_fs_type
= {
278 .owner
= THIS_MODULE
,
280 .mount
= nfs_fs_mount
,
281 .kill_sb
= nfs_kill_super
,
282 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
285 struct file_system_type nfs_xdev_fs_type
= {
286 .owner
= THIS_MODULE
,
288 .mount
= nfs_xdev_mount
,
289 .kill_sb
= nfs_kill_super
,
290 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
293 static const struct super_operations nfs_sops
= {
294 .alloc_inode
= nfs_alloc_inode
,
295 .destroy_inode
= nfs_destroy_inode
,
296 .write_inode
= nfs_write_inode
,
297 .put_super
= nfs_put_super
,
298 .statfs
= nfs_statfs
,
299 .evict_inode
= nfs_evict_inode
,
300 .umount_begin
= nfs_umount_begin
,
301 .show_options
= nfs_show_options
,
302 .show_devname
= nfs_show_devname
,
303 .show_path
= nfs_show_path
,
304 .show_stats
= nfs_show_stats
,
305 .remount_fs
= nfs_remount
,
309 static int nfs4_validate_text_mount_data(void *options
,
310 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
311 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
312 struct nfs_parsed_mount_data
*data
);
313 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
314 int flags
, const char *dev_name
, void *raw_data
);
315 static struct dentry
*nfs4_remote_mount(struct file_system_type
*fs_type
,
316 int flags
, const char *dev_name
, void *raw_data
);
317 static struct dentry
*nfs4_xdev_mount(struct file_system_type
*fs_type
,
318 int flags
, const char *dev_name
, void *raw_data
);
319 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
320 int flags
, const char *dev_name
, void *raw_data
);
321 static struct dentry
*nfs4_remote_referral_mount(struct file_system_type
*fs_type
,
322 int flags
, const char *dev_name
, void *raw_data
);
323 static void nfs4_kill_super(struct super_block
*sb
);
325 static struct file_system_type nfs4_fs_type
= {
326 .owner
= THIS_MODULE
,
329 .kill_sb
= nfs4_kill_super
,
330 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
333 static struct file_system_type nfs4_remote_fs_type
= {
334 .owner
= THIS_MODULE
,
336 .mount
= nfs4_remote_mount
,
337 .kill_sb
= nfs4_kill_super
,
338 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
341 struct file_system_type nfs4_xdev_fs_type
= {
342 .owner
= THIS_MODULE
,
344 .mount
= nfs4_xdev_mount
,
345 .kill_sb
= nfs4_kill_super
,
346 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
349 static struct file_system_type nfs4_remote_referral_fs_type
= {
350 .owner
= THIS_MODULE
,
352 .mount
= nfs4_remote_referral_mount
,
353 .kill_sb
= nfs4_kill_super
,
354 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
357 struct file_system_type nfs4_referral_fs_type
= {
358 .owner
= THIS_MODULE
,
360 .mount
= nfs4_referral_mount
,
361 .kill_sb
= nfs4_kill_super
,
362 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
365 static const struct super_operations nfs4_sops
= {
366 .alloc_inode
= nfs_alloc_inode
,
367 .destroy_inode
= nfs_destroy_inode
,
368 .write_inode
= nfs_write_inode
,
369 .put_super
= nfs_put_super
,
370 .statfs
= nfs_statfs
,
371 .evict_inode
= nfs4_evict_inode
,
372 .umount_begin
= nfs_umount_begin
,
373 .show_options
= nfs_show_options
,
374 .show_devname
= nfs_show_devname
,
375 .show_path
= nfs_show_path
,
376 .show_stats
= nfs_show_stats
,
377 .remount_fs
= nfs_remount
,
381 static struct shrinker acl_shrinker
= {
382 .shrink
= nfs_access_cache_shrinker
,
383 .seeks
= DEFAULT_SEEKS
,
387 * Register the NFS filesystems
389 int __init
register_nfs_fs(void)
393 ret
= register_filesystem(&nfs_fs_type
);
397 ret
= nfs_register_sysctl();
401 ret
= register_filesystem(&nfs4_fs_type
);
405 register_shrinker(&acl_shrinker
);
410 nfs_unregister_sysctl();
413 unregister_filesystem(&nfs_fs_type
);
419 * Unregister the NFS filesystems
421 void __exit
unregister_nfs_fs(void)
423 unregister_shrinker(&acl_shrinker
);
425 unregister_filesystem(&nfs4_fs_type
);
427 nfs_unregister_sysctl();
428 unregister_filesystem(&nfs_fs_type
);
431 void nfs_sb_active(struct super_block
*sb
)
433 struct nfs_server
*server
= NFS_SB(sb
);
435 if (atomic_inc_return(&server
->active
) == 1)
436 atomic_inc(&sb
->s_active
);
439 void nfs_sb_deactive(struct super_block
*sb
)
441 struct nfs_server
*server
= NFS_SB(sb
);
443 if (atomic_dec_and_test(&server
->active
))
444 deactivate_super(sb
);
448 * Deliver file system statistics to userspace
450 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
452 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
453 unsigned char blockbits
;
454 unsigned long blockres
;
455 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
456 struct nfs_fsstat res
;
459 res
.fattr
= nfs_alloc_fattr();
460 if (res
.fattr
== NULL
)
463 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
464 if (unlikely(error
== -ESTALE
)) {
465 struct dentry
*pd_dentry
;
467 pd_dentry
= dget_parent(dentry
);
468 if (pd_dentry
!= NULL
) {
469 nfs_zap_caches(pd_dentry
->d_inode
);
473 nfs_free_fattr(res
.fattr
);
477 buf
->f_type
= NFS_SUPER_MAGIC
;
480 * Current versions of glibc do not correctly handle the
481 * case where f_frsize != f_bsize. Eventually we want to
482 * report the value of wtmult in this field.
484 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
487 * On most *nix systems, f_blocks, f_bfree, and f_bavail
488 * are reported in units of f_frsize. Linux hasn't had
489 * an f_frsize field in its statfs struct until recently,
490 * thus historically Linux's sys_statfs reports these
491 * fields in units of f_bsize.
493 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
494 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
495 blockres
= (1 << blockbits
) - 1;
496 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
497 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
498 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
500 buf
->f_files
= res
.tfiles
;
501 buf
->f_ffree
= res
.afiles
;
503 buf
->f_namelen
= server
->namelen
;
508 dprintk("%s: statfs error = %d\n", __func__
, -error
);
513 * Map the security flavour number to a name
515 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
517 static const struct {
518 rpc_authflavor_t flavour
;
521 { RPC_AUTH_NULL
, "null" },
522 { RPC_AUTH_UNIX
, "sys" },
523 { RPC_AUTH_GSS_KRB5
, "krb5" },
524 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
525 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
526 { RPC_AUTH_GSS_LKEY
, "lkey" },
527 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
528 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
529 { RPC_AUTH_GSS_SPKM
, "spkm" },
530 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
531 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
532 { UINT_MAX
, "unknown" }
536 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
537 if (sec_flavours
[i
].flavour
== flavour
)
540 return sec_flavours
[i
].str
;
543 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
546 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
548 seq_printf(m
, ",mountproto=");
549 switch (sap
->sa_family
) {
551 switch (nfss
->mountd_protocol
) {
553 seq_printf(m
, RPCBIND_NETID_UDP
);
556 seq_printf(m
, RPCBIND_NETID_TCP
);
560 seq_printf(m
, "auto");
564 switch (nfss
->mountd_protocol
) {
566 seq_printf(m
, RPCBIND_NETID_UDP6
);
569 seq_printf(m
, RPCBIND_NETID_TCP6
);
573 seq_printf(m
, "auto");
578 seq_printf(m
, "auto");
582 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
585 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
587 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
590 switch (sap
->sa_family
) {
592 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
593 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
597 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
598 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
603 seq_printf(m
, ",mountaddr=unspecified");
606 if (nfss
->mountd_version
|| showdefaults
)
607 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
608 if ((nfss
->mountd_port
&&
609 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
611 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
613 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
617 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
620 struct nfs_client
*clp
= nfss
->nfs_client
;
622 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
623 seq_printf(m
, ",minorversion=%u", clp
->cl_minorversion
);
626 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
633 * Describe the mount options in force on this server representation
635 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
638 static const struct proc_nfs_info
{
643 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
644 { NFS_MOUNT_POSIX
, ",posix", "" },
645 { NFS_MOUNT_NOCTO
, ",nocto", "" },
646 { NFS_MOUNT_NOAC
, ",noac", "" },
647 { NFS_MOUNT_NONLM
, ",nolock", "" },
648 { NFS_MOUNT_NOACL
, ",noacl", "" },
649 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
650 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
651 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
654 const struct proc_nfs_info
*nfs_infop
;
655 struct nfs_client
*clp
= nfss
->nfs_client
;
656 u32 version
= clp
->rpc_ops
->version
;
657 int local_flock
, local_fcntl
;
659 seq_printf(m
, ",vers=%u", version
);
660 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
661 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
662 if (nfss
->bsize
!= 0)
663 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
664 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
665 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
666 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
667 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
668 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
669 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
670 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
671 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
672 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
673 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
674 if (nfss
->flags
& nfs_infop
->flag
)
675 seq_puts(m
, nfs_infop
->str
);
677 seq_puts(m
, nfs_infop
->nostr
);
679 seq_printf(m
, ",proto=%s",
680 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
682 if (nfss
->port
!= NFS_PORT
)
683 seq_printf(m
, ",port=%u", nfss
->port
);
686 seq_printf(m
, ",port=%u", nfss
->port
);
688 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
689 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
690 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
693 nfs_show_mountd_options(m
, nfss
, showdefaults
);
695 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
697 if (nfss
->options
& NFS_OPTION_FSCACHE
)
698 seq_printf(m
, ",fsc");
700 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
701 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
702 seq_printf(m
, ",lookupcache=none");
704 seq_printf(m
, ",lookupcache=pos");
707 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
708 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
710 if (!local_flock
&& !local_fcntl
)
711 seq_printf(m
, ",local_lock=none");
712 else if (local_flock
&& local_fcntl
)
713 seq_printf(m
, ",local_lock=all");
714 else if (local_flock
)
715 seq_printf(m
, ",local_lock=flock");
717 seq_printf(m
, ",local_lock=posix");
721 * Describe the mount options on this VFS mountpoint
723 static int nfs_show_options(struct seq_file
*m
, struct vfsmount
*mnt
)
725 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
727 nfs_show_mount_options(m
, nfss
, 0);
729 seq_printf(m
, ",addr=%s",
730 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
736 static int nfs_show_devname(struct seq_file
*m
, struct vfsmount
*mnt
)
738 char *page
= (char *) __get_free_page(GFP_KERNEL
);
739 char *devname
, *dummy
;
743 devname
= nfs_path(&dummy
, mnt
->mnt_root
, page
, PAGE_SIZE
);
745 err
= PTR_ERR(devname
);
747 seq_escape(m
, devname
, " \t\n\\");
748 free_page((unsigned long)page
);
752 static int nfs_show_path(struct seq_file
*m
, struct vfsmount
*mnt
)
759 * Present statistical information for this VFS mountpoint
761 static int nfs_show_stats(struct seq_file
*m
, struct vfsmount
*mnt
)
764 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
765 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
766 struct nfs_iostats totals
= { };
768 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
771 * Display all mount option settings
773 seq_printf(m
, "\n\topts:\t");
774 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
775 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
776 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
777 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
778 nfs_show_mount_options(m
, nfss
, 1);
780 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
782 seq_printf(m
, "\n\tcaps:\t");
783 seq_printf(m
, "caps=0x%x", nfss
->caps
);
784 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
785 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
786 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
787 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
790 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
791 seq_printf(m
, "\n\tnfsv4:\t");
792 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
793 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
794 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
799 * Display security flavor in effect for this mount
801 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
803 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
806 * Display superblock I/O counters
808 for_each_possible_cpu(cpu
) {
809 struct nfs_iostats
*stats
;
812 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
814 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
815 totals
.events
[i
] += stats
->events
[i
];
816 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
817 totals
.bytes
[i
] += stats
->bytes
[i
];
818 #ifdef CONFIG_NFS_FSCACHE
819 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
820 totals
.fscache
[i
] += stats
->fscache
[i
];
826 seq_printf(m
, "\n\tevents:\t");
827 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
828 seq_printf(m
, "%lu ", totals
.events
[i
]);
829 seq_printf(m
, "\n\tbytes:\t");
830 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
831 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
832 #ifdef CONFIG_NFS_FSCACHE
833 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
834 seq_printf(m
, "\n\tfsc:\t");
835 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
836 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
841 rpc_print_iostats(m
, nfss
->client
);
847 * Begin unmount by attempting to remove all automounted mountpoints we added
848 * in response to xdev traversals and referrals
850 static void nfs_umount_begin(struct super_block
*sb
)
852 struct nfs_server
*server
;
853 struct rpc_clnt
*rpc
;
856 /* -EIO all pending I/O */
857 rpc
= server
->client_acl
;
859 rpc_killall_tasks(rpc
);
860 rpc
= server
->client
;
862 rpc_killall_tasks(rpc
);
865 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(unsigned int version
)
867 struct nfs_parsed_mount_data
*data
;
869 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
871 data
->acregmin
= NFS_DEF_ACREGMIN
;
872 data
->acregmax
= NFS_DEF_ACREGMAX
;
873 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
874 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
875 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
876 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
877 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
878 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
879 data
->auth_flavor_len
= 1;
880 data
->version
= version
;
881 data
->minorversion
= 0;
887 * Sanity-check a server address provided by the mount command.
889 * Address family must be initialized, and address must not be
890 * the ANY address for that family.
892 static int nfs_verify_server_address(struct sockaddr
*addr
)
894 switch (addr
->sa_family
) {
896 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
897 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
900 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
901 return !ipv6_addr_any(sa
);
905 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
910 * Select between a default port value and a user-specified port value.
911 * If a zero value is set, then autobind will be used.
913 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
914 const unsigned short default_port
)
916 if (*port
== NFS_UNSPEC_PORT
)
917 *port
= default_port
;
919 rpc_set_port(sap
, *port
);
923 * Sanity check the NFS transport protocol.
926 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
928 switch (mnt
->nfs_server
.protocol
) {
929 case XPRT_TRANSPORT_UDP
:
930 case XPRT_TRANSPORT_TCP
:
931 case XPRT_TRANSPORT_RDMA
:
934 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
939 * For text based NFSv2/v3 mounts, the mount protocol transport default
940 * settings should depend upon the specified NFS transport.
942 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
944 nfs_validate_transport_protocol(mnt
);
946 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
947 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
949 switch (mnt
->nfs_server
.protocol
) {
950 case XPRT_TRANSPORT_UDP
:
951 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
953 case XPRT_TRANSPORT_TCP
:
954 case XPRT_TRANSPORT_RDMA
:
955 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
960 * Parse the value of the 'sec=' option.
962 static int nfs_parse_security_flavors(char *value
,
963 struct nfs_parsed_mount_data
*mnt
)
965 substring_t args
[MAX_OPT_ARGS
];
967 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
969 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
971 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
974 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
977 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
980 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
983 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
986 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
989 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
992 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
995 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
998 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
1001 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
1007 mnt
->flags
|= NFS_MOUNT_SECFLAVOUR
;
1008 mnt
->auth_flavor_len
= 1;
1012 static int nfs_get_option_str(substring_t args
[], char **option
)
1015 *option
= match_strdup(args
);
1019 static int nfs_get_option_ul(substring_t args
[], unsigned long *option
)
1024 string
= match_strdup(args
);
1027 rc
= strict_strtoul(string
, 10, option
);
1034 * Error-check and convert a string of mount options from user space into
1035 * a data structure. The whole mount string is processed; bad options are
1036 * skipped as they are encountered. If there were no errors, return 1;
1037 * otherwise return 0 (zero).
1039 static int nfs_parse_mount_options(char *raw
,
1040 struct nfs_parsed_mount_data
*mnt
)
1042 char *p
, *string
, *secdata
;
1043 int rc
, sloppy
= 0, invalid_option
= 0;
1044 unsigned short protofamily
= AF_UNSPEC
;
1045 unsigned short mountfamily
= AF_UNSPEC
;
1048 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
1051 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1053 secdata
= alloc_secdata();
1057 rc
= security_sb_copy_data(raw
, secdata
);
1059 goto out_security_failure
;
1061 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1063 goto out_security_failure
;
1065 free_secdata(secdata
);
1067 while ((p
= strsep(&raw
, ",")) != NULL
) {
1068 substring_t args
[MAX_OPT_ARGS
];
1069 unsigned long option
;
1075 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1077 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1081 * boolean options: foo/nofoo
1084 mnt
->flags
|= NFS_MOUNT_SOFT
;
1087 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1090 mnt
->flags
|= NFS_MOUNT_POSIX
;
1093 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1096 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1099 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1102 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1105 mnt
->flags
|= NFS_MOUNT_NOAC
;
1108 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1109 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1110 NFS_MOUNT_LOCAL_FCNTL
);
1113 mnt
->flags
|= NFS_MOUNT_NONLM
;
1114 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1115 NFS_MOUNT_LOCAL_FCNTL
);
1118 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1122 mnt
->flags
|= NFS_MOUNT_VER3
;
1126 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1130 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1131 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1134 mnt
->flags
|= NFS_MOUNT_TCP
;
1135 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1138 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1139 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1140 xprt_load_transport(p
);
1143 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1146 mnt
->flags
|= NFS_MOUNT_NOACL
;
1149 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1151 case Opt_nordirplus
:
1152 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1154 case Opt_sharecache
:
1155 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1157 case Opt_nosharecache
:
1158 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1161 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1163 case Opt_noresvport
:
1164 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1167 mnt
->options
|= NFS_OPTION_FSCACHE
;
1168 kfree(mnt
->fscache_uniq
);
1169 mnt
->fscache_uniq
= NULL
;
1172 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1173 kfree(mnt
->fscache_uniq
);
1174 mnt
->fscache_uniq
= NULL
;
1178 * options that take numeric values
1181 if (nfs_get_option_ul(args
, &option
) ||
1183 goto out_invalid_value
;
1184 mnt
->nfs_server
.port
= option
;
1187 if (nfs_get_option_ul(args
, &option
))
1188 goto out_invalid_value
;
1189 mnt
->rsize
= option
;
1192 if (nfs_get_option_ul(args
, &option
))
1193 goto out_invalid_value
;
1194 mnt
->wsize
= option
;
1197 if (nfs_get_option_ul(args
, &option
))
1198 goto out_invalid_value
;
1199 mnt
->bsize
= option
;
1202 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1203 goto out_invalid_value
;
1204 mnt
->timeo
= option
;
1207 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1208 goto out_invalid_value
;
1209 mnt
->retrans
= option
;
1212 if (nfs_get_option_ul(args
, &option
))
1213 goto out_invalid_value
;
1214 mnt
->acregmin
= option
;
1217 if (nfs_get_option_ul(args
, &option
))
1218 goto out_invalid_value
;
1219 mnt
->acregmax
= option
;
1222 if (nfs_get_option_ul(args
, &option
))
1223 goto out_invalid_value
;
1224 mnt
->acdirmin
= option
;
1227 if (nfs_get_option_ul(args
, &option
))
1228 goto out_invalid_value
;
1229 mnt
->acdirmax
= option
;
1232 if (nfs_get_option_ul(args
, &option
))
1233 goto out_invalid_value
;
1234 mnt
->acregmin
= mnt
->acregmax
=
1235 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1238 if (nfs_get_option_ul(args
, &option
))
1239 goto out_invalid_value
;
1240 mnt
->namlen
= option
;
1243 if (nfs_get_option_ul(args
, &option
) ||
1245 goto out_invalid_value
;
1246 mnt
->mount_server
.port
= option
;
1249 if (nfs_get_option_ul(args
, &option
) ||
1250 option
< NFS_MNT_VERSION
||
1251 option
> NFS_MNT3_VERSION
)
1252 goto out_invalid_value
;
1253 mnt
->mount_server
.version
= option
;
1256 if (nfs_get_option_ul(args
, &option
))
1257 goto out_invalid_value
;
1260 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1264 mnt
->flags
|= NFS_MOUNT_VER3
;
1268 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1272 goto out_invalid_value
;
1275 case Opt_minorversion
:
1276 if (nfs_get_option_ul(args
, &option
))
1277 goto out_invalid_value
;
1278 if (option
> NFS4_MAX_MINOR_VERSION
)
1279 goto out_invalid_value
;
1280 mnt
->minorversion
= option
;
1284 * options that take text values
1287 string
= match_strdup(args
);
1290 rc
= nfs_parse_security_flavors(string
, mnt
);
1293 dfprintk(MOUNT
, "NFS: unrecognized "
1294 "security flavor\n");
1299 string
= match_strdup(args
);
1302 token
= match_token(string
,
1303 nfs_xprt_protocol_tokens
, args
);
1305 protofamily
= AF_INET
;
1308 protofamily
= AF_INET6
;
1310 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1311 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1314 protofamily
= AF_INET6
;
1316 mnt
->flags
|= NFS_MOUNT_TCP
;
1317 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1320 /* vector side protocols to TCP */
1321 mnt
->flags
|= NFS_MOUNT_TCP
;
1322 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1323 xprt_load_transport(string
);
1326 dfprintk(MOUNT
, "NFS: unrecognized "
1327 "transport protocol\n");
1333 case Opt_mountproto
:
1334 string
= match_strdup(args
);
1337 token
= match_token(string
,
1338 nfs_xprt_protocol_tokens
, args
);
1341 mountfamily
= AF_INET
;
1344 mountfamily
= AF_INET6
;
1346 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1349 mountfamily
= AF_INET6
;
1351 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1353 case Opt_xprt_rdma
: /* not used for side protocols */
1355 dfprintk(MOUNT
, "NFS: unrecognized "
1356 "transport protocol\n");
1361 string
= match_strdup(args
);
1364 mnt
->nfs_server
.addrlen
=
1365 rpc_pton(string
, strlen(string
),
1367 &mnt
->nfs_server
.address
,
1368 sizeof(mnt
->nfs_server
.address
));
1370 if (mnt
->nfs_server
.addrlen
== 0)
1371 goto out_invalid_address
;
1373 case Opt_clientaddr
:
1374 if (nfs_get_option_str(args
, &mnt
->client_address
))
1378 if (nfs_get_option_str(args
,
1379 &mnt
->mount_server
.hostname
))
1383 string
= match_strdup(args
);
1386 mnt
->mount_server
.addrlen
=
1387 rpc_pton(string
, strlen(string
),
1389 &mnt
->mount_server
.address
,
1390 sizeof(mnt
->mount_server
.address
));
1392 if (mnt
->mount_server
.addrlen
== 0)
1393 goto out_invalid_address
;
1395 case Opt_lookupcache
:
1396 string
= match_strdup(args
);
1399 token
= match_token(string
,
1400 nfs_lookupcache_tokens
, args
);
1403 case Opt_lookupcache_all
:
1404 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1406 case Opt_lookupcache_positive
:
1407 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1408 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1410 case Opt_lookupcache_none
:
1411 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1414 dfprintk(MOUNT
, "NFS: invalid "
1415 "lookupcache argument\n");
1419 case Opt_fscache_uniq
:
1420 if (nfs_get_option_str(args
, &mnt
->fscache_uniq
))
1422 mnt
->options
|= NFS_OPTION_FSCACHE
;
1424 case Opt_local_lock
:
1425 string
= match_strdup(args
);
1428 token
= match_token(string
, nfs_local_lock_tokens
,
1432 case Opt_local_lock_all
:
1433 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1434 NFS_MOUNT_LOCAL_FCNTL
);
1436 case Opt_local_lock_flock
:
1437 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1439 case Opt_local_lock_posix
:
1440 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1442 case Opt_local_lock_none
:
1443 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1444 NFS_MOUNT_LOCAL_FCNTL
);
1447 dfprintk(MOUNT
, "NFS: invalid "
1448 "local_lock argument\n");
1458 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1461 case Opt_deprecated
:
1462 dfprintk(MOUNT
, "NFS: ignoring mount option "
1468 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1473 if (!sloppy
&& invalid_option
)
1477 * verify that any proto=/mountproto= options match the address
1478 * familiies in the addr=/mountaddr= options.
1480 if (protofamily
!= AF_UNSPEC
&&
1481 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1482 goto out_proto_mismatch
;
1484 if (mountfamily
!= AF_UNSPEC
) {
1485 if (mnt
->mount_server
.addrlen
) {
1486 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1487 goto out_mountproto_mismatch
;
1489 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1490 goto out_mountproto_mismatch
;
1496 out_mountproto_mismatch
:
1497 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1501 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1503 out_invalid_address
:
1504 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1507 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1510 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1512 out_security_failure
:
1513 free_secdata(secdata
);
1514 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1519 * Match the requested auth flavors with the list returned by
1520 * the server. Returns zero and sets the mount's authentication
1521 * flavor on success; returns -EACCES if server does not support
1522 * the requested flavor.
1524 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1525 struct nfs_mount_request
*request
)
1527 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1530 * Certain releases of Linux's mountd return an empty
1531 * flavor list. To prevent behavioral regression with
1532 * these servers (ie. rejecting mounts that used to
1533 * succeed), revert to pre-2.6.32 behavior (no checking)
1534 * if the returned flavor list is empty.
1536 if (server_authlist_len
== 0)
1540 * We avoid sophisticated negotiating here, as there are
1541 * plenty of cases where we can get it wrong, providing
1542 * either too little or too much security.
1544 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1545 * flavor listed first. However, some servers list
1546 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1547 * preferred default, in args->auth_flavors[0] if user
1548 * didn't specify sec= mount option.
1550 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1551 for (j
= 0; j
< server_authlist_len
; j
++)
1552 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1553 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1554 request
->auth_flavs
[j
]);
1555 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1559 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1560 nfs_umount(request
);
1565 * Use the remote server's MOUNT service to request the NFS file handle
1566 * corresponding to the provided path.
1568 static int nfs_try_mount(struct nfs_parsed_mount_data
*args
,
1569 struct nfs_fh
*root_fh
)
1571 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1572 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1573 struct nfs_mount_request request
= {
1574 .sap
= (struct sockaddr
*)
1575 &args
->mount_server
.address
,
1576 .dirpath
= args
->nfs_server
.export_path
,
1577 .protocol
= args
->mount_server
.protocol
,
1579 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1580 .auth_flav_len
= &server_authlist_len
,
1581 .auth_flavs
= server_authlist
,
1585 if (args
->mount_server
.version
== 0) {
1586 switch (args
->version
) {
1588 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1591 args
->mount_server
.version
= NFS_MNT_VERSION
;
1594 request
.version
= args
->mount_server
.version
;
1596 if (args
->mount_server
.hostname
)
1597 request
.hostname
= args
->mount_server
.hostname
;
1599 request
.hostname
= args
->nfs_server
.hostname
;
1602 * Construct the mount server's address.
1604 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1605 memcpy(request
.sap
, &args
->nfs_server
.address
,
1606 args
->nfs_server
.addrlen
);
1607 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1609 request
.salen
= args
->mount_server
.addrlen
;
1610 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1613 * Now ask the mount server to map our export path
1616 status
= nfs_mount(&request
);
1618 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1619 request
.hostname
, status
);
1624 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1626 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1628 return nfs_walk_authlist(args
, &request
);
1632 * Split "dev_name" into "hostname:export_path".
1634 * The leftmost colon demarks the split between the server's hostname
1635 * and the export path. If the hostname starts with a left square
1636 * bracket, then it may contain colons.
1638 * Note: caller frees hostname and export path, even on error.
1640 static int nfs_parse_devname(const char *dev_name
,
1641 char **hostname
, size_t maxnamlen
,
1642 char **export_path
, size_t maxpathlen
)
1647 /* Is the host name protected with square brakcets? */
1648 if (*dev_name
== '[') {
1649 end
= strchr(++dev_name
, ']');
1650 if (end
== NULL
|| end
[1] != ':')
1651 goto out_bad_devname
;
1653 len
= end
- dev_name
;
1658 end
= strchr(dev_name
, ':');
1660 goto out_bad_devname
;
1661 len
= end
- dev_name
;
1663 /* kill possible hostname list: not supported */
1664 comma
= strchr(dev_name
, ',');
1665 if (comma
!= NULL
&& comma
< end
)
1669 if (len
> maxnamlen
)
1672 /* N.B. caller will free nfs_server.hostname in all cases */
1673 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1674 if (*hostname
== NULL
)
1676 len
= strlen(++end
);
1677 if (len
> maxpathlen
)
1679 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1683 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1687 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1691 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1695 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1696 return -ENAMETOOLONG
;
1699 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1700 return -ENAMETOOLONG
;
1704 * Validate the NFS2/NFS3 mount data
1705 * - fills in the mount root filehandle
1707 * For option strings, user space handles the following behaviors:
1709 * + DNS: mapping server host name to IP address ("addr=" option)
1711 * + failure mode: how to behave if a mount request can't be handled
1712 * immediately ("fg/bg" option)
1714 * + retry: how often to retry a mount request ("retry=" option)
1716 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1717 * mountproto=tcp after mountproto=udp, and so on
1719 static int nfs_validate_mount_data(void *options
,
1720 struct nfs_parsed_mount_data
*args
,
1721 struct nfs_fh
*mntfh
,
1722 const char *dev_name
)
1724 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1725 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1730 switch (data
->version
) {
1736 if (data
->flags
& NFS_MOUNT_VER3
)
1738 data
->root
.size
= NFS2_FHSIZE
;
1739 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1741 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1744 memset(data
->context
, 0, sizeof(data
->context
));
1746 if (data
->flags
& NFS_MOUNT_VER3
) {
1747 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1748 goto out_invalid_fh
;
1749 mntfh
->size
= data
->root
.size
;
1752 mntfh
->size
= NFS2_FHSIZE
;
1757 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1758 if (mntfh
->size
< sizeof(mntfh
->data
))
1759 memset(mntfh
->data
+ mntfh
->size
, 0,
1760 sizeof(mntfh
->data
) - mntfh
->size
);
1763 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1766 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1767 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1768 args
->rsize
= data
->rsize
;
1769 args
->wsize
= data
->wsize
;
1770 args
->timeo
= data
->timeo
;
1771 args
->retrans
= data
->retrans
;
1772 args
->acregmin
= data
->acregmin
;
1773 args
->acregmax
= data
->acregmax
;
1774 args
->acdirmin
= data
->acdirmin
;
1775 args
->acdirmax
= data
->acdirmax
;
1777 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1778 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1779 if (!nfs_verify_server_address(sap
))
1780 goto out_no_address
;
1782 if (!(data
->flags
& NFS_MOUNT_TCP
))
1783 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1784 /* N.B. caller will free nfs_server.hostname in all cases */
1785 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1786 args
->namlen
= data
->namlen
;
1787 args
->bsize
= data
->bsize
;
1789 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1790 args
->auth_flavors
[0] = data
->pseudoflavor
;
1791 if (!args
->nfs_server
.hostname
)
1794 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1795 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1796 NFS_MOUNT_LOCAL_FCNTL
);
1798 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1799 NFS_MOUNT_LOCAL_FCNTL
);
1801 * The legacy version 6 binary mount data from userspace has a
1802 * field used only to transport selinux information into the
1803 * the kernel. To continue to support that functionality we
1804 * have a touch of selinux knowledge here in the NFS code. The
1805 * userspace code converted context=blah to just blah so we are
1806 * converting back to the full string selinux understands.
1808 if (data
->context
[0]){
1809 #ifdef CONFIG_SECURITY_SELINUX
1811 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1814 strcpy(opts_str
, "context=");
1815 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1816 strcat(opts_str
, &data
->context
[0]);
1817 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1830 if (nfs_parse_mount_options((char *)options
, args
) == 0)
1833 if (!nfs_verify_server_address(sap
))
1834 goto out_no_address
;
1836 if (args
->version
== 4)
1837 #ifdef CONFIG_NFS_V4
1838 return nfs4_validate_text_mount_data(options
,
1841 goto out_v4_not_compiled
;
1844 nfs_set_port(sap
, &args
->nfs_server
.port
, 0);
1846 nfs_set_mount_transport_protocol(args
);
1848 status
= nfs_parse_devname(dev_name
,
1849 &args
->nfs_server
.hostname
,
1851 &args
->nfs_server
.export_path
,
1854 status
= nfs_try_mount(args
, mntfh
);
1856 kfree(args
->nfs_server
.export_path
);
1857 args
->nfs_server
.export_path
= NULL
;
1866 #ifndef CONFIG_NFS_V3
1867 if (args
->version
== 3)
1868 goto out_v3_not_compiled
;
1869 #endif /* !CONFIG_NFS_V3 */
1874 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1878 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1883 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1886 #ifndef CONFIG_NFS_V3
1887 out_v3_not_compiled
:
1888 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1889 return -EPROTONOSUPPORT
;
1890 #endif /* !CONFIG_NFS_V3 */
1892 #ifndef CONFIG_NFS_V4
1893 out_v4_not_compiled
:
1894 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
1895 return -EPROTONOSUPPORT
;
1896 #endif /* !CONFIG_NFS_V4 */
1899 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
1903 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
1907 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
1912 nfs_compare_remount_data(struct nfs_server
*nfss
,
1913 struct nfs_parsed_mount_data
*data
)
1915 if (data
->flags
!= nfss
->flags
||
1916 data
->rsize
!= nfss
->rsize
||
1917 data
->wsize
!= nfss
->wsize
||
1918 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
1919 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
1920 data
->acregmin
!= nfss
->acregmin
/ HZ
||
1921 data
->acregmax
!= nfss
->acregmax
/ HZ
||
1922 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
1923 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
1924 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
1925 data
->nfs_server
.port
!= nfss
->port
||
1926 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
1927 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
1928 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
1935 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
1938 struct nfs_server
*nfss
= sb
->s_fs_info
;
1939 struct nfs_parsed_mount_data
*data
;
1940 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
1941 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
1942 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
1945 * Userspace mount programs that send binary options generally send
1946 * them populated with default values. We have no way to know which
1947 * ones were explicitly specified. Fall back to legacy behavior and
1948 * just return success.
1950 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
1951 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
1952 options
->version
<= 6))))
1955 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
1959 /* fill out struct with values from existing mount */
1960 data
->flags
= nfss
->flags
;
1961 data
->rsize
= nfss
->rsize
;
1962 data
->wsize
= nfss
->wsize
;
1963 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
1964 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
1965 data
->acregmin
= nfss
->acregmin
/ HZ
;
1966 data
->acregmax
= nfss
->acregmax
/ HZ
;
1967 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
1968 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
1969 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
1970 data
->nfs_server
.port
= nfss
->port
;
1971 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
1972 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
1973 data
->nfs_server
.addrlen
);
1975 /* overwrite those values with any that were specified */
1976 error
= nfs_parse_mount_options((char *)options
, data
);
1981 * noac is a special case. It implies -o sync, but that's not
1982 * necessarily reflected in the mtab options. do_remount_sb
1983 * will clear MS_SYNCHRONOUS if -o sync wasn't specified in the
1984 * remount options, so we have to explicitly reset it.
1986 if (data
->flags
& NFS_MOUNT_NOAC
)
1987 *flags
|= MS_SYNCHRONOUS
;
1989 /* compare new mount options with old ones */
1990 error
= nfs_compare_remount_data(nfss
, data
);
1997 * Initialise the common bits of the superblock
1999 static inline void nfs_initialise_sb(struct super_block
*sb
)
2001 struct nfs_server
*server
= NFS_SB(sb
);
2003 sb
->s_magic
= NFS_SUPER_MAGIC
;
2005 /* We probably want something more informative here */
2006 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2007 "%x:%x", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2009 if (sb
->s_blocksize
== 0)
2010 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2011 &sb
->s_blocksize_bits
);
2013 if (server
->flags
& NFS_MOUNT_NOAC
)
2014 sb
->s_flags
|= MS_SYNCHRONOUS
;
2016 sb
->s_bdi
= &server
->backing_dev_info
;
2018 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2022 * Finish setting up an NFS2/3 superblock
2024 static void nfs_fill_super(struct super_block
*sb
,
2025 struct nfs_parsed_mount_data
*data
)
2027 struct nfs_server
*server
= NFS_SB(sb
);
2029 sb
->s_blocksize_bits
= 0;
2030 sb
->s_blocksize
= 0;
2032 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2034 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2035 /* The VFS shouldn't apply the umask to mode bits. We will do
2036 * so ourselves when necessary.
2038 sb
->s_flags
|= MS_POSIXACL
;
2039 sb
->s_time_gran
= 1;
2042 sb
->s_op
= &nfs_sops
;
2043 nfs_initialise_sb(sb
);
2047 * Finish setting up a cloned NFS2/3 superblock
2049 static void nfs_clone_super(struct super_block
*sb
,
2050 const struct super_block
*old_sb
)
2052 struct nfs_server
*server
= NFS_SB(sb
);
2054 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2055 sb
->s_blocksize
= old_sb
->s_blocksize
;
2056 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2058 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2059 /* The VFS shouldn't apply the umask to mode bits. We will do
2060 * so ourselves when necessary.
2062 sb
->s_flags
|= MS_POSIXACL
;
2063 sb
->s_time_gran
= 1;
2066 sb
->s_op
= old_sb
->s_op
;
2067 nfs_initialise_sb(sb
);
2070 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2072 const struct nfs_server
*a
= s
->s_fs_info
;
2073 const struct rpc_clnt
*clnt_a
= a
->client
;
2074 const struct rpc_clnt
*clnt_b
= b
->client
;
2076 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2078 if (a
->nfs_client
!= b
->nfs_client
)
2080 if (a
->flags
!= b
->flags
)
2082 if (a
->wsize
!= b
->wsize
)
2084 if (a
->rsize
!= b
->rsize
)
2086 if (a
->acregmin
!= b
->acregmin
)
2088 if (a
->acregmax
!= b
->acregmax
)
2090 if (a
->acdirmin
!= b
->acdirmin
)
2092 if (a
->acdirmax
!= b
->acdirmax
)
2094 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2101 struct nfs_sb_mountdata
{
2102 struct nfs_server
*server
;
2106 static int nfs_set_super(struct super_block
*s
, void *data
)
2108 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2109 struct nfs_server
*server
= sb_mntdata
->server
;
2112 s
->s_flags
= sb_mntdata
->mntflags
;
2113 s
->s_fs_info
= server
;
2114 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
2115 ret
= set_anon_super(s
, server
);
2117 server
->s_dev
= s
->s_dev
;
2121 static int nfs_compare_super_address(struct nfs_server
*server1
,
2122 struct nfs_server
*server2
)
2124 struct sockaddr
*sap1
, *sap2
;
2126 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2127 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2129 if (sap1
->sa_family
!= sap2
->sa_family
)
2132 switch (sap1
->sa_family
) {
2134 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2135 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2136 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2138 if (sin1
->sin_port
!= sin2
->sin_port
)
2143 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2144 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2145 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2147 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2158 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2160 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2161 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2162 int mntflags
= sb_mntdata
->mntflags
;
2164 if (!nfs_compare_super_address(old
, server
))
2166 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2167 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2169 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2171 return nfs_compare_mount_options(sb
, server
, mntflags
);
2174 static int nfs_bdi_register(struct nfs_server
*server
)
2176 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2179 static struct dentry
*nfs_fs_mount(struct file_system_type
*fs_type
,
2180 int flags
, const char *dev_name
, void *raw_data
)
2182 struct nfs_server
*server
= NULL
;
2183 struct super_block
*s
;
2184 struct nfs_parsed_mount_data
*data
;
2185 struct nfs_fh
*mntfh
;
2186 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2187 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2188 struct nfs_sb_mountdata sb_mntdata
= {
2193 data
= nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION
);
2194 mntfh
= nfs_alloc_fhandle();
2195 if (data
== NULL
|| mntfh
== NULL
)
2198 security_init_mnt_opts(&data
->lsm_opts
);
2200 /* Validate the mount data */
2201 error
= nfs_validate_mount_data(raw_data
, data
, mntfh
, dev_name
);
2203 mntroot
= ERR_PTR(error
);
2207 #ifdef CONFIG_NFS_V4
2208 if (data
->version
== 4) {
2209 mntroot
= nfs4_try_mount(flags
, dev_name
, data
);
2210 kfree(data
->client_address
);
2211 kfree(data
->nfs_server
.export_path
);
2214 #endif /* CONFIG_NFS_V4 */
2216 /* Get a volume representation */
2217 server
= nfs_create_server(data
, mntfh
);
2218 if (IS_ERR(server
)) {
2219 mntroot
= ERR_CAST(server
);
2222 sb_mntdata
.server
= server
;
2224 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2225 compare_super
= NULL
;
2227 /* Get a superblock - note that we may end up sharing one that already exists */
2228 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2230 mntroot
= ERR_CAST(s
);
2234 if (s
->s_fs_info
!= server
) {
2235 nfs_free_server(server
);
2238 error
= nfs_bdi_register(server
);
2240 mntroot
= ERR_PTR(error
);
2241 goto error_splat_bdi
;
2246 /* initial superblock/root creation */
2247 nfs_fill_super(s
, data
);
2248 nfs_fscache_get_super_cookie(s
, data
->fscache_uniq
, NULL
);
2251 mntroot
= nfs_get_root(s
, mntfh
, dev_name
);
2252 if (IS_ERR(mntroot
))
2253 goto error_splat_super
;
2255 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2257 goto error_splat_root
;
2259 s
->s_flags
|= MS_ACTIVE
;
2262 kfree(data
->nfs_server
.hostname
);
2263 kfree(data
->mount_server
.hostname
);
2264 kfree(data
->fscache_uniq
);
2265 security_free_mnt_opts(&data
->lsm_opts
);
2267 nfs_free_fhandle(mntfh
);
2272 nfs_free_server(server
);
2277 mntroot
= ERR_PTR(error
);
2279 if (server
&& !s
->s_root
)
2280 bdi_unregister(&server
->backing_dev_info
);
2282 deactivate_locked_super(s
);
2287 * Ensure that we unregister the bdi before kill_anon_super
2288 * releases the device name
2290 static void nfs_put_super(struct super_block
*s
)
2292 struct nfs_server
*server
= NFS_SB(s
);
2294 bdi_unregister(&server
->backing_dev_info
);
2298 * Destroy an NFS2/3 superblock
2300 static void nfs_kill_super(struct super_block
*s
)
2302 struct nfs_server
*server
= NFS_SB(s
);
2305 nfs_fscache_release_super_cookie(s
);
2306 nfs_free_server(server
);
2310 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2312 static struct dentry
*
2313 nfs_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2314 const char *dev_name
, void *raw_data
)
2316 struct nfs_clone_mount
*data
= raw_data
;
2317 struct super_block
*s
;
2318 struct nfs_server
*server
;
2319 struct dentry
*mntroot
;
2320 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2321 struct nfs_sb_mountdata sb_mntdata
= {
2326 dprintk("--> nfs_xdev_mount()\n");
2328 /* create a new volume representation */
2329 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2330 if (IS_ERR(server
)) {
2331 error
= PTR_ERR(server
);
2332 goto out_err_noserver
;
2334 sb_mntdata
.server
= server
;
2336 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2337 compare_super
= NULL
;
2339 /* Get a superblock - note that we may end up sharing one that already exists */
2340 s
= sget(&nfs_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2346 if (s
->s_fs_info
!= server
) {
2347 nfs_free_server(server
);
2350 error
= nfs_bdi_register(server
);
2352 goto error_splat_bdi
;
2356 /* initial superblock/root creation */
2357 nfs_clone_super(s
, data
->sb
);
2358 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2361 mntroot
= nfs_get_root(s
, data
->fh
, dev_name
);
2362 if (IS_ERR(mntroot
)) {
2363 error
= PTR_ERR(mntroot
);
2364 goto error_splat_super
;
2366 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2369 goto error_splat_super
;
2372 s
->s_flags
|= MS_ACTIVE
;
2374 /* clone any lsm security options from the parent to the new sb */
2375 security_sb_clone_mnt_opts(data
->sb
, s
);
2377 dprintk("<-- nfs_xdev_mount() = 0\n");
2381 nfs_free_server(server
);
2383 dprintk("<-- nfs_xdev_mount() = %d [error]\n", error
);
2384 return ERR_PTR(error
);
2387 if (server
&& !s
->s_root
)
2388 bdi_unregister(&server
->backing_dev_info
);
2390 deactivate_locked_super(s
);
2391 dprintk("<-- nfs_xdev_mount() = %d [splat]\n", error
);
2392 return ERR_PTR(error
);
2395 #ifdef CONFIG_NFS_V4
2398 * Finish setting up a cloned NFS4 superblock
2400 static void nfs4_clone_super(struct super_block
*sb
,
2401 const struct super_block
*old_sb
)
2403 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2404 sb
->s_blocksize
= old_sb
->s_blocksize
;
2405 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2406 sb
->s_time_gran
= 1;
2407 sb
->s_op
= old_sb
->s_op
;
2409 * The VFS shouldn't apply the umask to mode bits. We will do
2410 * so ourselves when necessary.
2412 sb
->s_flags
|= MS_POSIXACL
;
2413 sb
->s_xattr
= old_sb
->s_xattr
;
2414 nfs_initialise_sb(sb
);
2418 * Set up an NFS4 superblock
2420 static void nfs4_fill_super(struct super_block
*sb
)
2422 sb
->s_time_gran
= 1;
2423 sb
->s_op
= &nfs4_sops
;
2425 * The VFS shouldn't apply the umask to mode bits. We will do
2426 * so ourselves when necessary.
2428 sb
->s_flags
|= MS_POSIXACL
;
2429 sb
->s_xattr
= nfs4_xattr_handlers
;
2430 nfs_initialise_sb(sb
);
2433 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2435 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2436 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2439 static int nfs4_validate_text_mount_data(void *options
,
2440 struct nfs_parsed_mount_data
*args
,
2441 const char *dev_name
)
2443 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2445 nfs_set_port(sap
, &args
->nfs_server
.port
, NFS_PORT
);
2447 nfs_validate_transport_protocol(args
);
2449 nfs4_validate_mount_flags(args
);
2451 if (args
->version
!= 4) {
2453 "NFS4: Illegal mount version\n");
2457 if (args
->auth_flavor_len
> 1) {
2459 "NFS4: Too many RPC auth flavours specified\n");
2463 if (args
->client_address
== NULL
) {
2465 "NFS4: mount program didn't pass callback address\n");
2469 return nfs_parse_devname(dev_name
,
2470 &args
->nfs_server
.hostname
,
2472 &args
->nfs_server
.export_path
,
2477 * Validate NFSv4 mount options
2479 static int nfs4_validate_mount_data(void *options
,
2480 struct nfs_parsed_mount_data
*args
,
2481 const char *dev_name
)
2483 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2484 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2490 switch (data
->version
) {
2492 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2493 goto out_no_address
;
2494 if (data
->host_addrlen
== 0)
2495 goto out_no_address
;
2496 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2497 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2499 if (!nfs_verify_server_address(sap
))
2500 goto out_no_address
;
2502 if (data
->auth_flavourlen
) {
2503 if (data
->auth_flavourlen
> 1)
2504 goto out_inval_auth
;
2505 if (copy_from_user(&args
->auth_flavors
[0],
2506 data
->auth_flavours
,
2507 sizeof(args
->auth_flavors
[0])))
2511 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2514 args
->nfs_server
.hostname
= c
;
2516 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2519 args
->nfs_server
.export_path
= c
;
2520 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2522 c
= strndup_user(data
->client_addr
.data
, 16);
2525 args
->client_address
= c
;
2528 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2532 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2533 args
->rsize
= data
->rsize
;
2534 args
->wsize
= data
->wsize
;
2535 args
->timeo
= data
->timeo
;
2536 args
->retrans
= data
->retrans
;
2537 args
->acregmin
= data
->acregmin
;
2538 args
->acregmax
= data
->acregmax
;
2539 args
->acdirmin
= data
->acdirmin
;
2540 args
->acdirmax
= data
->acdirmax
;
2541 args
->nfs_server
.protocol
= data
->proto
;
2542 nfs_validate_transport_protocol(args
);
2546 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2549 if (!nfs_verify_server_address(sap
))
2552 return nfs4_validate_text_mount_data(options
, args
, dev_name
);
2558 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2562 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2563 data
->auth_flavourlen
);
2567 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2572 * Get the superblock for the NFS4 root partition
2574 static struct dentry
*
2575 nfs4_remote_mount(struct file_system_type
*fs_type
, int flags
,
2576 const char *dev_name
, void *raw_data
)
2578 struct nfs_parsed_mount_data
*data
= raw_data
;
2579 struct super_block
*s
;
2580 struct nfs_server
*server
;
2581 struct nfs_fh
*mntfh
;
2582 struct dentry
*mntroot
;
2583 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2584 struct nfs_sb_mountdata sb_mntdata
= {
2587 int error
= -ENOMEM
;
2589 mntfh
= nfs_alloc_fhandle();
2590 if (data
== NULL
|| mntfh
== NULL
)
2593 security_init_mnt_opts(&data
->lsm_opts
);
2595 /* Get a volume representation */
2596 server
= nfs4_create_server(data
, mntfh
);
2597 if (IS_ERR(server
)) {
2598 error
= PTR_ERR(server
);
2601 sb_mntdata
.server
= server
;
2603 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2604 compare_super
= NULL
;
2606 /* Get a superblock - note that we may end up sharing one that already exists */
2607 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2613 if (s
->s_fs_info
!= server
) {
2614 nfs_free_server(server
);
2617 error
= nfs_bdi_register(server
);
2619 goto error_splat_bdi
;
2623 /* initial superblock/root creation */
2625 nfs_fscache_get_super_cookie(
2626 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2629 mntroot
= nfs4_get_root(s
, mntfh
, dev_name
);
2630 if (IS_ERR(mntroot
)) {
2631 error
= PTR_ERR(mntroot
);
2632 goto error_splat_super
;
2635 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2637 goto error_splat_root
;
2639 s
->s_flags
|= MS_ACTIVE
;
2641 security_free_mnt_opts(&data
->lsm_opts
);
2642 nfs_free_fhandle(mntfh
);
2646 security_free_mnt_opts(&data
->lsm_opts
);
2648 nfs_free_fhandle(mntfh
);
2649 return ERR_PTR(error
);
2652 nfs_free_server(server
);
2658 if (server
&& !s
->s_root
)
2659 bdi_unregister(&server
->backing_dev_info
);
2661 deactivate_locked_super(s
);
2665 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2666 int flags
, void *data
, const char *hostname
)
2668 struct vfsmount
*root_mnt
;
2672 len
= strlen(hostname
) + 3;
2673 root_devname
= kmalloc(len
, GFP_KERNEL
);
2674 if (root_devname
== NULL
)
2675 return ERR_PTR(-ENOMEM
);
2676 snprintf(root_devname
, len
, "%s:/", hostname
);
2677 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2678 kfree(root_devname
);
2682 struct nfs_referral_count
{
2683 struct list_head list
;
2684 const struct task_struct
*task
;
2685 unsigned int referral_count
;
2688 static LIST_HEAD(nfs_referral_count_list
);
2689 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2691 static struct nfs_referral_count
*nfs_find_referral_count(void)
2693 struct nfs_referral_count
*p
;
2695 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2696 if (p
->task
== current
)
2702 #define NFS_MAX_NESTED_REFERRALS 2
2704 static int nfs_referral_loop_protect(void)
2706 struct nfs_referral_count
*p
, *new;
2709 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2712 new->task
= current
;
2713 new->referral_count
= 1;
2716 spin_lock(&nfs_referral_count_list_lock
);
2717 p
= nfs_find_referral_count();
2719 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2722 p
->referral_count
++;
2724 list_add(&new->list
, &nfs_referral_count_list
);
2727 spin_unlock(&nfs_referral_count_list_lock
);
2733 static void nfs_referral_loop_unprotect(void)
2735 struct nfs_referral_count
*p
;
2737 spin_lock(&nfs_referral_count_list_lock
);
2738 p
= nfs_find_referral_count();
2739 p
->referral_count
--;
2740 if (p
->referral_count
== 0)
2744 spin_unlock(&nfs_referral_count_list_lock
);
2748 static struct dentry
*nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2749 const char *export_path
)
2751 struct nameidata
*nd
= NULL
;
2752 struct mnt_namespace
*ns_private
;
2753 struct super_block
*s
;
2754 struct dentry
*dentry
;
2757 nd
= kmalloc(sizeof(*nd
), GFP_KERNEL
);
2759 return ERR_PTR(-ENOMEM
);
2761 ns_private
= create_mnt_ns(root_mnt
);
2762 ret
= PTR_ERR(ns_private
);
2763 if (IS_ERR(ns_private
))
2766 ret
= nfs_referral_loop_protect();
2768 goto out_put_mnt_ns
;
2770 ret
= vfs_path_lookup(root_mnt
->mnt_root
, root_mnt
,
2771 export_path
, LOOKUP_FOLLOW
, nd
);
2773 nfs_referral_loop_unprotect();
2774 put_mnt_ns(ns_private
);
2779 s
= nd
->path
.mnt
->mnt_sb
;
2780 atomic_inc(&s
->s_active
);
2781 dentry
= dget(nd
->path
.dentry
);
2783 path_put(&nd
->path
);
2785 down_write(&s
->s_umount
);
2788 put_mnt_ns(ns_private
);
2793 return ERR_PTR(ret
);
2796 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
2797 struct nfs_parsed_mount_data
*data
)
2800 struct vfsmount
*root_mnt
;
2803 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2805 export_path
= data
->nfs_server
.export_path
;
2806 data
->nfs_server
.export_path
= "/";
2807 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2808 data
->nfs_server
.hostname
);
2809 data
->nfs_server
.export_path
= export_path
;
2811 res
= ERR_CAST(root_mnt
);
2812 if (!IS_ERR(root_mnt
))
2813 res
= nfs_follow_remote_path(root_mnt
, export_path
);
2815 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %ld%s\n",
2816 IS_ERR(res
) ? PTR_ERR(res
) : 0,
2817 IS_ERR(res
) ? " [error]" : "");
2822 * Get the superblock for an NFS4 mountpoint
2824 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
2825 int flags
, const char *dev_name
, void *raw_data
)
2827 struct nfs_parsed_mount_data
*data
;
2828 int error
= -ENOMEM
;
2829 struct dentry
*res
= ERR_PTR(-ENOMEM
);
2831 data
= nfs_alloc_parsed_mount_data(4);
2835 /* Validate the mount data */
2836 error
= nfs4_validate_mount_data(raw_data
, data
, dev_name
);
2838 res
= ERR_PTR(error
);
2842 res
= nfs4_try_mount(flags
, dev_name
, data
);
2844 error
= PTR_ERR(res
);
2847 kfree(data
->client_address
);
2848 kfree(data
->nfs_server
.export_path
);
2849 kfree(data
->nfs_server
.hostname
);
2850 kfree(data
->fscache_uniq
);
2853 dprintk("<-- nfs4_mount() = %d%s\n", error
,
2854 error
!= 0 ? " [error]" : "");
2858 static void nfs4_kill_super(struct super_block
*sb
)
2860 struct nfs_server
*server
= NFS_SB(sb
);
2862 dprintk("--> %s\n", __func__
);
2863 nfs_super_return_all_delegations(sb
);
2864 kill_anon_super(sb
);
2865 nfs_fscache_release_super_cookie(sb
);
2866 nfs_free_server(server
);
2867 dprintk("<-- %s\n", __func__
);
2871 * Clone an NFS4 server record on xdev traversal (FSID-change)
2873 static struct dentry
*
2874 nfs4_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2875 const char *dev_name
, void *raw_data
)
2877 struct nfs_clone_mount
*data
= raw_data
;
2878 struct super_block
*s
;
2879 struct nfs_server
*server
;
2880 struct dentry
*mntroot
;
2881 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2882 struct nfs_sb_mountdata sb_mntdata
= {
2887 dprintk("--> nfs4_xdev_mount()\n");
2889 /* create a new volume representation */
2890 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2891 if (IS_ERR(server
)) {
2892 error
= PTR_ERR(server
);
2893 goto out_err_noserver
;
2895 sb_mntdata
.server
= server
;
2897 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2898 compare_super
= NULL
;
2900 /* Get a superblock - note that we may end up sharing one that already exists */
2901 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2907 if (s
->s_fs_info
!= server
) {
2908 nfs_free_server(server
);
2911 error
= nfs_bdi_register(server
);
2913 goto error_splat_bdi
;
2917 /* initial superblock/root creation */
2918 nfs4_clone_super(s
, data
->sb
);
2919 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2922 mntroot
= nfs4_get_root(s
, data
->fh
, dev_name
);
2923 if (IS_ERR(mntroot
)) {
2924 error
= PTR_ERR(mntroot
);
2925 goto error_splat_super
;
2927 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2930 goto error_splat_super
;
2933 s
->s_flags
|= MS_ACTIVE
;
2935 security_sb_clone_mnt_opts(data
->sb
, s
);
2937 dprintk("<-- nfs4_xdev_mount() = 0\n");
2941 nfs_free_server(server
);
2943 dprintk("<-- nfs4_xdev_mount() = %d [error]\n", error
);
2944 return ERR_PTR(error
);
2947 if (server
&& !s
->s_root
)
2948 bdi_unregister(&server
->backing_dev_info
);
2950 deactivate_locked_super(s
);
2951 dprintk("<-- nfs4_xdev_mount() = %d [splat]\n", error
);
2952 return ERR_PTR(error
);
2955 static struct dentry
*
2956 nfs4_remote_referral_mount(struct file_system_type
*fs_type
, int flags
,
2957 const char *dev_name
, void *raw_data
)
2959 struct nfs_clone_mount
*data
= raw_data
;
2960 struct super_block
*s
;
2961 struct nfs_server
*server
;
2962 struct dentry
*mntroot
;
2963 struct nfs_fh
*mntfh
;
2964 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2965 struct nfs_sb_mountdata sb_mntdata
= {
2968 int error
= -ENOMEM
;
2970 dprintk("--> nfs4_referral_get_sb()\n");
2972 mntfh
= nfs_alloc_fhandle();
2976 /* create a new volume representation */
2977 server
= nfs4_create_referral_server(data
, mntfh
);
2978 if (IS_ERR(server
)) {
2979 error
= PTR_ERR(server
);
2980 goto out_err_noserver
;
2982 sb_mntdata
.server
= server
;
2984 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2985 compare_super
= NULL
;
2987 /* Get a superblock - note that we may end up sharing one that already exists */
2988 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2994 if (s
->s_fs_info
!= server
) {
2995 nfs_free_server(server
);
2998 error
= nfs_bdi_register(server
);
3000 goto error_splat_bdi
;
3004 /* initial superblock/root creation */
3006 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3009 mntroot
= nfs4_get_root(s
, mntfh
, dev_name
);
3010 if (IS_ERR(mntroot
)) {
3011 error
= PTR_ERR(mntroot
);
3012 goto error_splat_super
;
3014 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3017 goto error_splat_super
;
3020 s
->s_flags
|= MS_ACTIVE
;
3022 security_sb_clone_mnt_opts(data
->sb
, s
);
3024 nfs_free_fhandle(mntfh
);
3025 dprintk("<-- nfs4_referral_get_sb() = 0\n");
3029 nfs_free_server(server
);
3031 nfs_free_fhandle(mntfh
);
3033 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error
);
3034 return ERR_PTR(error
);
3037 if (server
&& !s
->s_root
)
3038 bdi_unregister(&server
->backing_dev_info
);
3040 deactivate_locked_super(s
);
3041 nfs_free_fhandle(mntfh
);
3042 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error
);
3043 return ERR_PTR(error
);
3047 * Create an NFS4 server record on referral traversal
3049 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
3050 int flags
, const char *dev_name
, void *raw_data
)
3052 struct nfs_clone_mount
*data
= raw_data
;
3054 struct vfsmount
*root_mnt
;
3057 dprintk("--> nfs4_referral_mount()\n");
3059 export_path
= data
->mnt_path
;
3060 data
->mnt_path
= "/";
3062 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
3063 flags
, data
, data
->hostname
);
3064 data
->mnt_path
= export_path
;
3066 res
= ERR_CAST(root_mnt
);
3067 if (!IS_ERR(root_mnt
))
3068 res
= nfs_follow_remote_path(root_mnt
, export_path
);
3069 dprintk("<-- nfs4_referral_mount() = %ld%s\n",
3070 IS_ERR(res
) ? PTR_ERR(res
) : 0,
3071 IS_ERR(res
) ? " [error]" : "");
3075 #endif /* CONFIG_NFS_V4 */