4 * Copyright (C) 1992 Rick Sladkey
6 * nfs superblock handling functions
8 * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
9 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
11 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
12 * J.S.Peatfield@damtp.cam.ac.uk
14 * Split from inode.c by David Howells <dhowells@redhat.com>
16 * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a
17 * particular server are held in the same superblock
18 * - NFS superblocks can have several effective roots to the dentry tree
19 * - directory type roots are spliced into the tree when a path from one root reaches the root
20 * of another (see nfs_lookup())
23 #include <linux/module.h>
24 #include <linux/init.h>
26 #include <linux/time.h>
27 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/stat.h>
31 #include <linux/errno.h>
32 #include <linux/unistd.h>
33 #include <linux/sunrpc/clnt.h>
34 #include <linux/sunrpc/stats.h>
35 #include <linux/sunrpc/metrics.h>
36 #include <linux/sunrpc/xprtsock.h>
37 #include <linux/sunrpc/xprtrdma.h>
38 #include <linux/nfs_fs.h>
39 #include <linux/nfs_mount.h>
40 #include <linux/nfs4_mount.h>
41 #include <linux/lockd/bind.h>
42 #include <linux/seq_file.h>
43 #include <linux/mount.h>
44 #include <linux/namei.h>
45 #include <linux/nfs_idmap.h>
46 #include <linux/vfs.h>
47 #include <linux/inet.h>
48 #include <linux/in6.h>
49 #include <linux/slab.h>
51 #include <linux/netdevice.h>
52 #include <linux/nfs_xdr.h>
53 #include <linux/magic.h>
54 #include <linux/parser.h>
56 #include <asm/system.h>
57 #include <asm/uaccess.h>
61 #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 dentry
*);
266 static int nfs_show_devname(struct seq_file
*, struct dentry
*);
267 static int nfs_show_path(struct seq_file
*, struct dentry
*);
268 static int nfs_show_stats(struct seq_file
*, struct dentry
*);
269 static struct dentry
*nfs_fs_mount(struct file_system_type
*,
270 int, const char *, void *);
271 static struct dentry
*nfs_xdev_mount(struct file_system_type
*fs_type
,
272 int flags
, const char *dev_name
, void *raw_data
);
273 static void nfs_put_super(struct super_block
*);
274 static void nfs_kill_super(struct super_block
*);
275 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
277 static struct file_system_type nfs_fs_type
= {
278 .owner
= THIS_MODULE
,
280 .mount
= nfs_fs_mount
,
281 .kill_sb
= nfs_kill_super
,
282 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
285 struct file_system_type nfs_xdev_fs_type
= {
286 .owner
= THIS_MODULE
,
288 .mount
= nfs_xdev_mount
,
289 .kill_sb
= nfs_kill_super
,
290 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
293 static const struct super_operations nfs_sops
= {
294 .alloc_inode
= nfs_alloc_inode
,
295 .destroy_inode
= nfs_destroy_inode
,
296 .write_inode
= nfs_write_inode
,
297 .put_super
= nfs_put_super
,
298 .statfs
= nfs_statfs
,
299 .evict_inode
= nfs_evict_inode
,
300 .umount_begin
= nfs_umount_begin
,
301 .show_options
= nfs_show_options
,
302 .show_devname
= nfs_show_devname
,
303 .show_path
= nfs_show_path
,
304 .show_stats
= nfs_show_stats
,
305 .remount_fs
= nfs_remount
,
309 static int nfs4_validate_text_mount_data(void *options
,
310 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
311 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
312 struct nfs_parsed_mount_data
*data
);
313 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
314 int flags
, const char *dev_name
, void *raw_data
);
315 static struct dentry
*nfs4_remote_mount(struct file_system_type
*fs_type
,
316 int flags
, const char *dev_name
, void *raw_data
);
317 static struct dentry
*nfs4_xdev_mount(struct file_system_type
*fs_type
,
318 int flags
, const char *dev_name
, void *raw_data
);
319 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
320 int flags
, const char *dev_name
, void *raw_data
);
321 static struct dentry
*nfs4_remote_referral_mount(struct file_system_type
*fs_type
,
322 int flags
, const char *dev_name
, void *raw_data
);
323 static void nfs4_kill_super(struct super_block
*sb
);
325 static struct file_system_type nfs4_fs_type
= {
326 .owner
= THIS_MODULE
,
329 .kill_sb
= nfs4_kill_super
,
330 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
333 static struct file_system_type nfs4_remote_fs_type
= {
334 .owner
= THIS_MODULE
,
336 .mount
= nfs4_remote_mount
,
337 .kill_sb
= nfs4_kill_super
,
338 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
341 struct file_system_type nfs4_xdev_fs_type
= {
342 .owner
= THIS_MODULE
,
344 .mount
= nfs4_xdev_mount
,
345 .kill_sb
= nfs4_kill_super
,
346 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
349 static struct file_system_type nfs4_remote_referral_fs_type
= {
350 .owner
= THIS_MODULE
,
352 .mount
= nfs4_remote_referral_mount
,
353 .kill_sb
= nfs4_kill_super
,
354 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
357 struct file_system_type nfs4_referral_fs_type
= {
358 .owner
= THIS_MODULE
,
360 .mount
= nfs4_referral_mount
,
361 .kill_sb
= nfs4_kill_super
,
362 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
365 static const struct super_operations nfs4_sops
= {
366 .alloc_inode
= nfs_alloc_inode
,
367 .destroy_inode
= nfs_destroy_inode
,
368 .write_inode
= nfs_write_inode
,
369 .put_super
= nfs_put_super
,
370 .statfs
= nfs_statfs
,
371 .evict_inode
= nfs4_evict_inode
,
372 .umount_begin
= nfs_umount_begin
,
373 .show_options
= nfs_show_options
,
374 .show_devname
= nfs_show_devname
,
375 .show_path
= nfs_show_path
,
376 .show_stats
= nfs_show_stats
,
377 .remount_fs
= nfs_remount
,
381 static struct shrinker acl_shrinker
= {
382 .shrink
= nfs_access_cache_shrinker
,
383 .seeks
= DEFAULT_SEEKS
,
387 * Register the NFS filesystems
389 int __init
register_nfs_fs(void)
393 ret
= register_filesystem(&nfs_fs_type
);
397 ret
= nfs_register_sysctl();
401 ret
= register_filesystem(&nfs4_fs_type
);
405 register_shrinker(&acl_shrinker
);
410 nfs_unregister_sysctl();
413 unregister_filesystem(&nfs_fs_type
);
419 * Unregister the NFS filesystems
421 void __exit
unregister_nfs_fs(void)
423 unregister_shrinker(&acl_shrinker
);
425 unregister_filesystem(&nfs4_fs_type
);
427 nfs_unregister_sysctl();
428 unregister_filesystem(&nfs_fs_type
);
431 void nfs_sb_active(struct super_block
*sb
)
433 struct nfs_server
*server
= NFS_SB(sb
);
435 if (atomic_inc_return(&server
->active
) == 1)
436 atomic_inc(&sb
->s_active
);
439 void nfs_sb_deactive(struct super_block
*sb
)
441 struct nfs_server
*server
= NFS_SB(sb
);
443 if (atomic_dec_and_test(&server
->active
))
444 deactivate_super(sb
);
448 * Deliver file system statistics to userspace
450 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
452 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
453 unsigned char blockbits
;
454 unsigned long blockres
;
455 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
456 struct nfs_fsstat res
;
459 res
.fattr
= nfs_alloc_fattr();
460 if (res
.fattr
== NULL
)
463 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
464 if (unlikely(error
== -ESTALE
)) {
465 struct dentry
*pd_dentry
;
467 pd_dentry
= dget_parent(dentry
);
468 if (pd_dentry
!= NULL
) {
469 nfs_zap_caches(pd_dentry
->d_inode
);
473 nfs_free_fattr(res
.fattr
);
477 buf
->f_type
= NFS_SUPER_MAGIC
;
480 * Current versions of glibc do not correctly handle the
481 * case where f_frsize != f_bsize. Eventually we want to
482 * report the value of wtmult in this field.
484 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
487 * On most *nix systems, f_blocks, f_bfree, and f_bavail
488 * are reported in units of f_frsize. Linux hasn't had
489 * an f_frsize field in its statfs struct until recently,
490 * thus historically Linux's sys_statfs reports these
491 * fields in units of f_bsize.
493 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
494 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
495 blockres
= (1 << blockbits
) - 1;
496 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
497 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
498 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
500 buf
->f_files
= res
.tfiles
;
501 buf
->f_ffree
= res
.afiles
;
503 buf
->f_namelen
= server
->namelen
;
508 dprintk("%s: statfs error = %d\n", __func__
, -error
);
513 * Map the security flavour number to a name
515 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
517 static const struct {
518 rpc_authflavor_t flavour
;
521 { RPC_AUTH_NULL
, "null" },
522 { RPC_AUTH_UNIX
, "sys" },
523 { RPC_AUTH_GSS_KRB5
, "krb5" },
524 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
525 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
526 { RPC_AUTH_GSS_LKEY
, "lkey" },
527 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
528 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
529 { RPC_AUTH_GSS_SPKM
, "spkm" },
530 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
531 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
532 { UINT_MAX
, "unknown" }
536 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
537 if (sec_flavours
[i
].flavour
== flavour
)
540 return sec_flavours
[i
].str
;
543 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
546 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
548 seq_printf(m
, ",mountproto=");
549 switch (sap
->sa_family
) {
551 switch (nfss
->mountd_protocol
) {
553 seq_printf(m
, RPCBIND_NETID_UDP
);
556 seq_printf(m
, RPCBIND_NETID_TCP
);
560 seq_printf(m
, "auto");
564 switch (nfss
->mountd_protocol
) {
566 seq_printf(m
, RPCBIND_NETID_UDP6
);
569 seq_printf(m
, RPCBIND_NETID_TCP6
);
573 seq_printf(m
, "auto");
578 seq_printf(m
, "auto");
582 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
585 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
587 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
590 switch (sap
->sa_family
) {
592 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
593 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
597 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
598 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
603 seq_printf(m
, ",mountaddr=unspecified");
606 if (nfss
->mountd_version
|| showdefaults
)
607 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
608 if ((nfss
->mountd_port
&&
609 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
611 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
613 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
617 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
620 struct nfs_client
*clp
= nfss
->nfs_client
;
622 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
623 seq_printf(m
, ",minorversion=%u", clp
->cl_minorversion
);
626 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
633 * Describe the mount options in force on this server representation
635 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
638 static const struct proc_nfs_info
{
643 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
644 { NFS_MOUNT_POSIX
, ",posix", "" },
645 { NFS_MOUNT_NOCTO
, ",nocto", "" },
646 { NFS_MOUNT_NOAC
, ",noac", "" },
647 { NFS_MOUNT_NONLM
, ",nolock", "" },
648 { NFS_MOUNT_NOACL
, ",noacl", "" },
649 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
650 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
651 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
654 const struct proc_nfs_info
*nfs_infop
;
655 struct nfs_client
*clp
= nfss
->nfs_client
;
656 u32 version
= clp
->rpc_ops
->version
;
657 int local_flock
, local_fcntl
;
659 seq_printf(m
, ",vers=%u", version
);
660 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
661 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
662 if (nfss
->bsize
!= 0)
663 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
664 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
665 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
666 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
667 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
668 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
669 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
670 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
671 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
672 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
673 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
674 if (nfss
->flags
& nfs_infop
->flag
)
675 seq_puts(m
, nfs_infop
->str
);
677 seq_puts(m
, nfs_infop
->nostr
);
679 seq_printf(m
, ",proto=%s",
680 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
682 if (nfss
->port
!= NFS_PORT
)
683 seq_printf(m
, ",port=%u", nfss
->port
);
686 seq_printf(m
, ",port=%u", nfss
->port
);
688 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
689 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
690 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
693 nfs_show_mountd_options(m
, nfss
, showdefaults
);
695 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
697 if (nfss
->options
& NFS_OPTION_FSCACHE
)
698 seq_printf(m
, ",fsc");
700 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
701 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
702 seq_printf(m
, ",lookupcache=none");
704 seq_printf(m
, ",lookupcache=pos");
707 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
708 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
710 if (!local_flock
&& !local_fcntl
)
711 seq_printf(m
, ",local_lock=none");
712 else if (local_flock
&& local_fcntl
)
713 seq_printf(m
, ",local_lock=all");
714 else if (local_flock
)
715 seq_printf(m
, ",local_lock=flock");
717 seq_printf(m
, ",local_lock=posix");
721 * Describe the mount options on this VFS mountpoint
723 static int nfs_show_options(struct seq_file
*m
, struct dentry
*root
)
725 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
727 nfs_show_mount_options(m
, nfss
, 0);
729 seq_printf(m
, ",addr=%s",
730 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
737 #ifdef CONFIG_NFS_V4_1
738 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
)
740 if (nfs4_has_session(server
->nfs_client
))
741 seq_printf(m
, ",sessions");
744 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
) {}
749 #ifdef CONFIG_NFS_V4_1
750 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
752 seq_printf(m
, ",pnfs=");
753 if (server
->pnfs_curr_ld
)
754 seq_printf(m
, "%s", server
->pnfs_curr_ld
->name
);
756 seq_printf(m
, "not configured");
759 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
) {}
763 static int nfs_show_devname(struct seq_file
*m
, struct dentry
*root
)
765 char *page
= (char *) __get_free_page(GFP_KERNEL
);
766 char *devname
, *dummy
;
770 devname
= nfs_path(&dummy
, root
, page
, PAGE_SIZE
);
772 err
= PTR_ERR(devname
);
774 seq_escape(m
, devname
, " \t\n\\");
775 free_page((unsigned long)page
);
779 static int nfs_show_path(struct seq_file
*m
, struct dentry
*dentry
)
786 * Present statistical information for this VFS mountpoint
788 static int nfs_show_stats(struct seq_file
*m
, struct dentry
*root
)
791 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
792 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
793 struct nfs_iostats totals
= { };
795 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
798 * Display all mount option settings
800 seq_printf(m
, "\n\topts:\t");
801 seq_puts(m
, root
->d_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
802 seq_puts(m
, root
->d_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
803 seq_puts(m
, root
->d_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
804 seq_puts(m
, root
->d_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
805 nfs_show_mount_options(m
, nfss
, 1);
807 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
809 seq_printf(m
, "\n\tcaps:\t");
810 seq_printf(m
, "caps=0x%x", nfss
->caps
);
811 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
812 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
813 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
814 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
817 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
818 seq_printf(m
, "\n\tnfsv4:\t");
819 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
820 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
821 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
822 show_sessions(m
, nfss
);
828 * Display security flavor in effect for this mount
830 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
832 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
835 * Display superblock I/O counters
837 for_each_possible_cpu(cpu
) {
838 struct nfs_iostats
*stats
;
841 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
843 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
844 totals
.events
[i
] += stats
->events
[i
];
845 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
846 totals
.bytes
[i
] += stats
->bytes
[i
];
847 #ifdef CONFIG_NFS_FSCACHE
848 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
849 totals
.fscache
[i
] += stats
->fscache
[i
];
855 seq_printf(m
, "\n\tevents:\t");
856 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
857 seq_printf(m
, "%lu ", totals
.events
[i
]);
858 seq_printf(m
, "\n\tbytes:\t");
859 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
860 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
861 #ifdef CONFIG_NFS_FSCACHE
862 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
863 seq_printf(m
, "\n\tfsc:\t");
864 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
865 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
870 rpc_print_iostats(m
, nfss
->client
);
876 * Begin unmount by attempting to remove all automounted mountpoints we added
877 * in response to xdev traversals and referrals
879 static void nfs_umount_begin(struct super_block
*sb
)
881 struct nfs_server
*server
;
882 struct rpc_clnt
*rpc
;
885 /* -EIO all pending I/O */
886 rpc
= server
->client_acl
;
888 rpc_killall_tasks(rpc
);
889 rpc
= server
->client
;
891 rpc_killall_tasks(rpc
);
894 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(unsigned int version
)
896 struct nfs_parsed_mount_data
*data
;
898 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
900 data
->acregmin
= NFS_DEF_ACREGMIN
;
901 data
->acregmax
= NFS_DEF_ACREGMAX
;
902 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
903 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
904 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
905 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
906 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
907 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
908 data
->auth_flavor_len
= 1;
909 data
->version
= version
;
910 data
->minorversion
= 0;
911 security_init_mnt_opts(&data
->lsm_opts
);
916 static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data
*data
)
919 kfree(data
->client_address
);
920 kfree(data
->mount_server
.hostname
);
921 kfree(data
->nfs_server
.export_path
);
922 kfree(data
->nfs_server
.hostname
);
923 kfree(data
->fscache_uniq
);
924 security_free_mnt_opts(&data
->lsm_opts
);
930 * Sanity-check a server address provided by the mount command.
932 * Address family must be initialized, and address must not be
933 * the ANY address for that family.
935 static int nfs_verify_server_address(struct sockaddr
*addr
)
937 switch (addr
->sa_family
) {
939 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
940 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
943 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
944 return !ipv6_addr_any(sa
);
948 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
953 * Select between a default port value and a user-specified port value.
954 * If a zero value is set, then autobind will be used.
956 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
957 const unsigned short default_port
)
959 if (*port
== NFS_UNSPEC_PORT
)
960 *port
= default_port
;
962 rpc_set_port(sap
, *port
);
966 * Sanity check the NFS transport protocol.
969 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
971 switch (mnt
->nfs_server
.protocol
) {
972 case XPRT_TRANSPORT_UDP
:
973 case XPRT_TRANSPORT_TCP
:
974 case XPRT_TRANSPORT_RDMA
:
977 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
982 * For text based NFSv2/v3 mounts, the mount protocol transport default
983 * settings should depend upon the specified NFS transport.
985 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
987 nfs_validate_transport_protocol(mnt
);
989 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
990 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
992 switch (mnt
->nfs_server
.protocol
) {
993 case XPRT_TRANSPORT_UDP
:
994 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
996 case XPRT_TRANSPORT_TCP
:
997 case XPRT_TRANSPORT_RDMA
:
998 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1003 * Parse the value of the 'sec=' option.
1005 static int nfs_parse_security_flavors(char *value
,
1006 struct nfs_parsed_mount_data
*mnt
)
1008 substring_t args
[MAX_OPT_ARGS
];
1010 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
1012 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
1014 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
1017 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
1020 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
1023 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
1026 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
1029 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
1032 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
1035 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
1038 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
1041 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
1044 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
1050 mnt
->flags
|= NFS_MOUNT_SECFLAVOUR
;
1051 mnt
->auth_flavor_len
= 1;
1055 static int nfs_get_option_str(substring_t args
[], char **option
)
1058 *option
= match_strdup(args
);
1062 static int nfs_get_option_ul(substring_t args
[], unsigned long *option
)
1067 string
= match_strdup(args
);
1070 rc
= strict_strtoul(string
, 10, option
);
1077 * Error-check and convert a string of mount options from user space into
1078 * a data structure. The whole mount string is processed; bad options are
1079 * skipped as they are encountered. If there were no errors, return 1;
1080 * otherwise return 0 (zero).
1082 static int nfs_parse_mount_options(char *raw
,
1083 struct nfs_parsed_mount_data
*mnt
)
1085 char *p
, *string
, *secdata
;
1086 int rc
, sloppy
= 0, invalid_option
= 0;
1087 unsigned short protofamily
= AF_UNSPEC
;
1088 unsigned short mountfamily
= AF_UNSPEC
;
1091 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
1094 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1096 secdata
= alloc_secdata();
1100 rc
= security_sb_copy_data(raw
, secdata
);
1102 goto out_security_failure
;
1104 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1106 goto out_security_failure
;
1108 free_secdata(secdata
);
1110 while ((p
= strsep(&raw
, ",")) != NULL
) {
1111 substring_t args
[MAX_OPT_ARGS
];
1112 unsigned long option
;
1118 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1120 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1124 * boolean options: foo/nofoo
1127 mnt
->flags
|= NFS_MOUNT_SOFT
;
1130 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1133 mnt
->flags
|= NFS_MOUNT_POSIX
;
1136 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1139 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1142 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1145 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1148 mnt
->flags
|= NFS_MOUNT_NOAC
;
1151 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1152 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1153 NFS_MOUNT_LOCAL_FCNTL
);
1156 mnt
->flags
|= NFS_MOUNT_NONLM
;
1157 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1158 NFS_MOUNT_LOCAL_FCNTL
);
1161 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1165 mnt
->flags
|= NFS_MOUNT_VER3
;
1169 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1173 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1174 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1177 mnt
->flags
|= NFS_MOUNT_TCP
;
1178 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1181 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1182 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1183 xprt_load_transport(p
);
1186 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1189 mnt
->flags
|= NFS_MOUNT_NOACL
;
1192 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1194 case Opt_nordirplus
:
1195 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1197 case Opt_sharecache
:
1198 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1200 case Opt_nosharecache
:
1201 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1204 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1206 case Opt_noresvport
:
1207 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1210 mnt
->options
|= NFS_OPTION_FSCACHE
;
1211 kfree(mnt
->fscache_uniq
);
1212 mnt
->fscache_uniq
= NULL
;
1215 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1216 kfree(mnt
->fscache_uniq
);
1217 mnt
->fscache_uniq
= NULL
;
1221 * options that take numeric values
1224 if (nfs_get_option_ul(args
, &option
) ||
1226 goto out_invalid_value
;
1227 mnt
->nfs_server
.port
= option
;
1230 if (nfs_get_option_ul(args
, &option
))
1231 goto out_invalid_value
;
1232 mnt
->rsize
= option
;
1235 if (nfs_get_option_ul(args
, &option
))
1236 goto out_invalid_value
;
1237 mnt
->wsize
= option
;
1240 if (nfs_get_option_ul(args
, &option
))
1241 goto out_invalid_value
;
1242 mnt
->bsize
= option
;
1245 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1246 goto out_invalid_value
;
1247 mnt
->timeo
= option
;
1250 if (nfs_get_option_ul(args
, &option
) || option
== 0)
1251 goto out_invalid_value
;
1252 mnt
->retrans
= option
;
1255 if (nfs_get_option_ul(args
, &option
))
1256 goto out_invalid_value
;
1257 mnt
->acregmin
= option
;
1260 if (nfs_get_option_ul(args
, &option
))
1261 goto out_invalid_value
;
1262 mnt
->acregmax
= option
;
1265 if (nfs_get_option_ul(args
, &option
))
1266 goto out_invalid_value
;
1267 mnt
->acdirmin
= option
;
1270 if (nfs_get_option_ul(args
, &option
))
1271 goto out_invalid_value
;
1272 mnt
->acdirmax
= option
;
1275 if (nfs_get_option_ul(args
, &option
))
1276 goto out_invalid_value
;
1277 mnt
->acregmin
= mnt
->acregmax
=
1278 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1281 if (nfs_get_option_ul(args
, &option
))
1282 goto out_invalid_value
;
1283 mnt
->namlen
= option
;
1286 if (nfs_get_option_ul(args
, &option
) ||
1288 goto out_invalid_value
;
1289 mnt
->mount_server
.port
= option
;
1292 if (nfs_get_option_ul(args
, &option
) ||
1293 option
< NFS_MNT_VERSION
||
1294 option
> NFS_MNT3_VERSION
)
1295 goto out_invalid_value
;
1296 mnt
->mount_server
.version
= option
;
1299 if (nfs_get_option_ul(args
, &option
))
1300 goto out_invalid_value
;
1303 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1307 mnt
->flags
|= NFS_MOUNT_VER3
;
1311 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1315 goto out_invalid_value
;
1318 case Opt_minorversion
:
1319 if (nfs_get_option_ul(args
, &option
))
1320 goto out_invalid_value
;
1321 if (option
> NFS4_MAX_MINOR_VERSION
)
1322 goto out_invalid_value
;
1323 mnt
->minorversion
= option
;
1327 * options that take text values
1330 string
= match_strdup(args
);
1333 rc
= nfs_parse_security_flavors(string
, mnt
);
1336 dfprintk(MOUNT
, "NFS: unrecognized "
1337 "security flavor\n");
1342 string
= match_strdup(args
);
1345 token
= match_token(string
,
1346 nfs_xprt_protocol_tokens
, args
);
1348 protofamily
= AF_INET
;
1351 protofamily
= AF_INET6
;
1353 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1354 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1357 protofamily
= AF_INET6
;
1359 mnt
->flags
|= NFS_MOUNT_TCP
;
1360 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1363 /* vector side protocols to TCP */
1364 mnt
->flags
|= NFS_MOUNT_TCP
;
1365 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1366 xprt_load_transport(string
);
1369 dfprintk(MOUNT
, "NFS: unrecognized "
1370 "transport protocol\n");
1376 case Opt_mountproto
:
1377 string
= match_strdup(args
);
1380 token
= match_token(string
,
1381 nfs_xprt_protocol_tokens
, args
);
1384 mountfamily
= AF_INET
;
1387 mountfamily
= AF_INET6
;
1389 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1392 mountfamily
= AF_INET6
;
1394 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1396 case Opt_xprt_rdma
: /* not used for side protocols */
1398 dfprintk(MOUNT
, "NFS: unrecognized "
1399 "transport protocol\n");
1404 string
= match_strdup(args
);
1407 mnt
->nfs_server
.addrlen
=
1408 rpc_pton(string
, strlen(string
),
1410 &mnt
->nfs_server
.address
,
1411 sizeof(mnt
->nfs_server
.address
));
1413 if (mnt
->nfs_server
.addrlen
== 0)
1414 goto out_invalid_address
;
1416 case Opt_clientaddr
:
1417 if (nfs_get_option_str(args
, &mnt
->client_address
))
1421 if (nfs_get_option_str(args
,
1422 &mnt
->mount_server
.hostname
))
1426 string
= match_strdup(args
);
1429 mnt
->mount_server
.addrlen
=
1430 rpc_pton(string
, strlen(string
),
1432 &mnt
->mount_server
.address
,
1433 sizeof(mnt
->mount_server
.address
));
1435 if (mnt
->mount_server
.addrlen
== 0)
1436 goto out_invalid_address
;
1438 case Opt_lookupcache
:
1439 string
= match_strdup(args
);
1442 token
= match_token(string
,
1443 nfs_lookupcache_tokens
, args
);
1446 case Opt_lookupcache_all
:
1447 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1449 case Opt_lookupcache_positive
:
1450 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1451 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1453 case Opt_lookupcache_none
:
1454 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1457 dfprintk(MOUNT
, "NFS: invalid "
1458 "lookupcache argument\n");
1462 case Opt_fscache_uniq
:
1463 if (nfs_get_option_str(args
, &mnt
->fscache_uniq
))
1465 mnt
->options
|= NFS_OPTION_FSCACHE
;
1467 case Opt_local_lock
:
1468 string
= match_strdup(args
);
1471 token
= match_token(string
, nfs_local_lock_tokens
,
1475 case Opt_local_lock_all
:
1476 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1477 NFS_MOUNT_LOCAL_FCNTL
);
1479 case Opt_local_lock_flock
:
1480 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1482 case Opt_local_lock_posix
:
1483 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1485 case Opt_local_lock_none
:
1486 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1487 NFS_MOUNT_LOCAL_FCNTL
);
1490 dfprintk(MOUNT
, "NFS: invalid "
1491 "local_lock argument\n");
1501 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1504 case Opt_deprecated
:
1505 dfprintk(MOUNT
, "NFS: ignoring mount option "
1511 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1516 if (!sloppy
&& invalid_option
)
1520 * verify that any proto=/mountproto= options match the address
1521 * familiies in the addr=/mountaddr= options.
1523 if (protofamily
!= AF_UNSPEC
&&
1524 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1525 goto out_proto_mismatch
;
1527 if (mountfamily
!= AF_UNSPEC
) {
1528 if (mnt
->mount_server
.addrlen
) {
1529 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1530 goto out_mountproto_mismatch
;
1532 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1533 goto out_mountproto_mismatch
;
1539 out_mountproto_mismatch
:
1540 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1544 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1546 out_invalid_address
:
1547 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1550 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1553 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1555 out_security_failure
:
1556 free_secdata(secdata
);
1557 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1562 * Match the requested auth flavors with the list returned by
1563 * the server. Returns zero and sets the mount's authentication
1564 * flavor on success; returns -EACCES if server does not support
1565 * the requested flavor.
1567 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1568 struct nfs_mount_request
*request
)
1570 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1573 * Certain releases of Linux's mountd return an empty
1574 * flavor list. To prevent behavioral regression with
1575 * these servers (ie. rejecting mounts that used to
1576 * succeed), revert to pre-2.6.32 behavior (no checking)
1577 * if the returned flavor list is empty.
1579 if (server_authlist_len
== 0)
1583 * We avoid sophisticated negotiating here, as there are
1584 * plenty of cases where we can get it wrong, providing
1585 * either too little or too much security.
1587 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1588 * flavor listed first. However, some servers list
1589 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1590 * preferred default, in args->auth_flavors[0] if user
1591 * didn't specify sec= mount option.
1593 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1594 for (j
= 0; j
< server_authlist_len
; j
++)
1595 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1596 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1597 request
->auth_flavs
[j
]);
1598 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1602 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1603 nfs_umount(request
);
1608 * Use the remote server's MOUNT service to request the NFS file handle
1609 * corresponding to the provided path.
1611 static int nfs_try_mount(struct nfs_parsed_mount_data
*args
,
1612 struct nfs_fh
*root_fh
)
1614 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1615 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1616 struct nfs_mount_request request
= {
1617 .sap
= (struct sockaddr
*)
1618 &args
->mount_server
.address
,
1619 .dirpath
= args
->nfs_server
.export_path
,
1620 .protocol
= args
->mount_server
.protocol
,
1622 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1623 .auth_flav_len
= &server_authlist_len
,
1624 .auth_flavs
= server_authlist
,
1628 if (args
->mount_server
.version
== 0) {
1629 switch (args
->version
) {
1631 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1634 args
->mount_server
.version
= NFS_MNT_VERSION
;
1637 request
.version
= args
->mount_server
.version
;
1639 if (args
->mount_server
.hostname
)
1640 request
.hostname
= args
->mount_server
.hostname
;
1642 request
.hostname
= args
->nfs_server
.hostname
;
1645 * Construct the mount server's address.
1647 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1648 memcpy(request
.sap
, &args
->nfs_server
.address
,
1649 args
->nfs_server
.addrlen
);
1650 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1652 request
.salen
= args
->mount_server
.addrlen
;
1653 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1656 * Now ask the mount server to map our export path
1659 status
= nfs_mount(&request
);
1661 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1662 request
.hostname
, status
);
1667 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1669 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1671 return nfs_walk_authlist(args
, &request
);
1675 * Split "dev_name" into "hostname:export_path".
1677 * The leftmost colon demarks the split between the server's hostname
1678 * and the export path. If the hostname starts with a left square
1679 * bracket, then it may contain colons.
1681 * Note: caller frees hostname and export path, even on error.
1683 static int nfs_parse_devname(const char *dev_name
,
1684 char **hostname
, size_t maxnamlen
,
1685 char **export_path
, size_t maxpathlen
)
1690 /* Is the host name protected with square brakcets? */
1691 if (*dev_name
== '[') {
1692 end
= strchr(++dev_name
, ']');
1693 if (end
== NULL
|| end
[1] != ':')
1694 goto out_bad_devname
;
1696 len
= end
- dev_name
;
1701 end
= strchr(dev_name
, ':');
1703 goto out_bad_devname
;
1704 len
= end
- dev_name
;
1706 /* kill possible hostname list: not supported */
1707 comma
= strchr(dev_name
, ',');
1708 if (comma
!= NULL
&& comma
< end
)
1712 if (len
> maxnamlen
)
1715 /* N.B. caller will free nfs_server.hostname in all cases */
1716 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1717 if (*hostname
== NULL
)
1719 len
= strlen(++end
);
1720 if (len
> maxpathlen
)
1722 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1726 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1730 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1734 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1738 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1739 return -ENAMETOOLONG
;
1742 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1743 return -ENAMETOOLONG
;
1747 * Validate the NFS2/NFS3 mount data
1748 * - fills in the mount root filehandle
1750 * For option strings, user space handles the following behaviors:
1752 * + DNS: mapping server host name to IP address ("addr=" option)
1754 * + failure mode: how to behave if a mount request can't be handled
1755 * immediately ("fg/bg" option)
1757 * + retry: how often to retry a mount request ("retry=" option)
1759 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1760 * mountproto=tcp after mountproto=udp, and so on
1762 static int nfs_validate_mount_data(void *options
,
1763 struct nfs_parsed_mount_data
*args
,
1764 struct nfs_fh
*mntfh
,
1765 const char *dev_name
)
1767 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1768 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1773 switch (data
->version
) {
1779 if (data
->flags
& NFS_MOUNT_VER3
)
1781 data
->root
.size
= NFS2_FHSIZE
;
1782 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1784 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1787 memset(data
->context
, 0, sizeof(data
->context
));
1789 if (data
->flags
& NFS_MOUNT_VER3
) {
1790 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1791 goto out_invalid_fh
;
1792 mntfh
->size
= data
->root
.size
;
1795 mntfh
->size
= NFS2_FHSIZE
;
1800 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1801 if (mntfh
->size
< sizeof(mntfh
->data
))
1802 memset(mntfh
->data
+ mntfh
->size
, 0,
1803 sizeof(mntfh
->data
) - mntfh
->size
);
1806 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1809 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1810 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1811 args
->rsize
= data
->rsize
;
1812 args
->wsize
= data
->wsize
;
1813 args
->timeo
= data
->timeo
;
1814 args
->retrans
= data
->retrans
;
1815 args
->acregmin
= data
->acregmin
;
1816 args
->acregmax
= data
->acregmax
;
1817 args
->acdirmin
= data
->acdirmin
;
1818 args
->acdirmax
= data
->acdirmax
;
1820 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1821 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1822 if (!nfs_verify_server_address(sap
))
1823 goto out_no_address
;
1825 if (!(data
->flags
& NFS_MOUNT_TCP
))
1826 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1827 /* N.B. caller will free nfs_server.hostname in all cases */
1828 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1829 args
->namlen
= data
->namlen
;
1830 args
->bsize
= data
->bsize
;
1832 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1833 args
->auth_flavors
[0] = data
->pseudoflavor
;
1834 if (!args
->nfs_server
.hostname
)
1837 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1838 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1839 NFS_MOUNT_LOCAL_FCNTL
);
1841 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1842 NFS_MOUNT_LOCAL_FCNTL
);
1844 * The legacy version 6 binary mount data from userspace has a
1845 * field used only to transport selinux information into the
1846 * the kernel. To continue to support that functionality we
1847 * have a touch of selinux knowledge here in the NFS code. The
1848 * userspace code converted context=blah to just blah so we are
1849 * converting back to the full string selinux understands.
1851 if (data
->context
[0]){
1852 #ifdef CONFIG_SECURITY_SELINUX
1854 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1857 strcpy(opts_str
, "context=");
1858 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1859 strcat(opts_str
, &data
->context
[0]);
1860 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1873 if (nfs_parse_mount_options((char *)options
, args
) == 0)
1876 if (!nfs_verify_server_address(sap
))
1877 goto out_no_address
;
1879 if (args
->version
== 4)
1880 #ifdef CONFIG_NFS_V4
1881 return nfs4_validate_text_mount_data(options
,
1884 goto out_v4_not_compiled
;
1887 nfs_set_port(sap
, &args
->nfs_server
.port
, 0);
1889 nfs_set_mount_transport_protocol(args
);
1891 status
= nfs_parse_devname(dev_name
,
1892 &args
->nfs_server
.hostname
,
1894 &args
->nfs_server
.export_path
,
1897 status
= nfs_try_mount(args
, mntfh
);
1899 kfree(args
->nfs_server
.export_path
);
1900 args
->nfs_server
.export_path
= NULL
;
1909 #ifndef CONFIG_NFS_V3
1910 if (args
->version
== 3)
1911 goto out_v3_not_compiled
;
1912 #endif /* !CONFIG_NFS_V3 */
1917 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1921 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1926 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1929 #ifndef CONFIG_NFS_V3
1930 out_v3_not_compiled
:
1931 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1932 return -EPROTONOSUPPORT
;
1933 #endif /* !CONFIG_NFS_V3 */
1935 #ifndef CONFIG_NFS_V4
1936 out_v4_not_compiled
:
1937 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
1938 return -EPROTONOSUPPORT
;
1939 #endif /* !CONFIG_NFS_V4 */
1942 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
1946 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
1950 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
1955 nfs_compare_remount_data(struct nfs_server
*nfss
,
1956 struct nfs_parsed_mount_data
*data
)
1958 if (data
->flags
!= nfss
->flags
||
1959 data
->rsize
!= nfss
->rsize
||
1960 data
->wsize
!= nfss
->wsize
||
1961 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
1962 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
1963 data
->acregmin
!= nfss
->acregmin
/ HZ
||
1964 data
->acregmax
!= nfss
->acregmax
/ HZ
||
1965 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
1966 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
1967 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
1968 data
->nfs_server
.port
!= nfss
->port
||
1969 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
1970 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
1971 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
1978 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
1981 struct nfs_server
*nfss
= sb
->s_fs_info
;
1982 struct nfs_parsed_mount_data
*data
;
1983 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
1984 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
1985 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
1988 * Userspace mount programs that send binary options generally send
1989 * them populated with default values. We have no way to know which
1990 * ones were explicitly specified. Fall back to legacy behavior and
1991 * just return success.
1993 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
1994 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
1995 options
->version
<= 6))))
1998 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
2002 /* fill out struct with values from existing mount */
2003 data
->flags
= nfss
->flags
;
2004 data
->rsize
= nfss
->rsize
;
2005 data
->wsize
= nfss
->wsize
;
2006 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2007 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
2008 data
->acregmin
= nfss
->acregmin
/ HZ
;
2009 data
->acregmax
= nfss
->acregmax
/ HZ
;
2010 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2011 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2012 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2013 data
->nfs_server
.port
= nfss
->port
;
2014 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2015 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2016 data
->nfs_server
.addrlen
);
2018 /* overwrite those values with any that were specified */
2019 error
= nfs_parse_mount_options((char *)options
, data
);
2024 * noac is a special case. It implies -o sync, but that's not
2025 * necessarily reflected in the mtab options. do_remount_sb
2026 * will clear MS_SYNCHRONOUS if -o sync wasn't specified in the
2027 * remount options, so we have to explicitly reset it.
2029 if (data
->flags
& NFS_MOUNT_NOAC
)
2030 *flags
|= MS_SYNCHRONOUS
;
2032 /* compare new mount options with old ones */
2033 error
= nfs_compare_remount_data(nfss
, data
);
2040 * Initialise the common bits of the superblock
2042 static inline void nfs_initialise_sb(struct super_block
*sb
)
2044 struct nfs_server
*server
= NFS_SB(sb
);
2046 sb
->s_magic
= NFS_SUPER_MAGIC
;
2048 /* We probably want something more informative here */
2049 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2050 "%x:%x", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2052 if (sb
->s_blocksize
== 0)
2053 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2054 &sb
->s_blocksize_bits
);
2056 sb
->s_bdi
= &server
->backing_dev_info
;
2058 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2062 * Finish setting up an NFS2/3 superblock
2064 static void nfs_fill_super(struct super_block
*sb
,
2065 struct nfs_parsed_mount_data
*data
)
2067 struct nfs_server
*server
= NFS_SB(sb
);
2069 sb
->s_blocksize_bits
= 0;
2070 sb
->s_blocksize
= 0;
2072 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2074 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2075 /* The VFS shouldn't apply the umask to mode bits. We will do
2076 * so ourselves when necessary.
2078 sb
->s_flags
|= MS_POSIXACL
;
2079 sb
->s_time_gran
= 1;
2082 sb
->s_op
= &nfs_sops
;
2083 nfs_initialise_sb(sb
);
2087 * Finish setting up a cloned NFS2/3 superblock
2089 static void nfs_clone_super(struct super_block
*sb
,
2090 const struct super_block
*old_sb
)
2092 struct nfs_server
*server
= NFS_SB(sb
);
2094 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2095 sb
->s_blocksize
= old_sb
->s_blocksize
;
2096 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2098 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2099 /* The VFS shouldn't apply the umask to mode bits. We will do
2100 * so ourselves when necessary.
2102 sb
->s_flags
|= MS_POSIXACL
;
2103 sb
->s_time_gran
= 1;
2106 sb
->s_op
= old_sb
->s_op
;
2107 nfs_initialise_sb(sb
);
2110 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2112 const struct nfs_server
*a
= s
->s_fs_info
;
2113 const struct rpc_clnt
*clnt_a
= a
->client
;
2114 const struct rpc_clnt
*clnt_b
= b
->client
;
2116 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2118 if (a
->nfs_client
!= b
->nfs_client
)
2120 if (a
->flags
!= b
->flags
)
2122 if (a
->wsize
!= b
->wsize
)
2124 if (a
->rsize
!= b
->rsize
)
2126 if (a
->acregmin
!= b
->acregmin
)
2128 if (a
->acregmax
!= b
->acregmax
)
2130 if (a
->acdirmin
!= b
->acdirmin
)
2132 if (a
->acdirmax
!= b
->acdirmax
)
2134 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2141 struct nfs_sb_mountdata
{
2142 struct nfs_server
*server
;
2146 static int nfs_set_super(struct super_block
*s
, void *data
)
2148 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2149 struct nfs_server
*server
= sb_mntdata
->server
;
2152 s
->s_flags
= sb_mntdata
->mntflags
;
2153 s
->s_fs_info
= server
;
2154 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
2155 ret
= set_anon_super(s
, server
);
2157 server
->s_dev
= s
->s_dev
;
2161 static int nfs_compare_super_address(struct nfs_server
*server1
,
2162 struct nfs_server
*server2
)
2164 struct sockaddr
*sap1
, *sap2
;
2166 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2167 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2169 if (sap1
->sa_family
!= sap2
->sa_family
)
2172 switch (sap1
->sa_family
) {
2174 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2175 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2176 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2178 if (sin1
->sin_port
!= sin2
->sin_port
)
2183 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2184 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2185 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2187 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2198 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2200 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2201 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2202 int mntflags
= sb_mntdata
->mntflags
;
2204 if (!nfs_compare_super_address(old
, server
))
2206 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2207 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2209 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2211 return nfs_compare_mount_options(sb
, server
, mntflags
);
2214 static int nfs_bdi_register(struct nfs_server
*server
)
2216 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2219 static struct dentry
*nfs_fs_mount(struct file_system_type
*fs_type
,
2220 int flags
, const char *dev_name
, void *raw_data
)
2222 struct nfs_server
*server
= NULL
;
2223 struct super_block
*s
;
2224 struct nfs_parsed_mount_data
*data
;
2225 struct nfs_fh
*mntfh
;
2226 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2227 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2228 struct nfs_sb_mountdata sb_mntdata
= {
2233 data
= nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION
);
2234 mntfh
= nfs_alloc_fhandle();
2235 if (data
== NULL
|| mntfh
== NULL
)
2238 /* Validate the mount data */
2239 error
= nfs_validate_mount_data(raw_data
, data
, mntfh
, dev_name
);
2241 mntroot
= ERR_PTR(error
);
2245 #ifdef CONFIG_NFS_V4
2246 if (data
->version
== 4) {
2247 mntroot
= nfs4_try_mount(flags
, dev_name
, data
);
2250 #endif /* CONFIG_NFS_V4 */
2252 /* Get a volume representation */
2253 server
= nfs_create_server(data
, mntfh
);
2254 if (IS_ERR(server
)) {
2255 mntroot
= ERR_CAST(server
);
2258 sb_mntdata
.server
= server
;
2260 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2261 compare_super
= NULL
;
2263 /* -o noac implies -o sync */
2264 if (server
->flags
& NFS_MOUNT_NOAC
)
2265 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2267 /* Get a superblock - note that we may end up sharing one that already exists */
2268 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2270 mntroot
= ERR_CAST(s
);
2274 if (s
->s_fs_info
!= server
) {
2275 nfs_free_server(server
);
2278 error
= nfs_bdi_register(server
);
2280 mntroot
= ERR_PTR(error
);
2281 goto error_splat_bdi
;
2286 /* initial superblock/root creation */
2287 nfs_fill_super(s
, data
);
2288 nfs_fscache_get_super_cookie(s
, data
->fscache_uniq
, NULL
);
2291 mntroot
= nfs_get_root(s
, mntfh
, dev_name
);
2292 if (IS_ERR(mntroot
))
2293 goto error_splat_super
;
2295 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2297 goto error_splat_root
;
2299 s
->s_flags
|= MS_ACTIVE
;
2302 nfs_free_parsed_mount_data(data
);
2303 nfs_free_fhandle(mntfh
);
2307 nfs_free_server(server
);
2312 mntroot
= ERR_PTR(error
);
2314 if (server
&& !s
->s_root
)
2315 bdi_unregister(&server
->backing_dev_info
);
2317 deactivate_locked_super(s
);
2322 * Ensure that we unregister the bdi before kill_anon_super
2323 * releases the device name
2325 static void nfs_put_super(struct super_block
*s
)
2327 struct nfs_server
*server
= NFS_SB(s
);
2329 bdi_unregister(&server
->backing_dev_info
);
2333 * Destroy an NFS2/3 superblock
2335 static void nfs_kill_super(struct super_block
*s
)
2337 struct nfs_server
*server
= NFS_SB(s
);
2340 nfs_fscache_release_super_cookie(s
);
2341 nfs_free_server(server
);
2345 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2347 static struct dentry
*
2348 nfs_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2349 const char *dev_name
, void *raw_data
)
2351 struct nfs_clone_mount
*data
= raw_data
;
2352 struct super_block
*s
;
2353 struct nfs_server
*server
;
2354 struct dentry
*mntroot
;
2355 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2356 struct nfs_sb_mountdata sb_mntdata
= {
2361 dprintk("--> nfs_xdev_mount()\n");
2363 /* create a new volume representation */
2364 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2365 if (IS_ERR(server
)) {
2366 error
= PTR_ERR(server
);
2367 goto out_err_noserver
;
2369 sb_mntdata
.server
= server
;
2371 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2372 compare_super
= NULL
;
2374 /* -o noac implies -o sync */
2375 if (server
->flags
& NFS_MOUNT_NOAC
)
2376 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2378 /* Get a superblock - note that we may end up sharing one that already exists */
2379 s
= sget(&nfs_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2385 if (s
->s_fs_info
!= server
) {
2386 nfs_free_server(server
);
2389 error
= nfs_bdi_register(server
);
2391 goto error_splat_bdi
;
2395 /* initial superblock/root creation */
2396 nfs_clone_super(s
, data
->sb
);
2397 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2400 mntroot
= nfs_get_root(s
, data
->fh
, dev_name
);
2401 if (IS_ERR(mntroot
)) {
2402 error
= PTR_ERR(mntroot
);
2403 goto error_splat_super
;
2405 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2408 goto error_splat_super
;
2411 s
->s_flags
|= MS_ACTIVE
;
2413 /* clone any lsm security options from the parent to the new sb */
2414 security_sb_clone_mnt_opts(data
->sb
, s
);
2416 dprintk("<-- nfs_xdev_mount() = 0\n");
2420 nfs_free_server(server
);
2422 dprintk("<-- nfs_xdev_mount() = %d [error]\n", error
);
2423 return ERR_PTR(error
);
2426 if (server
&& !s
->s_root
)
2427 bdi_unregister(&server
->backing_dev_info
);
2429 deactivate_locked_super(s
);
2430 dprintk("<-- nfs_xdev_mount() = %d [splat]\n", error
);
2431 return ERR_PTR(error
);
2434 #ifdef CONFIG_NFS_V4
2437 * Finish setting up a cloned NFS4 superblock
2439 static void nfs4_clone_super(struct super_block
*sb
,
2440 const struct super_block
*old_sb
)
2442 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2443 sb
->s_blocksize
= old_sb
->s_blocksize
;
2444 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2445 sb
->s_time_gran
= 1;
2446 sb
->s_op
= old_sb
->s_op
;
2448 * The VFS shouldn't apply the umask to mode bits. We will do
2449 * so ourselves when necessary.
2451 sb
->s_flags
|= MS_POSIXACL
;
2452 sb
->s_xattr
= old_sb
->s_xattr
;
2453 nfs_initialise_sb(sb
);
2457 * Set up an NFS4 superblock
2459 static void nfs4_fill_super(struct super_block
*sb
)
2461 sb
->s_time_gran
= 1;
2462 sb
->s_op
= &nfs4_sops
;
2464 * The VFS shouldn't apply the umask to mode bits. We will do
2465 * so ourselves when necessary.
2467 sb
->s_flags
|= MS_POSIXACL
;
2468 sb
->s_xattr
= nfs4_xattr_handlers
;
2469 nfs_initialise_sb(sb
);
2472 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2474 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2475 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2478 static int nfs4_validate_text_mount_data(void *options
,
2479 struct nfs_parsed_mount_data
*args
,
2480 const char *dev_name
)
2482 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2484 nfs_set_port(sap
, &args
->nfs_server
.port
, NFS_PORT
);
2486 nfs_validate_transport_protocol(args
);
2488 nfs4_validate_mount_flags(args
);
2490 if (args
->version
!= 4) {
2492 "NFS4: Illegal mount version\n");
2496 if (args
->auth_flavor_len
> 1) {
2498 "NFS4: Too many RPC auth flavours specified\n");
2502 if (args
->client_address
== NULL
) {
2504 "NFS4: mount program didn't pass callback address\n");
2508 return nfs_parse_devname(dev_name
,
2509 &args
->nfs_server
.hostname
,
2511 &args
->nfs_server
.export_path
,
2516 * Validate NFSv4 mount options
2518 static int nfs4_validate_mount_data(void *options
,
2519 struct nfs_parsed_mount_data
*args
,
2520 const char *dev_name
)
2522 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2523 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2529 switch (data
->version
) {
2531 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2532 goto out_no_address
;
2533 if (data
->host_addrlen
== 0)
2534 goto out_no_address
;
2535 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2536 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2538 if (!nfs_verify_server_address(sap
))
2539 goto out_no_address
;
2541 if (data
->auth_flavourlen
) {
2542 if (data
->auth_flavourlen
> 1)
2543 goto out_inval_auth
;
2544 if (copy_from_user(&args
->auth_flavors
[0],
2545 data
->auth_flavours
,
2546 sizeof(args
->auth_flavors
[0])))
2550 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2553 args
->nfs_server
.hostname
= c
;
2555 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2558 args
->nfs_server
.export_path
= c
;
2559 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2561 c
= strndup_user(data
->client_addr
.data
, 16);
2564 args
->client_address
= c
;
2567 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2571 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2572 args
->rsize
= data
->rsize
;
2573 args
->wsize
= data
->wsize
;
2574 args
->timeo
= data
->timeo
;
2575 args
->retrans
= data
->retrans
;
2576 args
->acregmin
= data
->acregmin
;
2577 args
->acregmax
= data
->acregmax
;
2578 args
->acdirmin
= data
->acdirmin
;
2579 args
->acdirmax
= data
->acdirmax
;
2580 args
->nfs_server
.protocol
= data
->proto
;
2581 nfs_validate_transport_protocol(args
);
2585 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2588 if (!nfs_verify_server_address(sap
))
2591 return nfs4_validate_text_mount_data(options
, args
, dev_name
);
2597 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2601 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2602 data
->auth_flavourlen
);
2606 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2611 * Get the superblock for the NFS4 root partition
2613 static struct dentry
*
2614 nfs4_remote_mount(struct file_system_type
*fs_type
, int flags
,
2615 const char *dev_name
, void *raw_data
)
2617 struct nfs_parsed_mount_data
*data
= raw_data
;
2618 struct super_block
*s
;
2619 struct nfs_server
*server
;
2620 struct nfs_fh
*mntfh
;
2621 struct dentry
*mntroot
;
2622 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2623 struct nfs_sb_mountdata sb_mntdata
= {
2626 int error
= -ENOMEM
;
2628 mntfh
= nfs_alloc_fhandle();
2629 if (data
== NULL
|| mntfh
== NULL
)
2632 /* Get a volume representation */
2633 server
= nfs4_create_server(data
, mntfh
);
2634 if (IS_ERR(server
)) {
2635 error
= PTR_ERR(server
);
2638 sb_mntdata
.server
= server
;
2640 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2641 compare_super
= NULL
;
2643 /* -o noac implies -o sync */
2644 if (server
->flags
& NFS_MOUNT_NOAC
)
2645 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2647 /* Get a superblock - note that we may end up sharing one that already exists */
2648 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2654 if (s
->s_fs_info
!= server
) {
2655 nfs_free_server(server
);
2658 error
= nfs_bdi_register(server
);
2660 goto error_splat_bdi
;
2664 /* initial superblock/root creation */
2666 nfs_fscache_get_super_cookie(
2667 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2670 mntroot
= nfs4_get_root(s
, mntfh
, dev_name
);
2671 if (IS_ERR(mntroot
)) {
2672 error
= PTR_ERR(mntroot
);
2673 goto error_splat_super
;
2676 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2678 goto error_splat_root
;
2680 s
->s_flags
|= MS_ACTIVE
;
2682 nfs_free_fhandle(mntfh
);
2686 nfs_free_fhandle(mntfh
);
2687 return ERR_PTR(error
);
2690 nfs_free_server(server
);
2696 if (server
&& !s
->s_root
)
2697 bdi_unregister(&server
->backing_dev_info
);
2699 deactivate_locked_super(s
);
2703 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2704 int flags
, void *data
, const char *hostname
)
2706 struct vfsmount
*root_mnt
;
2710 len
= strlen(hostname
) + 3;
2711 root_devname
= kmalloc(len
, GFP_KERNEL
);
2712 if (root_devname
== NULL
)
2713 return ERR_PTR(-ENOMEM
);
2714 snprintf(root_devname
, len
, "%s:/", hostname
);
2715 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2716 kfree(root_devname
);
2720 struct nfs_referral_count
{
2721 struct list_head list
;
2722 const struct task_struct
*task
;
2723 unsigned int referral_count
;
2726 static LIST_HEAD(nfs_referral_count_list
);
2727 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2729 static struct nfs_referral_count
*nfs_find_referral_count(void)
2731 struct nfs_referral_count
*p
;
2733 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2734 if (p
->task
== current
)
2740 #define NFS_MAX_NESTED_REFERRALS 2
2742 static int nfs_referral_loop_protect(void)
2744 struct nfs_referral_count
*p
, *new;
2747 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2750 new->task
= current
;
2751 new->referral_count
= 1;
2754 spin_lock(&nfs_referral_count_list_lock
);
2755 p
= nfs_find_referral_count();
2757 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2760 p
->referral_count
++;
2762 list_add(&new->list
, &nfs_referral_count_list
);
2765 spin_unlock(&nfs_referral_count_list_lock
);
2771 static void nfs_referral_loop_unprotect(void)
2773 struct nfs_referral_count
*p
;
2775 spin_lock(&nfs_referral_count_list_lock
);
2776 p
= nfs_find_referral_count();
2777 p
->referral_count
--;
2778 if (p
->referral_count
== 0)
2782 spin_unlock(&nfs_referral_count_list_lock
);
2786 static struct dentry
*nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2787 const char *export_path
)
2789 struct dentry
*dentry
;
2792 if (IS_ERR(root_mnt
))
2793 return ERR_CAST(root_mnt
);
2795 err
= nfs_referral_loop_protect();
2798 return ERR_PTR(err
);
2801 dentry
= mount_subtree(root_mnt
, export_path
);
2802 nfs_referral_loop_unprotect();
2807 static struct dentry
*nfs4_try_mount(int flags
, const char *dev_name
,
2808 struct nfs_parsed_mount_data
*data
)
2811 struct vfsmount
*root_mnt
;
2814 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2816 export_path
= data
->nfs_server
.export_path
;
2817 data
->nfs_server
.export_path
= "/";
2818 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2819 data
->nfs_server
.hostname
);
2820 data
->nfs_server
.export_path
= export_path
;
2822 res
= nfs_follow_remote_path(root_mnt
, export_path
);
2824 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %ld%s\n",
2825 IS_ERR(res
) ? PTR_ERR(res
) : 0,
2826 IS_ERR(res
) ? " [error]" : "");
2831 * Get the superblock for an NFS4 mountpoint
2833 static struct dentry
*nfs4_mount(struct file_system_type
*fs_type
,
2834 int flags
, const char *dev_name
, void *raw_data
)
2836 struct nfs_parsed_mount_data
*data
;
2837 int error
= -ENOMEM
;
2838 struct dentry
*res
= ERR_PTR(-ENOMEM
);
2840 data
= nfs_alloc_parsed_mount_data(4);
2844 /* Validate the mount data */
2845 error
= nfs4_validate_mount_data(raw_data
, data
, dev_name
);
2847 res
= ERR_PTR(error
);
2851 res
= nfs4_try_mount(flags
, dev_name
, data
);
2853 error
= PTR_ERR(res
);
2856 nfs_free_parsed_mount_data(data
);
2857 dprintk("<-- nfs4_mount() = %d%s\n", error
,
2858 error
!= 0 ? " [error]" : "");
2862 static void nfs4_kill_super(struct super_block
*sb
)
2864 struct nfs_server
*server
= NFS_SB(sb
);
2866 dprintk("--> %s\n", __func__
);
2867 nfs_super_return_all_delegations(sb
);
2868 kill_anon_super(sb
);
2869 nfs_fscache_release_super_cookie(sb
);
2870 nfs_free_server(server
);
2871 dprintk("<-- %s\n", __func__
);
2875 * Clone an NFS4 server record on xdev traversal (FSID-change)
2877 static struct dentry
*
2878 nfs4_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2879 const char *dev_name
, void *raw_data
)
2881 struct nfs_clone_mount
*data
= raw_data
;
2882 struct super_block
*s
;
2883 struct nfs_server
*server
;
2884 struct dentry
*mntroot
;
2885 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2886 struct nfs_sb_mountdata sb_mntdata
= {
2891 dprintk("--> nfs4_xdev_mount()\n");
2893 /* create a new volume representation */
2894 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2895 if (IS_ERR(server
)) {
2896 error
= PTR_ERR(server
);
2897 goto out_err_noserver
;
2899 sb_mntdata
.server
= server
;
2901 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2902 compare_super
= NULL
;
2904 /* -o noac implies -o sync */
2905 if (server
->flags
& NFS_MOUNT_NOAC
)
2906 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2908 /* Get a superblock - note that we may end up sharing one that already exists */
2909 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2915 if (s
->s_fs_info
!= server
) {
2916 nfs_free_server(server
);
2919 error
= nfs_bdi_register(server
);
2921 goto error_splat_bdi
;
2925 /* initial superblock/root creation */
2926 nfs4_clone_super(s
, data
->sb
);
2927 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2930 mntroot
= nfs4_get_root(s
, data
->fh
, dev_name
);
2931 if (IS_ERR(mntroot
)) {
2932 error
= PTR_ERR(mntroot
);
2933 goto error_splat_super
;
2935 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2938 goto error_splat_super
;
2941 s
->s_flags
|= MS_ACTIVE
;
2943 security_sb_clone_mnt_opts(data
->sb
, s
);
2945 dprintk("<-- nfs4_xdev_mount() = 0\n");
2949 nfs_free_server(server
);
2951 dprintk("<-- nfs4_xdev_mount() = %d [error]\n", error
);
2952 return ERR_PTR(error
);
2955 if (server
&& !s
->s_root
)
2956 bdi_unregister(&server
->backing_dev_info
);
2958 deactivate_locked_super(s
);
2959 dprintk("<-- nfs4_xdev_mount() = %d [splat]\n", error
);
2960 return ERR_PTR(error
);
2963 static struct dentry
*
2964 nfs4_remote_referral_mount(struct file_system_type
*fs_type
, int flags
,
2965 const char *dev_name
, void *raw_data
)
2967 struct nfs_clone_mount
*data
= raw_data
;
2968 struct super_block
*s
;
2969 struct nfs_server
*server
;
2970 struct dentry
*mntroot
;
2971 struct nfs_fh
*mntfh
;
2972 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2973 struct nfs_sb_mountdata sb_mntdata
= {
2976 int error
= -ENOMEM
;
2978 dprintk("--> nfs4_referral_get_sb()\n");
2980 mntfh
= nfs_alloc_fhandle();
2984 /* create a new volume representation */
2985 server
= nfs4_create_referral_server(data
, mntfh
);
2986 if (IS_ERR(server
)) {
2987 error
= PTR_ERR(server
);
2988 goto out_err_noserver
;
2990 sb_mntdata
.server
= server
;
2992 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2993 compare_super
= NULL
;
2995 /* -o noac implies -o sync */
2996 if (server
->flags
& NFS_MOUNT_NOAC
)
2997 sb_mntdata
.mntflags
|= MS_SYNCHRONOUS
;
2999 /* Get a superblock - note that we may end up sharing one that already exists */
3000 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3006 if (s
->s_fs_info
!= server
) {
3007 nfs_free_server(server
);
3010 error
= nfs_bdi_register(server
);
3012 goto error_splat_bdi
;
3016 /* initial superblock/root creation */
3018 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3021 mntroot
= nfs4_get_root(s
, mntfh
, dev_name
);
3022 if (IS_ERR(mntroot
)) {
3023 error
= PTR_ERR(mntroot
);
3024 goto error_splat_super
;
3026 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3029 goto error_splat_super
;
3032 s
->s_flags
|= MS_ACTIVE
;
3034 security_sb_clone_mnt_opts(data
->sb
, s
);
3036 nfs_free_fhandle(mntfh
);
3037 dprintk("<-- nfs4_referral_get_sb() = 0\n");
3041 nfs_free_server(server
);
3043 nfs_free_fhandle(mntfh
);
3045 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error
);
3046 return ERR_PTR(error
);
3049 if (server
&& !s
->s_root
)
3050 bdi_unregister(&server
->backing_dev_info
);
3052 deactivate_locked_super(s
);
3053 nfs_free_fhandle(mntfh
);
3054 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error
);
3055 return ERR_PTR(error
);
3059 * Create an NFS4 server record on referral traversal
3061 static struct dentry
*nfs4_referral_mount(struct file_system_type
*fs_type
,
3062 int flags
, const char *dev_name
, void *raw_data
)
3064 struct nfs_clone_mount
*data
= raw_data
;
3066 struct vfsmount
*root_mnt
;
3069 dprintk("--> nfs4_referral_mount()\n");
3071 export_path
= data
->mnt_path
;
3072 data
->mnt_path
= "/";
3074 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
3075 flags
, data
, data
->hostname
);
3076 data
->mnt_path
= export_path
;
3078 res
= nfs_follow_remote_path(root_mnt
, export_path
);
3079 dprintk("<-- nfs4_referral_mount() = %ld%s\n",
3080 IS_ERR(res
) ? PTR_ERR(res
) : 0,
3081 IS_ERR(res
) ? " [error]" : "");
3085 #endif /* CONFIG_NFS_V4 */