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/smp_lock.h>
43 #include <linux/seq_file.h>
44 #include <linux/mount.h>
45 #include <linux/mnt_namespace.h>
46 #include <linux/namei.h>
47 #include <linux/nfs_idmap.h>
48 #include <linux/vfs.h>
49 #include <linux/inet.h>
50 #include <linux/in6.h>
51 #include <linux/slab.h>
53 #include <linux/netdevice.h>
54 #include <linux/nfs_xdr.h>
55 #include <linux/magic.h>
56 #include <linux/parser.h>
58 #include <asm/system.h>
59 #include <asm/uaccess.h>
63 #include "delegation.h"
68 #define NFSDBG_FACILITY NFSDBG_VFS
71 /* Mount options that take no arguments */
73 Opt_posix
, Opt_noposix
,
77 Opt_v2
, Opt_v3
, Opt_v4
,
78 Opt_udp
, Opt_tcp
, Opt_rdma
,
80 Opt_rdirplus
, Opt_nordirplus
,
81 Opt_sharecache
, Opt_nosharecache
,
82 Opt_resvport
, Opt_noresvport
,
83 Opt_fscache
, Opt_nofscache
,
85 /* Mount options that take integer arguments */
87 Opt_rsize
, Opt_wsize
, Opt_bsize
,
88 Opt_timeo
, Opt_retrans
,
89 Opt_acregmin
, Opt_acregmax
,
90 Opt_acdirmin
, Opt_acdirmax
,
98 /* Mount options that take string arguments */
99 Opt_sec
, Opt_proto
, Opt_mountproto
, Opt_mounthost
,
100 Opt_addr
, Opt_mountaddr
, Opt_clientaddr
,
105 /* Special mount options */
106 Opt_userspace
, Opt_deprecated
, Opt_sloppy
,
111 static const match_table_t nfs_mount_option_tokens
= {
112 { Opt_userspace
, "bg" },
113 { Opt_userspace
, "fg" },
114 { Opt_userspace
, "retry=%s" },
116 { Opt_sloppy
, "sloppy" },
118 { Opt_soft
, "soft" },
119 { Opt_hard
, "hard" },
120 { Opt_deprecated
, "intr" },
121 { Opt_deprecated
, "nointr" },
122 { Opt_posix
, "posix" },
123 { Opt_noposix
, "noposix" },
125 { Opt_nocto
, "nocto" },
127 { Opt_noac
, "noac" },
128 { Opt_lock
, "lock" },
129 { Opt_nolock
, "nolock" },
135 { Opt_rdma
, "rdma" },
137 { Opt_noacl
, "noacl" },
138 { Opt_rdirplus
, "rdirplus" },
139 { Opt_nordirplus
, "nordirplus" },
140 { Opt_sharecache
, "sharecache" },
141 { Opt_nosharecache
, "nosharecache" },
142 { Opt_resvport
, "resvport" },
143 { Opt_noresvport
, "noresvport" },
144 { Opt_fscache
, "fsc" },
145 { Opt_nofscache
, "nofsc" },
147 { Opt_port
, "port=%s" },
148 { Opt_rsize
, "rsize=%s" },
149 { Opt_wsize
, "wsize=%s" },
150 { Opt_bsize
, "bsize=%s" },
151 { Opt_timeo
, "timeo=%s" },
152 { Opt_retrans
, "retrans=%s" },
153 { Opt_acregmin
, "acregmin=%s" },
154 { Opt_acregmax
, "acregmax=%s" },
155 { Opt_acdirmin
, "acdirmin=%s" },
156 { Opt_acdirmax
, "acdirmax=%s" },
157 { Opt_actimeo
, "actimeo=%s" },
158 { Opt_namelen
, "namlen=%s" },
159 { Opt_mountport
, "mountport=%s" },
160 { Opt_mountvers
, "mountvers=%s" },
161 { Opt_nfsvers
, "nfsvers=%s" },
162 { Opt_nfsvers
, "vers=%s" },
163 { Opt_minorversion
, "minorversion=%s" },
165 { Opt_sec
, "sec=%s" },
166 { Opt_proto
, "proto=%s" },
167 { Opt_mountproto
, "mountproto=%s" },
168 { Opt_addr
, "addr=%s" },
169 { Opt_clientaddr
, "clientaddr=%s" },
170 { Opt_mounthost
, "mounthost=%s" },
171 { Opt_mountaddr
, "mountaddr=%s" },
173 { Opt_lookupcache
, "lookupcache=%s" },
174 { Opt_fscache_uniq
, "fsc=%s" },
175 { Opt_local_lock
, "local_lock=%s" },
181 Opt_xprt_udp
, Opt_xprt_udp6
, Opt_xprt_tcp
, Opt_xprt_tcp6
, Opt_xprt_rdma
,
186 static const match_table_t nfs_xprt_protocol_tokens
= {
187 { Opt_xprt_udp
, "udp" },
188 { Opt_xprt_udp6
, "udp6" },
189 { Opt_xprt_tcp
, "tcp" },
190 { Opt_xprt_tcp6
, "tcp6" },
191 { Opt_xprt_rdma
, "rdma" },
193 { Opt_xprt_err
, NULL
}
197 Opt_sec_none
, Opt_sec_sys
,
198 Opt_sec_krb5
, Opt_sec_krb5i
, Opt_sec_krb5p
,
199 Opt_sec_lkey
, Opt_sec_lkeyi
, Opt_sec_lkeyp
,
200 Opt_sec_spkm
, Opt_sec_spkmi
, Opt_sec_spkmp
,
205 static const match_table_t nfs_secflavor_tokens
= {
206 { Opt_sec_none
, "none" },
207 { Opt_sec_none
, "null" },
208 { Opt_sec_sys
, "sys" },
210 { Opt_sec_krb5
, "krb5" },
211 { Opt_sec_krb5i
, "krb5i" },
212 { Opt_sec_krb5p
, "krb5p" },
214 { Opt_sec_lkey
, "lkey" },
215 { Opt_sec_lkeyi
, "lkeyi" },
216 { Opt_sec_lkeyp
, "lkeyp" },
218 { Opt_sec_spkm
, "spkm3" },
219 { Opt_sec_spkmi
, "spkm3i" },
220 { Opt_sec_spkmp
, "spkm3p" },
222 { Opt_sec_err
, NULL
}
226 Opt_lookupcache_all
, Opt_lookupcache_positive
,
227 Opt_lookupcache_none
,
232 static match_table_t nfs_lookupcache_tokens
= {
233 { Opt_lookupcache_all
, "all" },
234 { Opt_lookupcache_positive
, "pos" },
235 { Opt_lookupcache_positive
, "positive" },
236 { Opt_lookupcache_none
, "none" },
238 { Opt_lookupcache_err
, NULL
}
242 Opt_local_lock_all
, Opt_local_lock_flock
, Opt_local_lock_posix
,
248 static match_table_t nfs_local_lock_tokens
= {
249 { Opt_local_lock_all
, "all" },
250 { Opt_local_lock_flock
, "flock" },
251 { Opt_local_lock_posix
, "posix" },
252 { Opt_local_lock_none
, "none" },
254 { Opt_local_lock_err
, NULL
}
258 static void nfs_umount_begin(struct super_block
*);
259 static int nfs_statfs(struct dentry
*, struct kstatfs
*);
260 static int nfs_show_options(struct seq_file
*, struct vfsmount
*);
261 static int nfs_show_stats(struct seq_file
*, struct vfsmount
*);
262 static int nfs_get_sb(struct file_system_type
*, int, const char *, void *, struct vfsmount
*);
263 static int nfs_xdev_get_sb(struct file_system_type
*fs_type
,
264 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
265 static void nfs_put_super(struct super_block
*);
266 static void nfs_kill_super(struct super_block
*);
267 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
269 static struct file_system_type nfs_fs_type
= {
270 .owner
= THIS_MODULE
,
272 .get_sb
= nfs_get_sb
,
273 .kill_sb
= nfs_kill_super
,
274 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
277 struct file_system_type nfs_xdev_fs_type
= {
278 .owner
= THIS_MODULE
,
280 .get_sb
= nfs_xdev_get_sb
,
281 .kill_sb
= nfs_kill_super
,
282 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
285 static const struct super_operations nfs_sops
= {
286 .alloc_inode
= nfs_alloc_inode
,
287 .destroy_inode
= nfs_destroy_inode
,
288 .write_inode
= nfs_write_inode
,
289 .put_super
= nfs_put_super
,
290 .statfs
= nfs_statfs
,
291 .evict_inode
= nfs_evict_inode
,
292 .umount_begin
= nfs_umount_begin
,
293 .show_options
= nfs_show_options
,
294 .show_stats
= nfs_show_stats
,
295 .remount_fs
= nfs_remount
,
299 static int nfs4_validate_text_mount_data(void *options
,
300 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
301 static int nfs4_try_mount(int flags
, const char *dev_name
,
302 struct nfs_parsed_mount_data
*data
, struct vfsmount
*mnt
);
303 static int nfs4_get_sb(struct file_system_type
*fs_type
,
304 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
305 static int nfs4_remote_get_sb(struct file_system_type
*fs_type
,
306 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
307 static int nfs4_xdev_get_sb(struct file_system_type
*fs_type
,
308 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
309 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
310 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
311 static int nfs4_remote_referral_get_sb(struct file_system_type
*fs_type
,
312 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
313 static void nfs4_kill_super(struct super_block
*sb
);
315 static struct file_system_type nfs4_fs_type
= {
316 .owner
= THIS_MODULE
,
318 .get_sb
= nfs4_get_sb
,
319 .kill_sb
= nfs4_kill_super
,
320 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
323 static struct file_system_type nfs4_remote_fs_type
= {
324 .owner
= THIS_MODULE
,
326 .get_sb
= nfs4_remote_get_sb
,
327 .kill_sb
= nfs4_kill_super
,
328 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
331 struct file_system_type nfs4_xdev_fs_type
= {
332 .owner
= THIS_MODULE
,
334 .get_sb
= nfs4_xdev_get_sb
,
335 .kill_sb
= nfs4_kill_super
,
336 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
339 static struct file_system_type nfs4_remote_referral_fs_type
= {
340 .owner
= THIS_MODULE
,
342 .get_sb
= nfs4_remote_referral_get_sb
,
343 .kill_sb
= nfs4_kill_super
,
344 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
347 struct file_system_type nfs4_referral_fs_type
= {
348 .owner
= THIS_MODULE
,
350 .get_sb
= nfs4_referral_get_sb
,
351 .kill_sb
= nfs4_kill_super
,
352 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
355 static const struct super_operations nfs4_sops
= {
356 .alloc_inode
= nfs_alloc_inode
,
357 .destroy_inode
= nfs_destroy_inode
,
358 .write_inode
= nfs_write_inode
,
359 .put_super
= nfs_put_super
,
360 .statfs
= nfs_statfs
,
361 .evict_inode
= nfs4_evict_inode
,
362 .umount_begin
= nfs_umount_begin
,
363 .show_options
= nfs_show_options
,
364 .show_stats
= nfs_show_stats
,
365 .remount_fs
= nfs_remount
,
369 static struct shrinker acl_shrinker
= {
370 .shrink
= nfs_access_cache_shrinker
,
371 .seeks
= DEFAULT_SEEKS
,
375 * Register the NFS filesystems
377 int __init
register_nfs_fs(void)
381 ret
= register_filesystem(&nfs_fs_type
);
385 ret
= nfs_register_sysctl();
389 ret
= register_filesystem(&nfs4_fs_type
);
393 register_shrinker(&acl_shrinker
);
398 nfs_unregister_sysctl();
401 unregister_filesystem(&nfs_fs_type
);
407 * Unregister the NFS filesystems
409 void __exit
unregister_nfs_fs(void)
411 unregister_shrinker(&acl_shrinker
);
413 unregister_filesystem(&nfs4_fs_type
);
415 nfs_unregister_sysctl();
416 unregister_filesystem(&nfs_fs_type
);
419 void nfs_sb_active(struct super_block
*sb
)
421 struct nfs_server
*server
= NFS_SB(sb
);
423 if (atomic_inc_return(&server
->active
) == 1)
424 atomic_inc(&sb
->s_active
);
427 void nfs_sb_deactive(struct super_block
*sb
)
429 struct nfs_server
*server
= NFS_SB(sb
);
431 if (atomic_dec_and_test(&server
->active
))
432 deactivate_super(sb
);
436 * Deliver file system statistics to userspace
438 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
440 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
441 unsigned char blockbits
;
442 unsigned long blockres
;
443 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
444 struct nfs_fsstat res
;
447 res
.fattr
= nfs_alloc_fattr();
448 if (res
.fattr
== NULL
)
451 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
452 if (unlikely(error
== -ESTALE
)) {
453 struct dentry
*pd_dentry
;
455 pd_dentry
= dget_parent(dentry
);
456 if (pd_dentry
!= NULL
) {
457 nfs_zap_caches(pd_dentry
->d_inode
);
461 nfs_free_fattr(res
.fattr
);
465 buf
->f_type
= NFS_SUPER_MAGIC
;
468 * Current versions of glibc do not correctly handle the
469 * case where f_frsize != f_bsize. Eventually we want to
470 * report the value of wtmult in this field.
472 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
475 * On most *nix systems, f_blocks, f_bfree, and f_bavail
476 * are reported in units of f_frsize. Linux hasn't had
477 * an f_frsize field in its statfs struct until recently,
478 * thus historically Linux's sys_statfs reports these
479 * fields in units of f_bsize.
481 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
482 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
483 blockres
= (1 << blockbits
) - 1;
484 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
485 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
486 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
488 buf
->f_files
= res
.tfiles
;
489 buf
->f_ffree
= res
.afiles
;
491 buf
->f_namelen
= server
->namelen
;
496 dprintk("%s: statfs error = %d\n", __func__
, -error
);
501 * Map the security flavour number to a name
503 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
505 static const struct {
506 rpc_authflavor_t flavour
;
509 { RPC_AUTH_NULL
, "null" },
510 { RPC_AUTH_UNIX
, "sys" },
511 { RPC_AUTH_GSS_KRB5
, "krb5" },
512 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
513 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
514 { RPC_AUTH_GSS_LKEY
, "lkey" },
515 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
516 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
517 { RPC_AUTH_GSS_SPKM
, "spkm" },
518 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
519 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
520 { UINT_MAX
, "unknown" }
524 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
525 if (sec_flavours
[i
].flavour
== flavour
)
528 return sec_flavours
[i
].str
;
531 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
534 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
536 seq_printf(m
, ",mountproto=");
537 switch (sap
->sa_family
) {
539 switch (nfss
->mountd_protocol
) {
541 seq_printf(m
, RPCBIND_NETID_UDP
);
544 seq_printf(m
, RPCBIND_NETID_TCP
);
548 seq_printf(m
, "auto");
552 switch (nfss
->mountd_protocol
) {
554 seq_printf(m
, RPCBIND_NETID_UDP6
);
557 seq_printf(m
, RPCBIND_NETID_TCP6
);
561 seq_printf(m
, "auto");
566 seq_printf(m
, "auto");
570 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
573 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
575 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
578 switch (sap
->sa_family
) {
580 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
581 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
585 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
586 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
591 seq_printf(m
, ",mountaddr=unspecified");
594 if (nfss
->mountd_version
|| showdefaults
)
595 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
596 if (nfss
->mountd_port
|| showdefaults
)
597 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
599 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
603 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
606 struct nfs_client
*clp
= nfss
->nfs_client
;
608 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
609 seq_printf(m
, ",minorversion=%u", clp
->cl_minorversion
);
612 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
619 * Describe the mount options in force on this server representation
621 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
624 static const struct proc_nfs_info
{
629 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
630 { NFS_MOUNT_POSIX
, ",posix", "" },
631 { NFS_MOUNT_NOCTO
, ",nocto", "" },
632 { NFS_MOUNT_NOAC
, ",noac", "" },
633 { NFS_MOUNT_NONLM
, ",nolock", "" },
634 { NFS_MOUNT_NOACL
, ",noacl", "" },
635 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
636 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
637 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
640 const struct proc_nfs_info
*nfs_infop
;
641 struct nfs_client
*clp
= nfss
->nfs_client
;
642 u32 version
= clp
->rpc_ops
->version
;
643 int local_flock
, local_fcntl
;
645 seq_printf(m
, ",vers=%u", version
);
646 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
647 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
648 if (nfss
->bsize
!= 0)
649 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
650 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
651 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
652 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
653 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
654 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
655 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
656 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
657 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
658 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
659 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
660 if (nfss
->flags
& nfs_infop
->flag
)
661 seq_puts(m
, nfs_infop
->str
);
663 seq_puts(m
, nfs_infop
->nostr
);
665 seq_printf(m
, ",proto=%s",
666 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
668 if (nfss
->port
!= NFS_PORT
)
669 seq_printf(m
, ",port=%u", nfss
->port
);
672 seq_printf(m
, ",port=%u", nfss
->port
);
674 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
675 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
676 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
679 nfs_show_mountd_options(m
, nfss
, showdefaults
);
681 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
683 if (nfss
->options
& NFS_OPTION_FSCACHE
)
684 seq_printf(m
, ",fsc");
686 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
687 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
688 seq_printf(m
, ",lookupcache=none");
690 seq_printf(m
, ",lookupcache=pos");
693 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
694 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
696 if (!local_flock
&& !local_fcntl
)
697 seq_printf(m
, ",local_lock=none");
698 else if (local_flock
&& local_fcntl
)
699 seq_printf(m
, ",local_lock=all");
700 else if (local_flock
)
701 seq_printf(m
, ",local_lock=flock");
703 seq_printf(m
, ",local_lock=posix");
707 * Describe the mount options on this VFS mountpoint
709 static int nfs_show_options(struct seq_file
*m
, struct vfsmount
*mnt
)
711 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
713 nfs_show_mount_options(m
, nfss
, 0);
715 seq_printf(m
, ",addr=%s",
716 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
723 * Present statistical information for this VFS mountpoint
725 static int nfs_show_stats(struct seq_file
*m
, struct vfsmount
*mnt
)
728 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
729 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
730 struct nfs_iostats totals
= { };
732 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
735 * Display all mount option settings
737 seq_printf(m
, "\n\topts:\t");
738 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
739 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
740 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
741 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
742 nfs_show_mount_options(m
, nfss
, 1);
744 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
746 seq_printf(m
, "\n\tcaps:\t");
747 seq_printf(m
, "caps=0x%x", nfss
->caps
);
748 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
749 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
750 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
751 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
754 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
755 seq_printf(m
, "\n\tnfsv4:\t");
756 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
757 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
758 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
763 * Display security flavor in effect for this mount
765 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
767 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
770 * Display superblock I/O counters
772 for_each_possible_cpu(cpu
) {
773 struct nfs_iostats
*stats
;
776 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
778 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
779 totals
.events
[i
] += stats
->events
[i
];
780 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
781 totals
.bytes
[i
] += stats
->bytes
[i
];
782 #ifdef CONFIG_NFS_FSCACHE
783 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
784 totals
.fscache
[i
] += stats
->fscache
[i
];
790 seq_printf(m
, "\n\tevents:\t");
791 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
792 seq_printf(m
, "%lu ", totals
.events
[i
]);
793 seq_printf(m
, "\n\tbytes:\t");
794 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
795 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
796 #ifdef CONFIG_NFS_FSCACHE
797 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
798 seq_printf(m
, "\n\tfsc:\t");
799 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
800 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
805 rpc_print_iostats(m
, nfss
->client
);
811 * Begin unmount by attempting to remove all automounted mountpoints we added
812 * in response to xdev traversals and referrals
814 static void nfs_umount_begin(struct super_block
*sb
)
816 struct nfs_server
*server
;
817 struct rpc_clnt
*rpc
;
820 /* -EIO all pending I/O */
821 rpc
= server
->client_acl
;
823 rpc_killall_tasks(rpc
);
824 rpc
= server
->client
;
826 rpc_killall_tasks(rpc
);
829 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(unsigned int version
)
831 struct nfs_parsed_mount_data
*data
;
833 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
835 data
->acregmin
= NFS_DEF_ACREGMIN
;
836 data
->acregmax
= NFS_DEF_ACREGMAX
;
837 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
838 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
839 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
840 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
841 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
842 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
843 data
->auth_flavor_len
= 1;
844 data
->version
= version
;
845 data
->minorversion
= 0;
851 * Sanity-check a server address provided by the mount command.
853 * Address family must be initialized, and address must not be
854 * the ANY address for that family.
856 static int nfs_verify_server_address(struct sockaddr
*addr
)
858 switch (addr
->sa_family
) {
860 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
861 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
864 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
865 return !ipv6_addr_any(sa
);
869 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
874 * Select between a default port value and a user-specified port value.
875 * If a zero value is set, then autobind will be used.
877 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
878 const unsigned short default_port
)
880 if (*port
== NFS_UNSPEC_PORT
)
881 *port
= default_port
;
883 rpc_set_port(sap
, *port
);
887 * Sanity check the NFS transport protocol.
890 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
892 switch (mnt
->nfs_server
.protocol
) {
893 case XPRT_TRANSPORT_UDP
:
894 case XPRT_TRANSPORT_TCP
:
895 case XPRT_TRANSPORT_RDMA
:
898 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
903 * For text based NFSv2/v3 mounts, the mount protocol transport default
904 * settings should depend upon the specified NFS transport.
906 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
908 nfs_validate_transport_protocol(mnt
);
910 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
911 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
913 switch (mnt
->nfs_server
.protocol
) {
914 case XPRT_TRANSPORT_UDP
:
915 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
917 case XPRT_TRANSPORT_TCP
:
918 case XPRT_TRANSPORT_RDMA
:
919 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
924 * Parse the value of the 'sec=' option.
926 static int nfs_parse_security_flavors(char *value
,
927 struct nfs_parsed_mount_data
*mnt
)
929 substring_t args
[MAX_OPT_ARGS
];
931 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
933 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
935 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
938 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
941 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
944 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
947 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
950 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
953 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
956 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
959 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
962 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
965 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
971 mnt
->auth_flavor_len
= 1;
976 * Error-check and convert a string of mount options from user space into
977 * a data structure. The whole mount string is processed; bad options are
978 * skipped as they are encountered. If there were no errors, return 1;
979 * otherwise return 0 (zero).
981 static int nfs_parse_mount_options(char *raw
,
982 struct nfs_parsed_mount_data
*mnt
)
984 char *p
, *string
, *secdata
;
985 int rc
, sloppy
= 0, invalid_option
= 0;
986 unsigned short protofamily
= AF_UNSPEC
;
987 unsigned short mountfamily
= AF_UNSPEC
;
990 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
993 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
995 secdata
= alloc_secdata();
999 rc
= security_sb_copy_data(raw
, secdata
);
1001 goto out_security_failure
;
1003 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1005 goto out_security_failure
;
1007 free_secdata(secdata
);
1009 while ((p
= strsep(&raw
, ",")) != NULL
) {
1010 substring_t args
[MAX_OPT_ARGS
];
1011 unsigned long option
;
1017 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1019 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1023 * boolean options: foo/nofoo
1026 mnt
->flags
|= NFS_MOUNT_SOFT
;
1029 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1032 mnt
->flags
|= NFS_MOUNT_POSIX
;
1035 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1038 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1041 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1044 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1047 mnt
->flags
|= NFS_MOUNT_NOAC
;
1050 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1051 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1052 NFS_MOUNT_LOCAL_FCNTL
);
1055 mnt
->flags
|= NFS_MOUNT_NONLM
;
1056 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1057 NFS_MOUNT_LOCAL_FCNTL
);
1060 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1064 mnt
->flags
|= NFS_MOUNT_VER3
;
1067 #ifdef CONFIG_NFS_V4
1069 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1074 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1075 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1078 mnt
->flags
|= NFS_MOUNT_TCP
;
1079 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1082 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1083 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1084 xprt_load_transport(p
);
1087 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1090 mnt
->flags
|= NFS_MOUNT_NOACL
;
1093 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1095 case Opt_nordirplus
:
1096 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1098 case Opt_sharecache
:
1099 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1101 case Opt_nosharecache
:
1102 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1105 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1107 case Opt_noresvport
:
1108 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1111 mnt
->options
|= NFS_OPTION_FSCACHE
;
1112 kfree(mnt
->fscache_uniq
);
1113 mnt
->fscache_uniq
= NULL
;
1116 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1117 kfree(mnt
->fscache_uniq
);
1118 mnt
->fscache_uniq
= NULL
;
1122 * options that take numeric values
1125 string
= match_strdup(args
);
1128 rc
= strict_strtoul(string
, 10, &option
);
1130 if (rc
!= 0 || option
> USHRT_MAX
)
1131 goto out_invalid_value
;
1132 mnt
->nfs_server
.port
= option
;
1135 string
= match_strdup(args
);
1138 rc
= strict_strtoul(string
, 10, &option
);
1141 goto out_invalid_value
;
1142 mnt
->rsize
= option
;
1145 string
= match_strdup(args
);
1148 rc
= strict_strtoul(string
, 10, &option
);
1151 goto out_invalid_value
;
1152 mnt
->wsize
= option
;
1155 string
= match_strdup(args
);
1158 rc
= strict_strtoul(string
, 10, &option
);
1161 goto out_invalid_value
;
1162 mnt
->bsize
= option
;
1165 string
= match_strdup(args
);
1168 rc
= strict_strtoul(string
, 10, &option
);
1170 if (rc
!= 0 || option
== 0)
1171 goto out_invalid_value
;
1172 mnt
->timeo
= option
;
1175 string
= match_strdup(args
);
1178 rc
= strict_strtoul(string
, 10, &option
);
1180 if (rc
!= 0 || option
== 0)
1181 goto out_invalid_value
;
1182 mnt
->retrans
= option
;
1185 string
= match_strdup(args
);
1188 rc
= strict_strtoul(string
, 10, &option
);
1191 goto out_invalid_value
;
1192 mnt
->acregmin
= option
;
1195 string
= match_strdup(args
);
1198 rc
= strict_strtoul(string
, 10, &option
);
1201 goto out_invalid_value
;
1202 mnt
->acregmax
= option
;
1205 string
= match_strdup(args
);
1208 rc
= strict_strtoul(string
, 10, &option
);
1211 goto out_invalid_value
;
1212 mnt
->acdirmin
= option
;
1215 string
= match_strdup(args
);
1218 rc
= strict_strtoul(string
, 10, &option
);
1221 goto out_invalid_value
;
1222 mnt
->acdirmax
= option
;
1225 string
= match_strdup(args
);
1228 rc
= strict_strtoul(string
, 10, &option
);
1231 goto out_invalid_value
;
1232 mnt
->acregmin
= mnt
->acregmax
=
1233 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1236 string
= match_strdup(args
);
1239 rc
= strict_strtoul(string
, 10, &option
);
1242 goto out_invalid_value
;
1243 mnt
->namlen
= option
;
1246 string
= match_strdup(args
);
1249 rc
= strict_strtoul(string
, 10, &option
);
1251 if (rc
!= 0 || option
> USHRT_MAX
)
1252 goto out_invalid_value
;
1253 mnt
->mount_server
.port
= option
;
1256 string
= match_strdup(args
);
1259 rc
= strict_strtoul(string
, 10, &option
);
1262 option
< NFS_MNT_VERSION
||
1263 option
> NFS_MNT3_VERSION
)
1264 goto out_invalid_value
;
1265 mnt
->mount_server
.version
= option
;
1268 string
= match_strdup(args
);
1271 rc
= strict_strtoul(string
, 10, &option
);
1274 goto out_invalid_value
;
1277 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1281 mnt
->flags
|= NFS_MOUNT_VER3
;
1284 #ifdef CONFIG_NFS_V4
1286 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1291 goto out_invalid_value
;
1294 case Opt_minorversion
:
1295 string
= match_strdup(args
);
1298 rc
= strict_strtoul(string
, 10, &option
);
1301 goto out_invalid_value
;
1302 if (option
> NFS4_MAX_MINOR_VERSION
)
1303 goto out_invalid_value
;
1304 mnt
->minorversion
= option
;
1308 * options that take text values
1311 string
= match_strdup(args
);
1314 rc
= nfs_parse_security_flavors(string
, mnt
);
1317 dfprintk(MOUNT
, "NFS: unrecognized "
1318 "security flavor\n");
1323 string
= match_strdup(args
);
1326 token
= match_token(string
,
1327 nfs_xprt_protocol_tokens
, args
);
1329 protofamily
= AF_INET
;
1332 protofamily
= AF_INET6
;
1334 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1335 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1339 protofamily
= AF_INET6
;
1341 mnt
->flags
|= NFS_MOUNT_TCP
;
1342 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1346 /* vector side protocols to TCP */
1347 mnt
->flags
|= NFS_MOUNT_TCP
;
1348 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1349 xprt_load_transport(string
);
1353 dfprintk(MOUNT
, "NFS: unrecognized "
1354 "transport protocol\n");
1359 case Opt_mountproto
:
1360 string
= match_strdup(args
);
1363 token
= match_token(string
,
1364 nfs_xprt_protocol_tokens
, args
);
1367 mountfamily
= AF_INET
;
1370 mountfamily
= AF_INET6
;
1372 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1375 mountfamily
= AF_INET6
;
1377 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1379 case Opt_xprt_rdma
: /* not used for side protocols */
1381 dfprintk(MOUNT
, "NFS: unrecognized "
1382 "transport protocol\n");
1387 string
= match_strdup(args
);
1390 mnt
->nfs_server
.addrlen
=
1391 rpc_pton(string
, strlen(string
),
1393 &mnt
->nfs_server
.address
,
1394 sizeof(mnt
->nfs_server
.address
));
1396 if (mnt
->nfs_server
.addrlen
== 0)
1397 goto out_invalid_address
;
1399 case Opt_clientaddr
:
1400 string
= match_strdup(args
);
1403 kfree(mnt
->client_address
);
1404 mnt
->client_address
= string
;
1407 string
= match_strdup(args
);
1410 kfree(mnt
->mount_server
.hostname
);
1411 mnt
->mount_server
.hostname
= string
;
1414 string
= match_strdup(args
);
1417 mnt
->mount_server
.addrlen
=
1418 rpc_pton(string
, strlen(string
),
1420 &mnt
->mount_server
.address
,
1421 sizeof(mnt
->mount_server
.address
));
1423 if (mnt
->mount_server
.addrlen
== 0)
1424 goto out_invalid_address
;
1426 case Opt_lookupcache
:
1427 string
= match_strdup(args
);
1430 token
= match_token(string
,
1431 nfs_lookupcache_tokens
, args
);
1434 case Opt_lookupcache_all
:
1435 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1437 case Opt_lookupcache_positive
:
1438 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1439 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1441 case Opt_lookupcache_none
:
1442 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1445 dfprintk(MOUNT
, "NFS: invalid "
1446 "lookupcache argument\n");
1450 case Opt_fscache_uniq
:
1451 string
= match_strdup(args
);
1454 kfree(mnt
->fscache_uniq
);
1455 mnt
->fscache_uniq
= string
;
1456 mnt
->options
|= NFS_OPTION_FSCACHE
;
1458 case Opt_local_lock
:
1459 string
= match_strdup(args
);
1462 token
= match_token(string
, nfs_local_lock_tokens
,
1466 case Opt_local_lock_all
:
1467 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1468 NFS_MOUNT_LOCAL_FCNTL
);
1470 case Opt_local_lock_flock
:
1471 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1473 case Opt_local_lock_posix
:
1474 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1476 case Opt_local_lock_none
:
1477 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1478 NFS_MOUNT_LOCAL_FCNTL
);
1481 dfprintk(MOUNT
, "NFS: invalid "
1482 "local_lock argument\n");
1492 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1495 case Opt_deprecated
:
1496 dfprintk(MOUNT
, "NFS: ignoring mount option "
1502 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1507 if (!sloppy
&& invalid_option
)
1511 * verify that any proto=/mountproto= options match the address
1512 * familiies in the addr=/mountaddr= options.
1514 if (protofamily
!= AF_UNSPEC
&&
1515 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1516 goto out_proto_mismatch
;
1518 if (mountfamily
!= AF_UNSPEC
) {
1519 if (mnt
->mount_server
.addrlen
) {
1520 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1521 goto out_mountproto_mismatch
;
1523 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1524 goto out_mountproto_mismatch
;
1530 out_mountproto_mismatch
:
1531 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1535 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1537 out_invalid_address
:
1538 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1541 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1544 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1546 out_security_failure
:
1547 free_secdata(secdata
);
1548 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1553 * Match the requested auth flavors with the list returned by
1554 * the server. Returns zero and sets the mount's authentication
1555 * flavor on success; returns -EACCES if server does not support
1556 * the requested flavor.
1558 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1559 struct nfs_mount_request
*request
)
1561 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1564 * Certain releases of Linux's mountd return an empty
1565 * flavor list. To prevent behavioral regression with
1566 * these servers (ie. rejecting mounts that used to
1567 * succeed), revert to pre-2.6.32 behavior (no checking)
1568 * if the returned flavor list is empty.
1570 if (server_authlist_len
== 0)
1574 * We avoid sophisticated negotiating here, as there are
1575 * plenty of cases where we can get it wrong, providing
1576 * either too little or too much security.
1578 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1579 * flavor listed first. However, some servers list
1580 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1581 * preferred default, in args->auth_flavors[0] if user
1582 * didn't specify sec= mount option.
1584 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1585 for (j
= 0; j
< server_authlist_len
; j
++)
1586 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1587 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1588 request
->auth_flavs
[j
]);
1589 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1593 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1594 nfs_umount(request
);
1599 * Use the remote server's MOUNT service to request the NFS file handle
1600 * corresponding to the provided path.
1602 static int nfs_try_mount(struct nfs_parsed_mount_data
*args
,
1603 struct nfs_fh
*root_fh
)
1605 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1606 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1607 struct nfs_mount_request request
= {
1608 .sap
= (struct sockaddr
*)
1609 &args
->mount_server
.address
,
1610 .dirpath
= args
->nfs_server
.export_path
,
1611 .protocol
= args
->mount_server
.protocol
,
1613 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1614 .auth_flav_len
= &server_authlist_len
,
1615 .auth_flavs
= server_authlist
,
1619 if (args
->mount_server
.version
== 0) {
1620 switch (args
->version
) {
1622 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1625 args
->mount_server
.version
= NFS_MNT_VERSION
;
1628 request
.version
= args
->mount_server
.version
;
1630 if (args
->mount_server
.hostname
)
1631 request
.hostname
= args
->mount_server
.hostname
;
1633 request
.hostname
= args
->nfs_server
.hostname
;
1636 * Construct the mount server's address.
1638 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1639 memcpy(request
.sap
, &args
->nfs_server
.address
,
1640 args
->nfs_server
.addrlen
);
1641 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1643 request
.salen
= args
->mount_server
.addrlen
;
1644 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1647 * Now ask the mount server to map our export path
1650 status
= nfs_mount(&request
);
1652 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1653 request
.hostname
, status
);
1658 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1660 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1662 return nfs_walk_authlist(args
, &request
);
1665 static int nfs_parse_simple_hostname(const char *dev_name
,
1666 char **hostname
, size_t maxnamlen
,
1667 char **export_path
, size_t maxpathlen
)
1670 char *colon
, *comma
;
1672 colon
= strchr(dev_name
, ':');
1674 goto out_bad_devname
;
1676 len
= colon
- dev_name
;
1677 if (len
> maxnamlen
)
1680 /* N.B. caller will free nfs_server.hostname in all cases */
1681 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1685 /* kill possible hostname list: not supported */
1686 comma
= strchr(*hostname
, ',');
1687 if (comma
!= NULL
) {
1688 if (comma
== *hostname
)
1689 goto out_bad_devname
;
1694 len
= strlen(colon
);
1695 if (len
> maxpathlen
)
1697 *export_path
= kstrndup(colon
, len
, GFP_KERNEL
);
1701 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1705 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1709 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1713 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1714 return -ENAMETOOLONG
;
1717 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1718 return -ENAMETOOLONG
;
1722 * Hostname has square brackets around it because it contains one or
1723 * more colons. We look for the first closing square bracket, and a
1724 * colon must follow it.
1726 static int nfs_parse_protected_hostname(const char *dev_name
,
1727 char **hostname
, size_t maxnamlen
,
1728 char **export_path
, size_t maxpathlen
)
1733 start
= (char *)(dev_name
+ 1);
1735 end
= strchr(start
, ']');
1737 goto out_bad_devname
;
1738 if (*(end
+ 1) != ':')
1739 goto out_bad_devname
;
1742 if (len
> maxnamlen
)
1745 /* N.B. caller will free nfs_server.hostname in all cases */
1746 *hostname
= kstrndup(start
, len
, GFP_KERNEL
);
1747 if (*hostname
== NULL
)
1752 if (len
> maxpathlen
)
1754 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1761 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1765 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1769 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1770 return -ENAMETOOLONG
;
1773 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1774 return -ENAMETOOLONG
;
1778 * Split "dev_name" into "hostname:export_path".
1780 * The leftmost colon demarks the split between the server's hostname
1781 * and the export path. If the hostname starts with a left square
1782 * bracket, then it may contain colons.
1784 * Note: caller frees hostname and export path, even on error.
1786 static int nfs_parse_devname(const char *dev_name
,
1787 char **hostname
, size_t maxnamlen
,
1788 char **export_path
, size_t maxpathlen
)
1790 if (*dev_name
== '[')
1791 return nfs_parse_protected_hostname(dev_name
,
1792 hostname
, maxnamlen
,
1793 export_path
, maxpathlen
);
1795 return nfs_parse_simple_hostname(dev_name
,
1796 hostname
, maxnamlen
,
1797 export_path
, maxpathlen
);
1801 * Validate the NFS2/NFS3 mount data
1802 * - fills in the mount root filehandle
1804 * For option strings, user space handles the following behaviors:
1806 * + DNS: mapping server host name to IP address ("addr=" option)
1808 * + failure mode: how to behave if a mount request can't be handled
1809 * immediately ("fg/bg" option)
1811 * + retry: how often to retry a mount request ("retry=" option)
1813 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1814 * mountproto=tcp after mountproto=udp, and so on
1816 static int nfs_validate_mount_data(void *options
,
1817 struct nfs_parsed_mount_data
*args
,
1818 struct nfs_fh
*mntfh
,
1819 const char *dev_name
)
1821 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1822 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1827 switch (data
->version
) {
1833 if (data
->flags
& NFS_MOUNT_VER3
)
1835 data
->root
.size
= NFS2_FHSIZE
;
1836 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1838 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1841 memset(data
->context
, 0, sizeof(data
->context
));
1843 if (data
->flags
& NFS_MOUNT_VER3
) {
1844 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1845 goto out_invalid_fh
;
1846 mntfh
->size
= data
->root
.size
;
1849 mntfh
->size
= NFS2_FHSIZE
;
1854 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1855 if (mntfh
->size
< sizeof(mntfh
->data
))
1856 memset(mntfh
->data
+ mntfh
->size
, 0,
1857 sizeof(mntfh
->data
) - mntfh
->size
);
1860 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1863 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1864 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1865 args
->rsize
= data
->rsize
;
1866 args
->wsize
= data
->wsize
;
1867 args
->timeo
= data
->timeo
;
1868 args
->retrans
= data
->retrans
;
1869 args
->acregmin
= data
->acregmin
;
1870 args
->acregmax
= data
->acregmax
;
1871 args
->acdirmin
= data
->acdirmin
;
1872 args
->acdirmax
= data
->acdirmax
;
1874 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1875 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1876 if (!nfs_verify_server_address(sap
))
1877 goto out_no_address
;
1879 if (!(data
->flags
& NFS_MOUNT_TCP
))
1880 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1881 /* N.B. caller will free nfs_server.hostname in all cases */
1882 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1883 args
->namlen
= data
->namlen
;
1884 args
->bsize
= data
->bsize
;
1886 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1887 args
->auth_flavors
[0] = data
->pseudoflavor
;
1888 if (!args
->nfs_server
.hostname
)
1891 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1892 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1893 NFS_MOUNT_LOCAL_FCNTL
);
1895 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1896 NFS_MOUNT_LOCAL_FCNTL
);
1898 * The legacy version 6 binary mount data from userspace has a
1899 * field used only to transport selinux information into the
1900 * the kernel. To continue to support that functionality we
1901 * have a touch of selinux knowledge here in the NFS code. The
1902 * userspace code converted context=blah to just blah so we are
1903 * converting back to the full string selinux understands.
1905 if (data
->context
[0]){
1906 #ifdef CONFIG_SECURITY_SELINUX
1908 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1911 strcpy(opts_str
, "context=");
1912 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1913 strcat(opts_str
, &data
->context
[0]);
1914 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1927 if (nfs_parse_mount_options((char *)options
, args
) == 0)
1930 if (!nfs_verify_server_address(sap
))
1931 goto out_no_address
;
1933 if (args
->version
== 4)
1934 #ifdef CONFIG_NFS_V4
1935 return nfs4_validate_text_mount_data(options
,
1938 goto out_v4_not_compiled
;
1941 nfs_set_port(sap
, &args
->nfs_server
.port
, 0);
1943 nfs_set_mount_transport_protocol(args
);
1945 status
= nfs_parse_devname(dev_name
,
1946 &args
->nfs_server
.hostname
,
1948 &args
->nfs_server
.export_path
,
1951 status
= nfs_try_mount(args
, mntfh
);
1953 kfree(args
->nfs_server
.export_path
);
1954 args
->nfs_server
.export_path
= NULL
;
1963 #ifndef CONFIG_NFS_V3
1964 if (args
->version
== 3)
1965 goto out_v3_not_compiled
;
1966 #endif /* !CONFIG_NFS_V3 */
1971 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1975 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1980 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1983 #ifndef CONFIG_NFS_V3
1984 out_v3_not_compiled
:
1985 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1986 return -EPROTONOSUPPORT
;
1987 #endif /* !CONFIG_NFS_V3 */
1989 #ifndef CONFIG_NFS_V4
1990 out_v4_not_compiled
:
1991 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
1992 return -EPROTONOSUPPORT
;
1993 #endif /* !CONFIG_NFS_V4 */
1996 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
2000 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2004 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
2009 nfs_compare_remount_data(struct nfs_server
*nfss
,
2010 struct nfs_parsed_mount_data
*data
)
2012 if (data
->flags
!= nfss
->flags
||
2013 data
->rsize
!= nfss
->rsize
||
2014 data
->wsize
!= nfss
->wsize
||
2015 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
2016 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
2017 data
->acregmin
!= nfss
->acregmin
/ HZ
||
2018 data
->acregmax
!= nfss
->acregmax
/ HZ
||
2019 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
2020 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
2021 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
2022 data
->nfs_server
.port
!= nfss
->port
||
2023 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
2024 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
2025 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
2032 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
2035 struct nfs_server
*nfss
= sb
->s_fs_info
;
2036 struct nfs_parsed_mount_data
*data
;
2037 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
2038 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
2039 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
2042 * Userspace mount programs that send binary options generally send
2043 * them populated with default values. We have no way to know which
2044 * ones were explicitly specified. Fall back to legacy behavior and
2045 * just return success.
2047 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
2048 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
2049 options
->version
<= 6))))
2052 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
2056 /* fill out struct with values from existing mount */
2057 data
->flags
= nfss
->flags
;
2058 data
->rsize
= nfss
->rsize
;
2059 data
->wsize
= nfss
->wsize
;
2060 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2061 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
2062 data
->acregmin
= nfss
->acregmin
/ HZ
;
2063 data
->acregmax
= nfss
->acregmax
/ HZ
;
2064 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2065 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2066 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2067 data
->nfs_server
.port
= nfss
->port
;
2068 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2069 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2070 data
->nfs_server
.addrlen
);
2072 /* overwrite those values with any that were specified */
2073 error
= nfs_parse_mount_options((char *)options
, data
);
2077 /* compare new mount options with old ones */
2078 error
= nfs_compare_remount_data(nfss
, data
);
2085 * Initialise the common bits of the superblock
2087 static inline void nfs_initialise_sb(struct super_block
*sb
)
2089 struct nfs_server
*server
= NFS_SB(sb
);
2091 sb
->s_magic
= NFS_SUPER_MAGIC
;
2093 /* We probably want something more informative here */
2094 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2095 "%x:%x", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2097 if (sb
->s_blocksize
== 0)
2098 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2099 &sb
->s_blocksize_bits
);
2101 if (server
->flags
& NFS_MOUNT_NOAC
)
2102 sb
->s_flags
|= MS_SYNCHRONOUS
;
2104 sb
->s_bdi
= &server
->backing_dev_info
;
2106 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2110 * Finish setting up an NFS2/3 superblock
2112 static void nfs_fill_super(struct super_block
*sb
,
2113 struct nfs_parsed_mount_data
*data
)
2115 struct nfs_server
*server
= NFS_SB(sb
);
2117 sb
->s_blocksize_bits
= 0;
2118 sb
->s_blocksize
= 0;
2120 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2122 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2123 /* The VFS shouldn't apply the umask to mode bits. We will do
2124 * so ourselves when necessary.
2126 sb
->s_flags
|= MS_POSIXACL
;
2127 sb
->s_time_gran
= 1;
2130 sb
->s_op
= &nfs_sops
;
2131 nfs_initialise_sb(sb
);
2135 * Finish setting up a cloned NFS2/3 superblock
2137 static void nfs_clone_super(struct super_block
*sb
,
2138 const struct super_block
*old_sb
)
2140 struct nfs_server
*server
= NFS_SB(sb
);
2142 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2143 sb
->s_blocksize
= old_sb
->s_blocksize
;
2144 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2146 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2147 /* The VFS shouldn't apply the umask to mode bits. We will do
2148 * so ourselves when necessary.
2150 sb
->s_flags
|= MS_POSIXACL
;
2151 sb
->s_time_gran
= 1;
2154 sb
->s_op
= old_sb
->s_op
;
2155 nfs_initialise_sb(sb
);
2158 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2160 const struct nfs_server
*a
= s
->s_fs_info
;
2161 const struct rpc_clnt
*clnt_a
= a
->client
;
2162 const struct rpc_clnt
*clnt_b
= b
->client
;
2164 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2166 if (a
->nfs_client
!= b
->nfs_client
)
2168 if (a
->flags
!= b
->flags
)
2170 if (a
->wsize
!= b
->wsize
)
2172 if (a
->rsize
!= b
->rsize
)
2174 if (a
->acregmin
!= b
->acregmin
)
2176 if (a
->acregmax
!= b
->acregmax
)
2178 if (a
->acdirmin
!= b
->acdirmin
)
2180 if (a
->acdirmax
!= b
->acdirmax
)
2182 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2189 struct nfs_sb_mountdata
{
2190 struct nfs_server
*server
;
2194 static int nfs_set_super(struct super_block
*s
, void *data
)
2196 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2197 struct nfs_server
*server
= sb_mntdata
->server
;
2200 s
->s_flags
= sb_mntdata
->mntflags
;
2201 s
->s_fs_info
= server
;
2202 ret
= set_anon_super(s
, server
);
2204 server
->s_dev
= s
->s_dev
;
2208 static int nfs_compare_super_address(struct nfs_server
*server1
,
2209 struct nfs_server
*server2
)
2211 struct sockaddr
*sap1
, *sap2
;
2213 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2214 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2216 if (sap1
->sa_family
!= sap2
->sa_family
)
2219 switch (sap1
->sa_family
) {
2221 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2222 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2223 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2225 if (sin1
->sin_port
!= sin2
->sin_port
)
2230 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2231 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2232 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2234 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2245 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2247 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2248 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2249 int mntflags
= sb_mntdata
->mntflags
;
2251 if (!nfs_compare_super_address(old
, server
))
2253 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2254 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2256 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2258 return nfs_compare_mount_options(sb
, server
, mntflags
);
2261 static int nfs_bdi_register(struct nfs_server
*server
)
2263 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2266 static int nfs_get_sb(struct file_system_type
*fs_type
,
2267 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2269 struct nfs_server
*server
= NULL
;
2270 struct super_block
*s
;
2271 struct nfs_parsed_mount_data
*data
;
2272 struct nfs_fh
*mntfh
;
2273 struct dentry
*mntroot
;
2274 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2275 struct nfs_sb_mountdata sb_mntdata
= {
2278 int error
= -ENOMEM
;
2280 data
= nfs_alloc_parsed_mount_data(3);
2281 mntfh
= nfs_alloc_fhandle();
2282 if (data
== NULL
|| mntfh
== NULL
)
2285 security_init_mnt_opts(&data
->lsm_opts
);
2287 /* Validate the mount data */
2288 error
= nfs_validate_mount_data(raw_data
, data
, mntfh
, dev_name
);
2292 #ifdef CONFIG_NFS_V4
2293 if (data
->version
== 4) {
2294 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2295 kfree(data
->client_address
);
2296 kfree(data
->nfs_server
.export_path
);
2299 #endif /* CONFIG_NFS_V4 */
2301 /* Get a volume representation */
2302 server
= nfs_create_server(data
, mntfh
);
2303 if (IS_ERR(server
)) {
2304 error
= PTR_ERR(server
);
2307 sb_mntdata
.server
= server
;
2309 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2310 compare_super
= NULL
;
2312 /* Get a superblock - note that we may end up sharing one that already exists */
2313 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2319 if (s
->s_fs_info
!= server
) {
2320 nfs_free_server(server
);
2323 error
= nfs_bdi_register(server
);
2325 goto error_splat_bdi
;
2329 /* initial superblock/root creation */
2330 nfs_fill_super(s
, data
);
2331 nfs_fscache_get_super_cookie(
2332 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2335 mntroot
= nfs_get_root(s
, mntfh
);
2336 if (IS_ERR(mntroot
)) {
2337 error
= PTR_ERR(mntroot
);
2338 goto error_splat_super
;
2341 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2343 goto error_splat_root
;
2345 s
->s_flags
|= MS_ACTIVE
;
2347 mnt
->mnt_root
= mntroot
;
2351 kfree(data
->nfs_server
.hostname
);
2352 kfree(data
->mount_server
.hostname
);
2353 kfree(data
->fscache_uniq
);
2354 security_free_mnt_opts(&data
->lsm_opts
);
2356 nfs_free_fhandle(mntfh
);
2361 nfs_free_server(server
);
2367 if (server
&& !s
->s_root
)
2368 bdi_unregister(&server
->backing_dev_info
);
2370 deactivate_locked_super(s
);
2375 * Ensure that we unregister the bdi before kill_anon_super
2376 * releases the device name
2378 static void nfs_put_super(struct super_block
*s
)
2380 struct nfs_server
*server
= NFS_SB(s
);
2382 bdi_unregister(&server
->backing_dev_info
);
2386 * Destroy an NFS2/3 superblock
2388 static void nfs_kill_super(struct super_block
*s
)
2390 struct nfs_server
*server
= NFS_SB(s
);
2393 nfs_fscache_release_super_cookie(s
);
2394 nfs_free_server(server
);
2398 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2400 static int nfs_xdev_get_sb(struct file_system_type
*fs_type
, int flags
,
2401 const char *dev_name
, void *raw_data
,
2402 struct vfsmount
*mnt
)
2404 struct nfs_clone_mount
*data
= raw_data
;
2405 struct super_block
*s
;
2406 struct nfs_server
*server
;
2407 struct dentry
*mntroot
;
2408 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2409 struct nfs_sb_mountdata sb_mntdata
= {
2414 dprintk("--> nfs_xdev_get_sb()\n");
2416 /* create a new volume representation */
2417 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2418 if (IS_ERR(server
)) {
2419 error
= PTR_ERR(server
);
2420 goto out_err_noserver
;
2422 sb_mntdata
.server
= server
;
2424 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2425 compare_super
= NULL
;
2427 /* Get a superblock - note that we may end up sharing one that already exists */
2428 s
= sget(&nfs_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2434 if (s
->s_fs_info
!= server
) {
2435 nfs_free_server(server
);
2438 error
= nfs_bdi_register(server
);
2440 goto error_splat_bdi
;
2444 /* initial superblock/root creation */
2445 nfs_clone_super(s
, data
->sb
);
2446 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2449 mntroot
= nfs_get_root(s
, data
->fh
);
2450 if (IS_ERR(mntroot
)) {
2451 error
= PTR_ERR(mntroot
);
2452 goto error_splat_super
;
2454 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2457 goto error_splat_super
;
2460 s
->s_flags
|= MS_ACTIVE
;
2462 mnt
->mnt_root
= mntroot
;
2464 /* clone any lsm security options from the parent to the new sb */
2465 security_sb_clone_mnt_opts(data
->sb
, s
);
2467 dprintk("<-- nfs_xdev_get_sb() = 0\n");
2471 nfs_free_server(server
);
2473 dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error
);
2477 if (server
&& !s
->s_root
)
2478 bdi_unregister(&server
->backing_dev_info
);
2480 deactivate_locked_super(s
);
2481 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error
);
2485 #ifdef CONFIG_NFS_V4
2488 * Finish setting up a cloned NFS4 superblock
2490 static void nfs4_clone_super(struct super_block
*sb
,
2491 const struct super_block
*old_sb
)
2493 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2494 sb
->s_blocksize
= old_sb
->s_blocksize
;
2495 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2496 sb
->s_time_gran
= 1;
2497 sb
->s_op
= old_sb
->s_op
;
2498 nfs_initialise_sb(sb
);
2502 * Set up an NFS4 superblock
2504 static void nfs4_fill_super(struct super_block
*sb
)
2506 sb
->s_time_gran
= 1;
2507 sb
->s_op
= &nfs4_sops
;
2508 nfs_initialise_sb(sb
);
2511 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2513 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2514 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2517 static int nfs4_validate_text_mount_data(void *options
,
2518 struct nfs_parsed_mount_data
*args
,
2519 const char *dev_name
)
2521 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2523 nfs_set_port(sap
, &args
->nfs_server
.port
, NFS_PORT
);
2525 nfs_validate_transport_protocol(args
);
2527 nfs4_validate_mount_flags(args
);
2529 if (args
->version
!= 4) {
2531 "NFS4: Illegal mount version\n");
2535 if (args
->auth_flavor_len
> 1) {
2537 "NFS4: Too many RPC auth flavours specified\n");
2541 if (args
->client_address
== NULL
) {
2543 "NFS4: mount program didn't pass callback address\n");
2547 return nfs_parse_devname(dev_name
,
2548 &args
->nfs_server
.hostname
,
2550 &args
->nfs_server
.export_path
,
2555 * Validate NFSv4 mount options
2557 static int nfs4_validate_mount_data(void *options
,
2558 struct nfs_parsed_mount_data
*args
,
2559 const char *dev_name
)
2561 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2562 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2568 switch (data
->version
) {
2570 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2571 goto out_no_address
;
2572 if (data
->host_addrlen
== 0)
2573 goto out_no_address
;
2574 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2575 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2577 if (!nfs_verify_server_address(sap
))
2578 goto out_no_address
;
2580 if (data
->auth_flavourlen
) {
2581 if (data
->auth_flavourlen
> 1)
2582 goto out_inval_auth
;
2583 if (copy_from_user(&args
->auth_flavors
[0],
2584 data
->auth_flavours
,
2585 sizeof(args
->auth_flavors
[0])))
2589 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2592 args
->nfs_server
.hostname
= c
;
2594 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2597 args
->nfs_server
.export_path
= c
;
2598 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2600 c
= strndup_user(data
->client_addr
.data
, 16);
2603 args
->client_address
= c
;
2606 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2610 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2611 args
->rsize
= data
->rsize
;
2612 args
->wsize
= data
->wsize
;
2613 args
->timeo
= data
->timeo
;
2614 args
->retrans
= data
->retrans
;
2615 args
->acregmin
= data
->acregmin
;
2616 args
->acregmax
= data
->acregmax
;
2617 args
->acdirmin
= data
->acdirmin
;
2618 args
->acdirmax
= data
->acdirmax
;
2619 args
->nfs_server
.protocol
= data
->proto
;
2620 nfs_validate_transport_protocol(args
);
2624 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2627 if (!nfs_verify_server_address(sap
))
2630 return nfs4_validate_text_mount_data(options
, args
, dev_name
);
2636 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2640 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2641 data
->auth_flavourlen
);
2645 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2650 * Get the superblock for the NFS4 root partition
2652 static int nfs4_remote_get_sb(struct file_system_type
*fs_type
,
2653 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2655 struct nfs_parsed_mount_data
*data
= raw_data
;
2656 struct super_block
*s
;
2657 struct nfs_server
*server
;
2658 struct nfs_fh
*mntfh
;
2659 struct dentry
*mntroot
;
2660 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2661 struct nfs_sb_mountdata sb_mntdata
= {
2664 int error
= -ENOMEM
;
2666 mntfh
= nfs_alloc_fhandle();
2667 if (data
== NULL
|| mntfh
== NULL
)
2670 security_init_mnt_opts(&data
->lsm_opts
);
2672 /* Get a volume representation */
2673 server
= nfs4_create_server(data
, mntfh
);
2674 if (IS_ERR(server
)) {
2675 error
= PTR_ERR(server
);
2678 sb_mntdata
.server
= server
;
2680 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2681 compare_super
= NULL
;
2683 /* Get a superblock - note that we may end up sharing one that already exists */
2684 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2690 if (s
->s_fs_info
!= server
) {
2691 nfs_free_server(server
);
2694 error
= nfs_bdi_register(server
);
2696 goto error_splat_bdi
;
2700 /* initial superblock/root creation */
2702 nfs_fscache_get_super_cookie(
2703 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2706 mntroot
= nfs4_get_root(s
, mntfh
);
2707 if (IS_ERR(mntroot
)) {
2708 error
= PTR_ERR(mntroot
);
2709 goto error_splat_super
;
2712 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2714 goto error_splat_root
;
2716 s
->s_flags
|= MS_ACTIVE
;
2718 mnt
->mnt_root
= mntroot
;
2722 security_free_mnt_opts(&data
->lsm_opts
);
2724 nfs_free_fhandle(mntfh
);
2728 nfs_free_server(server
);
2734 if (server
&& !s
->s_root
)
2735 bdi_unregister(&server
->backing_dev_info
);
2737 deactivate_locked_super(s
);
2741 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2742 int flags
, void *data
, const char *hostname
)
2744 struct vfsmount
*root_mnt
;
2748 len
= strlen(hostname
) + 3;
2749 root_devname
= kmalloc(len
, GFP_KERNEL
);
2750 if (root_devname
== NULL
)
2751 return ERR_PTR(-ENOMEM
);
2752 snprintf(root_devname
, len
, "%s:/", hostname
);
2753 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2754 kfree(root_devname
);
2758 static void nfs_fix_devname(const struct path
*path
, struct vfsmount
*mnt
)
2760 char *page
= (char *) __get_free_page(GFP_KERNEL
);
2761 char *devname
, *tmp
;
2765 devname
= nfs_path(path
->mnt
->mnt_devname
,
2766 path
->mnt
->mnt_root
, path
->dentry
,
2768 if (IS_ERR(devname
))
2770 tmp
= kstrdup(devname
, GFP_KERNEL
);
2773 kfree(mnt
->mnt_devname
);
2774 mnt
->mnt_devname
= tmp
;
2776 free_page((unsigned long)page
);
2779 struct nfs_referral_count
{
2780 struct list_head list
;
2781 const struct task_struct
*task
;
2782 unsigned int referral_count
;
2785 static LIST_HEAD(nfs_referral_count_list
);
2786 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2788 static struct nfs_referral_count
*nfs_find_referral_count(void)
2790 struct nfs_referral_count
*p
;
2792 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2793 if (p
->task
== current
)
2799 #define NFS_MAX_NESTED_REFERRALS 2
2801 static int nfs_referral_loop_protect(void)
2803 struct nfs_referral_count
*p
, *new;
2806 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2809 new->task
= current
;
2810 new->referral_count
= 1;
2813 spin_lock(&nfs_referral_count_list_lock
);
2814 p
= nfs_find_referral_count();
2816 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2819 p
->referral_count
++;
2821 list_add(&new->list
, &nfs_referral_count_list
);
2824 spin_unlock(&nfs_referral_count_list_lock
);
2830 static void nfs_referral_loop_unprotect(void)
2832 struct nfs_referral_count
*p
;
2834 spin_lock(&nfs_referral_count_list_lock
);
2835 p
= nfs_find_referral_count();
2836 p
->referral_count
--;
2837 if (p
->referral_count
== 0)
2841 spin_unlock(&nfs_referral_count_list_lock
);
2845 static int nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2846 const char *export_path
, struct vfsmount
*mnt_target
)
2848 struct nameidata
*nd
= NULL
;
2849 struct mnt_namespace
*ns_private
;
2850 struct super_block
*s
;
2853 nd
= kmalloc(sizeof(*nd
), GFP_KERNEL
);
2857 ns_private
= create_mnt_ns(root_mnt
);
2858 ret
= PTR_ERR(ns_private
);
2859 if (IS_ERR(ns_private
))
2862 ret
= nfs_referral_loop_protect();
2864 goto out_put_mnt_ns
;
2866 ret
= vfs_path_lookup(root_mnt
->mnt_root
, root_mnt
,
2867 export_path
, LOOKUP_FOLLOW
, nd
);
2869 nfs_referral_loop_unprotect();
2870 put_mnt_ns(ns_private
);
2875 s
= nd
->path
.mnt
->mnt_sb
;
2876 atomic_inc(&s
->s_active
);
2877 mnt_target
->mnt_sb
= s
;
2878 mnt_target
->mnt_root
= dget(nd
->path
.dentry
);
2880 /* Correct the device pathname */
2881 nfs_fix_devname(&nd
->path
, mnt_target
);
2883 path_put(&nd
->path
);
2885 down_write(&s
->s_umount
);
2888 put_mnt_ns(ns_private
);
2896 static int nfs4_try_mount(int flags
, const char *dev_name
,
2897 struct nfs_parsed_mount_data
*data
,
2898 struct vfsmount
*mnt
)
2901 struct vfsmount
*root_mnt
;
2904 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2906 export_path
= data
->nfs_server
.export_path
;
2907 data
->nfs_server
.export_path
= "/";
2908 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2909 data
->nfs_server
.hostname
);
2910 data
->nfs_server
.export_path
= export_path
;
2912 error
= PTR_ERR(root_mnt
);
2913 if (IS_ERR(root_mnt
))
2916 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
2919 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %d%s\n", error
,
2920 error
!= 0 ? " [error]" : "");
2925 * Get the superblock for an NFS4 mountpoint
2927 static int nfs4_get_sb(struct file_system_type
*fs_type
,
2928 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2930 struct nfs_parsed_mount_data
*data
;
2931 int error
= -ENOMEM
;
2933 data
= nfs_alloc_parsed_mount_data(4);
2937 /* Validate the mount data */
2938 error
= nfs4_validate_mount_data(raw_data
, data
, dev_name
);
2942 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2945 kfree(data
->client_address
);
2946 kfree(data
->nfs_server
.export_path
);
2947 kfree(data
->nfs_server
.hostname
);
2948 kfree(data
->fscache_uniq
);
2951 dprintk("<-- nfs4_get_sb() = %d%s\n", error
,
2952 error
!= 0 ? " [error]" : "");
2956 static void nfs4_kill_super(struct super_block
*sb
)
2958 struct nfs_server
*server
= NFS_SB(sb
);
2960 dprintk("--> %s\n", __func__
);
2961 nfs_super_return_all_delegations(sb
);
2962 kill_anon_super(sb
);
2963 nfs_fscache_release_super_cookie(sb
);
2964 nfs_free_server(server
);
2965 dprintk("<-- %s\n", __func__
);
2969 * Clone an NFS4 server record on xdev traversal (FSID-change)
2971 static int nfs4_xdev_get_sb(struct file_system_type
*fs_type
, int flags
,
2972 const char *dev_name
, void *raw_data
,
2973 struct vfsmount
*mnt
)
2975 struct nfs_clone_mount
*data
= raw_data
;
2976 struct super_block
*s
;
2977 struct nfs_server
*server
;
2978 struct dentry
*mntroot
;
2979 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2980 struct nfs_sb_mountdata sb_mntdata
= {
2985 dprintk("--> nfs4_xdev_get_sb()\n");
2987 /* create a new volume representation */
2988 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2989 if (IS_ERR(server
)) {
2990 error
= PTR_ERR(server
);
2991 goto out_err_noserver
;
2993 sb_mntdata
.server
= server
;
2995 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2996 compare_super
= NULL
;
2998 /* Get a superblock - note that we may end up sharing one that already exists */
2999 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3005 if (s
->s_fs_info
!= server
) {
3006 nfs_free_server(server
);
3009 error
= nfs_bdi_register(server
);
3011 goto error_splat_bdi
;
3015 /* initial superblock/root creation */
3016 nfs4_clone_super(s
, data
->sb
);
3017 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3020 mntroot
= nfs4_get_root(s
, data
->fh
);
3021 if (IS_ERR(mntroot
)) {
3022 error
= PTR_ERR(mntroot
);
3023 goto error_splat_super
;
3025 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3028 goto error_splat_super
;
3031 s
->s_flags
|= MS_ACTIVE
;
3033 mnt
->mnt_root
= mntroot
;
3035 security_sb_clone_mnt_opts(data
->sb
, s
);
3037 dprintk("<-- nfs4_xdev_get_sb() = 0\n");
3041 nfs_free_server(server
);
3043 dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error
);
3047 if (server
&& !s
->s_root
)
3048 bdi_unregister(&server
->backing_dev_info
);
3050 deactivate_locked_super(s
);
3051 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error
);
3055 static int nfs4_remote_referral_get_sb(struct file_system_type
*fs_type
,
3056 int flags
, const char *dev_name
, void *raw_data
,
3057 struct vfsmount
*mnt
)
3059 struct nfs_clone_mount
*data
= raw_data
;
3060 struct super_block
*s
;
3061 struct nfs_server
*server
;
3062 struct dentry
*mntroot
;
3063 struct nfs_fh
*mntfh
;
3064 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
3065 struct nfs_sb_mountdata sb_mntdata
= {
3068 int error
= -ENOMEM
;
3070 dprintk("--> nfs4_referral_get_sb()\n");
3072 mntfh
= nfs_alloc_fhandle();
3076 /* create a new volume representation */
3077 server
= nfs4_create_referral_server(data
, mntfh
);
3078 if (IS_ERR(server
)) {
3079 error
= PTR_ERR(server
);
3080 goto out_err_noserver
;
3082 sb_mntdata
.server
= server
;
3084 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
3085 compare_super
= NULL
;
3087 /* Get a superblock - note that we may end up sharing one that already exists */
3088 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3094 if (s
->s_fs_info
!= server
) {
3095 nfs_free_server(server
);
3098 error
= nfs_bdi_register(server
);
3100 goto error_splat_bdi
;
3104 /* initial superblock/root creation */
3106 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3109 mntroot
= nfs4_get_root(s
, mntfh
);
3110 if (IS_ERR(mntroot
)) {
3111 error
= PTR_ERR(mntroot
);
3112 goto error_splat_super
;
3114 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3117 goto error_splat_super
;
3120 s
->s_flags
|= MS_ACTIVE
;
3122 mnt
->mnt_root
= mntroot
;
3124 security_sb_clone_mnt_opts(data
->sb
, s
);
3126 nfs_free_fhandle(mntfh
);
3127 dprintk("<-- nfs4_referral_get_sb() = 0\n");
3131 nfs_free_server(server
);
3133 nfs_free_fhandle(mntfh
);
3135 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error
);
3139 if (server
&& !s
->s_root
)
3140 bdi_unregister(&server
->backing_dev_info
);
3142 deactivate_locked_super(s
);
3143 nfs_free_fhandle(mntfh
);
3144 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error
);
3149 * Create an NFS4 server record on referral traversal
3151 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
3152 int flags
, const char *dev_name
, void *raw_data
,
3153 struct vfsmount
*mnt
)
3155 struct nfs_clone_mount
*data
= raw_data
;
3157 struct vfsmount
*root_mnt
;
3160 dprintk("--> nfs4_referral_get_sb()\n");
3162 export_path
= data
->mnt_path
;
3163 data
->mnt_path
= "/";
3165 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
3166 flags
, data
, data
->hostname
);
3167 data
->mnt_path
= export_path
;
3169 error
= PTR_ERR(root_mnt
);
3170 if (IS_ERR(root_mnt
))
3173 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
3175 dprintk("<-- nfs4_referral_get_sb() = %d%s\n", error
,
3176 error
!= 0 ? " [error]" : "");
3180 #endif /* CONFIG_NFS_V4 */