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/sched.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>
57 #include <linux/nsproxy.h>
58 #include <linux/rcupdate.h>
60 #include <linux/uaccess.h>
61 #include <linux/nfs_ssc.h>
63 #include <uapi/linux/tls.h>
67 #include "delegation.h"
71 #include "nfs4session.h"
77 #define NFSDBG_FACILITY NFSDBG_VFS
79 const struct super_operations nfs_sops
= {
80 .alloc_inode
= nfs_alloc_inode
,
81 .free_inode
= nfs_free_inode
,
82 .write_inode
= nfs_write_inode
,
83 .drop_inode
= nfs_drop_inode
,
85 .evict_inode
= nfs_evict_inode
,
86 .umount_begin
= nfs_umount_begin
,
87 .show_options
= nfs_show_options
,
88 .show_devname
= nfs_show_devname
,
89 .show_path
= nfs_show_path
,
90 .show_stats
= nfs_show_stats
,
92 EXPORT_SYMBOL_GPL(nfs_sops
);
94 #ifdef CONFIG_NFS_V4_2
95 static const struct nfs_ssc_client_ops nfs_ssc_clnt_ops_tbl
= {
96 .sco_sb_deactive
= nfs_sb_deactive
,
100 #if IS_ENABLED(CONFIG_NFS_V4)
101 static int __init
register_nfs4_fs(void)
103 return register_filesystem(&nfs4_fs_type
);
106 static void unregister_nfs4_fs(void)
108 unregister_filesystem(&nfs4_fs_type
);
111 static int __init
register_nfs4_fs(void)
116 static void unregister_nfs4_fs(void)
121 #ifdef CONFIG_NFS_V4_2
122 static void nfs_ssc_register_ops(void)
124 nfs_ssc_register(&nfs_ssc_clnt_ops_tbl
);
127 static void nfs_ssc_unregister_ops(void)
129 nfs_ssc_unregister(&nfs_ssc_clnt_ops_tbl
);
131 #endif /* CONFIG_NFS_V4_2 */
133 static struct shrinker
*acl_shrinker
;
136 * Register the NFS filesystems
138 int __init
register_nfs_fs(void)
142 ret
= register_filesystem(&nfs_fs_type
);
146 ret
= register_nfs4_fs();
150 ret
= nfs_register_sysctl();
154 acl_shrinker
= shrinker_alloc(0, "nfs-acl");
160 acl_shrinker
->count_objects
= nfs_access_cache_count
;
161 acl_shrinker
->scan_objects
= nfs_access_cache_scan
;
163 shrinker_register(acl_shrinker
);
165 #ifdef CONFIG_NFS_V4_2
166 nfs_ssc_register_ops();
170 nfs_unregister_sysctl();
172 unregister_nfs4_fs();
174 unregister_filesystem(&nfs_fs_type
);
180 * Unregister the NFS filesystems
182 void __exit
unregister_nfs_fs(void)
184 shrinker_free(acl_shrinker
);
185 nfs_unregister_sysctl();
186 unregister_nfs4_fs();
187 #ifdef CONFIG_NFS_V4_2
188 nfs_ssc_unregister_ops();
190 unregister_filesystem(&nfs_fs_type
);
193 bool nfs_sb_active(struct super_block
*sb
)
195 struct nfs_server
*server
= NFS_SB(sb
);
197 if (!atomic_inc_not_zero(&sb
->s_active
))
199 if (atomic_inc_return(&server
->active
) != 1)
200 atomic_dec(&sb
->s_active
);
203 EXPORT_SYMBOL_GPL(nfs_sb_active
);
205 void nfs_sb_deactive(struct super_block
*sb
)
207 struct nfs_server
*server
= NFS_SB(sb
);
209 if (atomic_dec_and_test(&server
->active
))
210 deactivate_super(sb
);
212 EXPORT_SYMBOL_GPL(nfs_sb_deactive
);
214 static int __nfs_list_for_each_server(struct list_head
*head
,
215 int (*fn
)(struct nfs_server
*, void *),
218 struct nfs_server
*server
, *last
= NULL
;
222 list_for_each_entry_rcu(server
, head
, client_link
) {
223 if (!(server
->super
&& nfs_sb_active(server
->super
)))
227 nfs_sb_deactive(last
->super
);
229 ret
= fn(server
, data
);
238 nfs_sb_deactive(last
->super
);
242 int nfs_client_for_each_server(struct nfs_client
*clp
,
243 int (*fn
)(struct nfs_server
*, void *),
246 return __nfs_list_for_each_server(&clp
->cl_superblocks
, fn
, data
);
248 EXPORT_SYMBOL_GPL(nfs_client_for_each_server
);
251 * Deliver file system statistics to userspace
253 int nfs_statfs(struct dentry
*dentry
, struct kstatfs
*buf
)
255 struct nfs_server
*server
= NFS_SB(dentry
->d_sb
);
256 unsigned char blockbits
;
257 unsigned long blockres
;
258 struct nfs_fh
*fh
= NFS_FH(d_inode(dentry
));
259 struct nfs_fsstat res
;
262 res
.fattr
= nfs_alloc_fattr();
263 if (res
.fattr
== NULL
)
266 error
= server
->nfs_client
->rpc_ops
->statfs(server
, fh
, &res
);
267 if (unlikely(error
== -ESTALE
)) {
268 struct dentry
*pd_dentry
;
270 pd_dentry
= dget_parent(dentry
);
271 nfs_zap_caches(d_inode(pd_dentry
));
274 nfs_free_fattr(res
.fattr
);
278 buf
->f_type
= NFS_SUPER_MAGIC
;
281 * Current versions of glibc do not correctly handle the
282 * case where f_frsize != f_bsize. Eventually we want to
283 * report the value of wtmult in this field.
285 buf
->f_frsize
= dentry
->d_sb
->s_blocksize
;
288 * On most *nix systems, f_blocks, f_bfree, and f_bavail
289 * are reported in units of f_frsize. Linux hasn't had
290 * an f_frsize field in its statfs struct until recently,
291 * thus historically Linux's sys_statfs reports these
292 * fields in units of f_bsize.
294 buf
->f_bsize
= dentry
->d_sb
->s_blocksize
;
295 blockbits
= dentry
->d_sb
->s_blocksize_bits
;
296 blockres
= (1 << blockbits
) - 1;
297 buf
->f_blocks
= (res
.tbytes
+ blockres
) >> blockbits
;
298 buf
->f_bfree
= (res
.fbytes
+ blockres
) >> blockbits
;
299 buf
->f_bavail
= (res
.abytes
+ blockres
) >> blockbits
;
301 buf
->f_files
= res
.tfiles
;
302 buf
->f_ffree
= res
.afiles
;
304 buf
->f_namelen
= server
->namelen
;
309 dprintk("%s: statfs error = %d\n", __func__
, -error
);
312 EXPORT_SYMBOL_GPL(nfs_statfs
);
315 * Map the security flavour number to a name
317 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour
)
319 static const struct {
320 rpc_authflavor_t flavour
;
322 } sec_flavours
[NFS_AUTH_INFO_MAX_FLAVORS
] = {
323 /* update NFS_AUTH_INFO_MAX_FLAVORS when this list changes! */
324 { RPC_AUTH_NULL
, "null" },
325 { RPC_AUTH_UNIX
, "sys" },
326 { RPC_AUTH_GSS_KRB5
, "krb5" },
327 { RPC_AUTH_GSS_KRB5I
, "krb5i" },
328 { RPC_AUTH_GSS_KRB5P
, "krb5p" },
329 { RPC_AUTH_GSS_LKEY
, "lkey" },
330 { RPC_AUTH_GSS_LKEYI
, "lkeyi" },
331 { RPC_AUTH_GSS_LKEYP
, "lkeyp" },
332 { RPC_AUTH_GSS_SPKM
, "spkm" },
333 { RPC_AUTH_GSS_SPKMI
, "spkmi" },
334 { RPC_AUTH_GSS_SPKMP
, "spkmp" },
335 { UINT_MAX
, "unknown" }
339 for (i
= 0; sec_flavours
[i
].flavour
!= UINT_MAX
; i
++) {
340 if (sec_flavours
[i
].flavour
== flavour
)
343 return sec_flavours
[i
].str
;
346 static void nfs_show_mountd_netid(struct seq_file
*m
, struct nfs_server
*nfss
,
349 struct sockaddr
*sap
= (struct sockaddr
*) &nfss
->mountd_address
;
352 switch (sap
->sa_family
) {
354 switch (nfss
->mountd_protocol
) {
356 proto
= RPCBIND_NETID_UDP
;
359 proto
= RPCBIND_NETID_TCP
;
364 switch (nfss
->mountd_protocol
) {
366 proto
= RPCBIND_NETID_UDP6
;
369 proto
= RPCBIND_NETID_TCP6
;
374 if (proto
|| showdefaults
)
375 seq_printf(m
, ",mountproto=%s", proto
?: "auto");
378 static void nfs_show_mountd_options(struct seq_file
*m
, struct nfs_server
*nfss
,
381 struct sockaddr
*sap
= (struct sockaddr
*)&nfss
->mountd_address
;
383 if (nfss
->flags
& NFS_MOUNT_LEGACY_INTERFACE
)
386 switch (sap
->sa_family
) {
388 struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
389 seq_printf(m
, ",mountaddr=%pI4", &sin
->sin_addr
.s_addr
);
393 struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
394 seq_printf(m
, ",mountaddr=%pI6c", &sin6
->sin6_addr
);
399 seq_puts(m
, ",mountaddr=unspecified");
402 if (nfss
->mountd_version
|| showdefaults
)
403 seq_printf(m
, ",mountvers=%u", nfss
->mountd_version
);
404 if ((nfss
->mountd_port
&&
405 nfss
->mountd_port
!= (unsigned short)NFS_UNSPEC_PORT
) ||
407 seq_printf(m
, ",mountport=%u", nfss
->mountd_port
);
409 nfs_show_mountd_netid(m
, nfss
, showdefaults
);
412 #if IS_ENABLED(CONFIG_NFS_V4)
413 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
416 struct nfs_client
*clp
= nfss
->nfs_client
;
418 seq_printf(m
, ",clientaddr=%s", clp
->cl_ipaddr
);
421 static void nfs_show_nfsv4_options(struct seq_file
*m
, struct nfs_server
*nfss
,
427 static void nfs_show_nfs_version(struct seq_file
*m
,
428 unsigned int version
,
429 unsigned int minorversion
)
431 seq_printf(m
, ",vers=%u", version
);
433 seq_printf(m
, ".%u", minorversion
);
437 * Describe the mount options in force on this server representation
439 static void nfs_show_mount_options(struct seq_file
*m
, struct nfs_server
*nfss
,
442 static const struct proc_nfs_info
{
447 { NFS_MOUNT_SOFT
, ",soft", "" },
448 { NFS_MOUNT_SOFTERR
, ",softerr", "" },
449 { NFS_MOUNT_SOFTREVAL
, ",softreval", "" },
450 { NFS_MOUNT_POSIX
, ",posix", "" },
451 { NFS_MOUNT_NOCTO
, ",nocto", "" },
452 { NFS_MOUNT_NOAC
, ",noac", "" },
453 { NFS_MOUNT_NONLM
, ",nolock", "" },
454 { NFS_MOUNT_NOACL
, ",noacl", "" },
455 { NFS_MOUNT_NORDIRPLUS
, ",nordirplus", "" },
456 { NFS_MOUNT_UNSHARED
, ",nosharecache", "" },
457 { NFS_MOUNT_NORESVPORT
, ",noresvport", "" },
460 const struct proc_nfs_info
*nfs_infop
;
461 struct nfs_client
*clp
= nfss
->nfs_client
;
462 u32 version
= clp
->rpc_ops
->version
;
463 int local_flock
, local_fcntl
;
465 nfs_show_nfs_version(m
, version
, clp
->cl_minorversion
);
466 seq_printf(m
, ",rsize=%u", nfss
->rsize
);
467 seq_printf(m
, ",wsize=%u", nfss
->wsize
);
468 if (nfss
->bsize
!= 0)
469 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
470 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
471 if (nfss
->acregmin
!= NFS_DEF_ACREGMIN
*HZ
|| showdefaults
)
472 seq_printf(m
, ",acregmin=%u", nfss
->acregmin
/HZ
);
473 if (nfss
->acregmax
!= NFS_DEF_ACREGMAX
*HZ
|| showdefaults
)
474 seq_printf(m
, ",acregmax=%u", nfss
->acregmax
/HZ
);
475 if (nfss
->acdirmin
!= NFS_DEF_ACDIRMIN
*HZ
|| showdefaults
)
476 seq_printf(m
, ",acdirmin=%u", nfss
->acdirmin
/HZ
);
477 if (nfss
->acdirmax
!= NFS_DEF_ACDIRMAX
*HZ
|| showdefaults
)
478 seq_printf(m
, ",acdirmax=%u", nfss
->acdirmax
/HZ
);
479 if (!(nfss
->flags
& (NFS_MOUNT_SOFT
|NFS_MOUNT_SOFTERR
)))
480 seq_puts(m
, ",hard");
481 for (nfs_infop
= nfs_info
; nfs_infop
->flag
; nfs_infop
++) {
482 if (nfss
->flags
& nfs_infop
->flag
)
483 seq_puts(m
, nfs_infop
->str
);
485 seq_puts(m
, nfs_infop
->nostr
);
488 seq_printf(m
, ",proto=%s",
489 rpc_peeraddr2str(nfss
->client
, RPC_DISPLAY_NETID
));
491 if (clp
->cl_nconnect
> 0)
492 seq_printf(m
, ",nconnect=%u", clp
->cl_nconnect
);
494 if (clp
->cl_max_connect
> 1)
495 seq_printf(m
, ",max_connect=%u", clp
->cl_max_connect
);
496 if (nfss
->port
!= NFS_PORT
)
497 seq_printf(m
, ",port=%u", nfss
->port
);
500 seq_printf(m
, ",port=%u", nfss
->port
);
502 seq_printf(m
, ",timeo=%lu", 10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
);
503 seq_printf(m
, ",retrans=%u", nfss
->client
->cl_timeout
->to_retries
);
504 seq_printf(m
, ",sec=%s", nfs_pseudoflavour_to_name(nfss
->client
->cl_auth
->au_flavor
));
505 switch (clp
->cl_xprtsec
.policy
) {
506 case RPC_XPRTSEC_TLS_ANON
:
507 seq_puts(m
, ",xprtsec=tls");
509 case RPC_XPRTSEC_TLS_X509
:
510 seq_puts(m
, ",xprtsec=mtls");
517 nfs_show_mountd_options(m
, nfss
, showdefaults
);
519 nfs_show_nfsv4_options(m
, nfss
, showdefaults
);
521 if (nfss
->options
& NFS_OPTION_FSCACHE
) {
522 #ifdef CONFIG_NFS_FSCACHE
523 if (nfss
->fscache_uniq
)
524 seq_printf(m
, ",fsc=%s", nfss
->fscache_uniq
);
532 if (nfss
->options
& NFS_OPTION_MIGRATION
)
533 seq_puts(m
, ",migration");
535 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONEG
) {
536 if (nfss
->flags
& NFS_MOUNT_LOOKUP_CACHE_NONE
)
537 seq_puts(m
, ",lookupcache=none");
539 seq_puts(m
, ",lookupcache=pos");
542 local_flock
= nfss
->flags
& NFS_MOUNT_LOCAL_FLOCK
;
543 local_fcntl
= nfss
->flags
& NFS_MOUNT_LOCAL_FCNTL
;
545 if (!local_flock
&& !local_fcntl
)
546 seq_puts(m
, ",local_lock=none");
547 else if (local_flock
&& local_fcntl
)
548 seq_puts(m
, ",local_lock=all");
549 else if (local_flock
)
550 seq_puts(m
, ",local_lock=flock");
552 seq_puts(m
, ",local_lock=posix");
554 if (nfss
->flags
& NFS_MOUNT_NO_ALIGNWRITE
)
555 seq_puts(m
, ",noalignwrite");
557 if (nfss
->flags
& NFS_MOUNT_WRITE_EAGER
) {
558 if (nfss
->flags
& NFS_MOUNT_WRITE_WAIT
)
559 seq_puts(m
, ",write=wait");
561 seq_puts(m
, ",write=eager");
566 * Describe the mount options on this VFS mountpoint
568 int nfs_show_options(struct seq_file
*m
, struct dentry
*root
)
570 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
572 nfs_show_mount_options(m
, nfss
, 0);
575 seq_printf(m
, ",addr=%s",
576 rpc_peeraddr2str(nfss
->nfs_client
->cl_rpcclient
,
582 EXPORT_SYMBOL_GPL(nfs_show_options
);
584 #if IS_ENABLED(CONFIG_NFS_V4)
585 static void show_lease(struct seq_file
*m
, struct nfs_server
*server
)
587 struct nfs_client
*clp
= server
->nfs_client
;
588 unsigned long expire
;
590 seq_printf(m
, ",lease_time=%ld", clp
->cl_lease_time
/ HZ
);
591 expire
= clp
->cl_last_renewal
+ clp
->cl_lease_time
;
592 seq_printf(m
, ",lease_expired=%ld",
593 time_after(expire
, jiffies
) ? 0 : (jiffies
- expire
) / HZ
);
595 #ifdef CONFIG_NFS_V4_1
596 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
)
598 if (nfs4_has_session(server
->nfs_client
))
599 seq_puts(m
, ",sessions");
602 static void show_sessions(struct seq_file
*m
, struct nfs_server
*server
) {}
606 #ifdef CONFIG_NFS_V4_1
607 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
609 seq_printf(m
, ",pnfs=");
610 if (server
->pnfs_curr_ld
)
611 seq_printf(m
, "%s", server
->pnfs_curr_ld
->name
);
613 seq_printf(m
, "not configured");
616 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
618 if (nfss
->nfs_client
&& nfss
->nfs_client
->cl_implid
) {
619 struct nfs41_impl_id
*impl_id
= nfss
->nfs_client
->cl_implid
;
620 seq_printf(m
, "\n\timpl_id:\tname='%s',domain='%s',"
622 impl_id
->name
, impl_id
->domain
,
623 impl_id
->date
.seconds
, impl_id
->date
.nseconds
);
627 #if IS_ENABLED(CONFIG_NFS_V4)
628 static void show_pnfs(struct seq_file
*m
, struct nfs_server
*server
)
632 static void show_implementation_id(struct seq_file
*m
, struct nfs_server
*nfss
)
637 int nfs_show_devname(struct seq_file
*m
, struct dentry
*root
)
639 char *page
= (char *) __get_free_page(GFP_KERNEL
);
640 char *devname
, *dummy
;
644 devname
= nfs_path(&dummy
, root
, page
, PAGE_SIZE
, 0);
646 err
= PTR_ERR(devname
);
648 seq_escape(m
, devname
, " \t\n\\");
649 free_page((unsigned long)page
);
652 EXPORT_SYMBOL_GPL(nfs_show_devname
);
654 int nfs_show_path(struct seq_file
*m
, struct dentry
*dentry
)
659 EXPORT_SYMBOL_GPL(nfs_show_path
);
662 * Present statistical information for this VFS mountpoint
664 int nfs_show_stats(struct seq_file
*m
, struct dentry
*root
)
667 struct nfs_server
*nfss
= NFS_SB(root
->d_sb
);
668 struct rpc_auth
*auth
= nfss
->client
->cl_auth
;
669 struct nfs_iostats totals
= { };
671 seq_printf(m
, "statvers=%s", NFS_IOSTAT_VERS
);
674 * Display all mount option settings
676 seq_puts(m
, "\n\topts:\t");
677 seq_puts(m
, sb_rdonly(root
->d_sb
) ? "ro" : "rw");
678 seq_puts(m
, root
->d_sb
->s_flags
& SB_SYNCHRONOUS
? ",sync" : "");
679 seq_puts(m
, root
->d_sb
->s_flags
& SB_NOATIME
? ",noatime" : "");
680 seq_puts(m
, root
->d_sb
->s_flags
& SB_NODIRATIME
? ",nodiratime" : "");
681 nfs_show_mount_options(m
, nfss
, 1);
683 seq_printf(m
, "\n\tage:\t%lu", (jiffies
- nfss
->mount_time
) / HZ
);
685 show_implementation_id(m
, nfss
);
687 seq_puts(m
, "\n\tcaps:\t");
688 seq_printf(m
, "caps=0x%x", nfss
->caps
);
689 seq_printf(m
, ",wtmult=%u", nfss
->wtmult
);
690 seq_printf(m
, ",dtsize=%u", nfss
->dtsize
);
691 seq_printf(m
, ",bsize=%u", nfss
->bsize
);
692 seq_printf(m
, ",namlen=%u", nfss
->namelen
);
694 #if IS_ENABLED(CONFIG_NFS_V4)
695 if (nfss
->nfs_client
->rpc_ops
->version
== 4) {
696 seq_puts(m
, "\n\tnfsv4:\t");
697 seq_printf(m
, "bm0=0x%x", nfss
->attr_bitmask
[0]);
698 seq_printf(m
, ",bm1=0x%x", nfss
->attr_bitmask
[1]);
699 seq_printf(m
, ",bm2=0x%x", nfss
->attr_bitmask
[2]);
700 seq_printf(m
, ",acl=0x%x", nfss
->acl_bitmask
);
701 show_sessions(m
, nfss
);
708 * Display security flavor in effect for this mount
710 seq_printf(m
, "\n\tsec:\tflavor=%u", auth
->au_ops
->au_flavor
);
712 seq_printf(m
, ",pseudoflavor=%u", auth
->au_flavor
);
715 * Display superblock I/O counters
717 for_each_possible_cpu(cpu
) {
718 struct nfs_iostats
*stats
;
721 stats
= per_cpu_ptr(nfss
->io_stats
, cpu
);
723 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
724 totals
.events
[i
] += stats
->events
[i
];
725 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
726 totals
.bytes
[i
] += stats
->bytes
[i
];
731 seq_puts(m
, "\n\tevents:\t");
732 for (i
= 0; i
< __NFSIOS_COUNTSMAX
; i
++)
733 seq_printf(m
, "%lu ", totals
.events
[i
]);
734 seq_puts(m
, "\n\tbytes:\t");
735 for (i
= 0; i
< __NFSIOS_BYTESMAX
; i
++)
736 seq_printf(m
, "%Lu ", totals
.bytes
[i
]);
739 rpc_clnt_show_stats(m
, nfss
->client
);
743 EXPORT_SYMBOL_GPL(nfs_show_stats
);
746 * Begin unmount by attempting to remove all automounted mountpoints we added
747 * in response to xdev traversals and referrals
749 void nfs_umount_begin(struct super_block
*sb
)
751 struct nfs_server
*server
;
752 struct rpc_clnt
*rpc
;
755 /* -EIO all pending I/O */
756 rpc
= server
->client_acl
;
758 rpc_killall_tasks(rpc
);
759 rpc
= server
->client
;
761 rpc_killall_tasks(rpc
);
763 EXPORT_SYMBOL_GPL(nfs_umount_begin
);
766 * Return true if 'match' is in auth_info or auth_info is empty.
767 * Return false otherwise.
769 bool nfs_auth_info_match(const struct nfs_auth_info
*auth_info
,
770 rpc_authflavor_t match
)
774 if (!auth_info
->flavor_len
)
777 for (i
= 0; i
< auth_info
->flavor_len
; i
++) {
778 if (auth_info
->flavors
[i
] == match
)
783 EXPORT_SYMBOL_GPL(nfs_auth_info_match
);
786 * Ensure that a specified authtype in ctx->auth_info is supported by
787 * the server. Returns 0 and sets ctx->selected_flavor if it's ok, and
790 static int nfs_verify_authflavors(struct nfs_fs_context
*ctx
,
791 rpc_authflavor_t
*server_authlist
,
794 rpc_authflavor_t flavor
= RPC_AUTH_MAXFLAVOR
;
795 bool found_auth_null
= false;
799 * If the sec= mount option is used, the specified flavor or AUTH_NULL
800 * must be in the list returned by the server.
802 * AUTH_NULL has a special meaning when it's in the server list - it
803 * means that the server will ignore the rpc creds, so any flavor
804 * can be used but still use the sec= that was specified.
806 * Note also that the MNT procedure in MNTv1 does not return a list
807 * of supported security flavors. In this case, nfs_mount() fabricates
808 * a security flavor list containing just AUTH_NULL.
810 for (i
= 0; i
< count
; i
++) {
811 flavor
= server_authlist
[i
];
813 if (nfs_auth_info_match(&ctx
->auth_info
, flavor
))
816 if (flavor
== RPC_AUTH_NULL
)
817 found_auth_null
= true;
820 if (found_auth_null
) {
821 flavor
= ctx
->auth_info
.flavors
[0];
826 "NFS: specified auth flavors not supported by server\n");
830 ctx
->selected_flavor
= flavor
;
831 dfprintk(MOUNT
, "NFS: using auth flavor %u\n", ctx
->selected_flavor
);
836 * Use the remote server's MOUNT service to request the NFS file handle
837 * corresponding to the provided path.
839 static int nfs_request_mount(struct fs_context
*fc
,
840 struct nfs_fh
*root_fh
,
841 rpc_authflavor_t
*server_authlist
,
842 unsigned int *server_authlist_len
)
844 struct nfs_fs_context
*ctx
= nfs_fc2context(fc
);
845 struct nfs_mount_request request
= {
846 .sap
= &ctx
->mount_server
._address
,
847 .dirpath
= ctx
->nfs_server
.export_path
,
848 .protocol
= ctx
->mount_server
.protocol
,
850 .noresvport
= ctx
->flags
& NFS_MOUNT_NORESVPORT
,
851 .auth_flav_len
= server_authlist_len
,
852 .auth_flavs
= server_authlist
,
857 if (ctx
->mount_server
.version
== 0) {
858 switch (ctx
->version
) {
860 ctx
->mount_server
.version
= NFS_MNT3_VERSION
;
863 ctx
->mount_server
.version
= NFS_MNT_VERSION
;
866 request
.version
= ctx
->mount_server
.version
;
868 if (ctx
->mount_server
.hostname
)
869 request
.hostname
= ctx
->mount_server
.hostname
;
871 request
.hostname
= ctx
->nfs_server
.hostname
;
874 * Construct the mount server's address.
876 if (ctx
->mount_server
.address
.sa_family
== AF_UNSPEC
) {
877 memcpy(request
.sap
, &ctx
->nfs_server
._address
,
878 ctx
->nfs_server
.addrlen
);
879 ctx
->mount_server
.addrlen
= ctx
->nfs_server
.addrlen
;
881 request
.salen
= ctx
->mount_server
.addrlen
;
882 nfs_set_port(request
.sap
, &ctx
->mount_server
.port
, 0);
885 * Now ask the mount server to map our export path
888 if ((request
.protocol
== XPRT_TRANSPORT_UDP
) ==
889 !(ctx
->flags
& NFS_MOUNT_TCP
))
891 * NFS protocol and mount protocol are both UDP or neither UDP
892 * so timeouts are compatible. Use NFS timeouts for MOUNT
894 status
= nfs_mount(&request
, ctx
->timeo
, ctx
->retrans
);
896 status
= nfs_mount(&request
, NFS_UNSPEC_TIMEO
, NFS_UNSPEC_RETRANS
);
898 dfprintk(MOUNT
, "NFS: unable to mount server %s, error %d\n",
899 request
.hostname
, status
);
906 static struct nfs_server
*nfs_try_mount_request(struct fs_context
*fc
)
908 struct nfs_fs_context
*ctx
= nfs_fc2context(fc
);
911 bool tried_auth_unix
= false;
912 bool auth_null_in_list
= false;
913 struct nfs_server
*server
= ERR_PTR(-EACCES
);
914 rpc_authflavor_t authlist
[NFS_MAX_SECFLAVORS
];
915 unsigned int authlist_len
= ARRAY_SIZE(authlist
);
917 /* make sure 'nolock'/'lock' override the 'local_lock' mount option */
918 if (ctx
->lock_status
) {
919 if (ctx
->lock_status
== NFS_LOCK_NOLOCK
) {
920 ctx
->flags
|= NFS_MOUNT_NONLM
;
921 ctx
->flags
|= (NFS_MOUNT_LOCAL_FLOCK
| NFS_MOUNT_LOCAL_FCNTL
);
923 ctx
->flags
&= ~NFS_MOUNT_NONLM
;
924 ctx
->flags
&= ~(NFS_MOUNT_LOCAL_FLOCK
| NFS_MOUNT_LOCAL_FCNTL
);
927 status
= nfs_request_mount(fc
, ctx
->mntfh
, authlist
, &authlist_len
);
929 return ERR_PTR(status
);
932 * Was a sec= authflavor specified in the options? First, verify
933 * whether the server supports it, and then just try to use it if so.
935 if (ctx
->auth_info
.flavor_len
> 0) {
936 status
= nfs_verify_authflavors(ctx
, authlist
, authlist_len
);
937 dfprintk(MOUNT
, "NFS: using auth flavor %u\n",
938 ctx
->selected_flavor
);
940 return ERR_PTR(status
);
941 return ctx
->nfs_mod
->rpc_ops
->create_server(fc
);
945 * No sec= option was provided. RFC 2623, section 2.7 suggests we
946 * SHOULD prefer the flavor listed first. However, some servers list
947 * AUTH_NULL first. Avoid ever choosing AUTH_NULL.
949 for (i
= 0; i
< authlist_len
; ++i
) {
950 rpc_authflavor_t flavor
;
951 struct rpcsec_gss_info info
;
953 flavor
= authlist
[i
];
956 tried_auth_unix
= true;
959 auth_null_in_list
= true;
962 if (rpcauth_get_gssinfo(flavor
, &info
) != 0)
966 dfprintk(MOUNT
, "NFS: attempting to use auth flavor %u\n", flavor
);
967 ctx
->selected_flavor
= flavor
;
968 server
= ctx
->nfs_mod
->rpc_ops
->create_server(fc
);
974 * Nothing we tried so far worked. At this point, give up if we've
975 * already tried AUTH_UNIX or if the server's list doesn't contain
978 if (tried_auth_unix
|| !auth_null_in_list
)
981 /* Last chance! Try AUTH_UNIX */
982 dfprintk(MOUNT
, "NFS: attempting to use auth flavor %u\n", RPC_AUTH_UNIX
);
983 ctx
->selected_flavor
= RPC_AUTH_UNIX
;
984 return ctx
->nfs_mod
->rpc_ops
->create_server(fc
);
987 int nfs_try_get_tree(struct fs_context
*fc
)
989 struct nfs_fs_context
*ctx
= nfs_fc2context(fc
);
992 ctx
->server
= nfs_try_mount_request(fc
);
994 ctx
->server
= ctx
->nfs_mod
->rpc_ops
->create_server(fc
);
996 return nfs_get_tree_common(fc
);
998 EXPORT_SYMBOL_GPL(nfs_try_get_tree
);
1001 #define NFS_REMOUNT_CMP_FLAGMASK ~(NFS_MOUNT_INTR \
1002 | NFS_MOUNT_SECURE \
1005 | NFS_MOUNT_KERBEROS \
1007 | NFS_MOUNT_BROKEN_SUID \
1008 | NFS_MOUNT_STRICTLOCK \
1009 | NFS_MOUNT_LEGACY_INTERFACE)
1011 #define NFS_MOUNT_CMP_FLAGMASK (NFS_REMOUNT_CMP_FLAGMASK & \
1012 ~(NFS_MOUNT_UNSHARED | NFS_MOUNT_NORESVPORT))
1015 nfs_compare_remount_data(struct nfs_server
*nfss
,
1016 struct nfs_fs_context
*ctx
)
1018 if ((ctx
->flags
^ nfss
->flags
) & NFS_REMOUNT_CMP_FLAGMASK
||
1019 ctx
->rsize
!= nfss
->rsize
||
1020 ctx
->wsize
!= nfss
->wsize
||
1021 ctx
->version
!= nfss
->nfs_client
->rpc_ops
->version
||
1022 ctx
->minorversion
!= nfss
->nfs_client
->cl_minorversion
||
1023 ctx
->retrans
!= nfss
->client
->cl_timeout
->to_retries
||
1024 !nfs_auth_info_match(&ctx
->auth_info
, nfss
->client
->cl_auth
->au_flavor
) ||
1025 ctx
->acregmin
!= nfss
->acregmin
/ HZ
||
1026 ctx
->acregmax
!= nfss
->acregmax
/ HZ
||
1027 ctx
->acdirmin
!= nfss
->acdirmin
/ HZ
||
1028 ctx
->acdirmax
!= nfss
->acdirmax
/ HZ
||
1029 ctx
->timeo
!= (10U * nfss
->client
->cl_timeout
->to_initval
/ HZ
) ||
1030 (ctx
->options
& NFS_OPTION_FSCACHE
) != (nfss
->options
& NFS_OPTION_FSCACHE
) ||
1031 ctx
->nfs_server
.port
!= nfss
->port
||
1032 ctx
->nfs_server
.addrlen
!= nfss
->nfs_client
->cl_addrlen
||
1033 !rpc_cmp_addr((struct sockaddr
*)&ctx
->nfs_server
.address
,
1034 (struct sockaddr
*)&nfss
->nfs_client
->cl_addr
))
1040 int nfs_reconfigure(struct fs_context
*fc
)
1042 struct nfs_fs_context
*ctx
= nfs_fc2context(fc
);
1043 struct super_block
*sb
= fc
->root
->d_sb
;
1044 struct nfs_server
*nfss
= sb
->s_fs_info
;
1047 sync_filesystem(sb
);
1050 * Userspace mount programs that send binary options generally send
1051 * them populated with default values. We have no way to know which
1052 * ones were explicitly specified. Fall back to legacy behavior and
1053 * just return success.
1055 if (ctx
->skip_reconfig_option_check
)
1059 * noac is a special case. It implies -o sync, but that's not
1060 * necessarily reflected in the mtab options. reconfigure_super
1061 * will clear SB_SYNCHRONOUS if -o sync wasn't specified in the
1062 * remount options, so we have to explicitly reset it.
1064 if (ctx
->flags
& NFS_MOUNT_NOAC
) {
1065 fc
->sb_flags
|= SB_SYNCHRONOUS
;
1066 fc
->sb_flags_mask
|= SB_SYNCHRONOUS
;
1069 /* compare new mount options with old ones */
1070 ret
= nfs_compare_remount_data(nfss
, ctx
);
1074 return nfs_probe_server(nfss
, NFS_FH(d_inode(fc
->root
)));
1076 EXPORT_SYMBOL_GPL(nfs_reconfigure
);
1079 * Finish setting up an NFS superblock
1081 static void nfs_fill_super(struct super_block
*sb
, struct nfs_fs_context
*ctx
)
1083 struct nfs_server
*server
= NFS_SB(sb
);
1085 sb
->s_blocksize_bits
= 0;
1086 sb
->s_blocksize
= 0;
1087 sb
->s_xattr
= server
->nfs_client
->cl_nfs_mod
->xattr
;
1088 sb
->s_op
= server
->nfs_client
->cl_nfs_mod
->sops
;
1090 sb
->s_blocksize
= nfs_block_size(ctx
->bsize
, &sb
->s_blocksize_bits
);
1092 switch (server
->nfs_client
->rpc_ops
->version
) {
1094 sb
->s_time_gran
= 1000;
1096 sb
->s_time_max
= U32_MAX
;
1100 * The VFS shouldn't apply the umask to mode bits.
1101 * We will do so ourselves when necessary.
1103 sb
->s_flags
|= SB_POSIXACL
;
1104 sb
->s_time_gran
= 1;
1106 sb
->s_time_max
= U32_MAX
;
1107 sb
->s_export_op
= &nfs_export_ops
;
1110 sb
->s_iflags
|= SB_I_NOUMASK
;
1111 sb
->s_time_gran
= 1;
1112 sb
->s_time_min
= S64_MIN
;
1113 sb
->s_time_max
= S64_MAX
;
1114 if (server
->caps
& NFS_CAP_ATOMIC_OPEN_V1
)
1115 sb
->s_export_op
= &nfs_export_ops
;
1119 sb
->s_magic
= NFS_SUPER_MAGIC
;
1121 /* We probably want something more informative here */
1122 snprintf(sb
->s_id
, sizeof(sb
->s_id
),
1123 "%u:%u", MAJOR(sb
->s_dev
), MINOR(sb
->s_dev
));
1125 if (sb
->s_blocksize
== 0)
1126 sb
->s_blocksize
= nfs_block_bits(server
->wsize
,
1127 &sb
->s_blocksize_bits
);
1129 nfs_super_set_maxbytes(sb
, server
->maxfilesize
);
1130 nfs_sysfs_move_server_to_sb(sb
);
1131 server
->has_sec_mnt_opts
= ctx
->has_sec_mnt_opts
;
1134 static int nfs_compare_mount_options(const struct super_block
*s
, const struct nfs_server
*b
,
1135 const struct fs_context
*fc
)
1137 const struct nfs_server
*a
= s
->s_fs_info
;
1138 const struct rpc_clnt
*clnt_a
= a
->client
;
1139 const struct rpc_clnt
*clnt_b
= b
->client
;
1141 if ((s
->s_flags
& NFS_SB_MASK
) != (fc
->sb_flags
& NFS_SB_MASK
))
1143 if (a
->nfs_client
!= b
->nfs_client
)
1145 if ((a
->flags
^ b
->flags
) & NFS_MOUNT_CMP_FLAGMASK
)
1147 if (a
->wsize
!= b
->wsize
)
1149 if (a
->rsize
!= b
->rsize
)
1151 if (a
->acregmin
!= b
->acregmin
)
1153 if (a
->acregmax
!= b
->acregmax
)
1155 if (a
->acdirmin
!= b
->acdirmin
)
1157 if (a
->acdirmax
!= b
->acdirmax
)
1159 if (clnt_a
->cl_auth
->au_flavor
!= clnt_b
->cl_auth
->au_flavor
)
1166 static int nfs_set_super(struct super_block
*s
, struct fs_context
*fc
)
1168 struct nfs_server
*server
= fc
->s_fs_info
;
1171 s
->s_d_op
= server
->nfs_client
->rpc_ops
->dentry_ops
;
1172 ret
= set_anon_super(s
, server
);
1174 server
->s_dev
= s
->s_dev
;
1178 static int nfs_compare_super_address(struct nfs_server
*server1
,
1179 struct nfs_server
*server2
)
1181 struct sockaddr
*sap1
, *sap2
;
1182 struct rpc_xprt
*xprt1
= server1
->client
->cl_xprt
;
1183 struct rpc_xprt
*xprt2
= server2
->client
->cl_xprt
;
1185 if (!net_eq(xprt1
->xprt_net
, xprt2
->xprt_net
))
1188 sap1
= (struct sockaddr
*)&server1
->nfs_client
->cl_addr
;
1189 sap2
= (struct sockaddr
*)&server2
->nfs_client
->cl_addr
;
1191 if (sap1
->sa_family
!= sap2
->sa_family
)
1194 switch (sap1
->sa_family
) {
1196 struct sockaddr_in
*sin1
= (struct sockaddr_in
*)sap1
;
1197 struct sockaddr_in
*sin2
= (struct sockaddr_in
*)sap2
;
1198 if (sin1
->sin_addr
.s_addr
!= sin2
->sin_addr
.s_addr
)
1200 if (sin1
->sin_port
!= sin2
->sin_port
)
1205 struct sockaddr_in6
*sin1
= (struct sockaddr_in6
*)sap1
;
1206 struct sockaddr_in6
*sin2
= (struct sockaddr_in6
*)sap2
;
1207 if (!ipv6_addr_equal(&sin1
->sin6_addr
, &sin2
->sin6_addr
))
1209 if (sin1
->sin6_port
!= sin2
->sin6_port
)
1220 static int nfs_compare_userns(const struct nfs_server
*old
,
1221 const struct nfs_server
*new)
1223 const struct user_namespace
*oldns
= &init_user_ns
;
1224 const struct user_namespace
*newns
= &init_user_ns
;
1226 if (old
->client
&& old
->client
->cl_cred
)
1227 oldns
= old
->client
->cl_cred
->user_ns
;
1228 if (new->client
&& new->client
->cl_cred
)
1229 newns
= new->client
->cl_cred
->user_ns
;
1235 static int nfs_compare_super(struct super_block
*sb
, struct fs_context
*fc
)
1237 struct nfs_server
*server
= fc
->s_fs_info
, *old
= NFS_SB(sb
);
1239 if (!nfs_compare_super_address(old
, server
))
1241 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
1242 if (old
->flags
& NFS_MOUNT_UNSHARED
)
1244 if (memcmp(&old
->fsid
, &server
->fsid
, sizeof(old
->fsid
)) != 0)
1246 if (!nfs_compare_userns(old
, server
))
1248 if ((old
->has_sec_mnt_opts
|| fc
->security
) &&
1249 security_sb_mnt_opts_compat(sb
, fc
->security
))
1251 return nfs_compare_mount_options(sb
, server
, fc
);
1254 #ifdef CONFIG_NFS_FSCACHE
1255 static int nfs_get_cache_cookie(struct super_block
*sb
,
1256 struct nfs_fs_context
*ctx
)
1258 struct nfs_server
*nfss
= NFS_SB(sb
);
1262 nfss
->fscache
= NULL
;
1267 if (ctx
->clone_data
.sb
) {
1268 struct nfs_server
*mnt_s
= NFS_SB(ctx
->clone_data
.sb
);
1269 if (!(mnt_s
->options
& NFS_OPTION_FSCACHE
))
1271 if (mnt_s
->fscache_uniq
) {
1272 uniq
= mnt_s
->fscache_uniq
;
1273 ulen
= strlen(uniq
);
1276 if (!(ctx
->options
& NFS_OPTION_FSCACHE
))
1278 if (ctx
->fscache_uniq
) {
1279 uniq
= ctx
->fscache_uniq
;
1280 ulen
= strlen(ctx
->fscache_uniq
);
1284 return nfs_fscache_get_super_cookie(sb
, uniq
, ulen
);
1287 static int nfs_get_cache_cookie(struct super_block
*sb
,
1288 struct nfs_fs_context
*ctx
)
1294 int nfs_get_tree_common(struct fs_context
*fc
)
1296 struct nfs_fs_context
*ctx
= nfs_fc2context(fc
);
1297 struct super_block
*s
;
1298 int (*compare_super
)(struct super_block
*, struct fs_context
*) = nfs_compare_super
;
1299 struct nfs_server
*server
= ctx
->server
;
1304 return PTR_ERR(server
);
1306 if (server
->flags
& NFS_MOUNT_UNSHARED
)
1307 compare_super
= NULL
;
1309 /* -o noac implies -o sync */
1310 if (server
->flags
& NFS_MOUNT_NOAC
)
1311 fc
->sb_flags
|= SB_SYNCHRONOUS
;
1313 if (ctx
->clone_data
.sb
)
1314 if (ctx
->clone_data
.sb
->s_flags
& SB_SYNCHRONOUS
)
1315 fc
->sb_flags
|= SB_SYNCHRONOUS
;
1317 /* Get a superblock - note that we may end up sharing one that already exists */
1318 fc
->s_fs_info
= server
;
1319 s
= sget_fc(fc
, compare_super
, nfs_set_super
);
1320 fc
->s_fs_info
= NULL
;
1323 nfs_errorf(fc
, "NFS: Couldn't get superblock");
1327 if (s
->s_fs_info
!= server
) {
1328 nfs_free_server(server
);
1331 error
= super_setup_bdi_name(s
, "%u:%u", MAJOR(server
->s_dev
),
1332 MINOR(server
->s_dev
));
1334 goto error_splat_super
;
1335 s
->s_bdi
->io_pages
= server
->rpages
;
1340 unsigned bsize
= ctx
->clone_data
.inherited_bsize
;
1341 /* initial superblock/root creation */
1342 nfs_fill_super(s
, ctx
);
1344 s
->s_blocksize_bits
= bsize
;
1345 s
->s_blocksize
= 1U << bsize
;
1347 error
= nfs_get_cache_cookie(s
, ctx
);
1349 goto error_splat_super
;
1352 error
= nfs_get_root(s
, fc
);
1354 nfs_errorf(fc
, "NFS: Couldn't get root dentry");
1355 goto error_splat_super
;
1358 s
->s_flags
|= SB_ACTIVE
;
1365 nfs_free_server(server
);
1368 deactivate_locked_super(s
);
1373 * Destroy an NFS superblock
1375 void nfs_kill_super(struct super_block
*s
)
1377 struct nfs_server
*server
= NFS_SB(s
);
1379 nfs_sysfs_move_sb_to_server(server
);
1382 nfs_fscache_release_super_cookie(s
);
1384 nfs_free_server(server
);
1386 EXPORT_SYMBOL_GPL(nfs_kill_super
);
1388 #if IS_ENABLED(CONFIG_NFS_V4)
1391 * NFS v4 module parameters need to stay in the
1392 * NFS client for backwards compatibility
1394 unsigned int nfs_callback_set_tcpport
;
1395 unsigned short nfs_callback_nr_threads
;
1396 /* Default cache timeout is 10 minutes */
1397 unsigned int nfs_idmap_cache_timeout
= 600;
1398 /* Turn off NFSv4 uid/gid mapping when using AUTH_SYS */
1399 bool nfs4_disable_idmapping
= true;
1400 unsigned short max_session_slots
= NFS4_DEF_SLOT_TABLE_SIZE
;
1401 unsigned short max_session_cb_slots
= NFS4_DEF_CB_SLOT_TABLE_SIZE
;
1402 unsigned short send_implementation_id
= 1;
1403 char nfs4_client_id_uniquifier
[NFS4_CLIENT_ID_UNIQ_LEN
] = "";
1404 bool recover_lost_locks
= false;
1405 short nfs_delay_retrans
= -1;
1407 EXPORT_SYMBOL_GPL(nfs_callback_nr_threads
);
1408 EXPORT_SYMBOL_GPL(nfs_callback_set_tcpport
);
1409 EXPORT_SYMBOL_GPL(nfs_idmap_cache_timeout
);
1410 EXPORT_SYMBOL_GPL(nfs4_disable_idmapping
);
1411 EXPORT_SYMBOL_GPL(max_session_slots
);
1412 EXPORT_SYMBOL_GPL(max_session_cb_slots
);
1413 EXPORT_SYMBOL_GPL(send_implementation_id
);
1414 EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier
);
1415 EXPORT_SYMBOL_GPL(recover_lost_locks
);
1416 EXPORT_SYMBOL_GPL(nfs_delay_retrans
);
1418 #define NFS_CALLBACK_MAXPORTNR (65535U)
1420 static int param_set_portnr(const char *val
, const struct kernel_param
*kp
)
1427 ret
= kstrtoul(val
, 0, &num
);
1428 if (ret
|| num
> NFS_CALLBACK_MAXPORTNR
)
1430 *((unsigned int *)kp
->arg
) = num
;
1433 static const struct kernel_param_ops param_ops_portnr
= {
1434 .set
= param_set_portnr
,
1435 .get
= param_get_uint
,
1437 #define param_check_portnr(name, p) __param_check(name, p, unsigned int)
1439 module_param_named(callback_tcpport
, nfs_callback_set_tcpport
, portnr
, 0644);
1440 module_param_named(callback_nr_threads
, nfs_callback_nr_threads
, ushort
, 0644);
1441 MODULE_PARM_DESC(callback_nr_threads
, "Number of threads that will be "
1442 "assigned to the NFSv4 callback channels.");
1443 module_param(nfs_idmap_cache_timeout
, int, 0644);
1444 module_param(nfs4_disable_idmapping
, bool, 0644);
1445 module_param_string(nfs4_unique_id
, nfs4_client_id_uniquifier
,
1446 NFS4_CLIENT_ID_UNIQ_LEN
, 0600);
1447 MODULE_PARM_DESC(nfs4_disable_idmapping
,
1448 "Turn off NFSv4 idmapping when using 'sec=sys'");
1449 module_param(max_session_slots
, ushort
, 0644);
1450 MODULE_PARM_DESC(max_session_slots
, "Maximum number of outstanding NFSv4.1 "
1451 "requests the client will negotiate");
1452 module_param(max_session_cb_slots
, ushort
, 0644);
1453 MODULE_PARM_DESC(max_session_cb_slots
, "Maximum number of parallel NFSv4.1 "
1454 "callbacks the client will process for a given server");
1455 module_param(send_implementation_id
, ushort
, 0644);
1456 MODULE_PARM_DESC(send_implementation_id
,
1457 "Send implementation ID with NFSv4.1 exchange_id");
1458 MODULE_PARM_DESC(nfs4_unique_id
, "nfs_client_id4 uniquifier string");
1460 module_param(recover_lost_locks
, bool, 0644);
1461 MODULE_PARM_DESC(recover_lost_locks
,
1462 "If the server reports that a lock might be lost, "
1463 "try to recover it risking data corruption.");
1465 module_param_named(delay_retrans
, nfs_delay_retrans
, short, 0644);
1466 MODULE_PARM_DESC(delay_retrans
,
1467 "Unless negative, specifies the number of times the NFSv4 "
1468 "client retries a request before returning an EAGAIN error, "
1469 "after a reply of NFS4ERR_DELAY from the server.");
1470 #endif /* CONFIG_NFS_V4 */