4 * Copyright (C) 1992 Rick Sladkey
6 * nfs superblock handling functions
8 * Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
9 * experimental NFS changes. Modularisation taken straight from SYS5 fs.
11 * Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
12 * J.S.Peatfield@damtp.cam.ac.uk
14 * Split from inode.c by David Howells <dhowells@redhat.com>
16 * - superblocks are indexed on server only - all inodes, dentries, etc. associated with a
17 * particular server are held in the same superblock
18 * - NFS superblocks can have several effective roots to the dentry tree
19 * - directory type roots are spliced into the tree when a path from one root reaches the root
20 * of another (see nfs_lookup())
23 #include <linux/module.h>
24 #include <linux/init.h>
26 #include <linux/time.h>
27 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/stat.h>
31 #include <linux/errno.h>
32 #include <linux/unistd.h>
33 #include <linux/sunrpc/clnt.h>
34 #include <linux/sunrpc/stats.h>
35 #include <linux/sunrpc/metrics.h>
36 #include <linux/sunrpc/xprtsock.h>
37 #include <linux/sunrpc/xprtrdma.h>
38 #include <linux/nfs_fs.h>
39 #include <linux/nfs_mount.h>
40 #include <linux/nfs4_mount.h>
41 #include <linux/lockd/bind.h>
42 #include <linux/smp_lock.h>
43 #include <linux/seq_file.h>
44 #include <linux/mount.h>
45 #include <linux/nfs_idmap.h>
46 #include <linux/vfs.h>
47 #include <linux/inet.h>
48 #include <linux/in6.h>
50 #include <linux/netdevice.h>
51 #include <linux/nfs_xdr.h>
52 #include <linux/magic.h>
53 #include <linux/parser.h>
55 #include <asm/system.h>
56 #include <asm/uaccess.h>
60 #include "delegation.h"
64 #define NFSDBG_FACILITY NFSDBG_VFS
67 /* Mount options that take no arguments */
69 Opt_posix, Opt_noposix,
74 Opt_udp, Opt_tcp, Opt_rdma,
76 Opt_rdirplus, Opt_nordirplus,
77 Opt_sharecache, Opt_nosharecache,
79 /* Mount options that take integer arguments */
81 Opt_rsize, Opt_wsize, Opt_bsize,
82 Opt_timeo, Opt_retrans,
83 Opt_acregmin, Opt_acregmax,
84 Opt_acdirmin, Opt_acdirmax,
91 /* Mount options that take string arguments */
92 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
93 Opt_addr, Opt_mountaddr, Opt_clientaddr,
96 /* Special mount options */
97 Opt_userspace, Opt_deprecated, Opt_sloppy,
102 static const match_table_t nfs_mount_option_tokens = {
103 { Opt_userspace, "bg" },
104 { Opt_userspace, "fg" },
105 { Opt_userspace, "retry=%s" },
107 { Opt_sloppy, "sloppy" },
109 { Opt_soft, "soft" },
110 { Opt_hard, "hard" },
111 { Opt_deprecated, "intr" },
112 { Opt_deprecated, "nointr" },
113 { Opt_posix, "posix" },
114 { Opt_noposix, "noposix" },
116 { Opt_nocto, "nocto" },
118 { Opt_noac, "noac" },
119 { Opt_lock, "lock" },
120 { Opt_nolock, "nolock" },
125 { Opt_rdma, "rdma" },
127 { Opt_noacl, "noacl" },
128 { Opt_rdirplus, "rdirplus" },
129 { Opt_nordirplus, "nordirplus" },
130 { Opt_sharecache, "sharecache" },
131 { Opt_nosharecache, "nosharecache" },
133 { Opt_port, "port=%u" },
134 { Opt_rsize, "rsize=%u" },
135 { Opt_wsize, "wsize=%u" },
136 { Opt_bsize, "bsize=%u" },
137 { Opt_timeo, "timeo=%u" },
138 { Opt_retrans, "retrans=%u" },
139 { Opt_acregmin, "acregmin=%u" },
140 { Opt_acregmax, "acregmax=%u" },
141 { Opt_acdirmin, "acdirmin=%u" },
142 { Opt_acdirmax, "acdirmax=%u" },
143 { Opt_actimeo, "actimeo=%u" },
144 { Opt_namelen, "namlen=%u" },
145 { Opt_mountport, "mountport=%u" },
146 { Opt_mountvers, "mountvers=%u" },
147 { Opt_nfsvers, "nfsvers=%u" },
148 { Opt_nfsvers, "vers=%u" },
150 { Opt_sec, "sec=%s" },
151 { Opt_proto, "proto=%s" },
152 { Opt_mountproto, "mountproto=%s" },
153 { Opt_addr, "addr=%s" },
154 { Opt_clientaddr, "clientaddr=%s" },
155 { Opt_mounthost, "mounthost=%s" },
156 { Opt_mountaddr, "mountaddr=%s" },
158 { Opt_lookupcache, "lookupcache=%s" },
164 Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma,
169 static const match_table_t nfs_xprt_protocol_tokens = {
170 { Opt_xprt_udp, "udp" },
171 { Opt_xprt_tcp, "tcp" },
172 { Opt_xprt_rdma, "rdma" },
174 { Opt_xprt_err, NULL }
178 Opt_sec_none, Opt_sec_sys,
179 Opt_sec_krb5, Opt_sec_krb5i, Opt_sec_krb5p,
180 Opt_sec_lkey, Opt_sec_lkeyi, Opt_sec_lkeyp,
181 Opt_sec_spkm, Opt_sec_spkmi, Opt_sec_spkmp,
186 static const match_table_t nfs_secflavor_tokens = {
187 { Opt_sec_none, "none" },
188 { Opt_sec_none, "null" },
189 { Opt_sec_sys, "sys" },
191 { Opt_sec_krb5, "krb5" },
192 { Opt_sec_krb5i, "krb5i" },
193 { Opt_sec_krb5p, "krb5p" },
195 { Opt_sec_lkey, "lkey" },
196 { Opt_sec_lkeyi, "lkeyi" },
197 { Opt_sec_lkeyp, "lkeyp" },
199 { Opt_sec_spkm, "spkm3" },
200 { Opt_sec_spkmi, "spkm3i" },
201 { Opt_sec_spkmp, "spkm3p" },
203 { Opt_sec_err, NULL }
207 Opt_lookupcache_all, Opt_lookupcache_positive,
208 Opt_lookupcache_none,
213 static match_table_t nfs_lookupcache_tokens = {
214 { Opt_lookupcache_all, "all" },
215 { Opt_lookupcache_positive, "pos" },
216 { Opt_lookupcache_positive, "positive" },
217 { Opt_lookupcache_none, "none" },
219 { Opt_lookupcache_err, NULL }
223 static void nfs_umount_begin(struct super_block *);
224 static int nfs_statfs(struct dentry *, struct kstatfs *);
225 static int nfs_show_options(struct seq_file *, struct vfsmount *);
226 static int nfs_show_stats(struct seq_file *, struct vfsmount *);
227 static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *);
228 static int nfs_xdev_get_sb(struct file_system_type *fs_type,
229 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
230 static void nfs_kill_super(struct super_block *);
231 static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
233 static struct file_system_type nfs_fs_type = {
234 .owner = THIS_MODULE,
236 .get_sb = nfs_get_sb,
237 .kill_sb = nfs_kill_super,
238 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
241 struct file_system_type nfs_xdev_fs_type = {
242 .owner = THIS_MODULE,
244 .get_sb = nfs_xdev_get_sb,
245 .kill_sb = nfs_kill_super,
246 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
249 static const struct super_operations nfs_sops = {
250 .alloc_inode = nfs_alloc_inode,
251 .destroy_inode = nfs_destroy_inode,
252 .write_inode = nfs_write_inode,
253 .statfs = nfs_statfs,
254 .clear_inode = nfs_clear_inode,
255 .umount_begin = nfs_umount_begin,
256 .show_options = nfs_show_options,
257 .show_stats = nfs_show_stats,
258 .remount_fs = nfs_remount,
262 static int nfs4_get_sb(struct file_system_type *fs_type,
263 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
264 static int nfs4_xdev_get_sb(struct file_system_type *fs_type,
265 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
266 static int nfs4_referral_get_sb(struct file_system_type *fs_type,
267 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
268 static void nfs4_kill_super(struct super_block *sb);
270 static struct file_system_type nfs4_fs_type = {
271 .owner = THIS_MODULE,
273 .get_sb = nfs4_get_sb,
274 .kill_sb = nfs4_kill_super,
275 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
278 struct file_system_type nfs4_xdev_fs_type = {
279 .owner = THIS_MODULE,
281 .get_sb = nfs4_xdev_get_sb,
282 .kill_sb = nfs4_kill_super,
283 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
286 struct file_system_type nfs4_referral_fs_type = {
287 .owner = THIS_MODULE,
289 .get_sb = nfs4_referral_get_sb,
290 .kill_sb = nfs4_kill_super,
291 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
294 static const struct super_operations nfs4_sops = {
295 .alloc_inode = nfs_alloc_inode,
296 .destroy_inode = nfs_destroy_inode,
297 .write_inode = nfs_write_inode,
298 .statfs = nfs_statfs,
299 .clear_inode = nfs4_clear_inode,
300 .umount_begin = nfs_umount_begin,
301 .show_options = nfs_show_options,
302 .show_stats = nfs_show_stats,
303 .remount_fs = nfs_remount,
307 static struct shrinker acl_shrinker = {
308 .shrink = nfs_access_cache_shrinker,
309 .seeks = DEFAULT_SEEKS,
313 * Register the NFS filesystems
315 int __init register_nfs_fs(void)
319 ret = register_filesystem(&nfs_fs_type);
323 ret = nfs_register_sysctl();
327 ret = register_filesystem(&nfs4_fs_type);
331 register_shrinker(&acl_shrinker);
336 nfs_unregister_sysctl();
339 unregister_filesystem(&nfs_fs_type);
345 * Unregister the NFS filesystems
347 void __exit unregister_nfs_fs(void)
349 unregister_shrinker(&acl_shrinker);
351 unregister_filesystem(&nfs4_fs_type);
353 nfs_unregister_sysctl();
354 unregister_filesystem(&nfs_fs_type);
357 void nfs_sb_active(struct super_block *sb)
359 struct nfs_server *server = NFS_SB(sb);
361 if (atomic_inc_return(&server->active) == 1)
362 atomic_inc(&sb->s_active);
365 void nfs_sb_deactive(struct super_block *sb)
367 struct nfs_server *server = NFS_SB(sb);
369 if (atomic_dec_and_test(&server->active))
370 deactivate_super(sb);
374 * Deliver file system statistics to userspace
376 static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
378 struct nfs_server *server = NFS_SB(dentry->d_sb);
379 unsigned char blockbits;
380 unsigned long blockres;
381 struct nfs_fh *fh = NFS_FH(dentry->d_inode);
382 struct nfs_fattr fattr;
383 struct nfs_fsstat res = {
388 error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
391 buf->f_type = NFS_SUPER_MAGIC;
394 * Current versions of glibc do not correctly handle the
395 * case where f_frsize != f_bsize. Eventually we want to
396 * report the value of wtmult in this field.
398 buf->f_frsize = dentry->d_sb->s_blocksize;
401 * On most *nix systems, f_blocks, f_bfree, and f_bavail
402 * are reported in units of f_frsize. Linux hasn't had
403 * an f_frsize field in its statfs struct until recently,
404 * thus historically Linux's sys_statfs reports these
405 * fields in units of f_bsize.
407 buf->f_bsize = dentry->d_sb->s_blocksize;
408 blockbits = dentry->d_sb->s_blocksize_bits;
409 blockres = (1 << blockbits) - 1;
410 buf->f_blocks = (res.tbytes + blockres) >> blockbits;
411 buf->f_bfree = (res.fbytes + blockres) >> blockbits;
412 buf->f_bavail = (res.abytes + blockres) >> blockbits;
414 buf->f_files = res.tfiles;
415 buf->f_ffree = res.afiles;
417 buf->f_namelen = server->namelen;
422 dprintk("%s: statfs error = %d\n", __func__, -error);
427 * Map the security flavour number to a name
429 static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
431 static const struct {
432 rpc_authflavor_t flavour;
435 { RPC_AUTH_NULL, "null" },
436 { RPC_AUTH_UNIX, "sys" },
437 { RPC_AUTH_GSS_KRB5, "krb5" },
438 { RPC_AUTH_GSS_KRB5I, "krb5i" },
439 { RPC_AUTH_GSS_KRB5P, "krb5p" },
440 { RPC_AUTH_GSS_LKEY, "lkey" },
441 { RPC_AUTH_GSS_LKEYI, "lkeyi" },
442 { RPC_AUTH_GSS_LKEYP, "lkeyp" },
443 { RPC_AUTH_GSS_SPKM, "spkm" },
444 { RPC_AUTH_GSS_SPKMI, "spkmi" },
445 { RPC_AUTH_GSS_SPKMP, "spkmp" },
446 { UINT_MAX, "unknown" }
450 for (i = 0; sec_flavours[i].flavour != UINT_MAX; i++) {
451 if (sec_flavours[i].flavour == flavour)
454 return sec_flavours[i].str;
457 static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
460 struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address;
462 switch (sap->sa_family) {
464 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
465 seq_printf(m, ",mountaddr=" NIPQUAD_FMT,
466 NIPQUAD(sin->sin_addr.s_addr));
470 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
471 seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr);
476 seq_printf(m, ",mountaddr=unspecified");
479 if (nfss->mountd_version || showdefaults)
480 seq_printf(m, ",mountvers=%u", nfss->mountd_version);
481 if (nfss->mountd_port || showdefaults)
482 seq_printf(m, ",mountport=%u", nfss->mountd_port);
484 switch (nfss->mountd_protocol) {
486 seq_printf(m, ",mountproto=udp");
489 seq_printf(m, ",mountproto=tcp");
493 seq_printf(m, ",mountproto=auto");
498 * Describe the mount options in force on this server representation
500 static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
503 static const struct proc_nfs_info {
508 { NFS_MOUNT_SOFT, ",soft", ",hard" },
509 { NFS_MOUNT_INTR, ",intr", ",nointr" },
510 { NFS_MOUNT_POSIX, ",posix", "" },
511 { NFS_MOUNT_NOCTO, ",nocto", "" },
512 { NFS_MOUNT_NOAC, ",noac", "" },
513 { NFS_MOUNT_NONLM, ",nolock", "" },
514 { NFS_MOUNT_NOACL, ",noacl", "" },
515 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
516 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
519 const struct proc_nfs_info *nfs_infop;
520 struct nfs_client *clp = nfss->nfs_client;
521 u32 version = clp->rpc_ops->version;
523 seq_printf(m, ",vers=%u", version);
524 seq_printf(m, ",rsize=%u", nfss->rsize);
525 seq_printf(m, ",wsize=%u", nfss->wsize);
526 if (nfss->bsize != 0)
527 seq_printf(m, ",bsize=%u", nfss->bsize);
528 seq_printf(m, ",namlen=%u", nfss->namelen);
529 if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults)
530 seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
531 if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults)
532 seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
533 if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults)
534 seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
535 if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults)
536 seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
537 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
538 if (nfss->flags & nfs_infop->flag)
539 seq_puts(m, nfs_infop->str);
541 seq_puts(m, nfs_infop->nostr);
543 seq_printf(m, ",proto=%s",
544 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
546 if (nfss->port != NFS_PORT)
547 seq_printf(m, ",port=%u", nfss->port);
550 seq_printf(m, ",port=%u", nfss->port);
552 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
553 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
554 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
557 nfs_show_mountd_options(m, nfss, showdefaults);
560 if (clp->rpc_ops->version == 4)
561 seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
566 * Describe the mount options on this VFS mountpoint
568 static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
570 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
572 nfs_show_mount_options(m, nfss, 0);
574 seq_printf(m, ",addr=%s",
575 rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient,
582 * Present statistical information for this VFS mountpoint
584 static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
587 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
588 struct rpc_auth *auth = nfss->client->cl_auth;
589 struct nfs_iostats totals = { };
591 seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS);
594 * Display all mount option settings
596 seq_printf(m, "\n\topts:\t");
597 seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw");
598 seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : "");
599 seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : "");
600 seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : "");
601 nfs_show_mount_options(m, nfss, 1);
603 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ);
605 seq_printf(m, "\n\tcaps:\t");
606 seq_printf(m, "caps=0x%x", nfss->caps);
607 seq_printf(m, ",wtmult=%u", nfss->wtmult);
608 seq_printf(m, ",dtsize=%u", nfss->dtsize);
609 seq_printf(m, ",bsize=%u", nfss->bsize);
610 seq_printf(m, ",namlen=%u", nfss->namelen);
613 if (nfss->nfs_client->rpc_ops->version == 4) {
614 seq_printf(m, "\n\tnfsv4:\t");
615 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
616 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
617 seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
622 * Display security flavor in effect for this mount
624 seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
626 seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
629 * Display superblock I/O counters
631 for_each_possible_cpu(cpu) {
632 struct nfs_iostats *stats;
635 stats = per_cpu_ptr(nfss->io_stats, cpu);
637 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
638 totals.events[i] += stats->events[i];
639 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
640 totals.bytes[i] += stats->bytes[i];
645 seq_printf(m, "\n\tevents:\t");
646 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
647 seq_printf(m, "%lu ", totals.events[i]);
648 seq_printf(m, "\n\tbytes:\t");
649 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
650 seq_printf(m, "%Lu ", totals.bytes[i]);
653 rpc_print_iostats(m, nfss->client);
659 * Begin unmount by attempting to remove all automounted mountpoints we added
660 * in response to xdev traversals and referrals
662 static void nfs_umount_begin(struct super_block *sb)
664 struct nfs_server *server = NFS_SB(sb);
665 struct rpc_clnt *rpc;
667 /* -EIO all pending I/O */
668 rpc = server->client_acl;
670 rpc_killall_tasks(rpc);
671 rpc = server->client;
673 rpc_killall_tasks(rpc);
677 * Sanity-check a server address provided by the mount command.
679 * Address family must be initialized, and address must not be
680 * the ANY address for that family.
682 static int nfs_verify_server_address(struct sockaddr *addr)
684 switch (addr->sa_family) {
686 struct sockaddr_in *sa = (struct sockaddr_in *)addr;
687 return sa->sin_addr.s_addr != htonl(INADDR_ANY);
690 struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
691 return !ipv6_addr_any(sa);
698 static void nfs_parse_ipv4_address(char *string, size_t str_len,
699 struct sockaddr *sap, size_t *addr_len)
701 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
702 u8 *addr = (u8 *)&sin->sin_addr.s_addr;
704 if (str_len <= INET_ADDRSTRLEN) {
705 dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n",
706 (int)str_len, string);
708 sin->sin_family = AF_INET;
709 *addr_len = sizeof(*sin);
710 if (in4_pton(string, str_len, addr, '\0', NULL))
714 sap->sa_family = AF_UNSPEC;
718 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
719 static int nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
721 struct sockaddr_in6 *sin6)
726 if ((string + str_len) == delim)
729 if (*delim != IPV6_SCOPE_DELIMITER)
732 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
735 len = (string + str_len) - delim - 1;
736 p = kstrndup(delim + 1, len, GFP_KERNEL);
738 unsigned long scope_id = 0;
739 struct net_device *dev;
741 dev = dev_get_by_name(&init_net, p);
743 scope_id = dev->ifindex;
746 if (strict_strtoul(p, 10, &scope_id) == 0) {
754 sin6->sin6_scope_id = scope_id;
755 dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id);
762 static void nfs_parse_ipv6_address(char *string, size_t str_len,
763 struct sockaddr *sap, size_t *addr_len)
765 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
766 u8 *addr = (u8 *)&sin6->sin6_addr.in6_u;
769 if (str_len <= INET6_ADDRSTRLEN) {
770 dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n",
771 (int)str_len, string);
773 sin6->sin6_family = AF_INET6;
774 *addr_len = sizeof(*sin6);
775 if (in6_pton(string, str_len, addr,
776 IPV6_SCOPE_DELIMITER, &delim) != 0) {
777 if (nfs_parse_ipv6_scope_id(string, str_len,
783 sap->sa_family = AF_UNSPEC;
787 static void nfs_parse_ipv6_address(char *string, size_t str_len,
788 struct sockaddr *sap, size_t *addr_len)
790 sap->sa_family = AF_UNSPEC;
796 * Construct a sockaddr based on the contents of a string that contains
797 * an IP address in presentation format.
799 * If there is a problem constructing the new sockaddr, set the address
800 * family to AF_UNSPEC.
802 void nfs_parse_ip_address(char *string, size_t str_len,
803 struct sockaddr *sap, size_t *addr_len)
805 unsigned int i, colons;
808 for (i = 0; i < str_len; i++)
809 if (string[i] == ':')
813 nfs_parse_ipv6_address(string, str_len, sap, addr_len);
815 nfs_parse_ipv4_address(string, str_len, sap, addr_len);
819 * Sanity check the NFS transport protocol.
822 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
824 switch (mnt->nfs_server.protocol) {
825 case XPRT_TRANSPORT_UDP:
826 case XPRT_TRANSPORT_TCP:
827 case XPRT_TRANSPORT_RDMA:
830 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
835 * For text based NFSv2/v3 mounts, the mount protocol transport default
836 * settings should depend upon the specified NFS transport.
838 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
840 nfs_validate_transport_protocol(mnt);
842 if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
843 mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
845 switch (mnt->nfs_server.protocol) {
846 case XPRT_TRANSPORT_UDP:
847 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
849 case XPRT_TRANSPORT_TCP:
850 case XPRT_TRANSPORT_RDMA:
851 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
856 * Parse the value of the 'sec=' option.
858 * The flavor_len setting is for v4 mounts.
860 static int nfs_parse_security_flavors(char *value,
861 struct nfs_parsed_mount_data *mnt)
863 substring_t args[MAX_OPT_ARGS];
865 dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value);
867 switch (match_token(value, nfs_secflavor_tokens, args)) {
869 mnt->auth_flavor_len = 0;
870 mnt->auth_flavors[0] = RPC_AUTH_NULL;
873 mnt->auth_flavor_len = 0;
874 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
877 mnt->auth_flavor_len = 1;
878 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
881 mnt->auth_flavor_len = 1;
882 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
885 mnt->auth_flavor_len = 1;
886 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
889 mnt->auth_flavor_len = 1;
890 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
893 mnt->auth_flavor_len = 1;
894 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
897 mnt->auth_flavor_len = 1;
898 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
901 mnt->auth_flavor_len = 1;
902 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
905 mnt->auth_flavor_len = 1;
906 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
909 mnt->auth_flavor_len = 1;
910 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
919 static void nfs_parse_invalid_value(const char *option)
921 dfprintk(MOUNT, "NFS: bad value specified for %s option\n", option);
925 * Error-check and convert a string of mount options from user space into
926 * a data structure. The whole mount string is processed; bad options are
927 * skipped as they are encountered. If there were no errors, return 1;
928 * otherwise return 0 (zero).
930 static int nfs_parse_mount_options(char *raw,
931 struct nfs_parsed_mount_data *mnt)
933 char *p, *string, *secdata;
934 int rc, sloppy = 0, errors = 0;
937 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
940 dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
942 secdata = alloc_secdata();
946 rc = security_sb_copy_data(raw, secdata);
948 goto out_security_failure;
950 rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
952 goto out_security_failure;
954 free_secdata(secdata);
956 while ((p = strsep(&raw, ",")) != NULL) {
957 substring_t args[MAX_OPT_ARGS];
963 dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p);
965 token = match_token(p, nfs_mount_option_tokens, args);
969 * boolean options: foo/nofoo
972 mnt->flags |= NFS_MOUNT_SOFT;
975 mnt->flags &= ~NFS_MOUNT_SOFT;
978 mnt->flags |= NFS_MOUNT_POSIX;
981 mnt->flags &= ~NFS_MOUNT_POSIX;
984 mnt->flags &= ~NFS_MOUNT_NOCTO;
987 mnt->flags |= NFS_MOUNT_NOCTO;
990 mnt->flags &= ~NFS_MOUNT_NOAC;
993 mnt->flags |= NFS_MOUNT_NOAC;
996 mnt->flags &= ~NFS_MOUNT_NONLM;
999 mnt->flags |= NFS_MOUNT_NONLM;
1002 mnt->flags &= ~NFS_MOUNT_VER3;
1005 mnt->flags |= NFS_MOUNT_VER3;
1008 mnt->flags &= ~NFS_MOUNT_TCP;
1009 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1012 mnt->flags |= NFS_MOUNT_TCP;
1013 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1016 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
1017 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1020 mnt->flags &= ~NFS_MOUNT_NOACL;
1023 mnt->flags |= NFS_MOUNT_NOACL;
1026 mnt->flags &= ~NFS_MOUNT_NORDIRPLUS;
1028 case Opt_nordirplus:
1029 mnt->flags |= NFS_MOUNT_NORDIRPLUS;
1031 case Opt_sharecache:
1032 mnt->flags &= ~NFS_MOUNT_UNSHARED;
1034 case Opt_nosharecache:
1035 mnt->flags |= NFS_MOUNT_UNSHARED;
1039 * options that take numeric values
1042 if (match_int(args, &option) ||
1043 option < 0 || option > USHORT_MAX) {
1045 nfs_parse_invalid_value("port");
1047 mnt->nfs_server.port = option;
1050 if (match_int(args, &option) || option < 0) {
1052 nfs_parse_invalid_value("rsize");
1054 mnt->rsize = option;
1057 if (match_int(args, &option) || option < 0) {
1059 nfs_parse_invalid_value("wsize");
1061 mnt->wsize = option;
1064 if (match_int(args, &option) || option < 0) {
1066 nfs_parse_invalid_value("bsize");
1068 mnt->bsize = option;
1071 if (match_int(args, &option) || option <= 0) {
1073 nfs_parse_invalid_value("timeo");
1075 mnt->timeo = option;
1078 if (match_int(args, &option) || option <= 0) {
1080 nfs_parse_invalid_value("retrans");
1082 mnt->retrans = option;
1085 if (match_int(args, &option) || option < 0) {
1087 nfs_parse_invalid_value("acregmin");
1089 mnt->acregmin = option;
1092 if (match_int(args, &option) || option < 0) {
1094 nfs_parse_invalid_value("acregmax");
1096 mnt->acregmax = option;
1099 if (match_int(args, &option) || option < 0) {
1101 nfs_parse_invalid_value("acdirmin");
1103 mnt->acdirmin = option;
1106 if (match_int(args, &option) || option < 0) {
1108 nfs_parse_invalid_value("acdirmax");
1110 mnt->acdirmax = option;
1113 if (match_int(args, &option) || option < 0) {
1115 nfs_parse_invalid_value("actimeo");
1117 mnt->acregmin = mnt->acregmax =
1118 mnt->acdirmin = mnt->acdirmax = option;
1121 if (match_int(args, &option) || option < 0) {
1123 nfs_parse_invalid_value("namlen");
1125 mnt->namlen = option;
1128 if (match_int(args, &option) ||
1129 option < 0 || option > USHORT_MAX) {
1131 nfs_parse_invalid_value("mountport");
1133 mnt->mount_server.port = option;
1136 if (match_int(args, &option) ||
1137 option < NFS_MNT_VERSION ||
1138 option > NFS_MNT3_VERSION) {
1140 nfs_parse_invalid_value("mountvers");
1142 mnt->mount_server.version = option;
1145 if (match_int(args, &option)) {
1147 nfs_parse_invalid_value("nfsvers");
1152 mnt->flags &= ~NFS_MOUNT_VER3;
1155 mnt->flags |= NFS_MOUNT_VER3;
1159 nfs_parse_invalid_value("nfsvers");
1164 * options that take text values
1167 string = match_strdup(args);
1170 rc = nfs_parse_security_flavors(string, mnt);
1174 dfprintk(MOUNT, "NFS: unrecognized "
1175 "security flavor\n");
1179 string = match_strdup(args);
1182 token = match_token(string,
1183 nfs_xprt_protocol_tokens, args);
1188 mnt->flags &= ~NFS_MOUNT_TCP;
1189 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1192 mnt->flags |= NFS_MOUNT_TCP;
1193 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1196 /* vector side protocols to TCP */
1197 mnt->flags |= NFS_MOUNT_TCP;
1198 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1202 dfprintk(MOUNT, "NFS: unrecognized "
1203 "transport protocol\n");
1206 case Opt_mountproto:
1207 string = match_strdup(args);
1210 token = match_token(string,
1211 nfs_xprt_protocol_tokens, args);
1216 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
1219 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
1221 case Opt_xprt_rdma: /* not used for side protocols */
1224 dfprintk(MOUNT, "NFS: unrecognized "
1225 "transport protocol\n");
1229 string = match_strdup(args);
1232 nfs_parse_ip_address(string, strlen(string),
1234 &mnt->nfs_server.address,
1235 &mnt->nfs_server.addrlen);
1238 case Opt_clientaddr:
1239 string = match_strdup(args);
1242 kfree(mnt->client_address);
1243 mnt->client_address = string;
1246 string = match_strdup(args);
1249 kfree(mnt->mount_server.hostname);
1250 mnt->mount_server.hostname = string;
1253 string = match_strdup(args);
1256 nfs_parse_ip_address(string, strlen(string),
1258 &mnt->mount_server.address,
1259 &mnt->mount_server.addrlen);
1262 case Opt_lookupcache:
1263 string = match_strdup(args);
1266 token = match_token(string,
1267 nfs_lookupcache_tokens, args);
1270 case Opt_lookupcache_all:
1271 mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
1273 case Opt_lookupcache_positive:
1274 mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
1275 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
1277 case Opt_lookupcache_none:
1278 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
1282 dfprintk(MOUNT, "NFS: invalid "
1283 "lookupcache argument\n");
1292 dfprintk(MOUNT, "NFS: relaxing parsing rules\n");
1295 case Opt_deprecated:
1296 dfprintk(MOUNT, "NFS: ignoring mount option "
1302 dfprintk(MOUNT, "NFS: unrecognized mount option "
1308 dfprintk(MOUNT, "NFS: parsing encountered %d error%s\n",
1309 errors, (errors == 1 ? "" : "s"));
1316 printk(KERN_INFO "NFS: not enough memory to parse option\n");
1318 out_security_failure:
1319 free_secdata(secdata);
1320 printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
1325 * Use the remote server's MOUNT service to request the NFS file handle
1326 * corresponding to the provided path.
1328 static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1329 struct nfs_fh *root_fh)
1331 struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address;
1335 if (args->mount_server.version == 0) {
1336 if (args->flags & NFS_MOUNT_VER3)
1337 args->mount_server.version = NFS_MNT3_VERSION;
1339 args->mount_server.version = NFS_MNT_VERSION;
1342 if (args->mount_server.hostname)
1343 hostname = args->mount_server.hostname;
1345 hostname = args->nfs_server.hostname;
1348 * Construct the mount server's address.
1350 if (args->mount_server.address.ss_family == AF_UNSPEC) {
1351 memcpy(sap, &args->nfs_server.address,
1352 args->nfs_server.addrlen);
1353 args->mount_server.addrlen = args->nfs_server.addrlen;
1357 * autobind will be used if mount_server.port == 0
1359 nfs_set_port(sap, args->mount_server.port);
1362 * Now ask the mount server to map our export path
1365 status = nfs_mount(sap,
1366 args->mount_server.addrlen,
1368 args->nfs_server.export_path,
1369 args->mount_server.version,
1370 args->mount_server.protocol,
1375 dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
1380 static int nfs_parse_simple_hostname(const char *dev_name,
1381 char **hostname, size_t maxnamlen,
1382 char **export_path, size_t maxpathlen)
1385 char *colon, *comma;
1387 colon = strchr(dev_name, ':');
1389 goto out_bad_devname;
1391 len = colon - dev_name;
1392 if (len > maxnamlen)
1395 /* N.B. caller will free nfs_server.hostname in all cases */
1396 *hostname = kstrndup(dev_name, len, GFP_KERNEL);
1400 /* kill possible hostname list: not supported */
1401 comma = strchr(*hostname, ',');
1402 if (comma != NULL) {
1403 if (comma == *hostname)
1404 goto out_bad_devname;
1409 len = strlen(colon);
1410 if (len > maxpathlen)
1412 *export_path = kstrndup(colon, len, GFP_KERNEL);
1416 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path);
1420 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1424 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1428 dfprintk(MOUNT, "NFS: server hostname too long\n");
1429 return -ENAMETOOLONG;
1432 dfprintk(MOUNT, "NFS: export pathname too long\n");
1433 return -ENAMETOOLONG;
1437 * Hostname has square brackets around it because it contains one or
1438 * more colons. We look for the first closing square bracket, and a
1439 * colon must follow it.
1441 static int nfs_parse_protected_hostname(const char *dev_name,
1442 char **hostname, size_t maxnamlen,
1443 char **export_path, size_t maxpathlen)
1448 start = (char *)(dev_name + 1);
1450 end = strchr(start, ']');
1452 goto out_bad_devname;
1453 if (*(end + 1) != ':')
1454 goto out_bad_devname;
1457 if (len > maxnamlen)
1460 /* N.B. caller will free nfs_server.hostname in all cases */
1461 *hostname = kstrndup(start, len, GFP_KERNEL);
1462 if (*hostname == NULL)
1467 if (len > maxpathlen)
1469 *export_path = kstrndup(end, len, GFP_KERNEL);
1476 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1480 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1484 dfprintk(MOUNT, "NFS: server hostname too long\n");
1485 return -ENAMETOOLONG;
1488 dfprintk(MOUNT, "NFS: export pathname too long\n");
1489 return -ENAMETOOLONG;
1493 * Split "dev_name" into "hostname:export_path".
1495 * The leftmost colon demarks the split between the server's hostname
1496 * and the export path. If the hostname starts with a left square
1497 * bracket, then it may contain colons.
1499 * Note: caller frees hostname and export path, even on error.
1501 static int nfs_parse_devname(const char *dev_name,
1502 char **hostname, size_t maxnamlen,
1503 char **export_path, size_t maxpathlen)
1505 if (*dev_name == '[')
1506 return nfs_parse_protected_hostname(dev_name,
1507 hostname, maxnamlen,
1508 export_path, maxpathlen);
1510 return nfs_parse_simple_hostname(dev_name,
1511 hostname, maxnamlen,
1512 export_path, maxpathlen);
1516 * Validate the NFS2/NFS3 mount data
1517 * - fills in the mount root filehandle
1519 * For option strings, user space handles the following behaviors:
1521 * + DNS: mapping server host name to IP address ("addr=" option)
1523 * + failure mode: how to behave if a mount request can't be handled
1524 * immediately ("fg/bg" option)
1526 * + retry: how often to retry a mount request ("retry=" option)
1528 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1529 * mountproto=tcp after mountproto=udp, and so on
1531 static int nfs_validate_mount_data(void *options,
1532 struct nfs_parsed_mount_data *args,
1533 struct nfs_fh *mntfh,
1534 const char *dev_name)
1536 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
1541 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1542 args->rsize = NFS_MAX_FILE_IO_SIZE;
1543 args->wsize = NFS_MAX_FILE_IO_SIZE;
1544 args->acregmin = NFS_DEF_ACREGMIN;
1545 args->acregmax = NFS_DEF_ACREGMAX;
1546 args->acdirmin = NFS_DEF_ACDIRMIN;
1547 args->acdirmax = NFS_DEF_ACDIRMAX;
1548 args->mount_server.port = 0; /* autobind unless user sets port */
1549 args->nfs_server.port = 0; /* autobind unless user sets port */
1550 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1551 args->auth_flavors[0] = RPC_AUTH_UNIX;
1553 switch (data->version) {
1559 if (data->flags & NFS_MOUNT_VER3)
1561 data->root.size = NFS2_FHSIZE;
1562 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1564 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1567 memset(data->context, 0, sizeof(data->context));
1569 if (data->flags & NFS_MOUNT_VER3) {
1570 if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
1571 goto out_invalid_fh;
1572 mntfh->size = data->root.size;
1574 mntfh->size = NFS2_FHSIZE;
1577 memcpy(mntfh->data, data->root.data, mntfh->size);
1578 if (mntfh->size < sizeof(mntfh->data))
1579 memset(mntfh->data + mntfh->size, 0,
1580 sizeof(mntfh->data) - mntfh->size);
1583 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1586 args->flags = data->flags & NFS_MOUNT_FLAGMASK;
1587 args->rsize = data->rsize;
1588 args->wsize = data->wsize;
1589 args->timeo = data->timeo;
1590 args->retrans = data->retrans;
1591 args->acregmin = data->acregmin;
1592 args->acregmax = data->acregmax;
1593 args->acdirmin = data->acdirmin;
1594 args->acdirmax = data->acdirmax;
1596 memcpy(&args->nfs_server.address, &data->addr,
1597 sizeof(data->addr));
1598 args->nfs_server.addrlen = sizeof(data->addr);
1599 if (!nfs_verify_server_address((struct sockaddr *)
1600 &args->nfs_server.address))
1601 goto out_no_address;
1603 if (!(data->flags & NFS_MOUNT_TCP))
1604 args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1605 /* N.B. caller will free nfs_server.hostname in all cases */
1606 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1607 args->namlen = data->namlen;
1608 args->bsize = data->bsize;
1610 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1611 args->auth_flavors[0] = data->pseudoflavor;
1612 if (!args->nfs_server.hostname)
1616 * The legacy version 6 binary mount data from userspace has a
1617 * field used only to transport selinux information into the
1618 * the kernel. To continue to support that functionality we
1619 * have a touch of selinux knowledge here in the NFS code. The
1620 * userspace code converted context=blah to just blah so we are
1621 * converting back to the full string selinux understands.
1623 if (data->context[0]){
1624 #ifdef CONFIG_SECURITY_SELINUX
1626 char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
1629 strcpy(opts_str, "context=");
1630 data->context[NFS_MAX_CONTEXT_LEN] = '\0';
1631 strcat(opts_str, &data->context[0]);
1632 rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
1645 if (nfs_parse_mount_options((char *)options, args) == 0)
1648 if (!nfs_verify_server_address((struct sockaddr *)
1649 &args->nfs_server.address))
1650 goto out_no_address;
1652 nfs_set_port((struct sockaddr *)&args->nfs_server.address,
1653 args->nfs_server.port);
1655 nfs_set_mount_transport_protocol(args);
1657 status = nfs_parse_devname(dev_name,
1658 &args->nfs_server.hostname,
1660 &args->nfs_server.export_path,
1663 status = nfs_try_mount(args, mntfh);
1665 kfree(args->nfs_server.export_path);
1666 args->nfs_server.export_path = NULL;
1675 #ifndef CONFIG_NFS_V3
1676 if (args->flags & NFS_MOUNT_VER3)
1677 goto out_v3_not_compiled;
1678 #endif /* !CONFIG_NFS_V3 */
1683 dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n");
1687 dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n",
1692 dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1695 #ifndef CONFIG_NFS_V3
1696 out_v3_not_compiled:
1697 dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n");
1698 return -EPROTONOSUPPORT;
1699 #endif /* !CONFIG_NFS_V3 */
1702 dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
1706 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
1710 dfprintk(MOUNT, "NFS: invalid root filehandle\n");
1715 nfs_compare_remount_data(struct nfs_server *nfss,
1716 struct nfs_parsed_mount_data *data)
1718 if (data->flags != nfss->flags ||
1719 data->rsize != nfss->rsize ||
1720 data->wsize != nfss->wsize ||
1721 data->retrans != nfss->client->cl_timeout->to_retries ||
1722 data->auth_flavors[0] != nfss->client->cl_auth->au_flavor ||
1723 data->acregmin != nfss->acregmin / HZ ||
1724 data->acregmax != nfss->acregmax / HZ ||
1725 data->acdirmin != nfss->acdirmin / HZ ||
1726 data->acdirmax != nfss->acdirmax / HZ ||
1727 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
1728 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
1729 memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1730 data->nfs_server.addrlen) != 0)
1737 nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1740 struct nfs_server *nfss = sb->s_fs_info;
1741 struct nfs_parsed_mount_data *data;
1742 struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data;
1743 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
1744 u32 nfsvers = nfss->nfs_client->rpc_ops->version;
1747 * Userspace mount programs that send binary options generally send
1748 * them populated with default values. We have no way to know which
1749 * ones were explicitly specified. Fall back to legacy behavior and
1750 * just return success.
1752 if ((nfsvers == 4 && (!options4 || options4->version == 1)) ||
1753 (nfsvers <= 3 && (!options || (options->version >= 1 &&
1754 options->version <= 6))))
1757 data = kzalloc(sizeof(*data), GFP_KERNEL);
1761 /* fill out struct with values from existing mount */
1762 data->flags = nfss->flags;
1763 data->rsize = nfss->rsize;
1764 data->wsize = nfss->wsize;
1765 data->retrans = nfss->client->cl_timeout->to_retries;
1766 data->auth_flavors[0] = nfss->client->cl_auth->au_flavor;
1767 data->acregmin = nfss->acregmin / HZ;
1768 data->acregmax = nfss->acregmax / HZ;
1769 data->acdirmin = nfss->acdirmin / HZ;
1770 data->acdirmax = nfss->acdirmax / HZ;
1771 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
1772 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
1773 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1774 data->nfs_server.addrlen);
1776 /* overwrite those values with any that were specified */
1777 error = nfs_parse_mount_options((char *)options, data);
1781 /* compare new mount options with old ones */
1782 error = nfs_compare_remount_data(nfss, data);
1789 * Initialise the common bits of the superblock
1791 static inline void nfs_initialise_sb(struct super_block *sb)
1793 struct nfs_server *server = NFS_SB(sb);
1795 sb->s_magic = NFS_SUPER_MAGIC;
1797 /* We probably want something more informative here */
1798 snprintf(sb->s_id, sizeof(sb->s_id),
1799 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
1801 if (sb->s_blocksize == 0)
1802 sb->s_blocksize = nfs_block_bits(server->wsize,
1803 &sb->s_blocksize_bits);
1805 if (server->flags & NFS_MOUNT_NOAC)
1806 sb->s_flags |= MS_SYNCHRONOUS;
1808 nfs_super_set_maxbytes(sb, server->maxfilesize);
1812 * Finish setting up an NFS2/3 superblock
1814 static void nfs_fill_super(struct super_block *sb,
1815 struct nfs_parsed_mount_data *data)
1817 struct nfs_server *server = NFS_SB(sb);
1819 sb->s_blocksize_bits = 0;
1820 sb->s_blocksize = 0;
1822 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
1824 if (server->flags & NFS_MOUNT_VER3) {
1825 /* The VFS shouldn't apply the umask to mode bits. We will do
1826 * so ourselves when necessary.
1828 sb->s_flags |= MS_POSIXACL;
1829 sb->s_time_gran = 1;
1832 sb->s_op = &nfs_sops;
1833 nfs_initialise_sb(sb);
1837 * Finish setting up a cloned NFS2/3 superblock
1839 static void nfs_clone_super(struct super_block *sb,
1840 const struct super_block *old_sb)
1842 struct nfs_server *server = NFS_SB(sb);
1844 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
1845 sb->s_blocksize = old_sb->s_blocksize;
1846 sb->s_maxbytes = old_sb->s_maxbytes;
1848 if (server->flags & NFS_MOUNT_VER3) {
1849 /* The VFS shouldn't apply the umask to mode bits. We will do
1850 * so ourselves when necessary.
1852 sb->s_flags |= MS_POSIXACL;
1853 sb->s_time_gran = 1;
1856 sb->s_op = old_sb->s_op;
1857 nfs_initialise_sb(sb);
1860 #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
1862 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
1864 const struct nfs_server *a = s->s_fs_info;
1865 const struct rpc_clnt *clnt_a = a->client;
1866 const struct rpc_clnt *clnt_b = b->client;
1868 if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK))
1870 if (a->nfs_client != b->nfs_client)
1872 if (a->flags != b->flags)
1874 if (a->wsize != b->wsize)
1876 if (a->rsize != b->rsize)
1878 if (a->acregmin != b->acregmin)
1880 if (a->acregmax != b->acregmax)
1882 if (a->acdirmin != b->acdirmin)
1884 if (a->acdirmax != b->acdirmax)
1886 if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
1893 struct nfs_sb_mountdata {
1894 struct nfs_server *server;
1898 static int nfs_set_super(struct super_block *s, void *data)
1900 struct nfs_sb_mountdata *sb_mntdata = data;
1901 struct nfs_server *server = sb_mntdata->server;
1904 s->s_flags = sb_mntdata->mntflags;
1905 s->s_fs_info = server;
1906 ret = set_anon_super(s, server);
1908 server->s_dev = s->s_dev;
1912 static int nfs_compare_super_address(struct nfs_server *server1,
1913 struct nfs_server *server2)
1915 struct sockaddr *sap1, *sap2;
1917 sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr;
1918 sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr;
1920 if (sap1->sa_family != sap2->sa_family)
1923 switch (sap1->sa_family) {
1925 struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1;
1926 struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2;
1927 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
1929 if (sin1->sin_port != sin2->sin_port)
1934 struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1;
1935 struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2;
1936 if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
1938 if (sin1->sin6_port != sin2->sin6_port)
1949 static int nfs_compare_super(struct super_block *sb, void *data)
1951 struct nfs_sb_mountdata *sb_mntdata = data;
1952 struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
1953 int mntflags = sb_mntdata->mntflags;
1955 if (!nfs_compare_super_address(old, server))
1957 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
1958 if (old->flags & NFS_MOUNT_UNSHARED)
1960 if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
1962 return nfs_compare_mount_options(sb, server, mntflags);
1965 static int nfs_bdi_register(struct nfs_server *server)
1967 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
1970 static int nfs_get_sb(struct file_system_type *fs_type,
1971 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
1973 struct nfs_server *server = NULL;
1974 struct super_block *s;
1975 struct nfs_parsed_mount_data *data;
1976 struct nfs_fh *mntfh;
1977 struct dentry *mntroot;
1978 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
1979 struct nfs_sb_mountdata sb_mntdata = {
1982 int error = -ENOMEM;
1984 data = kzalloc(sizeof(*data), GFP_KERNEL);
1985 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
1986 if (data == NULL || mntfh == NULL)
1989 security_init_mnt_opts(&data->lsm_opts);
1991 /* Validate the mount data */
1992 error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
1996 /* Get a volume representation */
1997 server = nfs_create_server(data, mntfh);
1998 if (IS_ERR(server)) {
1999 error = PTR_ERR(server);
2002 sb_mntdata.server = server;
2004 if (server->flags & NFS_MOUNT_UNSHARED)
2005 compare_super = NULL;
2007 /* Get a superblock - note that we may end up sharing one that already exists */
2008 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
2014 if (s->s_fs_info != server) {
2015 nfs_free_server(server);
2018 error = nfs_bdi_register(server);
2020 goto error_splat_super;
2024 /* initial superblock/root creation */
2025 nfs_fill_super(s, data);
2028 mntroot = nfs_get_root(s, mntfh);
2029 if (IS_ERR(mntroot)) {
2030 error = PTR_ERR(mntroot);
2031 goto error_splat_super;
2034 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
2036 goto error_splat_root;
2038 s->s_flags |= MS_ACTIVE;
2040 mnt->mnt_root = mntroot;
2044 kfree(data->nfs_server.hostname);
2045 kfree(data->mount_server.hostname);
2046 security_free_mnt_opts(&data->lsm_opts);
2053 nfs_free_server(server);
2059 up_write(&s->s_umount);
2060 deactivate_super(s);
2065 * Destroy an NFS2/3 superblock
2067 static void nfs_kill_super(struct super_block *s)
2069 struct nfs_server *server = NFS_SB(s);
2071 bdi_unregister(&server->backing_dev_info);
2073 nfs_free_server(server);
2077 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2079 static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
2080 const char *dev_name, void *raw_data,
2081 struct vfsmount *mnt)
2083 struct nfs_clone_mount *data = raw_data;
2084 struct super_block *s;
2085 struct nfs_server *server;
2086 struct dentry *mntroot;
2087 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2088 struct nfs_sb_mountdata sb_mntdata = {
2093 dprintk("--> nfs_xdev_get_sb()\n");
2095 /* create a new volume representation */
2096 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
2097 if (IS_ERR(server)) {
2098 error = PTR_ERR(server);
2099 goto out_err_noserver;
2101 sb_mntdata.server = server;
2103 if (server->flags & NFS_MOUNT_UNSHARED)
2104 compare_super = NULL;
2106 /* Get a superblock - note that we may end up sharing one that already exists */
2107 s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2113 if (s->s_fs_info != server) {
2114 nfs_free_server(server);
2117 error = nfs_bdi_register(server);
2119 goto error_splat_super;
2123 /* initial superblock/root creation */
2124 nfs_clone_super(s, data->sb);
2127 mntroot = nfs_get_root(s, data->fh);
2128 if (IS_ERR(mntroot)) {
2129 error = PTR_ERR(mntroot);
2130 goto error_splat_super;
2132 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2135 goto error_splat_super;
2138 s->s_flags |= MS_ACTIVE;
2140 mnt->mnt_root = mntroot;
2142 /* clone any lsm security options from the parent to the new sb */
2143 security_sb_clone_mnt_opts(data->sb, s);
2145 dprintk("<-- nfs_xdev_get_sb() = 0\n");
2149 nfs_free_server(server);
2151 dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error);
2155 up_write(&s->s_umount);
2156 deactivate_super(s);
2157 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
2161 #ifdef CONFIG_NFS_V4
2164 * Finish setting up a cloned NFS4 superblock
2166 static void nfs4_clone_super(struct super_block *sb,
2167 const struct super_block *old_sb)
2169 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
2170 sb->s_blocksize = old_sb->s_blocksize;
2171 sb->s_maxbytes = old_sb->s_maxbytes;
2172 sb->s_time_gran = 1;
2173 sb->s_op = old_sb->s_op;
2174 nfs_initialise_sb(sb);
2178 * Set up an NFS4 superblock
2180 static void nfs4_fill_super(struct super_block *sb)
2182 sb->s_time_gran = 1;
2183 sb->s_op = &nfs4_sops;
2184 nfs_initialise_sb(sb);
2188 * Validate NFSv4 mount options
2190 static int nfs4_validate_mount_data(void *options,
2191 struct nfs_parsed_mount_data *args,
2192 const char *dev_name)
2194 struct sockaddr_in *ap;
2195 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
2201 args->rsize = NFS_MAX_FILE_IO_SIZE;
2202 args->wsize = NFS_MAX_FILE_IO_SIZE;
2203 args->acregmin = NFS_DEF_ACREGMIN;
2204 args->acregmax = NFS_DEF_ACREGMAX;
2205 args->acdirmin = NFS_DEF_ACDIRMIN;
2206 args->acdirmax = NFS_DEF_ACDIRMAX;
2207 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
2208 args->auth_flavors[0] = RPC_AUTH_UNIX;
2209 args->auth_flavor_len = 0;
2211 switch (data->version) {
2213 ap = (struct sockaddr_in *)&args->nfs_server.address;
2214 if (data->host_addrlen > sizeof(args->nfs_server.address))
2215 goto out_no_address;
2216 if (data->host_addrlen == 0)
2217 goto out_no_address;
2218 args->nfs_server.addrlen = data->host_addrlen;
2219 if (copy_from_user(ap, data->host_addr, data->host_addrlen))
2221 if (!nfs_verify_server_address((struct sockaddr *)
2222 &args->nfs_server.address))
2223 goto out_no_address;
2225 if (data->auth_flavourlen) {
2226 if (data->auth_flavourlen > 1)
2227 goto out_inval_auth;
2228 if (copy_from_user(&args->auth_flavors[0],
2229 data->auth_flavours,
2230 sizeof(args->auth_flavors[0])))
2234 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
2237 args->nfs_server.hostname = c;
2239 c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
2242 args->nfs_server.export_path = c;
2243 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
2245 c = strndup_user(data->client_addr.data, 16);
2248 args->client_address = c;
2251 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2255 args->flags = data->flags & NFS4_MOUNT_FLAGMASK;
2256 args->rsize = data->rsize;
2257 args->wsize = data->wsize;
2258 args->timeo = data->timeo;
2259 args->retrans = data->retrans;
2260 args->acregmin = data->acregmin;
2261 args->acregmax = data->acregmax;
2262 args->acdirmin = data->acdirmin;
2263 args->acdirmax = data->acdirmax;
2264 args->nfs_server.protocol = data->proto;
2265 nfs_validate_transport_protocol(args);
2271 if (nfs_parse_mount_options((char *)options, args) == 0)
2274 if (!nfs_verify_server_address((struct sockaddr *)
2275 &args->nfs_server.address))
2278 nfs_set_port((struct sockaddr *)&args->nfs_server.address,
2279 args->nfs_server.port);
2281 nfs_validate_transport_protocol(args);
2283 if (args->auth_flavor_len > 1)
2284 goto out_inval_auth;
2286 if (args->client_address == NULL)
2287 goto out_no_client_address;
2289 status = nfs_parse_devname(dev_name,
2290 &args->nfs_server.hostname,
2292 &args->nfs_server.export_path,
2304 dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
2308 dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
2309 data->auth_flavourlen);
2313 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
2316 out_no_client_address:
2317 dfprintk(MOUNT, "NFS4: mount program didn't pass callback address\n");
2322 * Get the superblock for an NFS4 mountpoint
2324 static int nfs4_get_sb(struct file_system_type *fs_type,
2325 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
2327 struct nfs_parsed_mount_data *data;
2328 struct super_block *s;
2329 struct nfs_server *server;
2330 struct nfs_fh *mntfh;
2331 struct dentry *mntroot;
2332 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2333 struct nfs_sb_mountdata sb_mntdata = {
2336 int error = -ENOMEM;
2338 data = kzalloc(sizeof(*data), GFP_KERNEL);
2339 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2340 if (data == NULL || mntfh == NULL)
2343 security_init_mnt_opts(&data->lsm_opts);
2345 /* Validate the mount data */
2346 error = nfs4_validate_mount_data(raw_data, data, dev_name);
2350 /* Get a volume representation */
2351 server = nfs4_create_server(data, mntfh);
2352 if (IS_ERR(server)) {
2353 error = PTR_ERR(server);
2356 sb_mntdata.server = server;
2358 if (server->flags & NFS4_MOUNT_UNSHARED)
2359 compare_super = NULL;
2361 /* Get a superblock - note that we may end up sharing one that already exists */
2362 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
2368 if (s->s_fs_info != server) {
2369 nfs_free_server(server);
2372 error = nfs_bdi_register(server);
2374 goto error_splat_super;
2378 /* initial superblock/root creation */
2382 mntroot = nfs4_get_root(s, mntfh);
2383 if (IS_ERR(mntroot)) {
2384 error = PTR_ERR(mntroot);
2385 goto error_splat_super;
2388 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
2390 goto error_splat_root;
2392 s->s_flags |= MS_ACTIVE;
2394 mnt->mnt_root = mntroot;
2398 kfree(data->client_address);
2399 kfree(data->nfs_server.export_path);
2400 kfree(data->nfs_server.hostname);
2401 security_free_mnt_opts(&data->lsm_opts);
2408 nfs_free_server(server);
2414 up_write(&s->s_umount);
2415 deactivate_super(s);
2419 static void nfs4_kill_super(struct super_block *sb)
2421 struct nfs_server *server = NFS_SB(sb);
2423 nfs_return_all_delegations(sb);
2424 kill_anon_super(sb);
2426 nfs4_renewd_prepare_shutdown(server);
2427 nfs_free_server(server);
2431 * Clone an NFS4 server record on xdev traversal (FSID-change)
2433 static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2434 const char *dev_name, void *raw_data,
2435 struct vfsmount *mnt)
2437 struct nfs_clone_mount *data = raw_data;
2438 struct super_block *s;
2439 struct nfs_server *server;
2440 struct dentry *mntroot;
2441 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2442 struct nfs_sb_mountdata sb_mntdata = {
2447 dprintk("--> nfs4_xdev_get_sb()\n");
2449 /* create a new volume representation */
2450 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
2451 if (IS_ERR(server)) {
2452 error = PTR_ERR(server);
2453 goto out_err_noserver;
2455 sb_mntdata.server = server;
2457 if (server->flags & NFS4_MOUNT_UNSHARED)
2458 compare_super = NULL;
2460 /* Get a superblock - note that we may end up sharing one that already exists */
2461 s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2467 if (s->s_fs_info != server) {
2468 nfs_free_server(server);
2471 error = nfs_bdi_register(server);
2473 goto error_splat_super;
2477 /* initial superblock/root creation */
2478 nfs4_clone_super(s, data->sb);
2481 mntroot = nfs4_get_root(s, data->fh);
2482 if (IS_ERR(mntroot)) {
2483 error = PTR_ERR(mntroot);
2484 goto error_splat_super;
2486 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2489 goto error_splat_super;
2492 s->s_flags |= MS_ACTIVE;
2494 mnt->mnt_root = mntroot;
2496 security_sb_clone_mnt_opts(data->sb, s);
2498 dprintk("<-- nfs4_xdev_get_sb() = 0\n");
2502 nfs_free_server(server);
2504 dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error);
2508 up_write(&s->s_umount);
2509 deactivate_super(s);
2510 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
2515 * Create an NFS4 server record on referral traversal
2517 static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
2518 const char *dev_name, void *raw_data,
2519 struct vfsmount *mnt)
2521 struct nfs_clone_mount *data = raw_data;
2522 struct super_block *s;
2523 struct nfs_server *server;
2524 struct dentry *mntroot;
2525 struct nfs_fh mntfh;
2526 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2527 struct nfs_sb_mountdata sb_mntdata = {
2532 dprintk("--> nfs4_referral_get_sb()\n");
2534 /* create a new volume representation */
2535 server = nfs4_create_referral_server(data, &mntfh);
2536 if (IS_ERR(server)) {
2537 error = PTR_ERR(server);
2538 goto out_err_noserver;
2540 sb_mntdata.server = server;
2542 if (server->flags & NFS4_MOUNT_UNSHARED)
2543 compare_super = NULL;
2545 /* Get a superblock - note that we may end up sharing one that already exists */
2546 s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2552 if (s->s_fs_info != server) {
2553 nfs_free_server(server);
2556 error = nfs_bdi_register(server);
2558 goto error_splat_super;
2562 /* initial superblock/root creation */
2566 mntroot = nfs4_get_root(s, &mntfh);
2567 if (IS_ERR(mntroot)) {
2568 error = PTR_ERR(mntroot);
2569 goto error_splat_super;
2571 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2574 goto error_splat_super;
2577 s->s_flags |= MS_ACTIVE;
2579 mnt->mnt_root = mntroot;
2581 security_sb_clone_mnt_opts(data->sb, s);
2583 dprintk("<-- nfs4_referral_get_sb() = 0\n");
2587 nfs_free_server(server);
2589 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error);
2593 up_write(&s->s_umount);
2594 deactivate_super(s);
2595 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
2599 #endif /* CONFIG_NFS_V4 */