1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1992 Rick Sladkey
7 * nfs superblock handling functions
9 * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
10 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
12 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
13 * J.S.Peatfield@damtp.cam.ac.uk
15 * Split from inode.c by David Howells <dhowells@redhat.com>
17 * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a
18 * particular server are held in the same superblock
19 * - NFS superblocks can have several effective roots to the dentry tree
20 * - directory type roots are spliced into the tree when a path from one root reaches the root
21 * of another (see nfs_lookup())
24 #include <linux/module.h>
25 #include <linux/init.h>
27 #include <linux/time.h>
28 #include <linux/kernel.h>
30 #include <linux/string.h>
31 #include <linux/stat.h>
32 #include <linux/errno.h>
33 #include <linux/unistd.h>
34 #include <linux/sunrpc/clnt.h>
35 #include <linux/sunrpc/addr.h>
36 #include <linux/sunrpc/stats.h>
37 #include <linux/sunrpc/metrics.h>
38 #include <linux/sunrpc/xprtsock.h>
39 #include <linux/sunrpc/xprtrdma.h>
40 #include <linux/nfs_fs.h>
41 #include <linux/nfs_mount.h>
42 #include <linux/nfs4_mount.h>
43 #include <linux/lockd/bind.h>
44 #include <linux/seq_file.h>
45 #include <linux/mount.h>
46 #include <linux/namei.h>
47 #include <linux/vfs.h>
48 #include <linux/inet.h>
49 #include <linux/in6.h>
50 #include <linux/slab.h>
52 #include <linux/netdevice.h>
53 #include <linux/nfs_xdr.h>
54 #include <linux/magic.h>
55 #include <linux/parser.h>
56 #include <linux/nsproxy.h>
57 #include <linux/rcupdate.h>
59 #include <linux/uaccess.h>
63 #include "delegation.h"
67 #include "nfs4session.h"
71 #define NFSDBG_FACILITY NFSDBG_VFS
72 #define NFS_TEXT_DATA 1
74 #if IS_ENABLED(CONFIG_NFS_V3)
75 #define NFS_DEFAULT_VERSION 3
77 #define NFS_DEFAULT_VERSION 2
80 #define NFS_MAX_CONNECTIONS 16
83 /* Mount options that take no arguments */
84 Opt_soft
, Opt_softerr
, Opt_hard
,
85 Opt_posix
, Opt_noposix
,
89 Opt_udp
, Opt_tcp
, Opt_rdma
,
91 Opt_rdirplus
, Opt_nordirplus
,
92 Opt_sharecache
, Opt_nosharecache
,
93 Opt_resvport
, Opt_noresvport
,
94 Opt_fscache
, Opt_nofscache
,
95 Opt_migration
, Opt_nomigration
,
97 /* Mount options that take integer arguments */
99 Opt_rsize
, Opt_wsize
, Opt_bsize
,
100 Opt_timeo
, Opt_retrans
,
101 Opt_acregmin
, Opt_acregmax
,
102 Opt_acdirmin
, Opt_acdirmax
,
109 /* Mount options that take string arguments */
111 Opt_sec
, Opt_proto
, Opt_mountproto
, Opt_mounthost
,
112 Opt_addr
, Opt_mountaddr
, Opt_clientaddr
,
118 /* Special mount options */
119 Opt_userspace
, Opt_deprecated
, Opt_sloppy
,
124 static const match_table_t nfs_mount_option_tokens
= {
125 { Opt_userspace
, "bg" },
126 { Opt_userspace
, "fg" },
127 { Opt_userspace
, "retry=%s" },
129 { Opt_sloppy
, "sloppy" },
131 { Opt_soft
, "soft" },
132 { Opt_softerr
, "softerr" },
133 { Opt_hard
, "hard" },
134 { Opt_deprecated
, "intr" },
135 { Opt_deprecated
, "nointr" },
136 { Opt_posix
, "posix" },
137 { Opt_noposix
, "noposix" },
139 { Opt_nocto
, "nocto" },
141 { Opt_noac
, "noac" },
142 { Opt_lock
, "lock" },
143 { Opt_nolock
, "nolock" },
146 { Opt_rdma
, "rdma" },
148 { Opt_noacl
, "noacl" },
149 { Opt_rdirplus
, "rdirplus" },
150 { Opt_nordirplus
, "nordirplus" },
151 { Opt_sharecache
, "sharecache" },
152 { Opt_nosharecache
, "nosharecache" },
153 { Opt_resvport
, "resvport" },
154 { Opt_noresvport
, "noresvport" },
155 { Opt_fscache
, "fsc" },
156 { Opt_nofscache
, "nofsc" },
157 { Opt_migration
, "migration" },
158 { Opt_nomigration
, "nomigration" },
160 { Opt_port
, "port=%s" },
161 { Opt_rsize
, "rsize=%s" },
162 { Opt_wsize
, "wsize=%s" },
163 { Opt_bsize
, "bsize=%s" },
164 { Opt_timeo
, "timeo=%s" },
165 { Opt_retrans
, "retrans=%s" },
166 { Opt_acregmin
, "acregmin=%s" },
167 { Opt_acregmax
, "acregmax=%s" },
168 { Opt_acdirmin
, "acdirmin=%s" },
169 { Opt_acdirmax
, "acdirmax=%s" },
170 { Opt_actimeo
, "actimeo=%s" },
171 { Opt_namelen
, "namlen=%s" },
172 { Opt_mountport
, "mountport=%s" },
173 { Opt_mountvers
, "mountvers=%s" },
174 { Opt_minorversion
, "minorversion=%s" },
176 { Opt_nfsvers
, "nfsvers=%s" },
177 { Opt_nfsvers
, "vers=%s" },
179 { Opt_sec
, "sec=%s" },
180 { Opt_proto
, "proto=%s" },
181 { Opt_mountproto
, "mountproto=%s" },
182 { Opt_addr
, "addr=%s" },
183 { Opt_clientaddr
, "clientaddr=%s" },
184 { Opt_mounthost
, "mounthost=%s" },
185 { Opt_mountaddr
, "mountaddr=%s" },
187 { Opt_nconnect
, "nconnect=%s" },
189 { Opt_lookupcache
, "lookupcache=%s" },
190 { Opt_fscache_uniq
, "fsc=%s" },
191 { Opt_local_lock
, "local_lock=%s" },
193 /* The following needs to be listed after all other options */
194 { Opt_nfsvers
, "v%s" },
200 Opt_xprt_udp
, Opt_xprt_udp6
, Opt_xprt_tcp
, Opt_xprt_tcp6
, Opt_xprt_rdma
,
206 static const match_table_t nfs_xprt_protocol_tokens
= {
207 { Opt_xprt_udp
, "udp" },
208 { Opt_xprt_udp6
, "udp6" },
209 { Opt_xprt_tcp
, "tcp" },
210 { Opt_xprt_tcp6
, "tcp6" },
211 { Opt_xprt_rdma
, "rdma" },
212 { Opt_xprt_rdma6
, "rdma6" },
214 { Opt_xprt_err
, NULL
}
218 Opt_sec_none
, Opt_sec_sys
,
219 Opt_sec_krb5
, Opt_sec_krb5i
, Opt_sec_krb5p
,
220 Opt_sec_lkey
, Opt_sec_lkeyi
, Opt_sec_lkeyp
,
221 Opt_sec_spkm
, Opt_sec_spkmi
, Opt_sec_spkmp
,
226 static const match_table_t nfs_secflavor_tokens
= {
227 { Opt_sec_none
, "none" },
228 { Opt_sec_none
, "null" },
229 { Opt_sec_sys
, "sys" },
231 { Opt_sec_krb5
, "krb5" },
232 { Opt_sec_krb5i
, "krb5i" },
233 { Opt_sec_krb5p
, "krb5p" },
235 { Opt_sec_lkey
, "lkey" },
236 { Opt_sec_lkeyi
, "lkeyi" },
237 { Opt_sec_lkeyp
, "lkeyp" },
239 { Opt_sec_spkm
, "spkm3" },
240 { Opt_sec_spkmi
, "spkm3i" },
241 { Opt_sec_spkmp
, "spkm3p" },
243 { Opt_sec_err
, NULL
}
247 Opt_lookupcache_all
, Opt_lookupcache_positive
,
248 Opt_lookupcache_none
,
253 static match_table_t nfs_lookupcache_tokens
= {
254 { Opt_lookupcache_all
, "all" },
255 { Opt_lookupcache_positive
, "pos" },
256 { Opt_lookupcache_positive
, "positive" },
257 { Opt_lookupcache_none
, "none" },
259 { Opt_lookupcache_err
, NULL
}
263 Opt_local_lock_all
, Opt_local_lock_flock
, Opt_local_lock_posix
,
269 static match_table_t nfs_local_lock_tokens
= {
270 { Opt_local_lock_all
, "all" },
271 { Opt_local_lock_flock
, "flock" },
272 { Opt_local_lock_posix
, "posix" },
273 { Opt_local_lock_none
, "none" },
275 { Opt_local_lock_err
, NULL
}
279 Opt_vers_2
, Opt_vers_3
, Opt_vers_4
, Opt_vers_4_0
,
280 Opt_vers_4_1
, Opt_vers_4_2
,
285 static match_table_t nfs_vers_tokens
= {
289 { Opt_vers_4_0
, "4.0" },
290 { Opt_vers_4_1
, "4.1" },
291 { Opt_vers_4_2
, "4.2" },
293 { Opt_vers_err
, NULL
}
296 static struct dentry
*nfs_prepared_mount(struct file_system_type
*fs_type
,
297 int flags
, const char *dev_name
, void *raw_data
);
299 struct file_system_type nfs_fs_type
= {
300 .owner
= THIS_MODULE
,
302 .mount
= nfs_fs_mount
,
303 .kill_sb
= nfs_kill_super
,
304 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_BINARY_MOUNTDATA
,
306 MODULE_ALIAS_FS("nfs");
307 EXPORT_SYMBOL_GPL(nfs_fs_type
);
309 struct file_system_type nfs_prepared_fs_type
= {
310 .owner
= THIS_MODULE
,
312 .mount
= nfs_prepared_mount
,
313 .kill_sb
= nfs_kill_super
,
314 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_BINARY_MOUNTDATA
,
316 EXPORT_SYMBOL_GPL(nfs_prepared_fs_type
);
318 const struct super_operations nfs_sops
= {
319 .alloc_inode
= nfs_alloc_inode
,
320 .free_inode
= nfs_free_inode
,
321 .write_inode
= nfs_write_inode
,
322 .drop_inode
= nfs_drop_inode
,
323 .statfs
= nfs_statfs
,
324 .evict_inode
= nfs_evict_inode
,
325 .umount_begin
= nfs_umount_begin
,
326 .show_options
= nfs_show_options
,
327 .show_devname
= nfs_show_devname
,
328 .show_path
= nfs_show_path
,
329 .show_stats
= nfs_show_stats
,
330 .remount_fs
= nfs_remount
,
332 EXPORT_SYMBOL_GPL(nfs_sops
);
334 #if IS_ENABLED(CONFIG_NFS_V4)
335 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*);
336 static int nfs4_validate_mount_data(void *options
,
337 struct nfs_parsed_mount_data
*args
, const char *dev_name
);
339 struct file_system_type nfs4_fs_type
= {
340 .owner
= THIS_MODULE
,
342 .mount
= nfs_fs_mount
,
343 .kill_sb
= nfs_kill_super
,
344 .fs_flags
= FS_RENAME_DOES_D_MOVE
|FS_BINARY_MOUNTDATA
,
346 MODULE_ALIAS_FS("nfs4");
347 MODULE_ALIAS("nfs4");
348 EXPORT_SYMBOL_GPL(nfs4_fs_type
);
350 static int __init
register_nfs4_fs(void)
352 return register_filesystem(&nfs4_fs_type
);
355 static void unregister_nfs4_fs(void)
357 unregister_filesystem(&nfs4_fs_type
);
360 static int __init
register_nfs4_fs(void)
365 static void unregister_nfs4_fs(void)
370 static struct shrinker acl_shrinker
= {
371 .count_objects
= nfs_access_cache_count
,
372 .scan_objects
= nfs_access_cache_scan
,
373 .seeks
= DEFAULT_SEEKS
,
377 * Register the NFS filesystems
379 int __init
register_nfs_fs(void)
383 ret
= register_filesystem(&nfs_fs_type
);
387 ret
= register_nfs4_fs();
391 ret
= nfs_register_sysctl();
394 ret
= register_shrinker(&acl_shrinker
);
399 nfs_unregister_sysctl();
401 unregister_nfs4_fs();
403 unregister_filesystem(&nfs_fs_type
);
409 * Unregister the NFS filesystems
411 void __exit
unregister_nfs_fs(void)
413 unregister_shrinker(&acl_shrinker
);
414 nfs_unregister_sysctl();
415 unregister_nfs4_fs();
416 unregister_filesystem(&nfs_fs_type
);
419 bool nfs_sb_active(struct super_block
*sb
)
421 struct nfs_server
*server
= NFS_SB(sb
);
423 if (!atomic_inc_not_zero(&sb
->s_active
))
425 if (atomic_inc_return(&server
->active
) != 1)
426 atomic_dec(&sb
->s_active
);
429 EXPORT_SYMBOL_GPL(nfs_sb_active
);
431 void nfs_sb_deactive(struct super_block
*sb
)
433 struct nfs_server
*server
= NFS_SB(sb
);
435 if (atomic_dec_and_test(&server
->active
))
436 deactivate_super(sb
);
438 EXPORT_SYMBOL_GPL(nfs_sb_deactive
);
441 * Deliver file system statistics to userspace
443 int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
445 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
446 unsigned char blockbits
;
447 unsigned long blockres
;
448 struct nfs_fh
*fh
= NFS_FH(d_inode(dentry
));
449 struct nfs_fsstat res
;
452 res
.fattr
= nfs_alloc_fattr();
453 if (res
.fattr
== NULL
)
456 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
457 if (unlikely(error
== -ESTALE
)) {
458 struct dentry
*pd_dentry
;
460 pd_dentry
= dget_parent(dentry
);
461 nfs_zap_caches(d_inode(pd_dentry
));
464 nfs_free_fattr(res
.fattr
);
468 buf
->f_type
= NFS_SUPER_MAGIC
;
471 * Current versions of glibc do not correctly handle the
472 * case where f_frsize != f_bsize. Eventually we want to
473 * report the value of wtmult in this field.
475 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
478 * On most *nix systems, f_blocks, f_bfree, and f_bavail
479 * are reported in units of f_frsize. Linux hasn't had
480 * an f_frsize field in its statfs struct until recently,
481 * thus historically Linux's sys_statfs reports these
482 * fields in units of f_bsize.
484 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
485 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
486 blockres
= (1 << blockbits
) - 1;
487 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
488 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
489 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
491 buf
->f_files
= res
.tfiles
;
492 buf
->f_ffree
= res
.afiles
;
494 buf
->f_namelen
= server
->namelen
;
499 dprintk("%s: statfs error = %d\n", __func__
, -error
);
502 EXPORT_SYMBOL_GPL(nfs_statfs
);
505 * Map the security flavour number to a name
507 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
509 static const struct {
510 rpc_authflavor_t flavour
;
512 } sec_flavours
[NFS_AUTH_INFO_MAX_FLAVORS
] = {
513 /* update NFS_AUTH_INFO_MAX_FLAVORS when this list changes! */
514 { RPC_AUTH_NULL
, "null" },
515 { RPC_AUTH_UNIX
, "sys" },
516 { RPC_AUTH_GSS_KRB5
, "krb5" },
517 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
518 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
519 { RPC_AUTH_GSS_LKEY
, "lkey" },
520 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
521 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
522 { RPC_AUTH_GSS_SPKM
, "spkm" },
523 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
524 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
525 { UINT_MAX
, "unknown" }
529 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
530 if (sec_flavours
[i
].flavour
== flavour
)
533 return sec_flavours
[i
].str
;
536 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
539 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
542 switch (sap
->sa_family
) {
544 switch (nfss
->mountd_protocol
) {
546 proto
= RPCBIND_NETID_UDP
;
549 proto
= RPCBIND_NETID_TCP
;
554 switch (nfss
->mountd_protocol
) {
556 proto
= RPCBIND_NETID_UDP6
;
559 proto
= RPCBIND_NETID_TCP6
;
564 if (proto
|| showdefaults
)
565 seq_printf(m
, ",mountproto=%s", proto
?: "auto");
568 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
571 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
573 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
576 switch (sap
->sa_family
) {
578 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
579 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
583 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
584 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
589 seq_puts(m
, ",mountaddr=unspecified");
592 if (nfss
->mountd_version
|| showdefaults
)
593 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
594 if ((nfss
->mountd_port
&&
595 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
597 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
599 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
602 #if IS_ENABLED(CONFIG_NFS_V4)
603 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
606 struct nfs_client
*clp
= nfss
->nfs_client
;
608 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
611 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
617 static void nfs_show_nfs_version(struct seq_file
*m
,
618 unsigned int version
,
619 unsigned int minorversion
)
621 seq_printf(m
, ",vers=%u", version
);
623 seq_printf(m
, ".%u", minorversion
);
627 * Describe the mount options in force on this server representation
629 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
632 static const struct proc_nfs_info
{
637 { NFS_MOUNT_SOFT
, ",soft", "" },
638 { NFS_MOUNT_SOFTERR
, ",softerr", "" },
639 { NFS_MOUNT_POSIX
, ",posix", "" },
640 { NFS_MOUNT_NOCTO
, ",nocto", "" },
641 { NFS_MOUNT_NOAC
, ",noac", "" },
642 { NFS_MOUNT_NONLM
, ",nolock", "" },
643 { NFS_MOUNT_NOACL
, ",noacl", "" },
644 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
645 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
646 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
649 const struct proc_nfs_info
*nfs_infop
;
650 struct nfs_client
*clp
= nfss
->nfs_client
;
651 u32 version
= clp
->rpc_ops
->version
;
652 int local_flock
, local_fcntl
;
654 nfs_show_nfs_version(m
, version
, clp
->cl_minorversion
);
655 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
656 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
657 if (nfss
->bsize
!= 0)
658 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
659 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
660 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
661 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
662 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
663 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
664 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
665 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
666 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
667 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
668 if (!(nfss
->flags
& (NFS_MOUNT_SOFT
|NFS_MOUNT_SOFTERR
)))
669 seq_puts(m
, ",hard");
670 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
671 if (nfss
->flags
& nfs_infop
->flag
)
672 seq_puts(m
, nfs_infop
->str
);
674 seq_puts(m
, nfs_infop
->nostr
);
677 seq_printf(m
, ",proto=%s",
678 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
680 if (clp
->cl_nconnect
> 0)
681 seq_printf(m
, ",nconnect=%u", clp
->cl_nconnect
);
683 if (nfss
->port
!= NFS_PORT
)
684 seq_printf(m
, ",port=%u", nfss
->port
);
687 seq_printf(m
, ",port=%u", nfss
->port
);
689 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
690 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
691 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
694 nfs_show_mountd_options(m
, nfss
, showdefaults
);
696 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
698 if (nfss
->options
& NFS_OPTION_FSCACHE
)
701 if (nfss
->options
& NFS_OPTION_MIGRATION
)
702 seq_puts(m
, ",migration");
704 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
705 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
706 seq_puts(m
, ",lookupcache=none");
708 seq_puts(m
, ",lookupcache=pos");
711 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
712 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
714 if (!local_flock
&& !local_fcntl
)
715 seq_puts(m
, ",local_lock=none");
716 else if (local_flock
&& local_fcntl
)
717 seq_puts(m
, ",local_lock=all");
718 else if (local_flock
)
719 seq_puts(m
, ",local_lock=flock");
721 seq_puts(m
, ",local_lock=posix");
725 * Describe the mount options on this VFS mountpoint
727 int nfs_show_options(struct seq_file
*m
, struct dentry
*root
)
729 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
731 nfs_show_mount_options(m
, nfss
, 0);
734 seq_printf(m
, ",addr=%s",
735 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
741 EXPORT_SYMBOL_GPL(nfs_show_options
);
743 #if IS_ENABLED(CONFIG_NFS_V4)
744 static void show_lease(struct seq_file
*m
, struct nfs_server
*server
)
746 struct nfs_client
*clp
= server
->nfs_client
;
747 unsigned long expire
;
749 seq_printf(m
, ",lease_time=%ld", clp
->cl_lease_time
/ HZ
);
750 expire
= clp
->cl_last_renewal
+ clp
->cl_lease_time
;
751 seq_printf(m
, ",lease_expired=%ld",
752 time_after(expire
, jiffies
) ? 0 : (jiffies
- expire
) / HZ
);
754 #ifdef CONFIG_NFS_V4_1
755 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
)
757 if (nfs4_has_session(server
->nfs_client
))
758 seq_puts(m
, ",sessions");
761 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
) {}
765 #ifdef CONFIG_NFS_V4_1
766 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
768 seq_printf(m
, ",pnfs=");
769 if (server
->pnfs_curr_ld
)
770 seq_printf(m
, "%s", server
->pnfs_curr_ld
->name
);
772 seq_printf(m
, "not configured");
775 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
777 if (nfss
->nfs_client
&& nfss
->nfs_client
->cl_implid
) {
778 struct nfs41_impl_id
*impl_id
= nfss
->nfs_client
->cl_implid
;
779 seq_printf(m
, "\n\timpl_id:\tname='%s',domain='%s',"
781 impl_id
->name
, impl_id
->domain
,
782 impl_id
->date
.seconds
, impl_id
->date
.nseconds
);
786 #if IS_ENABLED(CONFIG_NFS_V4)
787 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
791 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
796 int nfs_show_devname(struct seq_file
*m
, struct dentry
*root
)
798 char *page
= (char *) __get_free_page(GFP_KERNEL
);
799 char *devname
, *dummy
;
803 devname
= nfs_path(&dummy
, root
, page
, PAGE_SIZE
, 0);
805 err
= PTR_ERR(devname
);
807 seq_escape(m
, devname
, " \t\n\\");
808 free_page((unsigned long)page
);
811 EXPORT_SYMBOL_GPL(nfs_show_devname
);
813 int nfs_show_path(struct seq_file
*m
, struct dentry
*dentry
)
818 EXPORT_SYMBOL_GPL(nfs_show_path
);
821 * Present statistical information for this VFS mountpoint
823 int nfs_show_stats(struct seq_file
*m
, struct dentry
*root
)
826 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
827 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
828 struct nfs_iostats totals
= { };
830 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
833 * Display all mount option settings
835 seq_puts(m
, "\n\topts:\t");
836 seq_puts(m
, sb_rdonly(root
->d_sb
) ? "ro" : "rw");
837 seq_puts(m
, root
->d_sb
->s_flags
& SB_SYNCHRONOUS
? ",sync" : "");
838 seq_puts(m
, root
->d_sb
->s_flags
& SB_NOATIME
? ",noatime" : "");
839 seq_puts(m
, root
->d_sb
->s_flags
& SB_NODIRATIME
? ",nodiratime" : "");
840 nfs_show_mount_options(m
, nfss
, 1);
842 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
844 show_implementation_id(m
, nfss
);
846 seq_puts(m
, "\n\tcaps:\t");
847 seq_printf(m
, "caps=0x%x", nfss
->caps
);
848 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
849 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
850 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
851 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
853 #if IS_ENABLED(CONFIG_NFS_V4)
854 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
855 seq_puts(m
, "\n\tnfsv4:\t");
856 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
857 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
858 seq_printf(m
, ",bm2=0x%x", nfss
->attr_bitmask
[2]);
859 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
860 show_sessions(m
, nfss
);
867 * Display security flavor in effect for this mount
869 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
871 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
874 * Display superblock I/O counters
876 for_each_possible_cpu(cpu
) {
877 struct nfs_iostats
*stats
;
880 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
882 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
883 totals
.events
[i
] += stats
->events
[i
];
884 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
885 totals
.bytes
[i
] += stats
->bytes
[i
];
886 #ifdef CONFIG_NFS_FSCACHE
887 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
888 totals
.fscache
[i
] += stats
->fscache
[i
];
894 seq_puts(m
, "\n\tevents:\t");
895 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
896 seq_printf(m
, "%lu ", totals
.events
[i
]);
897 seq_puts(m
, "\n\tbytes:\t");
898 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
899 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
900 #ifdef CONFIG_NFS_FSCACHE
901 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
902 seq_puts(m
, "\n\tfsc:\t");
903 for (i
= 0; i
< __NFSIOS_FSCACHEMAX
; i
++)
904 seq_printf(m
, "%Lu ", totals
.fscache
[i
]);
909 rpc_clnt_show_stats(m
, nfss
->client
);
913 EXPORT_SYMBOL_GPL(nfs_show_stats
);
916 * Begin unmount by attempting to remove all automounted mountpoints we added
917 * in response to xdev traversals and referrals
919 void nfs_umount_begin(struct super_block
*sb
)
921 struct nfs_server
*server
;
922 struct rpc_clnt
*rpc
;
925 /* -EIO all pending I/O */
926 rpc
= server
->client_acl
;
928 rpc_killall_tasks(rpc
);
929 rpc
= server
->client
;
931 rpc_killall_tasks(rpc
);
933 EXPORT_SYMBOL_GPL(nfs_umount_begin
);
935 static struct nfs_parsed_mount_data
*nfs_alloc_parsed_mount_data(void)
937 struct nfs_parsed_mount_data
*data
;
939 data
= kzalloc(sizeof(*data
), GFP_KERNEL
);
941 data
->timeo
= NFS_UNSPEC_TIMEO
;
942 data
->retrans
= NFS_UNSPEC_RETRANS
;
943 data
->acregmin
= NFS_DEF_ACREGMIN
;
944 data
->acregmax
= NFS_DEF_ACREGMAX
;
945 data
->acdirmin
= NFS_DEF_ACDIRMIN
;
946 data
->acdirmax
= NFS_DEF_ACDIRMAX
;
947 data
->mount_server
.port
= NFS_UNSPEC_PORT
;
948 data
->nfs_server
.port
= NFS_UNSPEC_PORT
;
949 data
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
950 data
->selected_flavor
= RPC_AUTH_MAXFLAVOR
;
951 data
->minorversion
= 0;
952 data
->need_mount
= true;
953 data
->net
= current
->nsproxy
->net_ns
;
954 data
->lsm_opts
= NULL
;
959 static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data
*data
)
962 kfree(data
->client_address
);
963 kfree(data
->mount_server
.hostname
);
964 kfree(data
->nfs_server
.export_path
);
965 kfree(data
->nfs_server
.hostname
);
966 kfree(data
->fscache_uniq
);
967 security_free_mnt_opts(&data
->lsm_opts
);
973 * Sanity-check a server address provided by the mount command.
975 * Address family must be initialized, and address must not be
976 * the ANY address for that family.
978 static int nfs_verify_server_address(struct sockaddr
*addr
)
980 switch (addr
->sa_family
) {
982 struct sockaddr_in
*sa
= (struct sockaddr_in
*)addr
;
983 return sa
->sin_addr
.s_addr
!= htonl(INADDR_ANY
);
986 struct in6_addr
*sa
= &((struct sockaddr_in6
*)addr
)->sin6_addr
;
987 return !ipv6_addr_any(sa
);
991 dfprintk(MOUNT
, "NFS: Invalid IP address specified\n");
996 * Select between a default port value and a user-specified port value.
997 * If a zero value is set, then autobind will be used.
999 static void nfs_set_port(struct sockaddr
*sap
, int *port
,
1000 const unsigned short default_port
)
1002 if (*port
== NFS_UNSPEC_PORT
)
1003 *port
= default_port
;
1005 rpc_set_port(sap
, *port
);
1009 * Sanity check the NFS transport protocol.
1012 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
1014 switch (mnt
->nfs_server
.protocol
) {
1015 case XPRT_TRANSPORT_UDP
:
1016 case XPRT_TRANSPORT_TCP
:
1017 case XPRT_TRANSPORT_RDMA
:
1020 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1025 * For text based NFSv2/v3 mounts, the mount protocol transport default
1026 * settings should depend upon the specified NFS transport.
1028 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data
*mnt
)
1030 nfs_validate_transport_protocol(mnt
);
1032 if (mnt
->mount_server
.protocol
== XPRT_TRANSPORT_UDP
||
1033 mnt
->mount_server
.protocol
== XPRT_TRANSPORT_TCP
)
1035 switch (mnt
->nfs_server
.protocol
) {
1036 case XPRT_TRANSPORT_UDP
:
1037 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1039 case XPRT_TRANSPORT_TCP
:
1040 case XPRT_TRANSPORT_RDMA
:
1041 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1046 * Add 'flavor' to 'auth_info' if not already present.
1047 * Returns true if 'flavor' ends up in the list, false otherwise
1049 static bool nfs_auth_info_add(struct nfs_auth_info
*auth_info
,
1050 rpc_authflavor_t flavor
)
1053 unsigned int max_flavor_len
= ARRAY_SIZE(auth_info
->flavors
);
1055 /* make sure this flavor isn't already in the list */
1056 for (i
= 0; i
< auth_info
->flavor_len
; i
++) {
1057 if (flavor
== auth_info
->flavors
[i
])
1061 if (auth_info
->flavor_len
+ 1 >= max_flavor_len
) {
1062 dfprintk(MOUNT
, "NFS: too many sec= flavors\n");
1066 auth_info
->flavors
[auth_info
->flavor_len
++] = flavor
;
1071 * Return true if 'match' is in auth_info or auth_info is empty.
1072 * Return false otherwise.
1074 bool nfs_auth_info_match(const struct nfs_auth_info
*auth_info
,
1075 rpc_authflavor_t match
)
1079 if (!auth_info
->flavor_len
)
1082 for (i
= 0; i
< auth_info
->flavor_len
; i
++) {
1083 if (auth_info
->flavors
[i
] == match
)
1088 EXPORT_SYMBOL_GPL(nfs_auth_info_match
);
1091 * Parse the value of the 'sec=' option.
1093 static int nfs_parse_security_flavors(char *value
,
1094 struct nfs_parsed_mount_data
*mnt
)
1096 substring_t args
[MAX_OPT_ARGS
];
1097 rpc_authflavor_t pseudoflavor
;
1100 dfprintk(MOUNT
, "NFS: parsing sec=%s option\n", value
);
1102 while ((p
= strsep(&value
, ":")) != NULL
) {
1103 switch (match_token(p
, nfs_secflavor_tokens
, args
)) {
1105 pseudoflavor
= RPC_AUTH_NULL
;
1108 pseudoflavor
= RPC_AUTH_UNIX
;
1111 pseudoflavor
= RPC_AUTH_GSS_KRB5
;
1114 pseudoflavor
= RPC_AUTH_GSS_KRB5I
;
1117 pseudoflavor
= RPC_AUTH_GSS_KRB5P
;
1120 pseudoflavor
= RPC_AUTH_GSS_LKEY
;
1123 pseudoflavor
= RPC_AUTH_GSS_LKEYI
;
1126 pseudoflavor
= RPC_AUTH_GSS_LKEYP
;
1129 pseudoflavor
= RPC_AUTH_GSS_SPKM
;
1132 pseudoflavor
= RPC_AUTH_GSS_SPKMI
;
1135 pseudoflavor
= RPC_AUTH_GSS_SPKMP
;
1139 "NFS: sec= option '%s' not recognized\n", p
);
1143 if (!nfs_auth_info_add(&mnt
->auth_info
, pseudoflavor
))
1150 static int nfs_parse_version_string(char *string
,
1151 struct nfs_parsed_mount_data
*mnt
,
1154 mnt
->flags
&= ~NFS_MOUNT_VER3
;
1155 switch (match_token(string
, nfs_vers_tokens
, args
)) {
1160 mnt
->flags
|= NFS_MOUNT_VER3
;
1164 /* Backward compatibility option. In future,
1165 * the mount program should always supply
1166 * a NFSv4 minor version number.
1172 mnt
->minorversion
= 0;
1176 mnt
->minorversion
= 1;
1180 mnt
->minorversion
= 2;
1188 static int nfs_get_option_str(substring_t args
[], char **option
)
1191 *option
= match_strdup(args
);
1195 static int nfs_get_option_ul(substring_t args
[], unsigned long *option
)
1200 string
= match_strdup(args
);
1203 rc
= kstrtoul(string
, 10, option
);
1209 static int nfs_get_option_ul_bound(substring_t args
[], unsigned long *option
,
1210 unsigned long l_bound
, unsigned long u_bound
)
1214 ret
= nfs_get_option_ul(args
, option
);
1217 if (*option
< l_bound
|| *option
> u_bound
)
1223 * Error-check and convert a string of mount options from user space into
1224 * a data structure. The whole mount string is processed; bad options are
1225 * skipped as they are encountered. If there were no errors, return 1;
1226 * otherwise return 0 (zero).
1228 static int nfs_parse_mount_options(char *raw
,
1229 struct nfs_parsed_mount_data
*mnt
)
1232 int rc
, sloppy
= 0, invalid_option
= 0;
1233 unsigned short protofamily
= AF_UNSPEC
;
1234 unsigned short mountfamily
= AF_UNSPEC
;
1237 dfprintk(MOUNT
, "NFS: mount options string was NULL.\n");
1240 dfprintk(MOUNT
, "NFS: nfs mount opts='%s'\n", raw
);
1242 rc
= security_sb_eat_lsm_opts(raw
, &mnt
->lsm_opts
);
1244 goto out_security_failure
;
1246 while ((p
= strsep(&raw
, ",")) != NULL
) {
1247 substring_t args
[MAX_OPT_ARGS
];
1248 unsigned long option
;
1254 dfprintk(MOUNT
, "NFS: parsing nfs mount option '%s'\n", p
);
1256 token
= match_token(p
, nfs_mount_option_tokens
, args
);
1260 * boolean options: foo/nofoo
1263 mnt
->flags
|= NFS_MOUNT_SOFT
;
1264 mnt
->flags
&= ~NFS_MOUNT_SOFTERR
;
1267 mnt
->flags
|= NFS_MOUNT_SOFTERR
;
1268 mnt
->flags
&= ~NFS_MOUNT_SOFT
;
1271 mnt
->flags
&= ~(NFS_MOUNT_SOFT
|NFS_MOUNT_SOFTERR
);
1274 mnt
->flags
|= NFS_MOUNT_POSIX
;
1277 mnt
->flags
&= ~NFS_MOUNT_POSIX
;
1280 mnt
->flags
&= ~NFS_MOUNT_NOCTO
;
1283 mnt
->flags
|= NFS_MOUNT_NOCTO
;
1286 mnt
->flags
&= ~NFS_MOUNT_NOAC
;
1289 mnt
->flags
|= NFS_MOUNT_NOAC
;
1292 mnt
->flags
&= ~NFS_MOUNT_NONLM
;
1293 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1294 NFS_MOUNT_LOCAL_FCNTL
);
1297 mnt
->flags
|= NFS_MOUNT_NONLM
;
1298 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1299 NFS_MOUNT_LOCAL_FCNTL
);
1302 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1303 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1306 mnt
->flags
|= NFS_MOUNT_TCP
;
1307 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1310 mnt
->flags
|= NFS_MOUNT_TCP
; /* for side protocols */
1311 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1312 xprt_load_transport(p
);
1315 mnt
->flags
&= ~NFS_MOUNT_NOACL
;
1318 mnt
->flags
|= NFS_MOUNT_NOACL
;
1321 mnt
->flags
&= ~NFS_MOUNT_NORDIRPLUS
;
1323 case Opt_nordirplus
:
1324 mnt
->flags
|= NFS_MOUNT_NORDIRPLUS
;
1326 case Opt_sharecache
:
1327 mnt
->flags
&= ~NFS_MOUNT_UNSHARED
;
1329 case Opt_nosharecache
:
1330 mnt
->flags
|= NFS_MOUNT_UNSHARED
;
1333 mnt
->flags
&= ~NFS_MOUNT_NORESVPORT
;
1335 case Opt_noresvport
:
1336 mnt
->flags
|= NFS_MOUNT_NORESVPORT
;
1339 mnt
->options
|= NFS_OPTION_FSCACHE
;
1340 kfree(mnt
->fscache_uniq
);
1341 mnt
->fscache_uniq
= NULL
;
1344 mnt
->options
&= ~NFS_OPTION_FSCACHE
;
1345 kfree(mnt
->fscache_uniq
);
1346 mnt
->fscache_uniq
= NULL
;
1349 mnt
->options
|= NFS_OPTION_MIGRATION
;
1351 case Opt_nomigration
:
1352 mnt
->options
&= ~NFS_OPTION_MIGRATION
;
1356 * options that take numeric values
1359 if (nfs_get_option_ul(args
, &option
) ||
1361 goto out_invalid_value
;
1362 mnt
->nfs_server
.port
= option
;
1365 if (nfs_get_option_ul(args
, &option
))
1366 goto out_invalid_value
;
1367 mnt
->rsize
= option
;
1370 if (nfs_get_option_ul(args
, &option
))
1371 goto out_invalid_value
;
1372 mnt
->wsize
= option
;
1375 if (nfs_get_option_ul(args
, &option
))
1376 goto out_invalid_value
;
1377 mnt
->bsize
= option
;
1380 if (nfs_get_option_ul_bound(args
, &option
, 1, INT_MAX
))
1381 goto out_invalid_value
;
1382 mnt
->timeo
= option
;
1385 if (nfs_get_option_ul_bound(args
, &option
, 0, INT_MAX
))
1386 goto out_invalid_value
;
1387 mnt
->retrans
= option
;
1390 if (nfs_get_option_ul(args
, &option
))
1391 goto out_invalid_value
;
1392 mnt
->acregmin
= option
;
1395 if (nfs_get_option_ul(args
, &option
))
1396 goto out_invalid_value
;
1397 mnt
->acregmax
= option
;
1400 if (nfs_get_option_ul(args
, &option
))
1401 goto out_invalid_value
;
1402 mnt
->acdirmin
= option
;
1405 if (nfs_get_option_ul(args
, &option
))
1406 goto out_invalid_value
;
1407 mnt
->acdirmax
= option
;
1410 if (nfs_get_option_ul(args
, &option
))
1411 goto out_invalid_value
;
1412 mnt
->acregmin
= mnt
->acregmax
=
1413 mnt
->acdirmin
= mnt
->acdirmax
= option
;
1416 if (nfs_get_option_ul(args
, &option
))
1417 goto out_invalid_value
;
1418 mnt
->namlen
= option
;
1421 if (nfs_get_option_ul(args
, &option
) ||
1423 goto out_invalid_value
;
1424 mnt
->mount_server
.port
= option
;
1427 if (nfs_get_option_ul(args
, &option
) ||
1428 option
< NFS_MNT_VERSION
||
1429 option
> NFS_MNT3_VERSION
)
1430 goto out_invalid_value
;
1431 mnt
->mount_server
.version
= option
;
1433 case Opt_minorversion
:
1434 if (nfs_get_option_ul(args
, &option
))
1435 goto out_invalid_value
;
1436 if (option
> NFS4_MAX_MINOR_VERSION
)
1437 goto out_invalid_value
;
1438 mnt
->minorversion
= option
;
1442 * options that take text values
1445 string
= match_strdup(args
);
1448 rc
= nfs_parse_version_string(string
, mnt
, args
);
1451 goto out_invalid_value
;
1454 string
= match_strdup(args
);
1457 rc
= nfs_parse_security_flavors(string
, mnt
);
1460 dfprintk(MOUNT
, "NFS: unrecognized "
1461 "security flavor\n");
1466 string
= match_strdup(args
);
1469 token
= match_token(string
,
1470 nfs_xprt_protocol_tokens
, args
);
1472 protofamily
= AF_INET
;
1475 protofamily
= AF_INET6
;
1478 mnt
->flags
&= ~NFS_MOUNT_TCP
;
1479 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
1482 protofamily
= AF_INET6
;
1485 mnt
->flags
|= NFS_MOUNT_TCP
;
1486 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_TCP
;
1488 case Opt_xprt_rdma6
:
1489 protofamily
= AF_INET6
;
1492 /* vector side protocols to TCP */
1493 mnt
->flags
|= NFS_MOUNT_TCP
;
1494 mnt
->nfs_server
.protocol
= XPRT_TRANSPORT_RDMA
;
1495 xprt_load_transport(string
);
1498 dfprintk(MOUNT
, "NFS: unrecognized "
1499 "transport protocol\n");
1505 case Opt_mountproto
:
1506 string
= match_strdup(args
);
1509 token
= match_token(string
,
1510 nfs_xprt_protocol_tokens
, args
);
1513 mountfamily
= AF_INET
;
1516 mountfamily
= AF_INET6
;
1519 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_UDP
;
1522 mountfamily
= AF_INET6
;
1525 mnt
->mount_server
.protocol
= XPRT_TRANSPORT_TCP
;
1527 case Opt_xprt_rdma
: /* not used for side protocols */
1529 dfprintk(MOUNT
, "NFS: unrecognized "
1530 "transport protocol\n");
1535 string
= match_strdup(args
);
1538 mnt
->nfs_server
.addrlen
=
1539 rpc_pton(mnt
->net
, string
, strlen(string
),
1541 &mnt
->nfs_server
.address
,
1542 sizeof(mnt
->nfs_server
.address
));
1544 if (mnt
->nfs_server
.addrlen
== 0)
1545 goto out_invalid_address
;
1547 case Opt_clientaddr
:
1548 if (nfs_get_option_str(args
, &mnt
->client_address
))
1552 if (nfs_get_option_str(args
,
1553 &mnt
->mount_server
.hostname
))
1557 string
= match_strdup(args
);
1560 mnt
->mount_server
.addrlen
=
1561 rpc_pton(mnt
->net
, string
, strlen(string
),
1563 &mnt
->mount_server
.address
,
1564 sizeof(mnt
->mount_server
.address
));
1566 if (mnt
->mount_server
.addrlen
== 0)
1567 goto out_invalid_address
;
1570 if (nfs_get_option_ul_bound(args
, &option
, 1, NFS_MAX_CONNECTIONS
))
1571 goto out_invalid_value
;
1572 mnt
->nfs_server
.nconnect
= option
;
1574 case Opt_lookupcache
:
1575 string
= match_strdup(args
);
1578 token
= match_token(string
,
1579 nfs_lookupcache_tokens
, args
);
1582 case Opt_lookupcache_all
:
1583 mnt
->flags
&= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
);
1585 case Opt_lookupcache_positive
:
1586 mnt
->flags
&= ~NFS_MOUNT_LOOKUP_CACHE_NONE
;
1587 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
;
1589 case Opt_lookupcache_none
:
1590 mnt
->flags
|= NFS_MOUNT_LOOKUP_CACHE_NONEG
|NFS_MOUNT_LOOKUP_CACHE_NONE
;
1593 dfprintk(MOUNT
, "NFS: invalid "
1594 "lookupcache argument\n");
1598 case Opt_fscache_uniq
:
1599 if (nfs_get_option_str(args
, &mnt
->fscache_uniq
))
1601 mnt
->options
|= NFS_OPTION_FSCACHE
;
1603 case Opt_local_lock
:
1604 string
= match_strdup(args
);
1607 token
= match_token(string
, nfs_local_lock_tokens
,
1611 case Opt_local_lock_all
:
1612 mnt
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
1613 NFS_MOUNT_LOCAL_FCNTL
);
1615 case Opt_local_lock_flock
:
1616 mnt
->flags
|= NFS_MOUNT_LOCAL_FLOCK
;
1618 case Opt_local_lock_posix
:
1619 mnt
->flags
|= NFS_MOUNT_LOCAL_FCNTL
;
1621 case Opt_local_lock_none
:
1622 mnt
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
1623 NFS_MOUNT_LOCAL_FCNTL
);
1626 dfprintk(MOUNT
, "NFS: invalid "
1627 "local_lock argument\n");
1637 dfprintk(MOUNT
, "NFS: relaxing parsing rules\n");
1640 case Opt_deprecated
:
1641 dfprintk(MOUNT
, "NFS: ignoring mount option "
1647 dfprintk(MOUNT
, "NFS: unrecognized mount option "
1652 if (!sloppy
&& invalid_option
)
1655 if (mnt
->minorversion
&& mnt
->version
!= 4)
1656 goto out_minorversion_mismatch
;
1658 if (mnt
->options
& NFS_OPTION_MIGRATION
&&
1659 (mnt
->version
!= 4 || mnt
->minorversion
!= 0))
1660 goto out_migration_misuse
;
1663 * verify that any proto=/mountproto= options match the address
1664 * families in the addr=/mountaddr= options.
1666 if (protofamily
!= AF_UNSPEC
&&
1667 protofamily
!= mnt
->nfs_server
.address
.ss_family
)
1668 goto out_proto_mismatch
;
1670 if (mountfamily
!= AF_UNSPEC
) {
1671 if (mnt
->mount_server
.addrlen
) {
1672 if (mountfamily
!= mnt
->mount_server
.address
.ss_family
)
1673 goto out_mountproto_mismatch
;
1675 if (mountfamily
!= mnt
->nfs_server
.address
.ss_family
)
1676 goto out_mountproto_mismatch
;
1682 out_mountproto_mismatch
:
1683 printk(KERN_INFO
"NFS: mount server address does not match mountproto= "
1687 printk(KERN_INFO
"NFS: server address does not match proto= option\n");
1689 out_invalid_address
:
1690 printk(KERN_INFO
"NFS: bad IP address specified: %s\n", p
);
1693 printk(KERN_INFO
"NFS: bad mount option value specified: %s\n", p
);
1695 out_minorversion_mismatch
:
1696 printk(KERN_INFO
"NFS: mount option vers=%u does not support "
1697 "minorversion=%u\n", mnt
->version
, mnt
->minorversion
);
1699 out_migration_misuse
:
1701 "NFS: 'migration' not supported for this NFS version\n");
1704 printk(KERN_INFO
"NFS: not enough memory to parse option\n");
1706 out_security_failure
:
1707 printk(KERN_INFO
"NFS: security options invalid: %d\n", rc
);
1712 * Ensure that a specified authtype in args->auth_info is supported by
1713 * the server. Returns 0 and sets args->selected_flavor if it's ok, and
1716 static int nfs_verify_authflavors(struct nfs_parsed_mount_data
*args
,
1717 rpc_authflavor_t
*server_authlist
, unsigned int count
)
1719 rpc_authflavor_t flavor
= RPC_AUTH_MAXFLAVOR
;
1720 bool found_auth_null
= false;
1724 * If the sec= mount option is used, the specified flavor or AUTH_NULL
1725 * must be in the list returned by the server.
1727 * AUTH_NULL has a special meaning when it's in the server list - it
1728 * means that the server will ignore the rpc creds, so any flavor
1729 * can be used but still use the sec= that was specified.
1731 * Note also that the MNT procedure in MNTv1 does not return a list
1732 * of supported security flavors. In this case, nfs_mount() fabricates
1733 * a security flavor list containing just AUTH_NULL.
1735 for (i
= 0; i
< count
; i
++) {
1736 flavor
= server_authlist
[i
];
1738 if (nfs_auth_info_match(&args
->auth_info
, flavor
))
1741 if (flavor
== RPC_AUTH_NULL
)
1742 found_auth_null
= true;
1745 if (found_auth_null
) {
1746 flavor
= args
->auth_info
.flavors
[0];
1751 "NFS: specified auth flavors not supported by server\n");
1755 args
->selected_flavor
= flavor
;
1756 dfprintk(MOUNT
, "NFS: using auth flavor %u\n", args
->selected_flavor
);
1761 * Use the remote server's MOUNT service to request the NFS file handle
1762 * corresponding to the provided path.
1764 static int nfs_request_mount(struct nfs_parsed_mount_data
*args
,
1765 struct nfs_fh
*root_fh
,
1766 rpc_authflavor_t
*server_authlist
,
1767 unsigned int *server_authlist_len
)
1769 struct nfs_mount_request request
= {
1770 .sap
= (struct sockaddr
*)
1771 &args
->mount_server
.address
,
1772 .dirpath
= args
->nfs_server
.export_path
,
1773 .protocol
= args
->mount_server
.protocol
,
1775 .noresvport
= args
->flags
& NFS_MOUNT_NORESVPORT
,
1776 .auth_flav_len
= server_authlist_len
,
1777 .auth_flavs
= server_authlist
,
1782 if (args
->mount_server
.version
== 0) {
1783 switch (args
->version
) {
1785 args
->mount_server
.version
= NFS_MNT3_VERSION
;
1788 args
->mount_server
.version
= NFS_MNT_VERSION
;
1791 request
.version
= args
->mount_server
.version
;
1793 if (args
->mount_server
.hostname
)
1794 request
.hostname
= args
->mount_server
.hostname
;
1796 request
.hostname
= args
->nfs_server
.hostname
;
1799 * Construct the mount server's address.
1801 if (args
->mount_server
.address
.ss_family
== AF_UNSPEC
) {
1802 memcpy(request
.sap
, &args
->nfs_server
.address
,
1803 args
->nfs_server
.addrlen
);
1804 args
->mount_server
.addrlen
= args
->nfs_server
.addrlen
;
1806 request
.salen
= args
->mount_server
.addrlen
;
1807 nfs_set_port(request
.sap
, &args
->mount_server
.port
, 0);
1810 * Now ask the mount server to map our export path
1813 status
= nfs_mount(&request
);
1815 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
1816 request
.hostname
, status
);
1823 static struct nfs_server
*nfs_try_mount_request(struct nfs_mount_info
*mount_info
)
1827 bool tried_auth_unix
= false;
1828 bool auth_null_in_list
= false;
1829 struct nfs_server
*server
= ERR_PTR(-EACCES
);
1830 struct nfs_parsed_mount_data
*args
= mount_info
->parsed
;
1831 rpc_authflavor_t authlist
[NFS_MAX_SECFLAVORS
];
1832 unsigned int authlist_len
= ARRAY_SIZE(authlist
);
1833 struct nfs_subversion
*nfs_mod
= mount_info
->nfs_mod
;
1835 status
= nfs_request_mount(args
, mount_info
->mntfh
, authlist
,
1838 return ERR_PTR(status
);
1841 * Was a sec= authflavor specified in the options? First, verify
1842 * whether the server supports it, and then just try to use it if so.
1844 if (args
->auth_info
.flavor_len
> 0) {
1845 status
= nfs_verify_authflavors(args
, authlist
, authlist_len
);
1846 dfprintk(MOUNT
, "NFS: using auth flavor %u\n",
1847 args
->selected_flavor
);
1849 return ERR_PTR(status
);
1850 return nfs_mod
->rpc_ops
->create_server(mount_info
);
1854 * No sec= option was provided. RFC 2623, section 2.7 suggests we
1855 * SHOULD prefer the flavor listed first. However, some servers list
1856 * AUTH_NULL first. Avoid ever choosing AUTH_NULL.
1858 for (i
= 0; i
< authlist_len
; ++i
) {
1859 rpc_authflavor_t flavor
;
1860 struct rpcsec_gss_info info
;
1862 flavor
= authlist
[i
];
1865 tried_auth_unix
= true;
1868 auth_null_in_list
= true;
1871 if (rpcauth_get_gssinfo(flavor
, &info
) != 0)
1875 dfprintk(MOUNT
, "NFS: attempting to use auth flavor %u\n", flavor
);
1876 args
->selected_flavor
= flavor
;
1877 server
= nfs_mod
->rpc_ops
->create_server(mount_info
);
1878 if (!IS_ERR(server
))
1883 * Nothing we tried so far worked. At this point, give up if we've
1884 * already tried AUTH_UNIX or if the server's list doesn't contain
1887 if (tried_auth_unix
|| !auth_null_in_list
)
1890 /* Last chance! Try AUTH_UNIX */
1891 dfprintk(MOUNT
, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX
);
1892 args
->selected_flavor
= RPC_AUTH_UNIX
;
1893 return nfs_mod
->rpc_ops
->create_server(mount_info
);
1896 static struct dentry
*nfs_fs_mount_common(int, const char *, struct nfs_mount_info
*);
1898 struct dentry
*nfs_try_mount(int flags
, const char *dev_name
,
1899 struct nfs_mount_info
*mount_info
)
1901 struct nfs_subversion
*nfs_mod
= mount_info
->nfs_mod
;
1902 if (mount_info
->parsed
->need_mount
)
1903 mount_info
->server
= nfs_try_mount_request(mount_info
);
1905 mount_info
->server
= nfs_mod
->rpc_ops
->create_server(mount_info
);
1907 return nfs_fs_mount_common(flags
, dev_name
, mount_info
);
1909 EXPORT_SYMBOL_GPL(nfs_try_mount
);
1912 * Split "dev_name" into "hostname:export_path".
1914 * The leftmost colon demarks the split between the server's hostname
1915 * and the export path. If the hostname starts with a left square
1916 * bracket, then it may contain colons.
1918 * Note: caller frees hostname and export path, even on error.
1920 static int nfs_parse_devname(const char *dev_name
,
1921 char **hostname
, size_t maxnamlen
,
1922 char **export_path
, size_t maxpathlen
)
1927 if (unlikely(!dev_name
|| !*dev_name
)) {
1928 dfprintk(MOUNT
, "NFS: device name not specified\n");
1932 /* Is the host name protected with square brakcets? */
1933 if (*dev_name
== '[') {
1934 end
= strchr(++dev_name
, ']');
1935 if (end
== NULL
|| end
[1] != ':')
1936 goto out_bad_devname
;
1938 len
= end
- dev_name
;
1943 end
= strchr(dev_name
, ':');
1945 goto out_bad_devname
;
1946 len
= end
- dev_name
;
1948 /* kill possible hostname list: not supported */
1949 comma
= strchr(dev_name
, ',');
1950 if (comma
!= NULL
&& comma
< end
)
1951 len
= comma
- dev_name
;
1954 if (len
> maxnamlen
)
1957 /* N.B. caller will free nfs_server.hostname in all cases */
1958 *hostname
= kstrndup(dev_name
, len
, GFP_KERNEL
);
1959 if (*hostname
== NULL
)
1961 len
= strlen(++end
);
1962 if (len
> maxpathlen
)
1964 *export_path
= kstrndup(end
, len
, GFP_KERNEL
);
1968 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", *export_path
);
1972 dfprintk(MOUNT
, "NFS: device name not in host:path format\n");
1976 dfprintk(MOUNT
, "NFS: not enough memory to parse device name\n");
1980 dfprintk(MOUNT
, "NFS: server hostname too long\n");
1981 return -ENAMETOOLONG
;
1984 dfprintk(MOUNT
, "NFS: export pathname too long\n");
1985 return -ENAMETOOLONG
;
1989 * Validate the NFS2/NFS3 mount data
1990 * - fills in the mount root filehandle
1992 * For option strings, user space handles the following behaviors:
1994 * + DNS: mapping server host name to IP address ("addr=" option)
1996 * + failure mode: how to behave if a mount request can't be handled
1997 * immediately ("fg/bg" option)
1999 * + retry: how often to retry a mount request ("retry=" option)
2001 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
2002 * mountproto=tcp after mountproto=udp, and so on
2004 static int nfs23_validate_mount_data(void *options
,
2005 struct nfs_parsed_mount_data
*args
,
2006 struct nfs_fh
*mntfh
,
2007 const char *dev_name
)
2009 struct nfs_mount_data
*data
= (struct nfs_mount_data
*)options
;
2010 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2011 int extra_flags
= NFS_MOUNT_LEGACY_INTERFACE
;
2016 args
->version
= NFS_DEFAULT_VERSION
;
2017 switch (data
->version
) {
2019 data
->namlen
= 0; /* fall through */
2021 data
->bsize
= 0; /* fall through */
2023 if (data
->flags
& NFS_MOUNT_VER3
)
2025 data
->root
.size
= NFS2_FHSIZE
;
2026 memcpy(data
->root
.data
, data
->old_root
.data
, NFS2_FHSIZE
);
2027 /* Turn off security negotiation */
2028 extra_flags
|= NFS_MOUNT_SECFLAVOUR
;
2031 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
2035 memset(data
->context
, 0, sizeof(data
->context
));
2038 if (data
->flags
& NFS_MOUNT_VER3
) {
2039 if (data
->root
.size
> NFS3_FHSIZE
|| data
->root
.size
== 0)
2040 goto out_invalid_fh
;
2041 mntfh
->size
= data
->root
.size
;
2044 mntfh
->size
= NFS2_FHSIZE
;
2049 memcpy(mntfh
->data
, data
->root
.data
, mntfh
->size
);
2050 if (mntfh
->size
< sizeof(mntfh
->data
))
2051 memset(mntfh
->data
+ mntfh
->size
, 0,
2052 sizeof(mntfh
->data
) - mntfh
->size
);
2055 * Translate to nfs_parsed_mount_data, which nfs_fill_super
2058 args
->flags
= data
->flags
& NFS_MOUNT_FLAGMASK
;
2059 args
->flags
|= extra_flags
;
2060 args
->rsize
= data
->rsize
;
2061 args
->wsize
= data
->wsize
;
2062 args
->timeo
= data
->timeo
;
2063 args
->retrans
= data
->retrans
;
2064 args
->acregmin
= data
->acregmin
;
2065 args
->acregmax
= data
->acregmax
;
2066 args
->acdirmin
= data
->acdirmin
;
2067 args
->acdirmax
= data
->acdirmax
;
2068 args
->need_mount
= false;
2070 memcpy(sap
, &data
->addr
, sizeof(data
->addr
));
2071 args
->nfs_server
.addrlen
= sizeof(data
->addr
);
2072 args
->nfs_server
.port
= ntohs(data
->addr
.sin_port
);
2073 if (sap
->sa_family
!= AF_INET
||
2074 !nfs_verify_server_address(sap
))
2075 goto out_no_address
;
2077 if (!(data
->flags
& NFS_MOUNT_TCP
))
2078 args
->nfs_server
.protocol
= XPRT_TRANSPORT_UDP
;
2079 /* N.B. caller will free nfs_server.hostname in all cases */
2080 args
->nfs_server
.hostname
= kstrdup(data
->hostname
, GFP_KERNEL
);
2081 args
->namlen
= data
->namlen
;
2082 args
->bsize
= data
->bsize
;
2084 if (data
->flags
& NFS_MOUNT_SECFLAVOUR
)
2085 args
->selected_flavor
= data
->pseudoflavor
;
2087 args
->selected_flavor
= RPC_AUTH_UNIX
;
2088 if (!args
->nfs_server
.hostname
)
2091 if (!(data
->flags
& NFS_MOUNT_NONLM
))
2092 args
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
|
2093 NFS_MOUNT_LOCAL_FCNTL
);
2095 args
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
|
2096 NFS_MOUNT_LOCAL_FCNTL
);
2098 * The legacy version 6 binary mount data from userspace has a
2099 * field used only to transport selinux information into the
2100 * the kernel. To continue to support that functionality we
2101 * have a touch of selinux knowledge here in the NFS code. The
2102 * userspace code converted context=blah to just blah so we are
2103 * converting back to the full string selinux understands.
2105 if (data
->context
[0]){
2106 #ifdef CONFIG_SECURITY_SELINUX
2108 data
->context
[NFS_MAX_CONTEXT_LEN
] = '\0';
2109 rc
= security_add_mnt_opt("context", data
->context
,
2110 strlen(data
->context
), &args
->lsm_opts
);
2120 return NFS_TEXT_DATA
;
2126 dfprintk(MOUNT
, "NFS: mount program didn't pass any mount data\n");
2130 dfprintk(MOUNT
, "NFS: nfs_mount_data version %d does not support v3\n",
2135 dfprintk(MOUNT
, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
2139 dfprintk(MOUNT
, "NFS: not enough memory to handle mount options\n");
2143 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2147 dfprintk(MOUNT
, "NFS: invalid root filehandle\n");
2151 #if IS_ENABLED(CONFIG_NFS_V4)
2152 static int nfs_validate_mount_data(struct file_system_type
*fs_type
,
2154 struct nfs_parsed_mount_data
*args
,
2155 struct nfs_fh
*mntfh
,
2156 const char *dev_name
)
2158 if (fs_type
== &nfs_fs_type
)
2159 return nfs23_validate_mount_data(options
, args
, mntfh
, dev_name
);
2160 return nfs4_validate_mount_data(options
, args
, dev_name
);
2163 static int nfs_validate_mount_data(struct file_system_type
*fs_type
,
2165 struct nfs_parsed_mount_data
*args
,
2166 struct nfs_fh
*mntfh
,
2167 const char *dev_name
)
2169 return nfs23_validate_mount_data(options
, args
, mntfh
, dev_name
);
2173 static int nfs_validate_text_mount_data(void *options
,
2174 struct nfs_parsed_mount_data
*args
,
2175 const char *dev_name
)
2178 int max_namelen
= PAGE_SIZE
;
2179 int max_pathlen
= NFS_MAXPATHLEN
;
2180 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2182 if (nfs_parse_mount_options((char *)options
, args
) == 0)
2185 if (!nfs_verify_server_address(sap
))
2186 goto out_no_address
;
2188 if (args
->version
== 4) {
2189 #if IS_ENABLED(CONFIG_NFS_V4)
2190 if (args
->nfs_server
.protocol
== XPRT_TRANSPORT_RDMA
)
2191 port
= NFS_RDMA_PORT
;
2194 max_namelen
= NFS4_MAXNAMLEN
;
2195 max_pathlen
= NFS4_MAXPATHLEN
;
2196 nfs_validate_transport_protocol(args
);
2197 if (args
->nfs_server
.protocol
== XPRT_TRANSPORT_UDP
)
2198 goto out_invalid_transport_udp
;
2199 nfs4_validate_mount_flags(args
);
2201 goto out_v4_not_compiled
;
2202 #endif /* CONFIG_NFS_V4 */
2204 nfs_set_mount_transport_protocol(args
);
2205 if (args
->nfs_server
.protocol
== XPRT_TRANSPORT_RDMA
)
2206 port
= NFS_RDMA_PORT
;
2209 nfs_set_port(sap
, &args
->nfs_server
.port
, port
);
2211 return nfs_parse_devname(dev_name
,
2212 &args
->nfs_server
.hostname
,
2214 &args
->nfs_server
.export_path
,
2217 #if !IS_ENABLED(CONFIG_NFS_V4)
2218 out_v4_not_compiled
:
2219 dfprintk(MOUNT
, "NFS: NFSv4 is not compiled into kernel\n");
2220 return -EPROTONOSUPPORT
;
2222 out_invalid_transport_udp
:
2223 dfprintk(MOUNT
, "NFSv4: Unsupported transport protocol udp\n");
2225 #endif /* !CONFIG_NFS_V4 */
2228 dfprintk(MOUNT
, "NFS: mount program didn't pass remote address\n");
2232 #define NFS_REMOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \
2233 | NFS_MOUNT_SECURE \
2236 | NFS_MOUNT_KERBEROS \
2238 | NFS_MOUNT_BROKEN_SUID \
2239 | NFS_MOUNT_STRICTLOCK \
2240 | NFS_MOUNT_LEGACY_INTERFACE)
2242 #define NFS_MOUNT_CMP_FLAGMASK (NFS_REMOUNT_CMP_FLAGMASK & \
2243 ~(NFS_MOUNT_UNSHARED | NFS_MOUNT_NORESVPORT))
2246 nfs_compare_remount_data(struct nfs_server
*nfss
,
2247 struct nfs_parsed_mount_data
*data
)
2249 if ((data
->flags
^ nfss
->flags
) & NFS_REMOUNT_CMP_FLAGMASK
||
2250 data
->rsize
!= nfss
->rsize
||
2251 data
->wsize
!= nfss
->wsize
||
2252 data
->version
!= nfss
->nfs_client
->rpc_ops
->version
||
2253 data
->minorversion
!= nfss
->nfs_client
->cl_minorversion
||
2254 data
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
2255 !nfs_auth_info_match(&data
->auth_info
, nfss
->client
->cl_auth
->au_flavor
) ||
2256 data
->acregmin
!= nfss
->acregmin
/ HZ
||
2257 data
->acregmax
!= nfss
->acregmax
/ HZ
||
2258 data
->acdirmin
!= nfss
->acdirmin
/ HZ
||
2259 data
->acdirmax
!= nfss
->acdirmax
/ HZ
||
2260 data
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
2261 (data
->options
& NFS_OPTION_FSCACHE
) != (nfss
->options
& NFS_OPTION_FSCACHE
) ||
2262 data
->nfs_server
.port
!= nfss
->port
||
2263 data
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
2264 !rpc_cmp_addr((struct sockaddr
*)&data
->nfs_server
.address
,
2265 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
2272 nfs_remount(struct super_block
*sb
, int *flags
, char *raw_data
)
2275 struct nfs_server
*nfss
= sb
->s_fs_info
;
2276 struct nfs_parsed_mount_data
*data
;
2277 struct nfs_mount_data
*options
= (struct nfs_mount_data
*)raw_data
;
2278 struct nfs4_mount_data
*options4
= (struct nfs4_mount_data
*)raw_data
;
2279 u32 nfsvers
= nfss
->nfs_client
->rpc_ops
->version
;
2281 sync_filesystem(sb
);
2284 * Userspace mount programs that send binary options generally send
2285 * them populated with default values. We have no way to know which
2286 * ones were explicitly specified. Fall back to legacy behavior and
2287 * just return success.
2289 if ((nfsvers
== 4 && (!options4
|| options4
->version
== 1)) ||
2290 (nfsvers
<= 3 && (!options
|| (options
->version
>= 1 &&
2291 options
->version
<= 6))))
2294 data
= nfs_alloc_parsed_mount_data();
2298 /* fill out struct with values from existing mount */
2299 data
->flags
= nfss
->flags
;
2300 data
->rsize
= nfss
->rsize
;
2301 data
->wsize
= nfss
->wsize
;
2302 data
->retrans
= nfss
->client
->cl_timeout
->to_retries
;
2303 data
->selected_flavor
= nfss
->client
->cl_auth
->au_flavor
;
2304 data
->acregmin
= nfss
->acregmin
/ HZ
;
2305 data
->acregmax
= nfss
->acregmax
/ HZ
;
2306 data
->acdirmin
= nfss
->acdirmin
/ HZ
;
2307 data
->acdirmax
= nfss
->acdirmax
/ HZ
;
2308 data
->timeo
= 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
;
2309 data
->nfs_server
.port
= nfss
->port
;
2310 data
->nfs_server
.addrlen
= nfss
->nfs_client
->cl_addrlen
;
2311 data
->version
= nfsvers
;
2312 data
->minorversion
= nfss
->nfs_client
->cl_minorversion
;
2313 data
->net
= current
->nsproxy
->net_ns
;
2314 memcpy(&data
->nfs_server
.address
, &nfss
->nfs_client
->cl_addr
,
2315 data
->nfs_server
.addrlen
);
2317 /* overwrite those values with any that were specified */
2319 if (!nfs_parse_mount_options((char *)options
, data
))
2323 * noac is a special case. It implies -o sync, but that's not
2324 * necessarily reflected in the mtab options. do_remount_sb
2325 * will clear SB_SYNCHRONOUS if -o sync wasn't specified in the
2326 * remount options, so we have to explicitly reset it.
2328 if (data
->flags
& NFS_MOUNT_NOAC
)
2329 *flags
|= SB_SYNCHRONOUS
;
2331 /* compare new mount options with old ones */
2332 error
= nfs_compare_remount_data(nfss
, data
);
2334 error
= security_sb_remount(sb
, data
->lsm_opts
);
2336 nfs_free_parsed_mount_data(data
);
2339 EXPORT_SYMBOL_GPL(nfs_remount
);
2342 * Finish setting up an NFS superblock
2344 static void nfs_fill_super(struct super_block
*sb
, struct nfs_mount_info
*mount_info
)
2346 struct nfs_parsed_mount_data
*data
= mount_info
->parsed
;
2347 struct nfs_server
*server
= NFS_SB(sb
);
2349 sb
->s_blocksize_bits
= 0;
2350 sb
->s_blocksize
= 0;
2351 sb
->s_xattr
= server
->nfs_client
->cl_nfs_mod
->xattr
;
2352 sb
->s_op
= server
->nfs_client
->cl_nfs_mod
->sops
;
2353 if (data
&& data
->bsize
)
2354 sb
->s_blocksize
= nfs_block_size(data
->bsize
, &sb
->s_blocksize_bits
);
2356 if (server
->nfs_client
->rpc_ops
->version
!= 2) {
2357 /* The VFS shouldn't apply the umask to mode bits. We will do
2358 * so ourselves when necessary.
2360 sb
->s_flags
|= SB_POSIXACL
;
2361 sb
->s_time_gran
= 1;
2362 sb
->s_export_op
= &nfs_export_ops
;
2364 sb
->s_time_gran
= 1000;
2366 if (server
->nfs_client
->rpc_ops
->version
!= 4) {
2368 sb
->s_time_max
= U32_MAX
;
2370 sb
->s_time_min
= S64_MIN
;
2371 sb
->s_time_max
= S64_MAX
;
2374 sb
->s_magic
= NFS_SUPER_MAGIC
;
2376 /* We probably want something more informative here */
2377 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
2378 "%u:%u", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
2380 if (sb
->s_blocksize
== 0)
2381 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
2382 &sb
->s_blocksize_bits
);
2384 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
2387 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
, int flags
)
2389 const struct nfs_server
*a
= s
->s_fs_info
;
2390 const struct rpc_clnt
*clnt_a
= a
->client
;
2391 const struct rpc_clnt
*clnt_b
= b
->client
;
2393 if ((s
->s_flags
& NFS_MS_MASK
) != (flags
& NFS_MS_MASK
))
2395 if (a
->nfs_client
!= b
->nfs_client
)
2397 if ((a
->flags
^ b
->flags
) & NFS_MOUNT_CMP_FLAGMASK
)
2399 if (a
->wsize
!= b
->wsize
)
2401 if (a
->rsize
!= b
->rsize
)
2403 if (a
->acregmin
!= b
->acregmin
)
2405 if (a
->acregmax
!= b
->acregmax
)
2407 if (a
->acdirmin
!= b
->acdirmin
)
2409 if (a
->acdirmax
!= b
->acdirmax
)
2411 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
2418 struct nfs_sb_mountdata
{
2419 struct nfs_server
*server
;
2423 static int nfs_set_super(struct super_block
*s
, void *data
)
2425 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2426 struct nfs_server
*server
= sb_mntdata
->server
;
2429 s
->s_flags
= sb_mntdata
->mntflags
;
2430 s
->s_fs_info
= server
;
2431 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
2432 ret
= set_anon_super(s
, server
);
2434 server
->s_dev
= s
->s_dev
;
2438 static int nfs_compare_super_address(struct nfs_server
*server1
,
2439 struct nfs_server
*server2
)
2441 struct sockaddr
*sap1
, *sap2
;
2442 struct rpc_xprt
*xprt1
= server1
->client
->cl_xprt
;
2443 struct rpc_xprt
*xprt2
= server2
->client
->cl_xprt
;
2445 if (!net_eq(xprt1
->xprt_net
, xprt2
->xprt_net
))
2448 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
2449 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
2451 if (sap1
->sa_family
!= sap2
->sa_family
)
2454 switch (sap1
->sa_family
) {
2456 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
2457 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
2458 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
2460 if (sin1
->sin_port
!= sin2
->sin_port
)
2465 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
2466 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
2467 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
2469 if (sin1
->sin6_port
!= sin2
->sin6_port
)
2480 static int nfs_compare_userns(const struct nfs_server
*old
,
2481 const struct nfs_server
*new)
2483 const struct user_namespace
*oldns
= &init_user_ns
;
2484 const struct user_namespace
*newns
= &init_user_ns
;
2486 if (old
->client
&& old
->client
->cl_cred
)
2487 oldns
= old
->client
->cl_cred
->user_ns
;
2488 if (new->client
&& new->client
->cl_cred
)
2489 newns
= new->client
->cl_cred
->user_ns
;
2495 static int nfs_compare_super(struct super_block
*sb
, void *data
)
2497 struct nfs_sb_mountdata
*sb_mntdata
= data
;
2498 struct nfs_server
*server
= sb_mntdata
->server
, *old
= NFS_SB(sb
);
2499 int mntflags
= sb_mntdata
->mntflags
;
2501 if (!nfs_compare_super_address(old
, server
))
2503 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
2504 if (old
->flags
& NFS_MOUNT_UNSHARED
)
2506 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
2508 if (!nfs_compare_userns(old
, server
))
2510 return nfs_compare_mount_options(sb
, server
, mntflags
);
2513 #ifdef CONFIG_NFS_FSCACHE
2514 static void nfs_get_cache_cookie(struct super_block
*sb
,
2515 struct nfs_parsed_mount_data
*parsed
,
2516 struct nfs_clone_mount
*cloned
)
2518 struct nfs_server
*nfss
= NFS_SB(sb
);
2522 nfss
->fscache_key
= NULL
;
2523 nfss
->fscache
= NULL
;
2526 if (!(parsed
->options
& NFS_OPTION_FSCACHE
))
2528 if (parsed
->fscache_uniq
) {
2529 uniq
= parsed
->fscache_uniq
;
2530 ulen
= strlen(parsed
->fscache_uniq
);
2532 } else if (cloned
) {
2533 struct nfs_server
*mnt_s
= NFS_SB(cloned
->sb
);
2534 if (!(mnt_s
->options
& NFS_OPTION_FSCACHE
))
2536 if (mnt_s
->fscache_key
) {
2537 uniq
= mnt_s
->fscache_key
->key
.uniquifier
;
2538 ulen
= mnt_s
->fscache_key
->key
.uniq_len
;
2543 nfs_fscache_get_super_cookie(sb
, uniq
, ulen
);
2546 static void nfs_get_cache_cookie(struct super_block
*sb
,
2547 struct nfs_parsed_mount_data
*parsed
,
2548 struct nfs_clone_mount
*cloned
)
2553 static void nfs_set_readahead(struct backing_dev_info
*bdi
,
2554 unsigned long iomax_pages
)
2556 bdi
->ra_pages
= VM_READAHEAD_PAGES
;
2557 bdi
->io_pages
= iomax_pages
;
2560 static struct dentry
*nfs_fs_mount_common(int flags
, const char *dev_name
,
2561 struct nfs_mount_info
*mount_info
)
2563 struct super_block
*s
;
2564 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2565 int (*compare_super
)(struct super_block
*, void *) = nfs_compare_super
;
2566 struct nfs_server
*server
= mount_info
->server
;
2567 unsigned long kflags
= 0, kflags_out
= 0;
2568 struct nfs_sb_mountdata sb_mntdata
= {
2574 mount_info
->server
= NULL
;
2576 return ERR_CAST(server
);
2578 if (server
->flags
& NFS_MOUNT_UNSHARED
)
2579 compare_super
= NULL
;
2581 /* -o noac implies -o sync */
2582 if (server
->flags
& NFS_MOUNT_NOAC
)
2583 sb_mntdata
.mntflags
|= SB_SYNCHRONOUS
;
2585 if (mount_info
->cloned
!= NULL
&& mount_info
->cloned
->sb
!= NULL
)
2586 if (mount_info
->cloned
->sb
->s_flags
& SB_SYNCHRONOUS
)
2587 sb_mntdata
.mntflags
|= SB_SYNCHRONOUS
;
2589 /* Get a superblock - note that we may end up sharing one that already exists */
2590 s
= sget(mount_info
->nfs_mod
->nfs_fs
, compare_super
, nfs_set_super
,
2591 flags
, &sb_mntdata
);
2593 mntroot
= ERR_CAST(s
);
2597 if (s
->s_fs_info
!= server
) {
2598 nfs_free_server(server
);
2601 error
= super_setup_bdi_name(s
, "%u:%u", MAJOR(server
->s_dev
),
2602 MINOR(server
->s_dev
));
2604 mntroot
= ERR_PTR(error
);
2605 goto error_splat_super
;
2607 nfs_set_readahead(s
->s_bdi
, server
->rpages
);
2612 unsigned bsize
= mount_info
->inherited_bsize
;
2613 /* initial superblock/root creation */
2614 nfs_fill_super(s
, mount_info
);
2616 s
->s_blocksize_bits
= bsize
;
2617 s
->s_blocksize
= 1U << bsize
;
2619 nfs_get_cache_cookie(s
, mount_info
->parsed
, mount_info
->cloned
);
2620 if (!(server
->flags
& NFS_MOUNT_UNSHARED
))
2621 s
->s_iflags
|= SB_I_MULTIROOT
;
2624 mntroot
= nfs_get_root(s
, mount_info
->mntfh
, dev_name
);
2625 if (IS_ERR(mntroot
))
2626 goto error_splat_super
;
2629 if (NFS_SB(s
)->caps
& NFS_CAP_SECURITY_LABEL
)
2630 kflags
|= SECURITY_LSM_NATIVE_LABELS
;
2631 if (mount_info
->cloned
) {
2632 if (d_inode(mntroot
)->i_fop
!= &nfs_dir_operations
) {
2634 goto error_splat_root
;
2636 /* clone any lsm security options from the parent to the new sb */
2637 error
= security_sb_clone_mnt_opts(mount_info
->cloned
->sb
, s
, kflags
,
2640 error
= security_sb_set_mnt_opts(s
, mount_info
->parsed
->lsm_opts
,
2641 kflags
, &kflags_out
);
2644 goto error_splat_root
;
2645 if (NFS_SB(s
)->caps
& NFS_CAP_SECURITY_LABEL
&&
2646 !(kflags_out
& SECURITY_LSM_NATIVE_LABELS
))
2647 NFS_SB(s
)->caps
&= ~NFS_CAP_SECURITY_LABEL
;
2649 goto error_splat_root
;
2651 s
->s_flags
|= SB_ACTIVE
;
2657 nfs_free_server(server
);
2662 mntroot
= ERR_PTR(error
);
2664 deactivate_locked_super(s
);
2668 struct dentry
*nfs_fs_mount(struct file_system_type
*fs_type
,
2669 int flags
, const char *dev_name
, void *raw_data
)
2671 struct nfs_mount_info mount_info
= {
2673 struct dentry
*mntroot
= ERR_PTR(-ENOMEM
);
2674 struct nfs_subversion
*nfs_mod
;
2677 mount_info
.parsed
= nfs_alloc_parsed_mount_data();
2678 mount_info
.mntfh
= nfs_alloc_fhandle();
2679 if (mount_info
.parsed
== NULL
|| mount_info
.mntfh
== NULL
)
2682 /* Validate the mount data */
2683 error
= nfs_validate_mount_data(fs_type
, raw_data
, mount_info
.parsed
, mount_info
.mntfh
, dev_name
);
2684 if (error
== NFS_TEXT_DATA
)
2685 error
= nfs_validate_text_mount_data(raw_data
, mount_info
.parsed
, dev_name
);
2687 mntroot
= ERR_PTR(error
);
2691 nfs_mod
= get_nfs_version(mount_info
.parsed
->version
);
2692 if (IS_ERR(nfs_mod
)) {
2693 mntroot
= ERR_CAST(nfs_mod
);
2696 mount_info
.nfs_mod
= nfs_mod
;
2698 mntroot
= nfs_mod
->rpc_ops
->try_mount(flags
, dev_name
, &mount_info
);
2700 put_nfs_version(nfs_mod
);
2702 nfs_free_parsed_mount_data(mount_info
.parsed
);
2703 nfs_free_fhandle(mount_info
.mntfh
);
2706 EXPORT_SYMBOL_GPL(nfs_fs_mount
);
2709 * Destroy an NFS2/3 superblock
2711 void nfs_kill_super(struct super_block
*s
)
2713 struct nfs_server
*server
= NFS_SB(s
);
2714 dev_t dev
= s
->s_dev
;
2716 generic_shutdown_super(s
);
2718 nfs_fscache_release_super_cookie(s
);
2720 nfs_free_server(server
);
2721 free_anon_bdev(dev
);
2723 EXPORT_SYMBOL_GPL(nfs_kill_super
);
2726 * Internal use only: mount_info is already set up by caller.
2727 * Used for mountpoint crossings and for nfs4 root.
2729 static struct dentry
*
2730 nfs_prepared_mount(struct file_system_type
*fs_type
, int flags
,
2731 const char *dev_name
, void *raw_data
)
2733 return nfs_fs_mount_common(flags
, dev_name
, raw_data
);
2736 #if IS_ENABLED(CONFIG_NFS_V4)
2738 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data
*args
)
2740 args
->flags
&= ~(NFS_MOUNT_NONLM
|NFS_MOUNT_NOACL
|NFS_MOUNT_VER3
|
2741 NFS_MOUNT_LOCAL_FLOCK
|NFS_MOUNT_LOCAL_FCNTL
);
2745 * Validate NFSv4 mount options
2747 static int nfs4_validate_mount_data(void *options
,
2748 struct nfs_parsed_mount_data
*args
,
2749 const char *dev_name
)
2751 struct sockaddr
*sap
= (struct sockaddr
*)&args
->nfs_server
.address
;
2752 struct nfs4_mount_data
*data
= (struct nfs4_mount_data
*)options
;
2760 switch (data
->version
) {
2762 if (data
->host_addrlen
> sizeof(args
->nfs_server
.address
))
2763 goto out_no_address
;
2764 if (data
->host_addrlen
== 0)
2765 goto out_no_address
;
2766 args
->nfs_server
.addrlen
= data
->host_addrlen
;
2767 if (copy_from_user(sap
, data
->host_addr
, data
->host_addrlen
))
2769 if (!nfs_verify_server_address(sap
))
2770 goto out_no_address
;
2771 args
->nfs_server
.port
= ntohs(((struct sockaddr_in
*)sap
)->sin_port
);
2773 if (data
->auth_flavourlen
) {
2774 rpc_authflavor_t pseudoflavor
;
2775 if (data
->auth_flavourlen
> 1)
2776 goto out_inval_auth
;
2777 if (copy_from_user(&pseudoflavor
,
2778 data
->auth_flavours
,
2779 sizeof(pseudoflavor
)))
2781 args
->selected_flavor
= pseudoflavor
;
2783 args
->selected_flavor
= RPC_AUTH_UNIX
;
2785 c
= strndup_user(data
->hostname
.data
, NFS4_MAXNAMLEN
);
2788 args
->nfs_server
.hostname
= c
;
2790 c
= strndup_user(data
->mnt_path
.data
, NFS4_MAXPATHLEN
);
2793 args
->nfs_server
.export_path
= c
;
2794 dfprintk(MOUNT
, "NFS: MNTPATH: '%s'\n", c
);
2796 c
= strndup_user(data
->client_addr
.data
, 16);
2799 args
->client_address
= c
;
2802 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2806 args
->flags
= data
->flags
& NFS4_MOUNT_FLAGMASK
;
2807 args
->rsize
= data
->rsize
;
2808 args
->wsize
= data
->wsize
;
2809 args
->timeo
= data
->timeo
;
2810 args
->retrans
= data
->retrans
;
2811 args
->acregmin
= data
->acregmin
;
2812 args
->acregmax
= data
->acregmax
;
2813 args
->acdirmin
= data
->acdirmin
;
2814 args
->acdirmax
= data
->acdirmax
;
2815 args
->nfs_server
.protocol
= data
->proto
;
2816 nfs_validate_transport_protocol(args
);
2817 if (args
->nfs_server
.protocol
== XPRT_TRANSPORT_UDP
)
2818 goto out_invalid_transport_udp
;
2822 return NFS_TEXT_DATA
;
2828 dfprintk(MOUNT
, "NFS4: mount program didn't pass any mount data\n");
2832 dfprintk(MOUNT
, "NFS4: Invalid number of RPC auth flavours %d\n",
2833 data
->auth_flavourlen
);
2837 dfprintk(MOUNT
, "NFS4: mount program didn't pass remote address\n");
2840 out_invalid_transport_udp
:
2841 dfprintk(MOUNT
, "NFSv4: Unsupported transport protocol udp\n");
2846 * NFS v4 module parameters need to stay in the
2847 * NFS client for backwards compatibility
2849 unsigned int nfs_callback_set_tcpport
;
2850 unsigned short nfs_callback_nr_threads
;
2851 /* Default cache timeout is 10 minutes */
2852 unsigned int nfs_idmap_cache_timeout
= 600;
2853 /* Turn off NFSv4 uid/gid mapping when using AUTH_SYS */
2854 bool nfs4_disable_idmapping
= true;
2855 unsigned short max_session_slots
= NFS4_DEF_SLOT_TABLE_SIZE
;
2856 unsigned short max_session_cb_slots
= NFS4_DEF_CB_SLOT_TABLE_SIZE
;
2857 unsigned short send_implementation_id
= 1;
2858 char nfs4_client_id_uniquifier
[NFS4_CLIENT_ID_UNIQ_LEN
] = "";
2859 bool recover_lost_locks
= false;
2861 EXPORT_SYMBOL_GPL(nfs_callback_nr_threads
);
2862 EXPORT_SYMBOL_GPL(nfs_callback_set_tcpport
);
2863 EXPORT_SYMBOL_GPL(nfs_idmap_cache_timeout
);
2864 EXPORT_SYMBOL_GPL(nfs4_disable_idmapping
);
2865 EXPORT_SYMBOL_GPL(max_session_slots
);
2866 EXPORT_SYMBOL_GPL(max_session_cb_slots
);
2867 EXPORT_SYMBOL_GPL(send_implementation_id
);
2868 EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier
);
2869 EXPORT_SYMBOL_GPL(recover_lost_locks
);
2871 #define NFS_CALLBACK_MAXPORTNR (65535U)
2873 static int param_set_portnr(const char *val
, const struct kernel_param
*kp
)
2880 ret
= kstrtoul(val
, 0, &num
);
2881 if (ret
|| num
> NFS_CALLBACK_MAXPORTNR
)
2883 *((unsigned int *)kp
->arg
) = num
;
2886 static const struct kernel_param_ops param_ops_portnr
= {
2887 .set
= param_set_portnr
,
2888 .get
= param_get_uint
,
2890 #define param_check_portnr(name, p) __param_check(name, p, unsigned int);
2892 module_param_named(callback_tcpport
, nfs_callback_set_tcpport
, portnr
, 0644);
2893 module_param_named(callback_nr_threads
, nfs_callback_nr_threads
, ushort
, 0644);
2894 MODULE_PARM_DESC(callback_nr_threads
, "Number of threads that will be "
2895 "assigned to the NFSv4 callback channels.");
2896 module_param(nfs_idmap_cache_timeout
, int, 0644);
2897 module_param(nfs4_disable_idmapping
, bool, 0644);
2898 module_param_string(nfs4_unique_id
, nfs4_client_id_uniquifier
,
2899 NFS4_CLIENT_ID_UNIQ_LEN
, 0600);
2900 MODULE_PARM_DESC(nfs4_disable_idmapping
,
2901 "Turn off NFSv4 idmapping when using 'sec=sys'");
2902 module_param(max_session_slots
, ushort
, 0644);
2903 MODULE_PARM_DESC(max_session_slots
, "Maximum number of outstanding NFSv4.1 "
2904 "requests the client will negotiate");
2905 module_param(max_session_cb_slots
, ushort
, 0644);
2906 MODULE_PARM_DESC(max_session_cb_slots
, "Maximum number of parallel NFSv4.1 "
2907 "callbacks the client will process for a given server");
2908 module_param(send_implementation_id
, ushort
, 0644);
2909 MODULE_PARM_DESC(send_implementation_id
,
2910 "Send implementation ID with NFSv4.1 exchange_id");
2911 MODULE_PARM_DESC(nfs4_unique_id
, "nfs_client_id4 uniquifier string");
2913 module_param(recover_lost_locks
, bool, 0644);
2914 MODULE_PARM_DESC(recover_lost_locks
,
2915 "If the server reports that a lock might be lost, "
2916 "try to recover it risking data corruption.");
2919 #endif /* CONFIG_NFS_V4 */