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 #define NFS_DEFAULT_VERSION 3
73 #define NFS_DEFAULT_VERSION 2
77 /* Mount options that take no arguments */
79 Opt_posix
, Opt_noposix
,
83 Opt_v2
, Opt_v3
, Opt_v4
,
84 Opt_udp
, Opt_tcp
, Opt_rdma
,
86 Opt_rdirplus
, Opt_nordirplus
,
87 Opt_sharecache
, Opt_nosharecache
,
88 Opt_resvport
, Opt_noresvport
,
89 Opt_fscache
, Opt_nofscache
,
91 /* Mount options that take integer arguments */
93 Opt_rsize
, Opt_wsize
, Opt_bsize
,
94 Opt_timeo
, Opt_retrans
,
95 Opt_acregmin
, Opt_acregmax
,
96 Opt_acdirmin
, Opt_acdirmax
,
104 /* Mount options that take string arguments */
105 Opt_sec
, Opt_proto
, Opt_mountproto
, Opt_mounthost
,
106 Opt_addr
, Opt_mountaddr
, Opt_clientaddr
,
111 /* Special mount options */
112 Opt_userspace
, Opt_deprecated
, Opt_sloppy
,
117 static const match_table_t nfs_mount_option_tokens
= {
118 { Opt_userspace
, "bg" },
119 { Opt_userspace
, "fg" },
120 { Opt_userspace
, "retry=%s" },
122 { Opt_sloppy
, "sloppy" },
124 { Opt_soft
, "soft" },
125 { Opt_hard
, "hard" },
126 { Opt_deprecated
, "intr" },
127 { Opt_deprecated
, "nointr" },
128 { Opt_posix
, "posix" },
129 { Opt_noposix
, "noposix" },
131 { Opt_nocto
, "nocto" },
133 { Opt_noac
, "noac" },
134 { Opt_lock
, "lock" },
135 { Opt_nolock
, "nolock" },
141 { Opt_rdma
, "rdma" },
143 { Opt_noacl
, "noacl" },
144 { Opt_rdirplus
, "rdirplus" },
145 { Opt_nordirplus
, "nordirplus" },
146 { Opt_sharecache
, "sharecache" },
147 { Opt_nosharecache
, "nosharecache" },
148 { Opt_resvport
, "resvport" },
149 { Opt_noresvport
, "noresvport" },
150 { Opt_fscache
, "fsc" },
151 { Opt_nofscache
, "nofsc" },
153 { Opt_port
, "port=%s" },
154 { Opt_rsize
, "rsize=%s" },
155 { Opt_wsize
, "wsize=%s" },
156 { Opt_bsize
, "bsize=%s" },
157 { Opt_timeo
, "timeo=%s" },
158 { Opt_retrans
, "retrans=%s" },
159 { Opt_acregmin
, "acregmin=%s" },
160 { Opt_acregmax
, "acregmax=%s" },
161 { Opt_acdirmin
, "acdirmin=%s" },
162 { Opt_acdirmax
, "acdirmax=%s" },
163 { Opt_actimeo
, "actimeo=%s" },
164 { Opt_namelen
, "namlen=%s" },
165 { Opt_mountport
, "mountport=%s" },
166 { Opt_mountvers
, "mountvers=%s" },
167 { Opt_nfsvers
, "nfsvers=%s" },
168 { Opt_nfsvers
, "vers=%s" },
169 { Opt_minorversion
, "minorversion=%s" },
171 { Opt_sec
, "sec=%s" },
172 { Opt_proto
, "proto=%s" },
173 { Opt_mountproto
, "mountproto=%s" },
174 { Opt_addr
, "addr=%s" },
175 { Opt_clientaddr
, "clientaddr=%s" },
176 { Opt_mounthost
, "mounthost=%s" },
177 { Opt_mountaddr
, "mountaddr=%s" },
179 { Opt_lookupcache
, "lookupcache=%s" },
180 { Opt_fscache_uniq
, "fsc=%s" },
181 { Opt_local_lock
, "local_lock=%s" },
187 Opt_xprt_udp
, Opt_xprt_udp6
, Opt_xprt_tcp
, Opt_xprt_tcp6
, Opt_xprt_rdma
,
192 static const match_table_t nfs_xprt_protocol_tokens
= {
193 { Opt_xprt_udp
, "udp" },
194 { Opt_xprt_udp6
, "udp6" },
195 { Opt_xprt_tcp
, "tcp" },
196 { Opt_xprt_tcp6
, "tcp6" },
197 { Opt_xprt_rdma
, "rdma" },
199 { Opt_xprt_err
, NULL
}
203 Opt_sec_none
, Opt_sec_sys
,
204 Opt_sec_krb5
, Opt_sec_krb5i
, Opt_sec_krb5p
,
205 Opt_sec_lkey
, Opt_sec_lkeyi
, Opt_sec_lkeyp
,
206 Opt_sec_spkm
, Opt_sec_spkmi
, Opt_sec_spkmp
,
211 static const match_table_t nfs_secflavor_tokens
= {
212 { Opt_sec_none
, "none" },
213 { Opt_sec_none
, "null" },
214 { Opt_sec_sys
, "sys" },
216 { Opt_sec_krb5
, "krb5" },
217 { Opt_sec_krb5i
, "krb5i" },
218 { Opt_sec_krb5p
, "krb5p" },
220 { Opt_sec_lkey
, "lkey" },
221 { Opt_sec_lkeyi
, "lkeyi" },
222 { Opt_sec_lkeyp
, "lkeyp" },
224 { Opt_sec_spkm
, "spkm3" },
225 { Opt_sec_spkmi
, "spkm3i" },
226 { Opt_sec_spkmp
, "spkm3p" },
228 { Opt_sec_err
, NULL
}
232 Opt_lookupcache_all
, Opt_lookupcache_positive
,
233 Opt_lookupcache_none
,
238 static match_table_t nfs_lookupcache_tokens
= {
239 { Opt_lookupcache_all
, "all" },
240 { Opt_lookupcache_positive
, "pos" },
241 { Opt_lookupcache_positive
, "positive" },
242 { Opt_lookupcache_none
, "none" },
244 { Opt_lookupcache_err
, NULL
}
248 Opt_local_lock_all
, Opt_local_lock_flock
, Opt_local_lock_posix
,
254 static match_table_t nfs_local_lock_tokens
= {
255 { Opt_local_lock_all
, "all" },
256 { Opt_local_lock_flock
, "flock" },
257 { Opt_local_lock_posix
, "posix" },
258 { Opt_local_lock_none
, "none" },
260 { Opt_local_lock_err
, NULL
}
264 static void nfs_umount_begin(struct super_block
*);
265 static int nfs_statfs(struct dentry
*, struct kstatfs
*);
266 static int nfs_show_options(struct seq_file
*, struct vfsmount
*);
267 static int nfs_show_stats(struct seq_file
*, struct vfsmount
*);
268 static int nfs_get_sb(struct file_system_type
*, int, const char *, void *, struct vfsmount
*);
269 static struct dentry
*nfs_xdev_mount(struct file_system_type
*fs_type
,
270 int flags
, const char *dev_name
, void *raw_data
);
271 static void nfs_put_super(struct super_block
*);
272 static void nfs_kill_super(struct super_block
*);
273 static int nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
);
275 static struct file_system_type nfs_fs_type
= {
276 .owner
= THIS_MODULE
,
278 .get_sb
= nfs_get_sb
,
279 .kill_sb
= nfs_kill_super
,
280 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
283 struct file_system_type nfs_xdev_fs_type
= {
284 .owner
= THIS_MODULE
,
286 .mount
= nfs_xdev_mount
,
287 .kill_sb
= nfs_kill_super
,
288 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
291 static const struct super_operations nfs_sops
= {
292 .alloc_inode
= nfs_alloc_inode
,
293 .destroy_inode
= nfs_destroy_inode
,
294 .write_inode
= nfs_write_inode
,
295 .put_super
= nfs_put_super
,
296 .statfs
= nfs_statfs
,
297 .evict_inode
= nfs_evict_inode
,
298 .umount_begin
= nfs_umount_begin
,
299 .show_options
= nfs_show_options
,
300 .show_stats
= nfs_show_stats
,
301 .remount_fs
= nfs_remount
,
305 static int nfs4_validate_text_mount_data(void *options
,
306 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
307 static int nfs4_try_mount(int flags
, const char *dev_name
,
308 struct nfs_parsed_mount_data
*data
, struct vfsmount
*mnt
);
309 static int nfs4_get_sb(struct file_system_type
*fs_type
,
310 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
311 static struct dentry
*nfs4_remote_mount(struct file_system_type
*fs_type
,
312 int flags
, const char *dev_name
, void *raw_data
);
313 static struct dentry
*nfs4_xdev_mount(struct file_system_type
*fs_type
,
314 int flags
, const char *dev_name
, void *raw_data
);
315 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
316 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
);
317 static struct dentry
*nfs4_remote_referral_mount(struct file_system_type
*fs_type
,
318 int flags
, const char *dev_name
, void *raw_data
);
319 static void nfs4_kill_super(struct super_block
*sb
);
321 static struct file_system_type nfs4_fs_type
= {
322 .owner
= THIS_MODULE
,
324 .get_sb
= nfs4_get_sb
,
325 .kill_sb
= nfs4_kill_super
,
326 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
329 static struct file_system_type nfs4_remote_fs_type
= {
330 .owner
= THIS_MODULE
,
332 .mount
= nfs4_remote_mount
,
333 .kill_sb
= nfs4_kill_super
,
334 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
337 struct file_system_type nfs4_xdev_fs_type
= {
338 .owner
= THIS_MODULE
,
340 .mount
= nfs4_xdev_mount
,
341 .kill_sb
= nfs4_kill_super
,
342 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
345 static struct file_system_type nfs4_remote_referral_fs_type
= {
346 .owner
= THIS_MODULE
,
348 .mount
= nfs4_remote_referral_mount
,
349 .kill_sb
= nfs4_kill_super
,
350 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
353 struct file_system_type nfs4_referral_fs_type
= {
354 .owner
= THIS_MODULE
,
356 .get_sb
= nfs4_referral_get_sb
,
357 .kill_sb
= nfs4_kill_super
,
358 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_REVAL_DOT
|FS_BINARY_MOUNTDATA
,
361 static const struct super_operations nfs4_sops
= {
362 .alloc_inode
= nfs_alloc_inode
,
363 .destroy_inode
= nfs_destroy_inode
,
364 .write_inode
= nfs_write_inode
,
365 .put_super
= nfs_put_super
,
366 .statfs
= nfs_statfs
,
367 .evict_inode
= nfs4_evict_inode
,
368 .umount_begin
= nfs_umount_begin
,
369 .show_options
= nfs_show_options
,
370 .show_stats
= nfs_show_stats
,
371 .remount_fs
= nfs_remount
,
375 static struct shrinker acl_shrinker
= {
376 .shrink
= nfs_access_cache_shrinker
,
377 .seeks
= DEFAULT_SEEKS
,
381 * Register the NFS filesystems
383 int __init
register_nfs_fs(void)
387 ret
= register_filesystem(&nfs_fs_type
);
391 ret
= nfs_register_sysctl();
395 ret
= register_filesystem(&nfs4_fs_type
);
399 register_shrinker(&acl_shrinker
);
404 nfs_unregister_sysctl();
407 unregister_filesystem(&nfs_fs_type
);
413 * Unregister the NFS filesystems
415 void __exit
unregister_nfs_fs(void)
417 unregister_shrinker(&acl_shrinker
);
419 unregister_filesystem(&nfs4_fs_type
);
421 nfs_unregister_sysctl();
422 unregister_filesystem(&nfs_fs_type
);
425 void nfs_sb_active(struct super_block
*sb
)
427 struct nfs_server
*server
= NFS_SB(sb
);
429 if (atomic_inc_return(&server
->active
) == 1)
430 atomic_inc(&sb
->s_active
);
433 void nfs_sb_deactive(struct super_block
*sb
)
435 struct nfs_server
*server
= NFS_SB(sb
);
437 if (atomic_dec_and_test(&server
->active
))
438 deactivate_super(sb
);
442 * Deliver file system statistics to userspace
444 static int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
446 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
447 unsigned char blockbits
;
448 unsigned long blockres
;
449 struct nfs_fh
*fh
= NFS_FH(dentry
->d_inode
);
450 struct nfs_fsstat res
;
453 res
.fattr
= nfs_alloc_fattr();
454 if (res
.fattr
== NULL
)
457 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
458 if (unlikely(error
== -ESTALE
)) {
459 struct dentry
*pd_dentry
;
461 pd_dentry
= dget_parent(dentry
);
462 if (pd_dentry
!= NULL
) {
463 nfs_zap_caches(pd_dentry
->d_inode
);
467 nfs_free_fattr(res
.fattr
);
471 buf
->f_type
= NFS_SUPER_MAGIC
;
474 * Current versions of glibc do not correctly handle the
475 * case where f_frsize != f_bsize. Eventually we want to
476 * report the value of wtmult in this field.
478 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
481 * On most *nix systems, f_blocks, f_bfree, and f_bavail
482 * are reported in units of f_frsize. Linux hasn't had
483 * an f_frsize field in its statfs struct until recently,
484 * thus historically Linux's sys_statfs reports these
485 * fields in units of f_bsize.
487 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
488 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
489 blockres
= (1 << blockbits
) - 1;
490 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
491 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
492 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
494 buf
->f_files
= res
.tfiles
;
495 buf
->f_ffree
= res
.afiles
;
497 buf
->f_namelen
= server
->namelen
;
502 dprintk("%s: statfs error = %d\n", __func__
, -error
);
507 * Map the security flavour number to a name
509 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
511 static const struct {
512 rpc_authflavor_t flavour
;
515 { RPC_AUTH_NULL
, "null" },
516 { RPC_AUTH_UNIX
, "sys" },
517 { RPC_AUTH_GSS_KRB5
, "krb5" },
518 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
519 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
520 { RPC_AUTH_GSS_LKEY
, "lkey" },
521 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
522 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
523 { RPC_AUTH_GSS_SPKM
, "spkm" },
524 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
525 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
526 { UINT_MAX
, "unknown" }
530 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
531 if (sec_flavours
[i
].flavour
== flavour
)
534 return sec_flavours
[i
].str
;
537 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
540 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
542 seq_printf(m
, ",mountproto=");
543 switch (sap
->sa_family
) {
545 switch (nfss
->mountd_protocol
) {
547 seq_printf(m
, RPCBIND_NETID_UDP
);
550 seq_printf(m
, RPCBIND_NETID_TCP
);
554 seq_printf(m
, "auto");
558 switch (nfss
->mountd_protocol
) {
560 seq_printf(m
, RPCBIND_NETID_UDP6
);
563 seq_printf(m
, RPCBIND_NETID_TCP6
);
567 seq_printf(m
, "auto");
572 seq_printf(m
, "auto");
576 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
579 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
581 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
584 switch (sap
->sa_family
) {
586 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
587 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
591 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
592 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
597 seq_printf(m
, ",mountaddr=unspecified");
600 if (nfss
->mountd_version
|| showdefaults
)
601 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
602 if (nfss
->mountd_port
|| showdefaults
)
603 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
605 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
609 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
612 struct nfs_client
*clp
= nfss
->nfs_client
;
614 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
615 seq_printf(m
, ",minorversion=%u", clp
->cl_minorversion
);
618 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
625 * Describe the mount options in force on this server representation
627 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
630 static const struct proc_nfs_info
{
635 { NFS_MOUNT_SOFT
, ",soft", ",hard" },
636 { NFS_MOUNT_POSIX
, ",posix", "" },
637 { NFS_MOUNT_NOCTO
, ",nocto", "" },
638 { NFS_MOUNT_NOAC
, ",noac", "" },
639 { NFS_MOUNT_NONLM
, ",nolock", "" },
640 { NFS_MOUNT_NOACL
, ",noacl", "" },
641 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
642 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
643 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
646 const struct proc_nfs_info
*nfs_infop
;
647 struct nfs_client
*clp
= nfss
->nfs_client
;
648 u32 version
= clp
->rpc_ops
->version
;
649 int local_flock
, local_fcntl
;
651 seq_printf(m
, ",vers=%u", version
);
652 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
653 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
654 if (nfss
->bsize
!= 0)
655 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
656 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
657 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
658 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
659 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
660 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
661 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
662 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
663 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
664 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
665 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
666 if (nfss
->flags
& nfs_infop
->flag
)
667 seq_puts(m
, nfs_infop
->str
);
669 seq_puts(m
, nfs_infop
->nostr
);
671 seq_printf(m
, ",proto=%s",
672 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
674 if (nfss
->port
!= NFS_PORT
)
675 seq_printf(m
, ",port=%u", nfss
->port
);
678 seq_printf(m
, ",port=%u", nfss
->port
);
680 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
681 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
682 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
685 nfs_show_mountd_options(m
, nfss
, showdefaults
);
687 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
689 if (nfss
->options
& NFS_OPTION_FSCACHE
)
690 seq_printf(m
, ",fsc");
692 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
693 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
694 seq_printf(m
, ",lookupcache=none");
696 seq_printf(m
, ",lookupcache=pos");
699 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
700 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
702 if (!local_flock
&& !local_fcntl
)
703 seq_printf(m
, ",local_lock=none");
704 else if (local_flock
&& local_fcntl
)
705 seq_printf(m
, ",local_lock=all");
706 else if (local_flock
)
707 seq_printf(m
, ",local_lock=flock");
709 seq_printf(m
, ",local_lock=posix");
713 * Describe the mount options on this VFS mountpoint
715 static int nfs_show_options(struct seq_file
*m
, struct vfsmount
*mnt
)
717 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
719 nfs_show_mount_options(m
, nfss
, 0);
721 seq_printf(m
, ",addr=%s",
722 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
729 * Present statistical information for this VFS mountpoint
731 static int nfs_show_stats(struct seq_file
*m
, struct vfsmount
*mnt
)
734 struct nfs_server
*nfss
= NFS_SB(mnt
->mnt_sb
);
735 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
736 struct nfs_iostats totals
= { };
738 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
741 * Display all mount option settings
743 seq_printf(m
, "\n\topts:\t");
744 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_RDONLY
? "ro" : "rw");
745 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_SYNCHRONOUS
? ",sync" : "");
746 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NOATIME
? ",noatime" : "");
747 seq_puts(m
, mnt
->mnt_sb
->s_flags
& MS_NODIRATIME
? ",nodiratime" : "");
748 nfs_show_mount_options(m
, nfss
, 1);
750 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
752 seq_printf(m
, "\n\tcaps:\t");
753 seq_printf(m
, "caps=0x%x", nfss
->caps
);
754 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
755 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
756 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
757 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
760 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
761 seq_printf(m
, "\n\tnfsv4:\t");
762 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
763 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
764 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
769 * Display security flavor in effect for this mount
771 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
773 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
776 * Display superblock I/O counters
778 for_each_possible_cpu(cpu
) {
779 struct nfs_iostats
*stats
;
782 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
784 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
785 totals
.events
[i
] += stats
->events
[i
];
786 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
787 totals
.bytes
[i
] += stats
->bytes
[i
];
788 #ifdef CONFIG_NFS_FSCACHE
789 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
790 totals
.fscache
[i
] += stats
->fscache
[i
];
796 seq_printf(m
, "\n\tevents:\t");
797 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
798 seq_printf(m
, "%lu ", totals
.events
[i
]);
799 seq_printf(m
, "\n\tbytes:\t");
800 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
801 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
802 #ifdef CONFIG_NFS_FSCACHE
803 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
804 seq_printf(m
, "\n\tfsc:\t");
805 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
806 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
811 rpc_print_iostats(m
, nfss
->client
);
817 * Begin unmount by attempting to remove all automounted mountpoints we added
818 * in response to xdev traversals and referrals
820 static void nfs_umount_begin(struct super_block
*sb
)
822 struct nfs_server
*server
;
823 struct rpc_clnt
*rpc
;
826 /* -EIO all pending I/O */
827 rpc
= server
->client_acl
;
829 rpc_killall_tasks(rpc
);
830 rpc
= server
->client
;
832 rpc_killall_tasks(rpc
);
835 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(unsigned int version
)
837 struct nfs_parsed_mount_data
*data
;
839 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
841 data
->acregmin
= NFS_DEF_ACREGMIN
;
842 data
->acregmax
= NFS_DEF_ACREGMAX
;
843 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
844 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
845 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
846 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
847 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
848 data
->auth_flavors
[0] = RPC_AUTH_UNIX
;
849 data
->auth_flavor_len
= 1;
850 data
->version
= version
;
851 data
->minorversion
= 0;
857 * Sanity-check a server address provided by the mount command.
859 * Address family must be initialized, and address must not be
860 * the ANY address for that family.
862 static int nfs_verify_server_address(struct sockaddr
*addr
)
864 switch (addr
->sa_family
) {
866 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
867 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
870 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
871 return !ipv6_addr_any(sa
);
875 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
880 * Select between a default port value and a user-specified port value.
881 * If a zero value is set, then autobind will be used.
883 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
884 const unsigned short default_port
)
886 if (*port
== NFS_UNSPEC_PORT
)
887 *port
= default_port
;
889 rpc_set_port(sap
, *port
);
893 * Sanity check the NFS transport protocol.
896 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
898 switch (mnt
->nfs_server
.protocol
) {
899 case XPRT_TRANSPORT_UDP
:
900 case XPRT_TRANSPORT_TCP
:
901 case XPRT_TRANSPORT_RDMA
:
904 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
909 * For text based NFSv2/v3 mounts, the mount protocol transport default
910 * settings should depend upon the specified NFS transport.
912 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
914 nfs_validate_transport_protocol(mnt
);
916 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
917 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
919 switch (mnt
->nfs_server
.protocol
) {
920 case XPRT_TRANSPORT_UDP
:
921 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
923 case XPRT_TRANSPORT_TCP
:
924 case XPRT_TRANSPORT_RDMA
:
925 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
930 * Parse the value of the 'sec=' option.
932 static int nfs_parse_security_flavors(char *value
,
933 struct nfs_parsed_mount_data
*mnt
)
935 substring_t args
[MAX_OPT_ARGS
];
937 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
939 switch (match_token(value
, nfs_secflavor_tokens
, args
)) {
941 mnt
->auth_flavors
[0] = RPC_AUTH_NULL
;
944 mnt
->auth_flavors
[0] = RPC_AUTH_UNIX
;
947 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5
;
950 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5I
;
953 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_KRB5P
;
956 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEY
;
959 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYI
;
962 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_LKEYP
;
965 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKM
;
968 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMI
;
971 mnt
->auth_flavors
[0] = RPC_AUTH_GSS_SPKMP
;
977 mnt
->auth_flavor_len
= 1;
982 * Error-check and convert a string of mount options from user space into
983 * a data structure. The whole mount string is processed; bad options are
984 * skipped as they are encountered. If there were no errors, return 1;
985 * otherwise return 0 (zero).
987 static int nfs_parse_mount_options(char *raw
,
988 struct nfs_parsed_mount_data
*mnt
)
990 char *p
, *string
, *secdata
;
991 int rc
, sloppy
= 0, invalid_option
= 0;
992 unsigned short protofamily
= AF_UNSPEC
;
993 unsigned short mountfamily
= AF_UNSPEC
;
996 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
999 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1001 secdata
= alloc_secdata();
1005 rc
= security_sb_copy_data(raw
, secdata
);
1007 goto out_security_failure
;
1009 rc
= security_sb_parse_opts_str(secdata
, &mnt
->lsm_opts
);
1011 goto out_security_failure
;
1013 free_secdata(secdata
);
1015 while ((p
= strsep(&raw
, ",")) != NULL
) {
1016 substring_t args
[MAX_OPT_ARGS
];
1017 unsigned long option
;
1023 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1025 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1029 * boolean options: foo/nofoo
1032 mnt
->flags
|= NFS_MOUNT_SOFT
;
1035 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1038 mnt
->flags
|= NFS_MOUNT_POSIX
;
1041 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1044 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1047 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1050 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1053 mnt
->flags
|= NFS_MOUNT_NOAC
;
1056 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1057 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1058 NFS_MOUNT_LOCAL_FCNTL
);
1061 mnt
->flags
|= NFS_MOUNT_NONLM
;
1062 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1063 NFS_MOUNT_LOCAL_FCNTL
);
1066 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1070 mnt
->flags
|= NFS_MOUNT_VER3
;
1073 #ifdef CONFIG_NFS_V4
1075 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1080 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1081 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1084 mnt
->flags
|= NFS_MOUNT_TCP
;
1085 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1088 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1089 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1090 xprt_load_transport(p
);
1093 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1096 mnt
->flags
|= NFS_MOUNT_NOACL
;
1099 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1101 case Opt_nordirplus
:
1102 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1104 case Opt_sharecache
:
1105 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1107 case Opt_nosharecache
:
1108 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1111 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1113 case Opt_noresvport
:
1114 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1117 mnt
->options
|= NFS_OPTION_FSCACHE
;
1118 kfree(mnt
->fscache_uniq
);
1119 mnt
->fscache_uniq
= NULL
;
1122 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1123 kfree(mnt
->fscache_uniq
);
1124 mnt
->fscache_uniq
= NULL
;
1128 * options that take numeric values
1131 string
= match_strdup(args
);
1134 rc
= strict_strtoul(string
, 10, &option
);
1136 if (rc
!= 0 || option
> USHRT_MAX
)
1137 goto out_invalid_value
;
1138 mnt
->nfs_server
.port
= option
;
1141 string
= match_strdup(args
);
1144 rc
= strict_strtoul(string
, 10, &option
);
1147 goto out_invalid_value
;
1148 mnt
->rsize
= option
;
1151 string
= match_strdup(args
);
1154 rc
= strict_strtoul(string
, 10, &option
);
1157 goto out_invalid_value
;
1158 mnt
->wsize
= option
;
1161 string
= match_strdup(args
);
1164 rc
= strict_strtoul(string
, 10, &option
);
1167 goto out_invalid_value
;
1168 mnt
->bsize
= option
;
1171 string
= match_strdup(args
);
1174 rc
= strict_strtoul(string
, 10, &option
);
1176 if (rc
!= 0 || option
== 0)
1177 goto out_invalid_value
;
1178 mnt
->timeo
= option
;
1181 string
= match_strdup(args
);
1184 rc
= strict_strtoul(string
, 10, &option
);
1186 if (rc
!= 0 || option
== 0)
1187 goto out_invalid_value
;
1188 mnt
->retrans
= option
;
1191 string
= match_strdup(args
);
1194 rc
= strict_strtoul(string
, 10, &option
);
1197 goto out_invalid_value
;
1198 mnt
->acregmin
= option
;
1201 string
= match_strdup(args
);
1204 rc
= strict_strtoul(string
, 10, &option
);
1207 goto out_invalid_value
;
1208 mnt
->acregmax
= option
;
1211 string
= match_strdup(args
);
1214 rc
= strict_strtoul(string
, 10, &option
);
1217 goto out_invalid_value
;
1218 mnt
->acdirmin
= option
;
1221 string
= match_strdup(args
);
1224 rc
= strict_strtoul(string
, 10, &option
);
1227 goto out_invalid_value
;
1228 mnt
->acdirmax
= option
;
1231 string
= match_strdup(args
);
1234 rc
= strict_strtoul(string
, 10, &option
);
1237 goto out_invalid_value
;
1238 mnt
->acregmin
= mnt
->acregmax
=
1239 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1242 string
= match_strdup(args
);
1245 rc
= strict_strtoul(string
, 10, &option
);
1248 goto out_invalid_value
;
1249 mnt
->namlen
= option
;
1252 string
= match_strdup(args
);
1255 rc
= strict_strtoul(string
, 10, &option
);
1257 if (rc
!= 0 || option
> USHRT_MAX
)
1258 goto out_invalid_value
;
1259 mnt
->mount_server
.port
= option
;
1262 string
= match_strdup(args
);
1265 rc
= strict_strtoul(string
, 10, &option
);
1268 option
< NFS_MNT_VERSION
||
1269 option
> NFS_MNT3_VERSION
)
1270 goto out_invalid_value
;
1271 mnt
->mount_server
.version
= option
;
1274 string
= match_strdup(args
);
1277 rc
= strict_strtoul(string
, 10, &option
);
1280 goto out_invalid_value
;
1283 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1287 mnt
->flags
|= NFS_MOUNT_VER3
;
1290 #ifdef CONFIG_NFS_V4
1292 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1297 goto out_invalid_value
;
1300 case Opt_minorversion
:
1301 string
= match_strdup(args
);
1304 rc
= strict_strtoul(string
, 10, &option
);
1307 goto out_invalid_value
;
1308 if (option
> NFS4_MAX_MINOR_VERSION
)
1309 goto out_invalid_value
;
1310 mnt
->minorversion
= option
;
1314 * options that take text values
1317 string
= match_strdup(args
);
1320 rc
= nfs_parse_security_flavors(string
, mnt
);
1323 dfprintk(MOUNT
, "NFS: unrecognized "
1324 "security flavor\n");
1329 string
= match_strdup(args
);
1332 token
= match_token(string
,
1333 nfs_xprt_protocol_tokens
, args
);
1335 protofamily
= AF_INET
;
1338 protofamily
= AF_INET6
;
1340 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1341 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1345 protofamily
= AF_INET6
;
1347 mnt
->flags
|= NFS_MOUNT_TCP
;
1348 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1352 /* vector side protocols to TCP */
1353 mnt
->flags
|= NFS_MOUNT_TCP
;
1354 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1355 xprt_load_transport(string
);
1359 dfprintk(MOUNT
, "NFS: unrecognized "
1360 "transport protocol\n");
1365 case Opt_mountproto
:
1366 string
= match_strdup(args
);
1369 token
= match_token(string
,
1370 nfs_xprt_protocol_tokens
, args
);
1373 mountfamily
= AF_INET
;
1376 mountfamily
= AF_INET6
;
1378 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1381 mountfamily
= AF_INET6
;
1383 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1385 case Opt_xprt_rdma
: /* not used for side protocols */
1387 dfprintk(MOUNT
, "NFS: unrecognized "
1388 "transport protocol\n");
1393 string
= match_strdup(args
);
1396 mnt
->nfs_server
.addrlen
=
1397 rpc_pton(string
, strlen(string
),
1399 &mnt
->nfs_server
.address
,
1400 sizeof(mnt
->nfs_server
.address
));
1402 if (mnt
->nfs_server
.addrlen
== 0)
1403 goto out_invalid_address
;
1405 case Opt_clientaddr
:
1406 string
= match_strdup(args
);
1409 kfree(mnt
->client_address
);
1410 mnt
->client_address
= string
;
1413 string
= match_strdup(args
);
1416 kfree(mnt
->mount_server
.hostname
);
1417 mnt
->mount_server
.hostname
= string
;
1420 string
= match_strdup(args
);
1423 mnt
->mount_server
.addrlen
=
1424 rpc_pton(string
, strlen(string
),
1426 &mnt
->mount_server
.address
,
1427 sizeof(mnt
->mount_server
.address
));
1429 if (mnt
->mount_server
.addrlen
== 0)
1430 goto out_invalid_address
;
1432 case Opt_lookupcache
:
1433 string
= match_strdup(args
);
1436 token
= match_token(string
,
1437 nfs_lookupcache_tokens
, args
);
1440 case Opt_lookupcache_all
:
1441 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1443 case Opt_lookupcache_positive
:
1444 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1445 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1447 case Opt_lookupcache_none
:
1448 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1451 dfprintk(MOUNT
, "NFS: invalid "
1452 "lookupcache argument\n");
1456 case Opt_fscache_uniq
:
1457 string
= match_strdup(args
);
1460 kfree(mnt
->fscache_uniq
);
1461 mnt
->fscache_uniq
= string
;
1462 mnt
->options
|= NFS_OPTION_FSCACHE
;
1464 case Opt_local_lock
:
1465 string
= match_strdup(args
);
1468 token
= match_token(string
, nfs_local_lock_tokens
,
1472 case Opt_local_lock_all
:
1473 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1474 NFS_MOUNT_LOCAL_FCNTL
);
1476 case Opt_local_lock_flock
:
1477 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1479 case Opt_local_lock_posix
:
1480 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1482 case Opt_local_lock_none
:
1483 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1484 NFS_MOUNT_LOCAL_FCNTL
);
1487 dfprintk(MOUNT
, "NFS: invalid "
1488 "local_lock argument\n");
1498 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1501 case Opt_deprecated
:
1502 dfprintk(MOUNT
, "NFS: ignoring mount option "
1508 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1513 if (!sloppy
&& invalid_option
)
1517 * verify that any proto=/mountproto= options match the address
1518 * familiies in the addr=/mountaddr= options.
1520 if (protofamily
!= AF_UNSPEC
&&
1521 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1522 goto out_proto_mismatch
;
1524 if (mountfamily
!= AF_UNSPEC
) {
1525 if (mnt
->mount_server
.addrlen
) {
1526 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1527 goto out_mountproto_mismatch
;
1529 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1530 goto out_mountproto_mismatch
;
1536 out_mountproto_mismatch
:
1537 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1541 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1543 out_invalid_address
:
1544 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1547 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1550 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1552 out_security_failure
:
1553 free_secdata(secdata
);
1554 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1559 * Match the requested auth flavors with the list returned by
1560 * the server. Returns zero and sets the mount's authentication
1561 * flavor on success; returns -EACCES if server does not support
1562 * the requested flavor.
1564 static int nfs_walk_authlist(struct nfs_parsed_mount_data
*args
,
1565 struct nfs_mount_request
*request
)
1567 unsigned int i
, j
, server_authlist_len
= *(request
->auth_flav_len
);
1570 * Certain releases of Linux's mountd return an empty
1571 * flavor list. To prevent behavioral regression with
1572 * these servers (ie. rejecting mounts that used to
1573 * succeed), revert to pre-2.6.32 behavior (no checking)
1574 * if the returned flavor list is empty.
1576 if (server_authlist_len
== 0)
1580 * We avoid sophisticated negotiating here, as there are
1581 * plenty of cases where we can get it wrong, providing
1582 * either too little or too much security.
1584 * RFC 2623, section 2.7 suggests we SHOULD prefer the
1585 * flavor listed first. However, some servers list
1586 * AUTH_NULL first. Our caller plants AUTH_SYS, the
1587 * preferred default, in args->auth_flavors[0] if user
1588 * didn't specify sec= mount option.
1590 for (i
= 0; i
< args
->auth_flavor_len
; i
++)
1591 for (j
= 0; j
< server_authlist_len
; j
++)
1592 if (args
->auth_flavors
[i
] == request
->auth_flavs
[j
]) {
1593 dfprintk(MOUNT
, "NFS: using auth flavor %d\n",
1594 request
->auth_flavs
[j
]);
1595 args
->auth_flavors
[0] = request
->auth_flavs
[j
];
1599 dfprintk(MOUNT
, "NFS: server does not support requested auth flavor\n");
1600 nfs_umount(request
);
1605 * Use the remote server's MOUNT service to request the NFS file handle
1606 * corresponding to the provided path.
1608 static int nfs_try_mount(struct nfs_parsed_mount_data
*args
,
1609 struct nfs_fh
*root_fh
)
1611 rpc_authflavor_t server_authlist
[NFS_MAX_SECFLAVORS
];
1612 unsigned int server_authlist_len
= ARRAY_SIZE(server_authlist
);
1613 struct nfs_mount_request request
= {
1614 .sap
= (struct sockaddr
*)
1615 &args
->mount_server
.address
,
1616 .dirpath
= args
->nfs_server
.export_path
,
1617 .protocol
= args
->mount_server
.protocol
,
1619 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1620 .auth_flav_len
= &server_authlist_len
,
1621 .auth_flavs
= server_authlist
,
1625 if (args
->mount_server
.version
== 0) {
1626 switch (args
->version
) {
1628 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1631 args
->mount_server
.version
= NFS_MNT_VERSION
;
1634 request
.version
= args
->mount_server
.version
;
1636 if (args
->mount_server
.hostname
)
1637 request
.hostname
= args
->mount_server
.hostname
;
1639 request
.hostname
= args
->nfs_server
.hostname
;
1642 * Construct the mount server's address.
1644 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1645 memcpy(request
.sap
, &args
->nfs_server
.address
,
1646 args
->nfs_server
.addrlen
);
1647 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1649 request
.salen
= args
->mount_server
.addrlen
;
1650 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1653 * Now ask the mount server to map our export path
1656 status
= nfs_mount(&request
);
1658 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1659 request
.hostname
, status
);
1664 * MNTv1 (NFSv2) does not support auth flavor negotiation.
1666 if (args
->mount_server
.version
!= NFS_MNT3_VERSION
)
1668 return nfs_walk_authlist(args
, &request
);
1671 static int nfs_parse_simple_hostname(const char *dev_name
,
1672 char **hostname
, size_t maxnamlen
,
1673 char **export_path
, size_t maxpathlen
)
1676 char *colon
, *comma
;
1678 colon
= strchr(dev_name
, ':');
1680 goto out_bad_devname
;
1682 len
= colon
- dev_name
;
1683 if (len
> maxnamlen
)
1686 /* N.B. caller will free nfs_server.hostname in all cases */
1687 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1691 /* kill possible hostname list: not supported */
1692 comma
= strchr(*hostname
, ',');
1693 if (comma
!= NULL
) {
1694 if (comma
== *hostname
)
1695 goto out_bad_devname
;
1700 len
= strlen(colon
);
1701 if (len
> maxpathlen
)
1703 *export_path
= kstrndup(colon
, len
, GFP_KERNEL
);
1707 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1711 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1715 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1719 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1720 return -ENAMETOOLONG
;
1723 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1724 return -ENAMETOOLONG
;
1728 * Hostname has square brackets around it because it contains one or
1729 * more colons. We look for the first closing square bracket, and a
1730 * colon must follow it.
1732 static int nfs_parse_protected_hostname(const char *dev_name
,
1733 char **hostname
, size_t maxnamlen
,
1734 char **export_path
, size_t maxpathlen
)
1739 start
= (char *)(dev_name
+ 1);
1741 end
= strchr(start
, ']');
1743 goto out_bad_devname
;
1744 if (*(end
+ 1) != ':')
1745 goto out_bad_devname
;
1748 if (len
> maxnamlen
)
1751 /* N.B. caller will free nfs_server.hostname in all cases */
1752 *hostname
= kstrndup(start
, len
, GFP_KERNEL
);
1753 if (*hostname
== NULL
)
1758 if (len
> maxpathlen
)
1760 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1767 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1771 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1775 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1776 return -ENAMETOOLONG
;
1779 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1780 return -ENAMETOOLONG
;
1784 * Split "dev_name" into "hostname:export_path".
1786 * The leftmost colon demarks the split between the server's hostname
1787 * and the export path. If the hostname starts with a left square
1788 * bracket, then it may contain colons.
1790 * Note: caller frees hostname and export path, even on error.
1792 static int nfs_parse_devname(const char *dev_name
,
1793 char **hostname
, size_t maxnamlen
,
1794 char **export_path
, size_t maxpathlen
)
1796 if (*dev_name
== '[')
1797 return nfs_parse_protected_hostname(dev_name
,
1798 hostname
, maxnamlen
,
1799 export_path
, maxpathlen
);
1801 return nfs_parse_simple_hostname(dev_name
,
1802 hostname
, maxnamlen
,
1803 export_path
, maxpathlen
);
1807 * Validate the NFS2/NFS3 mount data
1808 * - fills in the mount root filehandle
1810 * For option strings, user space handles the following behaviors:
1812 * + DNS: mapping server host name to IP address ("addr=" option)
1814 * + failure mode: how to behave if a mount request can't be handled
1815 * immediately ("fg/bg" option)
1817 * + retry: how often to retry a mount request ("retry=" option)
1819 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1820 * mountproto=tcp after mountproto=udp, and so on
1822 static int nfs_validate_mount_data(void *options
,
1823 struct nfs_parsed_mount_data
*args
,
1824 struct nfs_fh
*mntfh
,
1825 const char *dev_name
)
1827 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
1828 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
1833 switch (data
->version
) {
1839 if (data
->flags
& NFS_MOUNT_VER3
)
1841 data
->root
.size
= NFS2_FHSIZE
;
1842 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
1844 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1847 memset(data
->context
, 0, sizeof(data
->context
));
1849 if (data
->flags
& NFS_MOUNT_VER3
) {
1850 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
1851 goto out_invalid_fh
;
1852 mntfh
->size
= data
->root
.size
;
1855 mntfh
->size
= NFS2_FHSIZE
;
1860 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
1861 if (mntfh
->size
< sizeof(mntfh
->data
))
1862 memset(mntfh
->data
+ mntfh
->size
, 0,
1863 sizeof(mntfh
->data
) - mntfh
->size
);
1866 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1869 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
1870 args
->flags
|= NFS_MOUNT_LEGACY_INTERFACE
;
1871 args
->rsize
= data
->rsize
;
1872 args
->wsize
= data
->wsize
;
1873 args
->timeo
= data
->timeo
;
1874 args
->retrans
= data
->retrans
;
1875 args
->acregmin
= data
->acregmin
;
1876 args
->acregmax
= data
->acregmax
;
1877 args
->acdirmin
= data
->acdirmin
;
1878 args
->acdirmax
= data
->acdirmax
;
1880 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
1881 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
1882 if (!nfs_verify_server_address(sap
))
1883 goto out_no_address
;
1885 if (!(data
->flags
& NFS_MOUNT_TCP
))
1886 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1887 /* N.B. caller will free nfs_server.hostname in all cases */
1888 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
1889 args
->namlen
= data
->namlen
;
1890 args
->bsize
= data
->bsize
;
1892 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
1893 args
->auth_flavors
[0] = data
->pseudoflavor
;
1894 if (!args
->nfs_server
.hostname
)
1897 if (!(data
->flags
& NFS_MOUNT_NONLM
))
1898 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1899 NFS_MOUNT_LOCAL_FCNTL
);
1901 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1902 NFS_MOUNT_LOCAL_FCNTL
);
1904 * The legacy version 6 binary mount data from userspace has a
1905 * field used only to transport selinux information into the
1906 * the kernel. To continue to support that functionality we
1907 * have a touch of selinux knowledge here in the NFS code. The
1908 * userspace code converted context=blah to just blah so we are
1909 * converting back to the full string selinux understands.
1911 if (data
->context
[0]){
1912 #ifdef CONFIG_SECURITY_SELINUX
1914 char *opts_str
= kmalloc(sizeof(data
->context
) + 8, GFP_KERNEL
);
1917 strcpy(opts_str
, "context=");
1918 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
1919 strcat(opts_str
, &data
->context
[0]);
1920 rc
= security_sb_parse_opts_str(opts_str
, &args
->lsm_opts
);
1933 if (nfs_parse_mount_options((char *)options
, args
) == 0)
1936 if (!nfs_verify_server_address(sap
))
1937 goto out_no_address
;
1939 if (args
->version
== 4)
1940 #ifdef CONFIG_NFS_V4
1941 return nfs4_validate_text_mount_data(options
,
1944 goto out_v4_not_compiled
;
1947 nfs_set_port(sap
, &args
->nfs_server
.port
, 0);
1949 nfs_set_mount_transport_protocol(args
);
1951 status
= nfs_parse_devname(dev_name
,
1952 &args
->nfs_server
.hostname
,
1954 &args
->nfs_server
.export_path
,
1957 status
= nfs_try_mount(args
, mntfh
);
1959 kfree(args
->nfs_server
.export_path
);
1960 args
->nfs_server
.export_path
= NULL
;
1969 #ifndef CONFIG_NFS_V3
1970 if (args
->version
== 3)
1971 goto out_v3_not_compiled
;
1972 #endif /* !CONFIG_NFS_V3 */
1977 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
1981 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
1986 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1989 #ifndef CONFIG_NFS_V3
1990 out_v3_not_compiled
:
1991 dfprintk(MOUNT
, "NFS: NFSv3 is not compiled into kernel\n");
1992 return -EPROTONOSUPPORT
;
1993 #endif /* !CONFIG_NFS_V3 */
1995 #ifndef CONFIG_NFS_V4
1996 out_v4_not_compiled
:
1997 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
1998 return -EPROTONOSUPPORT
;
1999 #endif /* !CONFIG_NFS_V4 */
2002 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
2006 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2010 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
2015 nfs_compare_remount_data(struct nfs_server
*nfss
,
2016 struct nfs_parsed_mount_data
*data
)
2018 if (data
->flags
!= nfss
->flags
||
2019 data
->rsize
!= nfss
->rsize
||
2020 data
->wsize
!= nfss
->wsize
||
2021 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
2022 data
->auth_flavors
[0] != nfss
->client
->cl_auth
->au_flavor
||
2023 data
->acregmin
!= nfss
->acregmin
/ HZ
||
2024 data
->acregmax
!= nfss
->acregmax
/ HZ
||
2025 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
2026 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
2027 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
2028 data
->nfs_server
.port
!= nfss
->port
||
2029 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
2030 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
2031 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
2038 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
2041 struct nfs_server
*nfss
= sb
->s_fs_info
;
2042 struct nfs_parsed_mount_data
*data
;
2043 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
2044 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
2045 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
2048 * Userspace mount programs that send binary options generally send
2049 * them populated with default values. We have no way to know which
2050 * ones were explicitly specified. Fall back to legacy behavior and
2051 * just return success.
2053 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
2054 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
2055 options
->version
<= 6))))
2058 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
2062 /* fill out struct with values from existing mount */
2063 data
->flags
= nfss
->flags
;
2064 data
->rsize
= nfss
->rsize
;
2065 data
->wsize
= nfss
->wsize
;
2066 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2067 data
->auth_flavors
[0] = nfss
->client
->cl_auth
->au_flavor
;
2068 data
->acregmin
= nfss
->acregmin
/ HZ
;
2069 data
->acregmax
= nfss
->acregmax
/ HZ
;
2070 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2071 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2072 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2073 data
->nfs_server
.port
= nfss
->port
;
2074 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2075 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2076 data
->nfs_server
.addrlen
);
2078 /* overwrite those values with any that were specified */
2079 error
= nfs_parse_mount_options((char *)options
, data
);
2083 /* compare new mount options with old ones */
2084 error
= nfs_compare_remount_data(nfss
, data
);
2091 * Initialise the common bits of the superblock
2093 static inline void nfs_initialise_sb(struct super_block
*sb
)
2095 struct nfs_server
*server
= NFS_SB(sb
);
2097 sb
->s_magic
= NFS_SUPER_MAGIC
;
2099 /* We probably want something more informative here */
2100 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2101 "%x:%x", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2103 if (sb
->s_blocksize
== 0)
2104 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2105 &sb
->s_blocksize_bits
);
2107 if (server
->flags
& NFS_MOUNT_NOAC
)
2108 sb
->s_flags
|= MS_SYNCHRONOUS
;
2110 sb
->s_bdi
= &server
->backing_dev_info
;
2112 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2116 * Finish setting up an NFS2/3 superblock
2118 static void nfs_fill_super(struct super_block
*sb
,
2119 struct nfs_parsed_mount_data
*data
)
2121 struct nfs_server
*server
= NFS_SB(sb
);
2123 sb
->s_blocksize_bits
= 0;
2124 sb
->s_blocksize
= 0;
2126 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2128 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2129 /* The VFS shouldn't apply the umask to mode bits. We will do
2130 * so ourselves when necessary.
2132 sb
->s_flags
|= MS_POSIXACL
;
2133 sb
->s_time_gran
= 1;
2136 sb
->s_op
= &nfs_sops
;
2137 nfs_initialise_sb(sb
);
2141 * Finish setting up a cloned NFS2/3 superblock
2143 static void nfs_clone_super(struct super_block
*sb
,
2144 const struct super_block
*old_sb
)
2146 struct nfs_server
*server
= NFS_SB(sb
);
2148 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2149 sb
->s_blocksize
= old_sb
->s_blocksize
;
2150 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2152 if (server
->nfs_client
->rpc_ops
->version
== 3) {
2153 /* The VFS shouldn't apply the umask to mode bits. We will do
2154 * so ourselves when necessary.
2156 sb
->s_flags
|= MS_POSIXACL
;
2157 sb
->s_time_gran
= 1;
2160 sb
->s_op
= old_sb
->s_op
;
2161 nfs_initialise_sb(sb
);
2164 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2166 const struct nfs_server
*a
= s
->s_fs_info
;
2167 const struct rpc_clnt
*clnt_a
= a
->client
;
2168 const struct rpc_clnt
*clnt_b
= b
->client
;
2170 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2172 if (a
->nfs_client
!= b
->nfs_client
)
2174 if (a
->flags
!= b
->flags
)
2176 if (a
->wsize
!= b
->wsize
)
2178 if (a
->rsize
!= b
->rsize
)
2180 if (a
->acregmin
!= b
->acregmin
)
2182 if (a
->acregmax
!= b
->acregmax
)
2184 if (a
->acdirmin
!= b
->acdirmin
)
2186 if (a
->acdirmax
!= b
->acdirmax
)
2188 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2195 struct nfs_sb_mountdata
{
2196 struct nfs_server
*server
;
2200 static int nfs_set_super(struct super_block
*s
, void *data
)
2202 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2203 struct nfs_server
*server
= sb_mntdata
->server
;
2206 s
->s_flags
= sb_mntdata
->mntflags
;
2207 s
->s_fs_info
= server
;
2208 ret
= set_anon_super(s
, server
);
2210 server
->s_dev
= s
->s_dev
;
2214 static int nfs_compare_super_address(struct nfs_server
*server1
,
2215 struct nfs_server
*server2
)
2217 struct sockaddr
*sap1
, *sap2
;
2219 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2220 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2222 if (sap1
->sa_family
!= sap2
->sa_family
)
2225 switch (sap1
->sa_family
) {
2227 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2228 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2229 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2231 if (sin1
->sin_port
!= sin2
->sin_port
)
2236 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2237 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2238 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2240 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2251 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2253 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2254 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2255 int mntflags
= sb_mntdata
->mntflags
;
2257 if (!nfs_compare_super_address(old
, server
))
2259 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2260 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2262 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2264 return nfs_compare_mount_options(sb
, server
, mntflags
);
2267 static int nfs_bdi_register(struct nfs_server
*server
)
2269 return bdi_register_dev(&server
->backing_dev_info
, server
->s_dev
);
2272 static int nfs_get_sb(struct file_system_type
*fs_type
,
2273 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2275 struct nfs_server
*server
= NULL
;
2276 struct super_block
*s
;
2277 struct nfs_parsed_mount_data
*data
;
2278 struct nfs_fh
*mntfh
;
2279 struct dentry
*mntroot
;
2280 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2281 struct nfs_sb_mountdata sb_mntdata
= {
2284 int error
= -ENOMEM
;
2286 data
= nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION
);
2287 mntfh
= nfs_alloc_fhandle();
2288 if (data
== NULL
|| mntfh
== NULL
)
2291 security_init_mnt_opts(&data
->lsm_opts
);
2293 /* Validate the mount data */
2294 error
= nfs_validate_mount_data(raw_data
, data
, mntfh
, dev_name
);
2298 #ifdef CONFIG_NFS_V4
2299 if (data
->version
== 4) {
2300 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2301 kfree(data
->client_address
);
2302 kfree(data
->nfs_server
.export_path
);
2305 #endif /* CONFIG_NFS_V4 */
2307 /* Get a volume representation */
2308 server
= nfs_create_server(data
, mntfh
);
2309 if (IS_ERR(server
)) {
2310 error
= PTR_ERR(server
);
2313 sb_mntdata
.server
= server
;
2315 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2316 compare_super
= NULL
;
2318 /* Get a superblock - note that we may end up sharing one that already exists */
2319 s
= sget(fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2325 if (s
->s_fs_info
!= server
) {
2326 nfs_free_server(server
);
2329 error
= nfs_bdi_register(server
);
2331 goto error_splat_bdi
;
2335 /* initial superblock/root creation */
2336 nfs_fill_super(s
, data
);
2337 nfs_fscache_get_super_cookie(
2338 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2341 mntroot
= nfs_get_root(s
, mntfh
);
2342 if (IS_ERR(mntroot
)) {
2343 error
= PTR_ERR(mntroot
);
2344 goto error_splat_super
;
2347 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2349 goto error_splat_root
;
2351 s
->s_flags
|= MS_ACTIVE
;
2353 mnt
->mnt_root
= mntroot
;
2357 kfree(data
->nfs_server
.hostname
);
2358 kfree(data
->mount_server
.hostname
);
2359 kfree(data
->fscache_uniq
);
2360 security_free_mnt_opts(&data
->lsm_opts
);
2362 nfs_free_fhandle(mntfh
);
2367 nfs_free_server(server
);
2373 if (server
&& !s
->s_root
)
2374 bdi_unregister(&server
->backing_dev_info
);
2376 deactivate_locked_super(s
);
2381 * Ensure that we unregister the bdi before kill_anon_super
2382 * releases the device name
2384 static void nfs_put_super(struct super_block
*s
)
2386 struct nfs_server
*server
= NFS_SB(s
);
2388 bdi_unregister(&server
->backing_dev_info
);
2392 * Destroy an NFS2/3 superblock
2394 static void nfs_kill_super(struct super_block
*s
)
2396 struct nfs_server
*server
= NFS_SB(s
);
2399 nfs_fscache_release_super_cookie(s
);
2400 nfs_free_server(server
);
2404 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2406 static struct dentry
*
2407 nfs_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2408 const char *dev_name
, void *raw_data
)
2410 struct nfs_clone_mount
*data
= raw_data
;
2411 struct super_block
*s
;
2412 struct nfs_server
*server
;
2413 struct dentry
*mntroot
;
2414 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2415 struct nfs_sb_mountdata sb_mntdata
= {
2420 dprintk("--> nfs_xdev_mount()\n");
2422 /* create a new volume representation */
2423 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2424 if (IS_ERR(server
)) {
2425 error
= PTR_ERR(server
);
2426 goto out_err_noserver
;
2428 sb_mntdata
.server
= server
;
2430 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2431 compare_super
= NULL
;
2433 /* Get a superblock - note that we may end up sharing one that already exists */
2434 s
= sget(&nfs_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2440 if (s
->s_fs_info
!= server
) {
2441 nfs_free_server(server
);
2444 error
= nfs_bdi_register(server
);
2446 goto error_splat_bdi
;
2450 /* initial superblock/root creation */
2451 nfs_clone_super(s
, data
->sb
);
2452 nfs_fscache_get_super_cookie(s
, NULL
, data
);
2455 mntroot
= nfs_get_root(s
, data
->fh
);
2456 if (IS_ERR(mntroot
)) {
2457 error
= PTR_ERR(mntroot
);
2458 goto error_splat_super
;
2460 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
2463 goto error_splat_super
;
2466 s
->s_flags
|= MS_ACTIVE
;
2468 /* clone any lsm security options from the parent to the new sb */
2469 security_sb_clone_mnt_opts(data
->sb
, s
);
2471 dprintk("<-- nfs_xdev_mount() = 0\n");
2475 nfs_free_server(server
);
2477 dprintk("<-- nfs_xdev_mount() = %d [error]\n", error
);
2478 return ERR_PTR(error
);
2481 if (server
&& !s
->s_root
)
2482 bdi_unregister(&server
->backing_dev_info
);
2484 deactivate_locked_super(s
);
2485 dprintk("<-- nfs_xdev_mount() = %d [splat]\n", error
);
2486 return ERR_PTR(error
);
2489 #ifdef CONFIG_NFS_V4
2492 * Finish setting up a cloned NFS4 superblock
2494 static void nfs4_clone_super(struct super_block
*sb
,
2495 const struct super_block
*old_sb
)
2497 sb
->s_blocksize_bits
= old_sb
->s_blocksize_bits
;
2498 sb
->s_blocksize
= old_sb
->s_blocksize
;
2499 sb
->s_maxbytes
= old_sb
->s_maxbytes
;
2500 sb
->s_time_gran
= 1;
2501 sb
->s_op
= old_sb
->s_op
;
2502 nfs_initialise_sb(sb
);
2506 * Set up an NFS4 superblock
2508 static void nfs4_fill_super(struct super_block
*sb
)
2510 sb
->s_time_gran
= 1;
2511 sb
->s_op
= &nfs4_sops
;
2512 nfs_initialise_sb(sb
);
2515 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2517 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2518 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2521 static int nfs4_validate_text_mount_data(void *options
,
2522 struct nfs_parsed_mount_data
*args
,
2523 const char *dev_name
)
2525 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2527 nfs_set_port(sap
, &args
->nfs_server
.port
, NFS_PORT
);
2529 nfs_validate_transport_protocol(args
);
2531 nfs4_validate_mount_flags(args
);
2533 if (args
->version
!= 4) {
2535 "NFS4: Illegal mount version\n");
2539 if (args
->auth_flavor_len
> 1) {
2541 "NFS4: Too many RPC auth flavours specified\n");
2545 if (args
->client_address
== NULL
) {
2547 "NFS4: mount program didn't pass callback address\n");
2551 return nfs_parse_devname(dev_name
,
2552 &args
->nfs_server
.hostname
,
2554 &args
->nfs_server
.export_path
,
2559 * Validate NFSv4 mount options
2561 static int nfs4_validate_mount_data(void *options
,
2562 struct nfs_parsed_mount_data
*args
,
2563 const char *dev_name
)
2565 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2566 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2572 switch (data
->version
) {
2574 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2575 goto out_no_address
;
2576 if (data
->host_addrlen
== 0)
2577 goto out_no_address
;
2578 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2579 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2581 if (!nfs_verify_server_address(sap
))
2582 goto out_no_address
;
2584 if (data
->auth_flavourlen
) {
2585 if (data
->auth_flavourlen
> 1)
2586 goto out_inval_auth
;
2587 if (copy_from_user(&args
->auth_flavors
[0],
2588 data
->auth_flavours
,
2589 sizeof(args
->auth_flavors
[0])))
2593 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2596 args
->nfs_server
.hostname
= c
;
2598 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2601 args
->nfs_server
.export_path
= c
;
2602 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2604 c
= strndup_user(data
->client_addr
.data
, 16);
2607 args
->client_address
= c
;
2610 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2614 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2615 args
->rsize
= data
->rsize
;
2616 args
->wsize
= data
->wsize
;
2617 args
->timeo
= data
->timeo
;
2618 args
->retrans
= data
->retrans
;
2619 args
->acregmin
= data
->acregmin
;
2620 args
->acregmax
= data
->acregmax
;
2621 args
->acdirmin
= data
->acdirmin
;
2622 args
->acdirmax
= data
->acdirmax
;
2623 args
->nfs_server
.protocol
= data
->proto
;
2624 nfs_validate_transport_protocol(args
);
2628 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2631 if (!nfs_verify_server_address(sap
))
2634 return nfs4_validate_text_mount_data(options
, args
, dev_name
);
2640 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2644 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2645 data
->auth_flavourlen
);
2649 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2654 * Get the superblock for the NFS4 root partition
2656 static struct dentry
*
2657 nfs4_remote_mount(struct file_system_type
*fs_type
, int flags
,
2658 const char *dev_name
, void *raw_data
)
2660 struct nfs_parsed_mount_data
*data
= raw_data
;
2661 struct super_block
*s
;
2662 struct nfs_server
*server
;
2663 struct nfs_fh
*mntfh
;
2664 struct dentry
*mntroot
;
2665 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2666 struct nfs_sb_mountdata sb_mntdata
= {
2669 int error
= -ENOMEM
;
2671 mntfh
= nfs_alloc_fhandle();
2672 if (data
== NULL
|| mntfh
== NULL
)
2675 security_init_mnt_opts(&data
->lsm_opts
);
2677 /* Get a volume representation */
2678 server
= nfs4_create_server(data
, mntfh
);
2679 if (IS_ERR(server
)) {
2680 error
= PTR_ERR(server
);
2683 sb_mntdata
.server
= server
;
2685 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
2686 compare_super
= NULL
;
2688 /* Get a superblock - note that we may end up sharing one that already exists */
2689 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
2695 if (s
->s_fs_info
!= server
) {
2696 nfs_free_server(server
);
2699 error
= nfs_bdi_register(server
);
2701 goto error_splat_bdi
;
2705 /* initial superblock/root creation */
2707 nfs_fscache_get_super_cookie(
2708 s
, data
? data
->fscache_uniq
: NULL
, NULL
);
2711 mntroot
= nfs4_get_root(s
, mntfh
);
2712 if (IS_ERR(mntroot
)) {
2713 error
= PTR_ERR(mntroot
);
2714 goto error_splat_super
;
2717 error
= security_sb_set_mnt_opts(s
, &data
->lsm_opts
);
2719 goto error_splat_root
;
2721 s
->s_flags
|= MS_ACTIVE
;
2723 security_free_mnt_opts(&data
->lsm_opts
);
2724 nfs_free_fhandle(mntfh
);
2728 security_free_mnt_opts(&data
->lsm_opts
);
2730 nfs_free_fhandle(mntfh
);
2731 return ERR_PTR(error
);
2734 nfs_free_server(server
);
2740 if (server
&& !s
->s_root
)
2741 bdi_unregister(&server
->backing_dev_info
);
2743 deactivate_locked_super(s
);
2747 static struct vfsmount
*nfs_do_root_mount(struct file_system_type
*fs_type
,
2748 int flags
, void *data
, const char *hostname
)
2750 struct vfsmount
*root_mnt
;
2754 len
= strlen(hostname
) + 3;
2755 root_devname
= kmalloc(len
, GFP_KERNEL
);
2756 if (root_devname
== NULL
)
2757 return ERR_PTR(-ENOMEM
);
2758 snprintf(root_devname
, len
, "%s:/", hostname
);
2759 root_mnt
= vfs_kern_mount(fs_type
, flags
, root_devname
, data
);
2760 kfree(root_devname
);
2764 static void nfs_fix_devname(const struct path
*path
, struct vfsmount
*mnt
)
2766 char *page
= (char *) __get_free_page(GFP_KERNEL
);
2767 char *devname
, *tmp
;
2771 devname
= nfs_path(path
->mnt
->mnt_devname
,
2772 path
->mnt
->mnt_root
, path
->dentry
,
2774 if (IS_ERR(devname
))
2776 tmp
= kstrdup(devname
, GFP_KERNEL
);
2779 kfree(mnt
->mnt_devname
);
2780 mnt
->mnt_devname
= tmp
;
2782 free_page((unsigned long)page
);
2785 struct nfs_referral_count
{
2786 struct list_head list
;
2787 const struct task_struct
*task
;
2788 unsigned int referral_count
;
2791 static LIST_HEAD(nfs_referral_count_list
);
2792 static DEFINE_SPINLOCK(nfs_referral_count_list_lock
);
2794 static struct nfs_referral_count
*nfs_find_referral_count(void)
2796 struct nfs_referral_count
*p
;
2798 list_for_each_entry(p
, &nfs_referral_count_list
, list
) {
2799 if (p
->task
== current
)
2805 #define NFS_MAX_NESTED_REFERRALS 2
2807 static int nfs_referral_loop_protect(void)
2809 struct nfs_referral_count
*p
, *new;
2812 new = kmalloc(sizeof(*new), GFP_KERNEL
);
2815 new->task
= current
;
2816 new->referral_count
= 1;
2819 spin_lock(&nfs_referral_count_list_lock
);
2820 p
= nfs_find_referral_count();
2822 if (p
->referral_count
>= NFS_MAX_NESTED_REFERRALS
)
2825 p
->referral_count
++;
2827 list_add(&new->list
, &nfs_referral_count_list
);
2830 spin_unlock(&nfs_referral_count_list_lock
);
2836 static void nfs_referral_loop_unprotect(void)
2838 struct nfs_referral_count
*p
;
2840 spin_lock(&nfs_referral_count_list_lock
);
2841 p
= nfs_find_referral_count();
2842 p
->referral_count
--;
2843 if (p
->referral_count
== 0)
2847 spin_unlock(&nfs_referral_count_list_lock
);
2851 static int nfs_follow_remote_path(struct vfsmount
*root_mnt
,
2852 const char *export_path
, struct vfsmount
*mnt_target
)
2854 struct nameidata
*nd
= NULL
;
2855 struct mnt_namespace
*ns_private
;
2856 struct super_block
*s
;
2859 nd
= kmalloc(sizeof(*nd
), GFP_KERNEL
);
2863 ns_private
= create_mnt_ns(root_mnt
);
2864 ret
= PTR_ERR(ns_private
);
2865 if (IS_ERR(ns_private
))
2868 ret
= nfs_referral_loop_protect();
2870 goto out_put_mnt_ns
;
2872 ret
= vfs_path_lookup(root_mnt
->mnt_root
, root_mnt
,
2873 export_path
, LOOKUP_FOLLOW
, nd
);
2875 nfs_referral_loop_unprotect();
2876 put_mnt_ns(ns_private
);
2881 s
= nd
->path
.mnt
->mnt_sb
;
2882 atomic_inc(&s
->s_active
);
2883 mnt_target
->mnt_sb
= s
;
2884 mnt_target
->mnt_root
= dget(nd
->path
.dentry
);
2886 /* Correct the device pathname */
2887 nfs_fix_devname(&nd
->path
, mnt_target
);
2889 path_put(&nd
->path
);
2891 down_write(&s
->s_umount
);
2894 put_mnt_ns(ns_private
);
2902 static int nfs4_try_mount(int flags
, const char *dev_name
,
2903 struct nfs_parsed_mount_data
*data
,
2904 struct vfsmount
*mnt
)
2907 struct vfsmount
*root_mnt
;
2910 dfprintk(MOUNT
, "--> nfs4_try_mount()\n");
2912 export_path
= data
->nfs_server
.export_path
;
2913 data
->nfs_server
.export_path
= "/";
2914 root_mnt
= nfs_do_root_mount(&nfs4_remote_fs_type
, flags
, data
,
2915 data
->nfs_server
.hostname
);
2916 data
->nfs_server
.export_path
= export_path
;
2918 error
= PTR_ERR(root_mnt
);
2919 if (IS_ERR(root_mnt
))
2922 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
2925 dfprintk(MOUNT
, "<-- nfs4_try_mount() = %d%s\n", error
,
2926 error
!= 0 ? " [error]" : "");
2931 * Get the superblock for an NFS4 mountpoint
2933 static int nfs4_get_sb(struct file_system_type
*fs_type
,
2934 int flags
, const char *dev_name
, void *raw_data
, struct vfsmount
*mnt
)
2936 struct nfs_parsed_mount_data
*data
;
2937 int error
= -ENOMEM
;
2939 data
= nfs_alloc_parsed_mount_data(4);
2943 /* Validate the mount data */
2944 error
= nfs4_validate_mount_data(raw_data
, data
, dev_name
);
2948 error
= nfs4_try_mount(flags
, dev_name
, data
, mnt
);
2951 kfree(data
->client_address
);
2952 kfree(data
->nfs_server
.export_path
);
2953 kfree(data
->nfs_server
.hostname
);
2954 kfree(data
->fscache_uniq
);
2957 dprintk("<-- nfs4_get_sb() = %d%s\n", error
,
2958 error
!= 0 ? " [error]" : "");
2962 static void nfs4_kill_super(struct super_block
*sb
)
2964 struct nfs_server
*server
= NFS_SB(sb
);
2966 dprintk("--> %s\n", __func__
);
2967 nfs_super_return_all_delegations(sb
);
2968 kill_anon_super(sb
);
2969 nfs_fscache_release_super_cookie(sb
);
2970 nfs_free_server(server
);
2971 dprintk("<-- %s\n", __func__
);
2975 * Clone an NFS4 server record on xdev traversal (FSID-change)
2977 static struct dentry
*
2978 nfs4_xdev_mount(struct file_system_type
*fs_type
, int flags
,
2979 const char *dev_name
, void *raw_data
)
2981 struct nfs_clone_mount
*data
= raw_data
;
2982 struct super_block
*s
;
2983 struct nfs_server
*server
;
2984 struct dentry
*mntroot
;
2985 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2986 struct nfs_sb_mountdata sb_mntdata
= {
2991 dprintk("--> nfs4_xdev_mount()\n");
2993 /* create a new volume representation */
2994 server
= nfs_clone_server(NFS_SB(data
->sb
), data
->fh
, data
->fattr
);
2995 if (IS_ERR(server
)) {
2996 error
= PTR_ERR(server
);
2997 goto out_err_noserver
;
2999 sb_mntdata
.server
= server
;
3001 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
3002 compare_super
= NULL
;
3004 /* Get a superblock - note that we may end up sharing one that already exists */
3005 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3011 if (s
->s_fs_info
!= server
) {
3012 nfs_free_server(server
);
3015 error
= nfs_bdi_register(server
);
3017 goto error_splat_bdi
;
3021 /* initial superblock/root creation */
3022 nfs4_clone_super(s
, data
->sb
);
3023 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3026 mntroot
= nfs4_get_root(s
, data
->fh
);
3027 if (IS_ERR(mntroot
)) {
3028 error
= PTR_ERR(mntroot
);
3029 goto error_splat_super
;
3031 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3034 goto error_splat_super
;
3037 s
->s_flags
|= MS_ACTIVE
;
3039 security_sb_clone_mnt_opts(data
->sb
, s
);
3041 dprintk("<-- nfs4_xdev_mount() = 0\n");
3045 nfs_free_server(server
);
3047 dprintk("<-- nfs4_xdev_mount() = %d [error]\n", error
);
3048 return ERR_PTR(error
);
3051 if (server
&& !s
->s_root
)
3052 bdi_unregister(&server
->backing_dev_info
);
3054 deactivate_locked_super(s
);
3055 dprintk("<-- nfs4_xdev_mount() = %d [splat]\n", error
);
3056 return ERR_PTR(error
);
3059 static struct dentry
*
3060 nfs4_remote_referral_mount(struct file_system_type
*fs_type
, int flags
,
3061 const char *dev_name
, void *raw_data
)
3063 struct nfs_clone_mount
*data
= raw_data
;
3064 struct super_block
*s
;
3065 struct nfs_server
*server
;
3066 struct dentry
*mntroot
;
3067 struct nfs_fh
*mntfh
;
3068 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
3069 struct nfs_sb_mountdata sb_mntdata
= {
3072 int error
= -ENOMEM
;
3074 dprintk("--> nfs4_referral_get_sb()\n");
3076 mntfh
= nfs_alloc_fhandle();
3080 /* create a new volume representation */
3081 server
= nfs4_create_referral_server(data
, mntfh
);
3082 if (IS_ERR(server
)) {
3083 error
= PTR_ERR(server
);
3084 goto out_err_noserver
;
3086 sb_mntdata
.server
= server
;
3088 if (server
->flags
& NFS4_MOUNT_UNSHARED
)
3089 compare_super
= NULL
;
3091 /* Get a superblock - note that we may end up sharing one that already exists */
3092 s
= sget(&nfs4_fs_type
, compare_super
, nfs_set_super
, &sb_mntdata
);
3098 if (s
->s_fs_info
!= server
) {
3099 nfs_free_server(server
);
3102 error
= nfs_bdi_register(server
);
3104 goto error_splat_bdi
;
3108 /* initial superblock/root creation */
3110 nfs_fscache_get_super_cookie(s
, NULL
, data
);
3113 mntroot
= nfs4_get_root(s
, mntfh
);
3114 if (IS_ERR(mntroot
)) {
3115 error
= PTR_ERR(mntroot
);
3116 goto error_splat_super
;
3118 if (mntroot
->d_inode
->i_op
!= NFS_SB(s
)->nfs_client
->rpc_ops
->dir_inode_ops
) {
3121 goto error_splat_super
;
3124 s
->s_flags
|= MS_ACTIVE
;
3126 security_sb_clone_mnt_opts(data
->sb
, s
);
3128 nfs_free_fhandle(mntfh
);
3129 dprintk("<-- nfs4_referral_get_sb() = 0\n");
3133 nfs_free_server(server
);
3135 nfs_free_fhandle(mntfh
);
3137 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error
);
3138 return ERR_PTR(error
);
3141 if (server
&& !s
->s_root
)
3142 bdi_unregister(&server
->backing_dev_info
);
3144 deactivate_locked_super(s
);
3145 nfs_free_fhandle(mntfh
);
3146 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error
);
3147 return ERR_PTR(error
);
3151 * Create an NFS4 server record on referral traversal
3153 static int nfs4_referral_get_sb(struct file_system_type
*fs_type
,
3154 int flags
, const char *dev_name
, void *raw_data
,
3155 struct vfsmount
*mnt
)
3157 struct nfs_clone_mount
*data
= raw_data
;
3159 struct vfsmount
*root_mnt
;
3162 dprintk("--> nfs4_referral_get_sb()\n");
3164 export_path
= data
->mnt_path
;
3165 data
->mnt_path
= "/";
3167 root_mnt
= nfs_do_root_mount(&nfs4_remote_referral_fs_type
,
3168 flags
, data
, data
->hostname
);
3169 data
->mnt_path
= export_path
;
3171 error
= PTR_ERR(root_mnt
);
3172 if (IS_ERR(root_mnt
))
3175 error
= nfs_follow_remote_path(root_mnt
, export_path
, mnt
);
3177 dprintk("<-- nfs4_referral_get_sb() = %d%s\n", error
,
3178 error
!= 0 ? " [error]" : "");
3182 #endif /* CONFIG_NFS_V4 */