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_stats(struct seq_file
*, struct vfsmount
*);
267 static int nfs_get_sb(struct file_system_type
*, int, const char *, void *, struct vfsmount
*);
268 static struct dentry
*nfs_xdev_mount(struct file_system_type
*fs_type
,
269 int flags
, const char *dev_name
, void *raw_data
);
270 static void nfs_put_super(struct super_block
*);
271 static void nfs_kill_super(struct super_block
*);
272 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
274 static struct file_system_type nfs_fs_type
= {
275 .owner
= THIS_MODULE
,
277 .get_sb
= nfs_get_sb
,
278 .kill_sb
= nfs_kill_super
,
279 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
282 struct file_system_type nfs_xdev_fs_type
= {
283 .owner
= THIS_MODULE
,
285 .mount
= nfs_xdev_mount
,
286 .kill_sb
= nfs_kill_super
,
287 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
290 static const struct super_operations nfs_sops
= {
291 .alloc_inode
= nfs_alloc_inode
,
292 .destroy_inode
= nfs_destroy_inode
,
293 .write_inode
= nfs_write_inode
,
294 .put_super
= nfs_put_super
,
295 .statfs
= nfs_statfs
,
296 .evict_inode
= nfs_evict_inode
,
297 .umount_begin
= nfs_umount_begin
,
298 .show_options
= nfs_show_options
,
299 .show_stats
= nfs_show_stats
,
300 .remount_fs
= nfs_remount
,
304 static int nfs4_validate_text_mount_data(void *options
,
305 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
306 static int nfs4_try_mount(int flags
, const char *dev_name
,
307 struct nfs_parsed_mount_data
*data
, struct vfsmount
*mnt
);
308 static int nfs4_get_sb(struct file_system_type
*fs_type
,
309 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
310 static struct dentry
*nfs4_remote_mount(struct file_system_type
*fs_type
,
311 int flags
, const char *dev_name
, void *raw_data
);
312 static struct dentry
*nfs4_xdev_mount(struct file_system_type
*fs_type
,
313 int flags
, const char *dev_name
, void *raw_data
);
314 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
315 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
316 static struct dentry
*nfs4_remote_referral_mount(struct file_system_type
*fs_type
,
317 int flags
, const char *dev_name
, void *raw_data
);
318 static void nfs4_kill_super(struct super_block
*sb
);
320 static struct file_system_type nfs4_fs_type
= {
321 .owner
= THIS_MODULE
,
323 .get_sb
= nfs4_get_sb
,
324 .kill_sb
= nfs4_kill_super
,
325 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
328 static struct file_system_type nfs4_remote_fs_type
= {
329 .owner
= THIS_MODULE
,
331 .mount
= nfs4_remote_mount
,
332 .kill_sb
= nfs4_kill_super
,
333 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
336 struct file_system_type nfs4_xdev_fs_type
= {
337 .owner
= THIS_MODULE
,
339 .mount
= nfs4_xdev_mount
,
340 .kill_sb
= nfs4_kill_super
,
341 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
344 static struct file_system_type nfs4_remote_referral_fs_type
= {
345 .owner
= THIS_MODULE
,
347 .mount
= nfs4_remote_referral_mount
,
348 .kill_sb
= nfs4_kill_super
,
349 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
352 struct file_system_type nfs4_referral_fs_type
= {
353 .owner
= THIS_MODULE
,
355 .get_sb
= nfs4_referral_get_sb
,
356 .kill_sb
= nfs4_kill_super
,
357 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
360 static const struct super_operations nfs4_sops
= {
361 .alloc_inode
= nfs_alloc_inode
,
362 .destroy_inode
= nfs_destroy_inode
,
363 .write_inode
= nfs_write_inode
,
364 .put_super
= nfs_put_super
,
365 .statfs
= nfs_statfs
,
366 .evict_inode
= nfs4_evict_inode
,
367 .umount_begin
= nfs_umount_begin
,
368 .show_options
= nfs_show_options
,
369 .show_stats
= nfs_show_stats
,
370 .remount_fs
= nfs_remount
,
374 static struct shrinker acl_shrinker
= {
375 .shrink
= nfs_access_cache_shrinker
,
376 .seeks
= DEFAULT_SEEKS
,
380 * Register the NFS filesystems
382 int __init
register_nfs_fs(void)
386 ret
= register_filesystem(&nfs_fs_type
);
390 ret
= nfs_register_sysctl();
394 ret
= register_filesystem(&nfs4_fs_type
);
398 register_shrinker(&acl_shrinker
);
403 nfs_unregister_sysctl();
406 unregister_filesystem(&nfs_fs_type
);
412 * Unregister the NFS filesystems
414 void __exit
unregister_nfs_fs(void)
416 unregister_shrinker(&acl_shrinker
);
418 unregister_filesystem(&nfs4_fs_type
);
420 nfs_unregister_sysctl();
421 unregister_filesystem(&nfs_fs_type
);
424 void nfs_sb_active(struct super_block
*sb
)
426 struct nfs_server
*server
= NFS_SB(sb
);
428 if (atomic_inc_return(&server
->active
) == 1)
429 atomic_inc(&sb
->s_active
);
432 void nfs_sb_deactive(struct super_block
*sb
)
434 struct nfs_server
*server
= NFS_SB(sb
);
436 if (atomic_dec_and_test(&server
->active
))
437 deactivate_super(sb
);
441 * Deliver file system statistics to userspace
443 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
445 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
446 unsigned char blockbits
;
447 unsigned long blockres
;
448 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
449 struct nfs_fsstat res
;
452 res
.fattr
= nfs_alloc_fattr();
453 if (res
.fattr
== NULL
)
456 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
457 if (unlikely(error
== -ESTALE
)) {
458 struct dentry
*pd_dentry
;
460 pd_dentry
= dget_parent(dentry
);
461 if (pd_dentry
!= NULL
) {
462 nfs_zap_caches(pd_dentry
->d_inode
);
466 nfs_free_fattr(res
.fattr
);
470 buf
->f_type
= NFS_SUPER_MAGIC
;
473 * Current versions of glibc do not correctly handle the
474 * case where f_frsize != f_bsize. Eventually we want to
475 * report the value of wtmult in this field.
477 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
480 * On most *nix systems, f_blocks, f_bfree, and f_bavail
481 * are reported in units of f_frsize. Linux hasn't had
482 * an f_frsize field in its statfs struct until recently,
483 * thus historically Linux's sys_statfs reports these
484 * fields in units of f_bsize.
486 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
487 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
488 blockres
= (1 << blockbits
) - 1;
489 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
490 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
491 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
493 buf
->f_files
= res
.tfiles
;
494 buf
->f_ffree
= res
.afiles
;
496 buf
->f_namelen
= server
->namelen
;
501 dprintk("%s: statfs error = %d\n", __func__
, -error
);
506 * Map the security flavour number to a name
508 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
510 static const struct {
511 rpc_authflavor_t flavour
;
514 { RPC_AUTH_NULL
, "null" },
515 { RPC_AUTH_UNIX
, "sys" },
516 { RPC_AUTH_GSS_KRB5
, "krb5" },
517 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
518 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
519 { RPC_AUTH_GSS_LKEY
, "lkey" },
520 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
521 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
522 { RPC_AUTH_GSS_SPKM
, "spkm" },
523 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
524 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
525 { UINT_MAX
, "unknown" }
529 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
530 if (sec_flavours
[i
].flavour
== flavour
)
533 return sec_flavours
[i
].str
;
536 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
539 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
541 seq_printf(m
, ",mountproto=");
542 switch (sap
->sa_family
) {
544 switch (nfss
->mountd_protocol
) {
546 seq_printf(m
, RPCBIND_NETID_UDP
);
549 seq_printf(m
, RPCBIND_NETID_TCP
);
553 seq_printf(m
, "auto");
557 switch (nfss
->mountd_protocol
) {
559 seq_printf(m
, RPCBIND_NETID_UDP6
);
562 seq_printf(m
, RPCBIND_NETID_TCP6
);
566 seq_printf(m
, "auto");
571 seq_printf(m
, "auto");
575 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
578 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
580 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
583 switch (sap
->sa_family
) {
585 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
586 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
590 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
591 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
596 seq_printf(m
, ",mountaddr=unspecified");
599 if (nfss
->mountd_version
|| showdefaults
)
600 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
601 if ((nfss
->mountd_port
&&
602 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
604 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
606 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
610 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
613 struct nfs_client
*clp
= nfss
->nfs_client
;
615 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
616 seq_printf(m
, ",minorversion=%u", clp
->cl_minorversion
);
619 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
626 * Describe the mount options in force on this server representation
628 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
631 static const struct proc_nfs_info
{
636 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
637 { NFS_MOUNT_POSIX
, ",posix", "" },
638 { NFS_MOUNT_NOCTO
, ",nocto", "" },
639 { NFS_MOUNT_NOAC
, ",noac", "" },
640 { NFS_MOUNT_NONLM
, ",nolock", "" },
641 { NFS_MOUNT_NOACL
, ",noacl", "" },
642 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
643 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
644 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
647 const struct proc_nfs_info
*nfs_infop
;
648 struct nfs_client
*clp
= nfss
->nfs_client
;
649 u32 version
= clp
->rpc_ops
->version
;
650 int local_flock
, local_fcntl
;
652 seq_printf(m
, ",vers=%u", version
);
653 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
654 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
655 if (nfss
->bsize
!= 0)
656 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
657 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
658 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
659 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
660 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
661 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
662 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
663 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
664 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
665 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
666 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
667 if (nfss
->flags
& nfs_infop
->flag
)
668 seq_puts(m
, nfs_infop
->str
);
670 seq_puts(m
, nfs_infop
->nostr
);
672 seq_printf(m
, ",proto=%s",
673 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
675 if (nfss
->port
!= NFS_PORT
)
676 seq_printf(m
, ",port=%u", nfss
->port
);
679 seq_printf(m
, ",port=%u", nfss
->port
);
681 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
682 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
683 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
686 nfs_show_mountd_options(m
, nfss
, showdefaults
);
688 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
690 if (nfss
->options
& NFS_OPTION_FSCACHE
)
691 seq_printf(m
, ",fsc");
693 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
694 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
695 seq_printf(m
, ",lookupcache=none");
697 seq_printf(m
, ",lookupcache=pos");
700 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
701 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
703 if (!local_flock
&& !local_fcntl
)
704 seq_printf(m
, ",local_lock=none");
705 else if (local_flock
&& local_fcntl
)
706 seq_printf(m
, ",local_lock=all");
707 else if (local_flock
)
708 seq_printf(m
, ",local_lock=flock");
710 seq_printf(m
, ",local_lock=posix");
714 * Describe the mount options on this VFS mountpoint
716 static int nfs_show_options(struct seq_file
*m
, struct vfsmount
*mnt
)
718 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
720 nfs_show_mount_options(m
, nfss
, 0);
722 seq_printf(m
, ",addr=%s",
723 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
730 * Present statistical information for this VFS mountpoint
732 static int nfs_show_stats(struct seq_file
*m
, struct vfsmount
*mnt
)
735 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
736 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
737 struct nfs_iostats totals
= { };
739 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
742 * Display all mount option settings
744 seq_printf(m
, "\n\topts:\t");
745 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
746 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
747 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
748 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
749 nfs_show_mount_options(m
, nfss
, 1);
751 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
753 seq_printf(m
, "\n\tcaps:\t");
754 seq_printf(m
, "caps=0x%x", nfss
->caps
);
755 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
756 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
757 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
758 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
761 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
762 seq_printf(m
, "\n\tnfsv4:\t");
763 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
764 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
765 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
770 * Display security flavor in effect for this mount
772 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
774 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
777 * Display superblock I/O counters
779 for_each_possible_cpu(cpu
) {
780 struct nfs_iostats
*stats
;
783 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
785 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
786 totals
.events
[i
] += stats
->events
[i
];
787 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
788 totals
.bytes
[i
] += stats
->bytes
[i
];
789 #ifdef CONFIG_NFS_FSCACHE
790 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
791 totals
.fscache
[i
] += stats
->fscache
[i
];
797 seq_printf(m
, "\n\tevents:\t");
798 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
799 seq_printf(m
, "%lu ", totals
.events
[i
]);
800 seq_printf(m
, "\n\tbytes:\t");
801 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
802 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
803 #ifdef CONFIG_NFS_FSCACHE
804 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
805 seq_printf(m
, "\n\tfsc:\t");
806 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
807 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
812 rpc_print_iostats(m
, nfss
->client
);
818 * Begin unmount by attempting to remove all automounted mountpoints we added
819 * in response to xdev traversals and referrals
821 static void nfs_umount_begin(struct super_block
*sb
)
823 struct nfs_server
*server
;
824 struct rpc_clnt
*rpc
;
827 /* -EIO all pending I/O */
828 rpc
= server
->client_acl
;
830 rpc_killall_tasks(rpc
);
831 rpc
= server
->client
;
833 rpc_killall_tasks(rpc
);
836 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(unsigned int version
)
838 struct nfs_parsed_mount_data
*data
;
840 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
842 data
->acregmin
= NFS_DEF_ACREGMIN
;
843 data
->acregmax
= NFS_DEF_ACREGMAX
;
844 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
845 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
846 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
847 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
848 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
849 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
850 data
->auth_flavor_len
= 1;
851 data
->version
= version
;
852 data
->minorversion
= 0;
858 * Sanity-check a server address provided by the mount command.
860 * Address family must be initialized, and address must not be
861 * the ANY address for that family.
863 static int nfs_verify_server_address(struct sockaddr
*addr
)
865 switch (addr
->sa_family
) {
867 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
868 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
871 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
872 return !ipv6_addr_any(sa
);
876 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
881 * Select between a default port value and a user-specified port value.
882 * If a zero value is set, then autobind will be used.
884 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
885 const unsigned short default_port
)
887 if (*port
== NFS_UNSPEC_PORT
)
888 *port
= default_port
;
890 rpc_set_port(sap
, *port
);
894 * Sanity check the NFS transport protocol.
897 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
899 switch (mnt
->nfs_server
.protocol
) {
900 case XPRT_TRANSPORT_UDP
:
901 case XPRT_TRANSPORT_TCP
:
902 case XPRT_TRANSPORT_RDMA
:
905 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
910 * For text based NFSv2/v3 mounts, the mount protocol transport default
911 * settings should depend upon the specified NFS transport.
913 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
915 nfs_validate_transport_protocol(mnt
);
917 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
918 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
920 switch (mnt
->nfs_server
.protocol
) {
921 case XPRT_TRANSPORT_UDP
:
922 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
924 case XPRT_TRANSPORT_TCP
:
925 case XPRT_TRANSPORT_RDMA
:
926 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
931 * Parse the value of the 'sec=' option.
933 static int nfs_parse_security_flavors(char *value
,
934 struct nfs_parsed_mount_data
*mnt
)
936 substring_t args
[MAX_OPT_ARGS
];
938 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
940 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
942 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
945 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
948 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
951 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
954 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
957 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
960 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
963 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
966 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
969 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
972 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
978 mnt
->auth_flavor_len
= 1;
983 * Error-check and convert a string of mount options from user space into
984 * a data structure. The whole mount string is processed; bad options are
985 * skipped as they are encountered. If there were no errors, return 1;
986 * otherwise return 0 (zero).
988 static int nfs_parse_mount_options(char *raw
,
989 struct nfs_parsed_mount_data
*mnt
)
991 char *p
, *string
, *secdata
;
992 int rc
, sloppy
= 0, invalid_option
= 0;
993 unsigned short protofamily
= AF_UNSPEC
;
994 unsigned short mountfamily
= AF_UNSPEC
;
997 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
1000 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1002 secdata
= alloc_secdata();
1006 rc
= security_sb_copy_data(raw
, secdata
);
1008 goto out_security_failure
;
1010 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1012 goto out_security_failure
;
1014 free_secdata(secdata
);
1016 while ((p
= strsep(&raw
, ",")) != NULL
) {
1017 substring_t args
[MAX_OPT_ARGS
];
1018 unsigned long option
;
1024 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1026 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1030 * boolean options: foo/nofoo
1033 mnt
->flags
|= NFS_MOUNT_SOFT
;
1036 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1039 mnt
->flags
|= NFS_MOUNT_POSIX
;
1042 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1045 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1048 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1051 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1054 mnt
->flags
|= NFS_MOUNT_NOAC
;
1057 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1058 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1059 NFS_MOUNT_LOCAL_FCNTL
);
1062 mnt
->flags
|= NFS_MOUNT_NONLM
;
1063 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1064 NFS_MOUNT_LOCAL_FCNTL
);
1067 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1071 mnt
->flags
|= NFS_MOUNT_VER3
;
1075 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1079 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1080 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1083 mnt
->flags
|= NFS_MOUNT_TCP
;
1084 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1087 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1088 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1089 xprt_load_transport(p
);
1092 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1095 mnt
->flags
|= NFS_MOUNT_NOACL
;
1098 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1100 case Opt_nordirplus
:
1101 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1103 case Opt_sharecache
:
1104 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1106 case Opt_nosharecache
:
1107 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1110 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1112 case Opt_noresvport
:
1113 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1116 mnt
->options
|= NFS_OPTION_FSCACHE
;
1117 kfree(mnt
->fscache_uniq
);
1118 mnt
->fscache_uniq
= NULL
;
1121 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1122 kfree(mnt
->fscache_uniq
);
1123 mnt
->fscache_uniq
= NULL
;
1127 * options that take numeric values
1130 string
= match_strdup(args
);
1133 rc
= strict_strtoul(string
, 10, &option
);
1135 if (rc
!= 0 || option
> USHRT_MAX
)
1136 goto out_invalid_value
;
1137 mnt
->nfs_server
.port
= option
;
1140 string
= match_strdup(args
);
1143 rc
= strict_strtoul(string
, 10, &option
);
1146 goto out_invalid_value
;
1147 mnt
->rsize
= option
;
1150 string
= match_strdup(args
);
1153 rc
= strict_strtoul(string
, 10, &option
);
1156 goto out_invalid_value
;
1157 mnt
->wsize
= option
;
1160 string
= match_strdup(args
);
1163 rc
= strict_strtoul(string
, 10, &option
);
1166 goto out_invalid_value
;
1167 mnt
->bsize
= option
;
1170 string
= match_strdup(args
);
1173 rc
= strict_strtoul(string
, 10, &option
);
1175 if (rc
!= 0 || option
== 0)
1176 goto out_invalid_value
;
1177 mnt
->timeo
= option
;
1180 string
= match_strdup(args
);
1183 rc
= strict_strtoul(string
, 10, &option
);
1185 if (rc
!= 0 || option
== 0)
1186 goto out_invalid_value
;
1187 mnt
->retrans
= option
;
1190 string
= match_strdup(args
);
1193 rc
= strict_strtoul(string
, 10, &option
);
1196 goto out_invalid_value
;
1197 mnt
->acregmin
= option
;
1200 string
= match_strdup(args
);
1203 rc
= strict_strtoul(string
, 10, &option
);
1206 goto out_invalid_value
;
1207 mnt
->acregmax
= option
;
1210 string
= match_strdup(args
);
1213 rc
= strict_strtoul(string
, 10, &option
);
1216 goto out_invalid_value
;
1217 mnt
->acdirmin
= option
;
1220 string
= match_strdup(args
);
1223 rc
= strict_strtoul(string
, 10, &option
);
1226 goto out_invalid_value
;
1227 mnt
->acdirmax
= option
;
1230 string
= match_strdup(args
);
1233 rc
= strict_strtoul(string
, 10, &option
);
1236 goto out_invalid_value
;
1237 mnt
->acregmin
= mnt
->acregmax
=
1238 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1241 string
= match_strdup(args
);
1244 rc
= strict_strtoul(string
, 10, &option
);
1247 goto out_invalid_value
;
1248 mnt
->namlen
= option
;
1251 string
= match_strdup(args
);
1254 rc
= strict_strtoul(string
, 10, &option
);
1256 if (rc
!= 0 || option
> USHRT_MAX
)
1257 goto out_invalid_value
;
1258 mnt
->mount_server
.port
= option
;
1261 string
= match_strdup(args
);
1264 rc
= strict_strtoul(string
, 10, &option
);
1267 option
< NFS_MNT_VERSION
||
1268 option
> NFS_MNT3_VERSION
)
1269 goto out_invalid_value
;
1270 mnt
->mount_server
.version
= option
;
1273 string
= match_strdup(args
);
1276 rc
= strict_strtoul(string
, 10, &option
);
1279 goto out_invalid_value
;
1282 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1286 mnt
->flags
|= NFS_MOUNT_VER3
;
1290 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1294 goto out_invalid_value
;
1297 case Opt_minorversion
:
1298 string
= match_strdup(args
);
1301 rc
= strict_strtoul(string
, 10, &option
);
1304 goto out_invalid_value
;
1305 if (option
> NFS4_MAX_MINOR_VERSION
)
1306 goto out_invalid_value
;
1307 mnt
->minorversion
= option
;
1311 * options that take text values
1314 string
= match_strdup(args
);
1317 rc
= nfs_parse_security_flavors(string
, mnt
);
1320 dfprintk(MOUNT
, "NFS: unrecognized "
1321 "security flavor\n");
1326 string
= match_strdup(args
);
1329 token
= match_token(string
,
1330 nfs_xprt_protocol_tokens
, args
);
1332 protofamily
= AF_INET
;
1335 protofamily
= AF_INET6
;
1337 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1338 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1342 protofamily
= AF_INET6
;
1344 mnt
->flags
|= NFS_MOUNT_TCP
;
1345 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1349 /* vector side protocols to TCP */
1350 mnt
->flags
|= NFS_MOUNT_TCP
;
1351 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1352 xprt_load_transport(string
);
1356 dfprintk(MOUNT
, "NFS: unrecognized "
1357 "transport protocol\n");
1362 case Opt_mountproto
:
1363 string
= match_strdup(args
);
1366 token
= match_token(string
,
1367 nfs_xprt_protocol_tokens
, args
);
1370 mountfamily
= AF_INET
;
1373 mountfamily
= AF_INET6
;
1375 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1378 mountfamily
= AF_INET6
;
1380 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1382 case Opt_xprt_rdma
: /* not used for side protocols */
1384 dfprintk(MOUNT
, "NFS: unrecognized "
1385 "transport protocol\n");
1390 string
= match_strdup(args
);
1393 mnt
->nfs_server
.addrlen
=
1394 rpc_pton(string
, strlen(string
),
1396 &mnt
->nfs_server
.address
,
1397 sizeof(mnt
->nfs_server
.address
));
1399 if (mnt
->nfs_server
.addrlen
== 0)
1400 goto out_invalid_address
;
1402 case Opt_clientaddr
:
1403 string
= match_strdup(args
);
1406 kfree(mnt
->client_address
);
1407 mnt
->client_address
= string
;
1410 string
= match_strdup(args
);
1413 kfree(mnt
->mount_server
.hostname
);
1414 mnt
->mount_server
.hostname
= string
;
1417 string
= match_strdup(args
);
1420 mnt
->mount_server
.addrlen
=
1421 rpc_pton(string
, strlen(string
),
1423 &mnt
->mount_server
.address
,
1424 sizeof(mnt
->mount_server
.address
));
1426 if (mnt
->mount_server
.addrlen
== 0)
1427 goto out_invalid_address
;
1429 case Opt_lookupcache
:
1430 string
= match_strdup(args
);
1433 token
= match_token(string
,
1434 nfs_lookupcache_tokens
, args
);
1437 case Opt_lookupcache_all
:
1438 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1440 case Opt_lookupcache_positive
:
1441 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1442 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1444 case Opt_lookupcache_none
:
1445 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1448 dfprintk(MOUNT
, "NFS: invalid "
1449 "lookupcache argument\n");
1453 case Opt_fscache_uniq
:
1454 string
= match_strdup(args
);
1457 kfree(mnt
->fscache_uniq
);
1458 mnt
->fscache_uniq
= string
;
1459 mnt
->options
|= NFS_OPTION_FSCACHE
;
1461 case Opt_local_lock
:
1462 string
= match_strdup(args
);
1465 token
= match_token(string
, nfs_local_lock_tokens
,
1469 case Opt_local_lock_all
:
1470 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1471 NFS_MOUNT_LOCAL_FCNTL
);
1473 case Opt_local_lock_flock
:
1474 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1476 case Opt_local_lock_posix
:
1477 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1479 case Opt_local_lock_none
:
1480 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1481 NFS_MOUNT_LOCAL_FCNTL
);
1484 dfprintk(MOUNT
, "NFS: invalid "
1485 "local_lock argument\n");
1495 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1498 case Opt_deprecated
:
1499 dfprintk(MOUNT
, "NFS: ignoring mount option "
1505 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1510 if (!sloppy
&& invalid_option
)
1514 * verify that any proto=/mountproto= options match the address
1515 * familiies in the addr=/mountaddr= options.
1517 if (protofamily
!= AF_UNSPEC
&&
1518 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1519 goto out_proto_mismatch
;
1521 if (mountfamily
!= AF_UNSPEC
) {
1522 if (mnt
->mount_server
.addrlen
) {
1523 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1524 goto out_mountproto_mismatch
;
1526 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1527 goto out_mountproto_mismatch
;
1533 out_mountproto_mismatch
:
1534 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1538 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1540 out_invalid_address
:
1541 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1544 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1547 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1549 out_security_failure
:
1550 free_secdata(secdata
);
1551 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1556 * Match the requested auth flavors with the list returned by
1557 * the server. Returns zero and sets the mount's authentication
1558 * flavor on success; returns -EACCES if server does not support
1559 * the requested flavor.
1561 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1562 struct nfs_mount_request
*request
)
1564 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1567 * Certain releases of Linux's mountd return an empty
1568 * flavor list. To prevent behavioral regression with
1569 * these servers (ie. rejecting mounts that used to
1570 * succeed), revert to pre-2.6.32 behavior (no checking)
1571 * if the returned flavor list is empty.
1573 if (server_authlist_len
== 0)
1577 * We avoid sophisticated negotiating here, as there are
1578 * plenty of cases where we can get it wrong, providing
1579 * either too little or too much security.
1581 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1582 * flavor listed first. However, some servers list
1583 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1584 * preferred default, in args->auth_flavors[0] if user
1585 * didn't specify sec= mount option.
1587 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1588 for (j
= 0; j
< server_authlist_len
; j
++)
1589 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1590 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1591 request
->auth_flavs
[j
]);
1592 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1596 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1597 nfs_umount(request
);
1602 * Use the remote server's MOUNT service to request the NFS file handle
1603 * corresponding to the provided path.
1605 static int nfs_try_mount(struct nfs_parsed_mount_data
*args
,
1606 struct nfs_fh
*root_fh
)
1608 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1609 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1610 struct nfs_mount_request request
= {
1611 .sap
= (struct sockaddr
*)
1612 &args
->mount_server
.address
,
1613 .dirpath
= args
->nfs_server
.export_path
,
1614 .protocol
= args
->mount_server
.protocol
,
1616 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1617 .auth_flav_len
= &server_authlist_len
,
1618 .auth_flavs
= server_authlist
,
1622 if (args
->mount_server
.version
== 0) {
1623 switch (args
->version
) {
1625 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1628 args
->mount_server
.version
= NFS_MNT_VERSION
;
1631 request
.version
= args
->mount_server
.version
;
1633 if (args
->mount_server
.hostname
)
1634 request
.hostname
= args
->mount_server
.hostname
;
1636 request
.hostname
= args
->nfs_server
.hostname
;
1639 * Construct the mount server's address.
1641 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1642 memcpy(request
.sap
, &args
->nfs_server
.address
,
1643 args
->nfs_server
.addrlen
);
1644 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1646 request
.salen
= args
->mount_server
.addrlen
;
1647 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1650 * Now ask the mount server to map our export path
1653 status
= nfs_mount(&request
);
1655 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1656 request
.hostname
, status
);
1661 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1663 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1665 return nfs_walk_authlist(args
, &request
);
1669 * Split "dev_name" into "hostname:export_path".
1671 * The leftmost colon demarks the split between the server's hostname
1672 * and the export path. If the hostname starts with a left square
1673 * bracket, then it may contain colons.
1675 * Note: caller frees hostname and export path, even on error.
1677 static int nfs_parse_devname(const char *dev_name
,
1678 char **hostname
, size_t maxnamlen
,
1679 char **export_path
, size_t maxpathlen
)
1684 /* Is the host name protected with square brakcets? */
1685 if (*dev_name
== '[') {
1686 end
= strchr(++dev_name
, ']');
1687 if (end
== NULL
|| end
[1] != ':')
1688 goto out_bad_devname
;
1690 len
= end
- dev_name
;
1695 end
= strchr(dev_name
, ':');
1697 goto out_bad_devname
;
1698 len
= end
- dev_name
;
1700 /* kill possible hostname list: not supported */
1701 comma
= strchr(dev_name
, ',');
1702 if (comma
!= NULL
&& comma
< end
)
1706 if (len
> maxnamlen
)
1709 /* N.B. caller will free nfs_server.hostname in all cases */
1710 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1711 if (*hostname
== NULL
)
1713 len
= strlen(++end
);
1714 if (len
> maxpathlen
)
1716 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1720 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1724 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1728 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1732 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1733 return -ENAMETOOLONG
;
1736 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1737 return -ENAMETOOLONG
;
1741 * Validate the NFS2/NFS3 mount data
1742 * - fills in the mount root filehandle
1744 * For option strings, user space handles the following behaviors:
1746 * + DNS: mapping server host name to IP address ("addr=" option)
1748 * + failure mode: how to behave if a mount request can't be handled
1749 * immediately ("fg/bg" option)
1751 * + retry: how often to retry a mount request ("retry=" option)
1753 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1754 * mountproto=tcp after mountproto=udp, and so on
1756 static int nfs_validate_mount_data(void *options
,
1757 struct nfs_parsed_mount_data
*args
,
1758 struct nfs_fh
*mntfh
,
1759 const char *dev_name
)
1761 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1762 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1767 switch (data
->version
) {
1773 if (data
->flags
& NFS_MOUNT_VER3
)
1775 data
->root
.size
= NFS2_FHSIZE
;
1776 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1778 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1781 memset(data
->context
, 0, sizeof(data
->context
));
1783 if (data
->flags
& NFS_MOUNT_VER3
) {
1784 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1785 goto out_invalid_fh
;
1786 mntfh
->size
= data
->root
.size
;
1789 mntfh
->size
= NFS2_FHSIZE
;
1794 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1795 if (mntfh
->size
< sizeof(mntfh
->data
))
1796 memset(mntfh
->data
+ mntfh
->size
, 0,
1797 sizeof(mntfh
->data
) - mntfh
->size
);
1800 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1803 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1804 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1805 args
->rsize
= data
->rsize
;
1806 args
->wsize
= data
->wsize
;
1807 args
->timeo
= data
->timeo
;
1808 args
->retrans
= data
->retrans
;
1809 args
->acregmin
= data
->acregmin
;
1810 args
->acregmax
= data
->acregmax
;
1811 args
->acdirmin
= data
->acdirmin
;
1812 args
->acdirmax
= data
->acdirmax
;
1814 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1815 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1816 if (!nfs_verify_server_address(sap
))
1817 goto out_no_address
;
1819 if (!(data
->flags
& NFS_MOUNT_TCP
))
1820 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1821 /* N.B. caller will free nfs_server.hostname in all cases */
1822 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1823 args
->namlen
= data
->namlen
;
1824 args
->bsize
= data
->bsize
;
1826 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1827 args
->auth_flavors
[0] = data
->pseudoflavor
;
1828 if (!args
->nfs_server
.hostname
)
1831 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1832 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1833 NFS_MOUNT_LOCAL_FCNTL
);
1835 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1836 NFS_MOUNT_LOCAL_FCNTL
);
1838 * The legacy version 6 binary mount data from userspace has a
1839 * field used only to transport selinux information into the
1840 * the kernel. To continue to support that functionality we
1841 * have a touch of selinux knowledge here in the NFS code. The
1842 * userspace code converted context=blah to just blah so we are
1843 * converting back to the full string selinux understands.
1845 if (data
->context
[0]){
1846 #ifdef CONFIG_SECURITY_SELINUX
1848 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1851 strcpy(opts_str
, "context=");
1852 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1853 strcat(opts_str
, &data
->context
[0]);
1854 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1867 if (nfs_parse_mount_options((char *)options
, args
) == 0)
1870 if (!nfs_verify_server_address(sap
))
1871 goto out_no_address
;
1873 if (args
->version
== 4)
1874 #ifdef CONFIG_NFS_V4
1875 return nfs4_validate_text_mount_data(options
,
1878 goto out_v4_not_compiled
;
1881 nfs_set_port(sap
, &args
->nfs_server
.port
, 0);
1883 nfs_set_mount_transport_protocol(args
);
1885 status
= nfs_parse_devname(dev_name
,
1886 &args
->nfs_server
.hostname
,
1888 &args
->nfs_server
.export_path
,
1891 status
= nfs_try_mount(args
, mntfh
);
1893 kfree(args
->nfs_server
.export_path
);
1894 args
->nfs_server
.export_path
= NULL
;
1903 #ifndef CONFIG_NFS_V3
1904 if (args
->version
== 3)
1905 goto out_v3_not_compiled
;
1906 #endif /* !CONFIG_NFS_V3 */
1911 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1915 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1920 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1923 #ifndef CONFIG_NFS_V3
1924 out_v3_not_compiled
:
1925 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1926 return -EPROTONOSUPPORT
;
1927 #endif /* !CONFIG_NFS_V3 */
1929 #ifndef CONFIG_NFS_V4
1930 out_v4_not_compiled
:
1931 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
1932 return -EPROTONOSUPPORT
;
1933 #endif /* !CONFIG_NFS_V4 */
1936 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
1940 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
1944 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
1949 nfs_compare_remount_data(struct nfs_server
*nfss
,
1950 struct nfs_parsed_mount_data
*data
)
1952 if (data
->flags
!= nfss
->flags
||
1953 data
->rsize
!= nfss
->rsize
||
1954 data
->wsize
!= nfss
->wsize
||
1955 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
1956 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
1957 data
->acregmin
!= nfss
->acregmin
/ HZ
||
1958 data
->acregmax
!= nfss
->acregmax
/ HZ
||
1959 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
1960 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
1961 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
1962 data
->nfs_server
.port
!= nfss
->port
||
1963 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
1964 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
1965 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
1972 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
1975 struct nfs_server
*nfss
= sb
->s_fs_info
;
1976 struct nfs_parsed_mount_data
*data
;
1977 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
1978 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
1979 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
1982 * Userspace mount programs that send binary options generally send
1983 * them populated with default values. We have no way to know which
1984 * ones were explicitly specified. Fall back to legacy behavior and
1985 * just return success.
1987 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
1988 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
1989 options
->version
<= 6))))
1992 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
1996 /* fill out struct with values from existing mount */
1997 data
->flags
= nfss
->flags
;
1998 data
->rsize
= nfss
->rsize
;
1999 data
->wsize
= nfss
->wsize
;
2000 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2001 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
2002 data
->acregmin
= nfss
->acregmin
/ HZ
;
2003 data
->acregmax
= nfss
->acregmax
/ HZ
;
2004 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2005 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2006 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2007 data
->nfs_server
.port
= nfss
->port
;
2008 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2009 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2010 data
->nfs_server
.addrlen
);
2012 /* overwrite those values with any that were specified */
2013 error
= nfs_parse_mount_options((char *)options
, data
);
2017 /* compare new mount options with old ones */
2018 error
= nfs_compare_remount_data(nfss
, data
);
2025 * Initialise the common bits of the superblock
2027 static inline void nfs_initialise_sb(struct super_block
*sb
)
2029 struct nfs_server
*server
= NFS_SB(sb
);
2031 sb
->s_magic
= NFS_SUPER_MAGIC
;
2033 /* We probably want something more informative here */
2034 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2035 "%x:%x", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2037 if (sb
->s_blocksize
== 0)
2038 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2039 &sb
->s_blocksize_bits
);
2041 if (server
->flags
& NFS_MOUNT_NOAC
)
2042 sb
->s_flags
|= MS_SYNCHRONOUS
;
2044 sb
->s_bdi
= &server
->backing_dev_info
;
2046 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2050 * Finish setting up an NFS2/3 superblock
2052 static void nfs_fill_super(struct super_block
*sb
,
2053 struct nfs_parsed_mount_data
*data
)
2055 struct nfs_server
*server
= NFS_SB(sb
);
2057 sb
->s_blocksize_bits
= 0;
2058 sb
->s_blocksize
= 0;
2060 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2062 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2063 /* The VFS shouldn't apply the umask to mode bits. We will do
2064 * so ourselves when necessary.
2066 sb
->s_flags
|= MS_POSIXACL
;
2067 sb
->s_time_gran
= 1;
2070 sb
->s_op
= &nfs_sops
;
2071 nfs_initialise_sb(sb
);
2075 * Finish setting up a cloned NFS2/3 superblock
2077 static void nfs_clone_super(struct super_block
*sb
,
2078 const struct super_block
*old_sb
)
2080 struct nfs_server
*server
= NFS_SB(sb
);
2082 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2083 sb
->s_blocksize
= old_sb
->s_blocksize
;
2084 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2086 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2087 /* The VFS shouldn't apply the umask to mode bits. We will do
2088 * so ourselves when necessary.
2090 sb
->s_flags
|= MS_POSIXACL
;
2091 sb
->s_time_gran
= 1;
2094 sb
->s_op
= old_sb
->s_op
;
2095 nfs_initialise_sb(sb
);
2098 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2100 const struct nfs_server
*a
= s
->s_fs_info
;
2101 const struct rpc_clnt
*clnt_a
= a
->client
;
2102 const struct rpc_clnt
*clnt_b
= b
->client
;
2104 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2106 if (a
->nfs_client
!= b
->nfs_client
)
2108 if (a
->flags
!= b
->flags
)
2110 if (a
->wsize
!= b
->wsize
)
2112 if (a
->rsize
!= b
->rsize
)
2114 if (a
->acregmin
!= b
->acregmin
)
2116 if (a
->acregmax
!= b
->acregmax
)
2118 if (a
->acdirmin
!= b
->acdirmin
)
2120 if (a
->acdirmax
!= b
->acdirmax
)
2122 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2129 struct nfs_sb_mountdata
{
2130 struct nfs_server
*server
;
2134 static int nfs_set_super(struct super_block
*s
, void *data
)
2136 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2137 struct nfs_server
*server
= sb_mntdata
->server
;
2140 s
->s_flags
= sb_mntdata
->mntflags
;
2141 s
->s_fs_info
= server
;
2142 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
2143 ret
= set_anon_super(s
, server
);
2145 server
->s_dev
= s
->s_dev
;
2149 static int nfs_compare_super_address(struct nfs_server
*server1
,
2150 struct nfs_server
*server2
)
2152 struct sockaddr
*sap1
, *sap2
;
2154 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2155 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2157 if (sap1
->sa_family
!= sap2
->sa_family
)
2160 switch (sap1
->sa_family
) {
2162 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2163 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2164 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2166 if (sin1
->sin_port
!= sin2
->sin_port
)
2171 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2172 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2173 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2175 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2186 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2188 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2189 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2190 int mntflags
= sb_mntdata
->mntflags
;
2192 if (!nfs_compare_super_address(old
, server
))
2194 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2195 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2197 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2199 return nfs_compare_mount_options(sb
, server
, mntflags
);
2202 static int nfs_bdi_register(struct nfs_server
*server
)
2204 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2207 static int nfs_get_sb(struct file_system_type
*fs_type
,
2208 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2210 struct nfs_server
*server
= NULL
;
2211 struct super_block
*s
;
2212 struct nfs_parsed_mount_data
*data
;
2213 struct nfs_fh
*mntfh
;
2214 struct dentry
*mntroot
;
2215 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2216 struct nfs_sb_mountdata sb_mntdata
= {
2219 int error
= -ENOMEM
;
2221 data
= nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION
);
2222 mntfh
= nfs_alloc_fhandle();
2223 if (data
== NULL
|| mntfh
== NULL
)
2226 security_init_mnt_opts(&data
->lsm_opts
);
2228 /* Validate the mount data */
2229 error
= nfs_validate_mount_data(raw_data
, data
, mntfh
, dev_name
);
2233 #ifdef CONFIG_NFS_V4
2234 if (data
->version
== 4) {
2235 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2236 kfree(data
->client_address
);
2237 kfree(data
->nfs_server
.export_path
);
2240 #endif /* CONFIG_NFS_V4 */
2242 /* Get a volume representation */
2243 server
= nfs_create_server(data
, mntfh
);
2244 if (IS_ERR(server
)) {
2245 error
= PTR_ERR(server
);
2248 sb_mntdata
.server
= server
;
2250 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2251 compare_super
= NULL
;
2253 /* Get a superblock - note that we may end up sharing one that already exists */
2254 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2260 if (s
->s_fs_info
!= server
) {
2261 nfs_free_server(server
);
2264 error
= nfs_bdi_register(server
);
2266 goto error_splat_bdi
;
2270 /* initial superblock/root creation */
2271 nfs_fill_super(s
, data
);
2272 nfs_fscache_get_super_cookie(
2273 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2276 mntroot
= nfs_get_root(s
, mntfh
);
2277 if (IS_ERR(mntroot
)) {
2278 error
= PTR_ERR(mntroot
);
2279 goto error_splat_super
;
2282 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2284 goto error_splat_root
;
2286 s
->s_flags
|= MS_ACTIVE
;
2288 mnt
->mnt_root
= mntroot
;
2292 kfree(data
->nfs_server
.hostname
);
2293 kfree(data
->mount_server
.hostname
);
2294 kfree(data
->fscache_uniq
);
2295 security_free_mnt_opts(&data
->lsm_opts
);
2297 nfs_free_fhandle(mntfh
);
2302 nfs_free_server(server
);
2308 if (server
&& !s
->s_root
)
2309 bdi_unregister(&server
->backing_dev_info
);
2311 deactivate_locked_super(s
);
2316 * Ensure that we unregister the bdi before kill_anon_super
2317 * releases the device name
2319 static void nfs_put_super(struct super_block
*s
)
2321 struct nfs_server
*server
= NFS_SB(s
);
2323 bdi_unregister(&server
->backing_dev_info
);
2327 * Destroy an NFS2/3 superblock
2329 static void nfs_kill_super(struct super_block
*s
)
2331 struct nfs_server
*server
= NFS_SB(s
);
2334 nfs_fscache_release_super_cookie(s
);
2335 nfs_free_server(server
);
2339 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2341 static struct dentry
*
2342 nfs_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2343 const char *dev_name
, void *raw_data
)
2345 struct nfs_clone_mount
*data
= raw_data
;
2346 struct super_block
*s
;
2347 struct nfs_server
*server
;
2348 struct dentry
*mntroot
;
2349 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2350 struct nfs_sb_mountdata sb_mntdata
= {
2355 dprintk("--> nfs_xdev_mount()\n");
2357 /* create a new volume representation */
2358 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2359 if (IS_ERR(server
)) {
2360 error
= PTR_ERR(server
);
2361 goto out_err_noserver
;
2363 sb_mntdata
.server
= server
;
2365 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2366 compare_super
= NULL
;
2368 /* Get a superblock - note that we may end up sharing one that already exists */
2369 s
= sget(&nfs_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2375 if (s
->s_fs_info
!= server
) {
2376 nfs_free_server(server
);
2379 error
= nfs_bdi_register(server
);
2381 goto error_splat_bdi
;
2385 /* initial superblock/root creation */
2386 nfs_clone_super(s
, data
->sb
);
2387 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2390 mntroot
= nfs_get_root(s
, data
->fh
);
2391 if (IS_ERR(mntroot
)) {
2392 error
= PTR_ERR(mntroot
);
2393 goto error_splat_super
;
2395 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2398 goto error_splat_super
;
2401 s
->s_flags
|= MS_ACTIVE
;
2403 /* clone any lsm security options from the parent to the new sb */
2404 security_sb_clone_mnt_opts(data
->sb
, s
);
2406 dprintk("<-- nfs_xdev_mount() = 0\n");
2410 nfs_free_server(server
);
2412 dprintk("<-- nfs_xdev_mount() = %d [error]\n", error
);
2413 return ERR_PTR(error
);
2416 if (server
&& !s
->s_root
)
2417 bdi_unregister(&server
->backing_dev_info
);
2419 deactivate_locked_super(s
);
2420 dprintk("<-- nfs_xdev_mount() = %d [splat]\n", error
);
2421 return ERR_PTR(error
);
2424 #ifdef CONFIG_NFS_V4
2427 * Finish setting up a cloned NFS4 superblock
2429 static void nfs4_clone_super(struct super_block
*sb
,
2430 const struct super_block
*old_sb
)
2432 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2433 sb
->s_blocksize
= old_sb
->s_blocksize
;
2434 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2435 sb
->s_time_gran
= 1;
2436 sb
->s_op
= old_sb
->s_op
;
2438 * The VFS shouldn't apply the umask to mode bits. We will do
2439 * so ourselves when necessary.
2441 sb
->s_flags
|= MS_POSIXACL
;
2442 sb
->s_xattr
= old_sb
->s_xattr
;
2443 nfs_initialise_sb(sb
);
2447 * Set up an NFS4 superblock
2449 static void nfs4_fill_super(struct super_block
*sb
)
2451 sb
->s_time_gran
= 1;
2452 sb
->s_op
= &nfs4_sops
;
2454 * The VFS shouldn't apply the umask to mode bits. We will do
2455 * so ourselves when necessary.
2457 sb
->s_flags
|= MS_POSIXACL
;
2458 sb
->s_xattr
= nfs4_xattr_handlers
;
2459 nfs_initialise_sb(sb
);
2462 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2464 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2465 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2468 static int nfs4_validate_text_mount_data(void *options
,
2469 struct nfs_parsed_mount_data
*args
,
2470 const char *dev_name
)
2472 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2474 nfs_set_port(sap
, &args
->nfs_server
.port
, NFS_PORT
);
2476 nfs_validate_transport_protocol(args
);
2478 nfs4_validate_mount_flags(args
);
2480 if (args
->version
!= 4) {
2482 "NFS4: Illegal mount version\n");
2486 if (args
->auth_flavor_len
> 1) {
2488 "NFS4: Too many RPC auth flavours specified\n");
2492 if (args
->client_address
== NULL
) {
2494 "NFS4: mount program didn't pass callback address\n");
2498 return nfs_parse_devname(dev_name
,
2499 &args
->nfs_server
.hostname
,
2501 &args
->nfs_server
.export_path
,
2506 * Validate NFSv4 mount options
2508 static int nfs4_validate_mount_data(void *options
,
2509 struct nfs_parsed_mount_data
*args
,
2510 const char *dev_name
)
2512 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2513 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2519 switch (data
->version
) {
2521 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2522 goto out_no_address
;
2523 if (data
->host_addrlen
== 0)
2524 goto out_no_address
;
2525 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2526 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2528 if (!nfs_verify_server_address(sap
))
2529 goto out_no_address
;
2531 if (data
->auth_flavourlen
) {
2532 if (data
->auth_flavourlen
> 1)
2533 goto out_inval_auth
;
2534 if (copy_from_user(&args
->auth_flavors
[0],
2535 data
->auth_flavours
,
2536 sizeof(args
->auth_flavors
[0])))
2540 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2543 args
->nfs_server
.hostname
= c
;
2545 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2548 args
->nfs_server
.export_path
= c
;
2549 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2551 c
= strndup_user(data
->client_addr
.data
, 16);
2554 args
->client_address
= c
;
2557 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2561 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2562 args
->rsize
= data
->rsize
;
2563 args
->wsize
= data
->wsize
;
2564 args
->timeo
= data
->timeo
;
2565 args
->retrans
= data
->retrans
;
2566 args
->acregmin
= data
->acregmin
;
2567 args
->acregmax
= data
->acregmax
;
2568 args
->acdirmin
= data
->acdirmin
;
2569 args
->acdirmax
= data
->acdirmax
;
2570 args
->nfs_server
.protocol
= data
->proto
;
2571 nfs_validate_transport_protocol(args
);
2575 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2578 if (!nfs_verify_server_address(sap
))
2581 return nfs4_validate_text_mount_data(options
, args
, dev_name
);
2587 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2591 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2592 data
->auth_flavourlen
);
2596 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2601 * Get the superblock for the NFS4 root partition
2603 static struct dentry
*
2604 nfs4_remote_mount(struct file_system_type
*fs_type
, int flags
,
2605 const char *dev_name
, void *raw_data
)
2607 struct nfs_parsed_mount_data
*data
= raw_data
;
2608 struct super_block
*s
;
2609 struct nfs_server
*server
;
2610 struct nfs_fh
*mntfh
;
2611 struct dentry
*mntroot
;
2612 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2613 struct nfs_sb_mountdata sb_mntdata
= {
2616 int error
= -ENOMEM
;
2618 mntfh
= nfs_alloc_fhandle();
2619 if (data
== NULL
|| mntfh
== NULL
)
2622 security_init_mnt_opts(&data
->lsm_opts
);
2624 /* Get a volume representation */
2625 server
= nfs4_create_server(data
, mntfh
);
2626 if (IS_ERR(server
)) {
2627 error
= PTR_ERR(server
);
2630 sb_mntdata
.server
= server
;
2632 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2633 compare_super
= NULL
;
2635 /* Get a superblock - note that we may end up sharing one that already exists */
2636 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2642 if (s
->s_fs_info
!= server
) {
2643 nfs_free_server(server
);
2646 error
= nfs_bdi_register(server
);
2648 goto error_splat_bdi
;
2652 /* initial superblock/root creation */
2654 nfs_fscache_get_super_cookie(
2655 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2658 mntroot
= nfs4_get_root(s
, mntfh
);
2659 if (IS_ERR(mntroot
)) {
2660 error
= PTR_ERR(mntroot
);
2661 goto error_splat_super
;
2664 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2666 goto error_splat_root
;
2668 s
->s_flags
|= MS_ACTIVE
;
2670 security_free_mnt_opts(&data
->lsm_opts
);
2671 nfs_free_fhandle(mntfh
);
2675 security_free_mnt_opts(&data
->lsm_opts
);
2677 nfs_free_fhandle(mntfh
);
2678 return ERR_PTR(error
);
2681 nfs_free_server(server
);
2687 if (server
&& !s
->s_root
)
2688 bdi_unregister(&server
->backing_dev_info
);
2690 deactivate_locked_super(s
);
2694 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2695 int flags
, void *data
, const char *hostname
)
2697 struct vfsmount
*root_mnt
;
2701 len
= strlen(hostname
) + 3;
2702 root_devname
= kmalloc(len
, GFP_KERNEL
);
2703 if (root_devname
== NULL
)
2704 return ERR_PTR(-ENOMEM
);
2705 snprintf(root_devname
, len
, "%s:/", hostname
);
2706 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2707 kfree(root_devname
);
2711 static void nfs_fix_devname(const struct path
*path
, struct vfsmount
*mnt
)
2713 char *page
= (char *) __get_free_page(GFP_KERNEL
);
2714 char *devname
, *tmp
;
2718 devname
= nfs_path(path
->mnt
->mnt_devname
,
2719 path
->mnt
->mnt_root
, path
->dentry
,
2721 if (IS_ERR(devname
))
2723 tmp
= kstrdup(devname
, GFP_KERNEL
);
2726 kfree(mnt
->mnt_devname
);
2727 mnt
->mnt_devname
= tmp
;
2729 free_page((unsigned long)page
);
2732 struct nfs_referral_count
{
2733 struct list_head list
;
2734 const struct task_struct
*task
;
2735 unsigned int referral_count
;
2738 static LIST_HEAD(nfs_referral_count_list
);
2739 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2741 static struct nfs_referral_count
*nfs_find_referral_count(void)
2743 struct nfs_referral_count
*p
;
2745 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2746 if (p
->task
== current
)
2752 #define NFS_MAX_NESTED_REFERRALS 2
2754 static int nfs_referral_loop_protect(void)
2756 struct nfs_referral_count
*p
, *new;
2759 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2762 new->task
= current
;
2763 new->referral_count
= 1;
2766 spin_lock(&nfs_referral_count_list_lock
);
2767 p
= nfs_find_referral_count();
2769 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2772 p
->referral_count
++;
2774 list_add(&new->list
, &nfs_referral_count_list
);
2777 spin_unlock(&nfs_referral_count_list_lock
);
2783 static void nfs_referral_loop_unprotect(void)
2785 struct nfs_referral_count
*p
;
2787 spin_lock(&nfs_referral_count_list_lock
);
2788 p
= nfs_find_referral_count();
2789 p
->referral_count
--;
2790 if (p
->referral_count
== 0)
2794 spin_unlock(&nfs_referral_count_list_lock
);
2798 static int nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2799 const char *export_path
, struct vfsmount
*mnt_target
)
2801 struct nameidata
*nd
= NULL
;
2802 struct mnt_namespace
*ns_private
;
2803 struct super_block
*s
;
2806 nd
= kmalloc(sizeof(*nd
), GFP_KERNEL
);
2810 ns_private
= create_mnt_ns(root_mnt
);
2811 ret
= PTR_ERR(ns_private
);
2812 if (IS_ERR(ns_private
))
2815 ret
= nfs_referral_loop_protect();
2817 goto out_put_mnt_ns
;
2819 ret
= vfs_path_lookup(root_mnt
->mnt_root
, root_mnt
,
2820 export_path
, LOOKUP_FOLLOW
, nd
);
2822 nfs_referral_loop_unprotect();
2823 put_mnt_ns(ns_private
);
2828 s
= nd
->path
.mnt
->mnt_sb
;
2829 atomic_inc(&s
->s_active
);
2830 mnt_target
->mnt_sb
= s
;
2831 mnt_target
->mnt_root
= dget(nd
->path
.dentry
);
2833 /* Correct the device pathname */
2834 nfs_fix_devname(&nd
->path
, mnt_target
);
2836 path_put(&nd
->path
);
2838 down_write(&s
->s_umount
);
2841 put_mnt_ns(ns_private
);
2849 static int nfs4_try_mount(int flags
, const char *dev_name
,
2850 struct nfs_parsed_mount_data
*data
,
2851 struct vfsmount
*mnt
)
2854 struct vfsmount
*root_mnt
;
2857 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2859 export_path
= data
->nfs_server
.export_path
;
2860 data
->nfs_server
.export_path
= "/";
2861 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2862 data
->nfs_server
.hostname
);
2863 data
->nfs_server
.export_path
= export_path
;
2865 error
= PTR_ERR(root_mnt
);
2866 if (IS_ERR(root_mnt
))
2869 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
2872 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %d%s\n", error
,
2873 error
!= 0 ? " [error]" : "");
2878 * Get the superblock for an NFS4 mountpoint
2880 static int nfs4_get_sb(struct file_system_type
*fs_type
,
2881 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2883 struct nfs_parsed_mount_data
*data
;
2884 int error
= -ENOMEM
;
2886 data
= nfs_alloc_parsed_mount_data(4);
2890 /* Validate the mount data */
2891 error
= nfs4_validate_mount_data(raw_data
, data
, dev_name
);
2895 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2898 kfree(data
->client_address
);
2899 kfree(data
->nfs_server
.export_path
);
2900 kfree(data
->nfs_server
.hostname
);
2901 kfree(data
->fscache_uniq
);
2904 dprintk("<-- nfs4_get_sb() = %d%s\n", error
,
2905 error
!= 0 ? " [error]" : "");
2909 static void nfs4_kill_super(struct super_block
*sb
)
2911 struct nfs_server
*server
= NFS_SB(sb
);
2913 dprintk("--> %s\n", __func__
);
2914 nfs_super_return_all_delegations(sb
);
2915 kill_anon_super(sb
);
2916 nfs_fscache_release_super_cookie(sb
);
2917 nfs_free_server(server
);
2918 dprintk("<-- %s\n", __func__
);
2922 * Clone an NFS4 server record on xdev traversal (FSID-change)
2924 static struct dentry
*
2925 nfs4_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2926 const char *dev_name
, void *raw_data
)
2928 struct nfs_clone_mount
*data
= raw_data
;
2929 struct super_block
*s
;
2930 struct nfs_server
*server
;
2931 struct dentry
*mntroot
;
2932 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2933 struct nfs_sb_mountdata sb_mntdata
= {
2938 dprintk("--> nfs4_xdev_mount()\n");
2940 /* create a new volume representation */
2941 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2942 if (IS_ERR(server
)) {
2943 error
= PTR_ERR(server
);
2944 goto out_err_noserver
;
2946 sb_mntdata
.server
= server
;
2948 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2949 compare_super
= NULL
;
2951 /* Get a superblock - note that we may end up sharing one that already exists */
2952 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2958 if (s
->s_fs_info
!= server
) {
2959 nfs_free_server(server
);
2962 error
= nfs_bdi_register(server
);
2964 goto error_splat_bdi
;
2968 /* initial superblock/root creation */
2969 nfs4_clone_super(s
, data
->sb
);
2970 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2973 mntroot
= nfs4_get_root(s
, data
->fh
);
2974 if (IS_ERR(mntroot
)) {
2975 error
= PTR_ERR(mntroot
);
2976 goto error_splat_super
;
2978 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2981 goto error_splat_super
;
2984 s
->s_flags
|= MS_ACTIVE
;
2986 security_sb_clone_mnt_opts(data
->sb
, s
);
2988 dprintk("<-- nfs4_xdev_mount() = 0\n");
2992 nfs_free_server(server
);
2994 dprintk("<-- nfs4_xdev_mount() = %d [error]\n", error
);
2995 return ERR_PTR(error
);
2998 if (server
&& !s
->s_root
)
2999 bdi_unregister(&server
->backing_dev_info
);
3001 deactivate_locked_super(s
);
3002 dprintk("<-- nfs4_xdev_mount() = %d [splat]\n", error
);
3003 return ERR_PTR(error
);
3006 static struct dentry
*
3007 nfs4_remote_referral_mount(struct file_system_type
*fs_type
, int flags
,
3008 const char *dev_name
, void *raw_data
)
3010 struct nfs_clone_mount
*data
= raw_data
;
3011 struct super_block
*s
;
3012 struct nfs_server
*server
;
3013 struct dentry
*mntroot
;
3014 struct nfs_fh
*mntfh
;
3015 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
3016 struct nfs_sb_mountdata sb_mntdata
= {
3019 int error
= -ENOMEM
;
3021 dprintk("--> nfs4_referral_get_sb()\n");
3023 mntfh
= nfs_alloc_fhandle();
3027 /* create a new volume representation */
3028 server
= nfs4_create_referral_server(data
, mntfh
);
3029 if (IS_ERR(server
)) {
3030 error
= PTR_ERR(server
);
3031 goto out_err_noserver
;
3033 sb_mntdata
.server
= server
;
3035 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
3036 compare_super
= NULL
;
3038 /* Get a superblock - note that we may end up sharing one that already exists */
3039 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3045 if (s
->s_fs_info
!= server
) {
3046 nfs_free_server(server
);
3049 error
= nfs_bdi_register(server
);
3051 goto error_splat_bdi
;
3055 /* initial superblock/root creation */
3057 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3060 mntroot
= nfs4_get_root(s
, mntfh
);
3061 if (IS_ERR(mntroot
)) {
3062 error
= PTR_ERR(mntroot
);
3063 goto error_splat_super
;
3065 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3068 goto error_splat_super
;
3071 s
->s_flags
|= MS_ACTIVE
;
3073 security_sb_clone_mnt_opts(data
->sb
, s
);
3075 nfs_free_fhandle(mntfh
);
3076 dprintk("<-- nfs4_referral_get_sb() = 0\n");
3080 nfs_free_server(server
);
3082 nfs_free_fhandle(mntfh
);
3084 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error
);
3085 return ERR_PTR(error
);
3088 if (server
&& !s
->s_root
)
3089 bdi_unregister(&server
->backing_dev_info
);
3091 deactivate_locked_super(s
);
3092 nfs_free_fhandle(mntfh
);
3093 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error
);
3094 return ERR_PTR(error
);
3098 * Create an NFS4 server record on referral traversal
3100 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
3101 int flags
, const char *dev_name
, void *raw_data
,
3102 struct vfsmount
*mnt
)
3104 struct nfs_clone_mount
*data
= raw_data
;
3106 struct vfsmount
*root_mnt
;
3109 dprintk("--> nfs4_referral_get_sb()\n");
3111 export_path
= data
->mnt_path
;
3112 data
->mnt_path
= "/";
3114 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
3115 flags
, data
, data
->hostname
);
3116 data
->mnt_path
= export_path
;
3118 error
= PTR_ERR(root_mnt
);
3119 if (IS_ERR(root_mnt
))
3122 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
3124 dprintk("<-- nfs4_referral_get_sb() = %d%s\n", error
,
3125 error
!= 0 ? " [error]" : "");
3129 #endif /* CONFIG_NFS_V4 */