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=%pI4", &sin->sin_addr.s_addr);
469 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
470 seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr);
475 seq_printf(m, ",mountaddr=unspecified");
478 if (nfss->mountd_version || showdefaults)
479 seq_printf(m, ",mountvers=%u", nfss->mountd_version);
480 if (nfss->mountd_port || showdefaults)
481 seq_printf(m, ",mountport=%u", nfss->mountd_port);
483 switch (nfss->mountd_protocol) {
485 seq_printf(m, ",mountproto=udp");
488 seq_printf(m, ",mountproto=tcp");
492 seq_printf(m, ",mountproto=auto");
497 * Describe the mount options in force on this server representation
499 static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
502 static const struct proc_nfs_info {
507 { NFS_MOUNT_SOFT, ",soft", ",hard" },
508 { NFS_MOUNT_INTR, ",intr", ",nointr" },
509 { NFS_MOUNT_POSIX, ",posix", "" },
510 { NFS_MOUNT_NOCTO, ",nocto", "" },
511 { NFS_MOUNT_NOAC, ",noac", "" },
512 { NFS_MOUNT_NONLM, ",nolock", "" },
513 { NFS_MOUNT_NOACL, ",noacl", "" },
514 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
515 { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
518 const struct proc_nfs_info *nfs_infop;
519 struct nfs_client *clp = nfss->nfs_client;
520 u32 version = clp->rpc_ops->version;
522 seq_printf(m, ",vers=%u", version);
523 seq_printf(m, ",rsize=%u", nfss->rsize);
524 seq_printf(m, ",wsize=%u", nfss->wsize);
525 if (nfss->bsize != 0)
526 seq_printf(m, ",bsize=%u", nfss->bsize);
527 seq_printf(m, ",namlen=%u", nfss->namelen);
528 if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults)
529 seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
530 if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults)
531 seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
532 if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults)
533 seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
534 if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults)
535 seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
536 for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
537 if (nfss->flags & nfs_infop->flag)
538 seq_puts(m, nfs_infop->str);
540 seq_puts(m, nfs_infop->nostr);
542 seq_printf(m, ",proto=%s",
543 rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
545 if (nfss->port != NFS_PORT)
546 seq_printf(m, ",port=%u", nfss->port);
549 seq_printf(m, ",port=%u", nfss->port);
551 seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
552 seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
553 seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
556 nfs_show_mountd_options(m, nfss, showdefaults);
559 if (clp->rpc_ops->version == 4)
560 seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
565 * Describe the mount options on this VFS mountpoint
567 static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt)
569 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
571 nfs_show_mount_options(m, nfss, 0);
573 seq_printf(m, ",addr=%s",
574 rpc_peeraddr2str(nfss->nfs_client->cl_rpcclient,
581 * Present statistical information for this VFS mountpoint
583 static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
586 struct nfs_server *nfss = NFS_SB(mnt->mnt_sb);
587 struct rpc_auth *auth = nfss->client->cl_auth;
588 struct nfs_iostats totals = { };
590 seq_printf(m, "statvers=%s", NFS_IOSTAT_VERS);
593 * Display all mount option settings
595 seq_printf(m, "\n\topts:\t");
596 seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? "ro" : "rw");
597 seq_puts(m, mnt->mnt_sb->s_flags & MS_SYNCHRONOUS ? ",sync" : "");
598 seq_puts(m, mnt->mnt_sb->s_flags & MS_NOATIME ? ",noatime" : "");
599 seq_puts(m, mnt->mnt_sb->s_flags & MS_NODIRATIME ? ",nodiratime" : "");
600 nfs_show_mount_options(m, nfss, 1);
602 seq_printf(m, "\n\tage:\t%lu", (jiffies - nfss->mount_time) / HZ);
604 seq_printf(m, "\n\tcaps:\t");
605 seq_printf(m, "caps=0x%x", nfss->caps);
606 seq_printf(m, ",wtmult=%u", nfss->wtmult);
607 seq_printf(m, ",dtsize=%u", nfss->dtsize);
608 seq_printf(m, ",bsize=%u", nfss->bsize);
609 seq_printf(m, ",namlen=%u", nfss->namelen);
612 if (nfss->nfs_client->rpc_ops->version == 4) {
613 seq_printf(m, "\n\tnfsv4:\t");
614 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
615 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
616 seq_printf(m, ",acl=0x%x", nfss->acl_bitmask);
621 * Display security flavor in effect for this mount
623 seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
625 seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
628 * Display superblock I/O counters
630 for_each_possible_cpu(cpu) {
631 struct nfs_iostats *stats;
634 stats = per_cpu_ptr(nfss->io_stats, cpu);
636 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
637 totals.events[i] += stats->events[i];
638 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
639 totals.bytes[i] += stats->bytes[i];
644 seq_printf(m, "\n\tevents:\t");
645 for (i = 0; i < __NFSIOS_COUNTSMAX; i++)
646 seq_printf(m, "%lu ", totals.events[i]);
647 seq_printf(m, "\n\tbytes:\t");
648 for (i = 0; i < __NFSIOS_BYTESMAX; i++)
649 seq_printf(m, "%Lu ", totals.bytes[i]);
652 rpc_print_iostats(m, nfss->client);
658 * Begin unmount by attempting to remove all automounted mountpoints we added
659 * in response to xdev traversals and referrals
661 static void nfs_umount_begin(struct super_block *sb)
663 struct nfs_server *server = NFS_SB(sb);
664 struct rpc_clnt *rpc;
666 /* -EIO all pending I/O */
667 rpc = server->client_acl;
669 rpc_killall_tasks(rpc);
670 rpc = server->client;
672 rpc_killall_tasks(rpc);
676 * Sanity-check a server address provided by the mount command.
678 * Address family must be initialized, and address must not be
679 * the ANY address for that family.
681 static int nfs_verify_server_address(struct sockaddr *addr)
683 switch (addr->sa_family) {
685 struct sockaddr_in *sa = (struct sockaddr_in *)addr;
686 return sa->sin_addr.s_addr != htonl(INADDR_ANY);
689 struct in6_addr *sa = &((struct sockaddr_in6 *)addr)->sin6_addr;
690 return !ipv6_addr_any(sa);
697 static void nfs_parse_ipv4_address(char *string, size_t str_len,
698 struct sockaddr *sap, size_t *addr_len)
700 struct sockaddr_in *sin = (struct sockaddr_in *)sap;
701 u8 *addr = (u8 *)&sin->sin_addr.s_addr;
703 if (str_len <= INET_ADDRSTRLEN) {
704 dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n",
705 (int)str_len, string);
707 sin->sin_family = AF_INET;
708 *addr_len = sizeof(*sin);
709 if (in4_pton(string, str_len, addr, '\0', NULL))
713 sap->sa_family = AF_UNSPEC;
717 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
718 static int nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
720 struct sockaddr_in6 *sin6)
725 if ((string + str_len) == delim)
728 if (*delim != IPV6_SCOPE_DELIMITER)
731 if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
734 len = (string + str_len) - delim - 1;
735 p = kstrndup(delim + 1, len, GFP_KERNEL);
737 unsigned long scope_id = 0;
738 struct net_device *dev;
740 dev = dev_get_by_name(&init_net, p);
742 scope_id = dev->ifindex;
745 if (strict_strtoul(p, 10, &scope_id) == 0) {
753 sin6->sin6_scope_id = scope_id;
754 dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id);
761 static void nfs_parse_ipv6_address(char *string, size_t str_len,
762 struct sockaddr *sap, size_t *addr_len)
764 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
765 u8 *addr = (u8 *)&sin6->sin6_addr.in6_u;
768 if (str_len <= INET6_ADDRSTRLEN) {
769 dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n",
770 (int)str_len, string);
772 sin6->sin6_family = AF_INET6;
773 *addr_len = sizeof(*sin6);
774 if (in6_pton(string, str_len, addr,
775 IPV6_SCOPE_DELIMITER, &delim) != 0) {
776 if (nfs_parse_ipv6_scope_id(string, str_len,
782 sap->sa_family = AF_UNSPEC;
786 static void nfs_parse_ipv6_address(char *string, size_t str_len,
787 struct sockaddr *sap, size_t *addr_len)
789 sap->sa_family = AF_UNSPEC;
795 * Construct a sockaddr based on the contents of a string that contains
796 * an IP address in presentation format.
798 * If there is a problem constructing the new sockaddr, set the address
799 * family to AF_UNSPEC.
801 void nfs_parse_ip_address(char *string, size_t str_len,
802 struct sockaddr *sap, size_t *addr_len)
804 unsigned int i, colons;
807 for (i = 0; i < str_len; i++)
808 if (string[i] == ':')
812 nfs_parse_ipv6_address(string, str_len, sap, addr_len);
814 nfs_parse_ipv4_address(string, str_len, sap, addr_len);
818 * Sanity check the NFS transport protocol.
821 static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
823 switch (mnt->nfs_server.protocol) {
824 case XPRT_TRANSPORT_UDP:
825 case XPRT_TRANSPORT_TCP:
826 case XPRT_TRANSPORT_RDMA:
829 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
834 * For text based NFSv2/v3 mounts, the mount protocol transport default
835 * settings should depend upon the specified NFS transport.
837 static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
839 nfs_validate_transport_protocol(mnt);
841 if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
842 mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
844 switch (mnt->nfs_server.protocol) {
845 case XPRT_TRANSPORT_UDP:
846 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
848 case XPRT_TRANSPORT_TCP:
849 case XPRT_TRANSPORT_RDMA:
850 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
855 * Parse the value of the 'sec=' option.
857 * The flavor_len setting is for v4 mounts.
859 static int nfs_parse_security_flavors(char *value,
860 struct nfs_parsed_mount_data *mnt)
862 substring_t args[MAX_OPT_ARGS];
864 dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value);
866 switch (match_token(value, nfs_secflavor_tokens, args)) {
868 mnt->auth_flavor_len = 0;
869 mnt->auth_flavors[0] = RPC_AUTH_NULL;
872 mnt->auth_flavor_len = 0;
873 mnt->auth_flavors[0] = RPC_AUTH_UNIX;
876 mnt->auth_flavor_len = 1;
877 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
880 mnt->auth_flavor_len = 1;
881 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
884 mnt->auth_flavor_len = 1;
885 mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
888 mnt->auth_flavor_len = 1;
889 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
892 mnt->auth_flavor_len = 1;
893 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
896 mnt->auth_flavor_len = 1;
897 mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
900 mnt->auth_flavor_len = 1;
901 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
904 mnt->auth_flavor_len = 1;
905 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
908 mnt->auth_flavor_len = 1;
909 mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
918 static void nfs_parse_invalid_value(const char *option)
920 dfprintk(MOUNT, "NFS: bad value specified for %s option\n", option);
924 * Error-check and convert a string of mount options from user space into
925 * a data structure. The whole mount string is processed; bad options are
926 * skipped as they are encountered. If there were no errors, return 1;
927 * otherwise return 0 (zero).
929 static int nfs_parse_mount_options(char *raw,
930 struct nfs_parsed_mount_data *mnt)
932 char *p, *string, *secdata;
933 int rc, sloppy = 0, errors = 0;
936 dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
939 dfprintk(MOUNT, "NFS: nfs mount opts='%s'\n", raw);
941 secdata = alloc_secdata();
945 rc = security_sb_copy_data(raw, secdata);
947 goto out_security_failure;
949 rc = security_sb_parse_opts_str(secdata, &mnt->lsm_opts);
951 goto out_security_failure;
953 free_secdata(secdata);
955 while ((p = strsep(&raw, ",")) != NULL) {
956 substring_t args[MAX_OPT_ARGS];
962 dfprintk(MOUNT, "NFS: parsing nfs mount option '%s'\n", p);
964 token = match_token(p, nfs_mount_option_tokens, args);
968 * boolean options: foo/nofoo
971 mnt->flags |= NFS_MOUNT_SOFT;
974 mnt->flags &= ~NFS_MOUNT_SOFT;
977 mnt->flags |= NFS_MOUNT_POSIX;
980 mnt->flags &= ~NFS_MOUNT_POSIX;
983 mnt->flags &= ~NFS_MOUNT_NOCTO;
986 mnt->flags |= NFS_MOUNT_NOCTO;
989 mnt->flags &= ~NFS_MOUNT_NOAC;
992 mnt->flags |= NFS_MOUNT_NOAC;
995 mnt->flags &= ~NFS_MOUNT_NONLM;
998 mnt->flags |= NFS_MOUNT_NONLM;
1001 mnt->flags &= ~NFS_MOUNT_VER3;
1004 mnt->flags |= NFS_MOUNT_VER3;
1007 mnt->flags &= ~NFS_MOUNT_TCP;
1008 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1011 mnt->flags |= NFS_MOUNT_TCP;
1012 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1015 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
1016 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1019 mnt->flags &= ~NFS_MOUNT_NOACL;
1022 mnt->flags |= NFS_MOUNT_NOACL;
1025 mnt->flags &= ~NFS_MOUNT_NORDIRPLUS;
1027 case Opt_nordirplus:
1028 mnt->flags |= NFS_MOUNT_NORDIRPLUS;
1030 case Opt_sharecache:
1031 mnt->flags &= ~NFS_MOUNT_UNSHARED;
1033 case Opt_nosharecache:
1034 mnt->flags |= NFS_MOUNT_UNSHARED;
1038 * options that take numeric values
1041 if (match_int(args, &option) ||
1042 option < 0 || option > USHORT_MAX) {
1044 nfs_parse_invalid_value("port");
1046 mnt->nfs_server.port = option;
1049 if (match_int(args, &option) || option < 0) {
1051 nfs_parse_invalid_value("rsize");
1053 mnt->rsize = option;
1056 if (match_int(args, &option) || option < 0) {
1058 nfs_parse_invalid_value("wsize");
1060 mnt->wsize = option;
1063 if (match_int(args, &option) || option < 0) {
1065 nfs_parse_invalid_value("bsize");
1067 mnt->bsize = option;
1070 if (match_int(args, &option) || option <= 0) {
1072 nfs_parse_invalid_value("timeo");
1074 mnt->timeo = option;
1077 if (match_int(args, &option) || option <= 0) {
1079 nfs_parse_invalid_value("retrans");
1081 mnt->retrans = option;
1084 if (match_int(args, &option) || option < 0) {
1086 nfs_parse_invalid_value("acregmin");
1088 mnt->acregmin = option;
1091 if (match_int(args, &option) || option < 0) {
1093 nfs_parse_invalid_value("acregmax");
1095 mnt->acregmax = option;
1098 if (match_int(args, &option) || option < 0) {
1100 nfs_parse_invalid_value("acdirmin");
1102 mnt->acdirmin = option;
1105 if (match_int(args, &option) || option < 0) {
1107 nfs_parse_invalid_value("acdirmax");
1109 mnt->acdirmax = option;
1112 if (match_int(args, &option) || option < 0) {
1114 nfs_parse_invalid_value("actimeo");
1116 mnt->acregmin = mnt->acregmax =
1117 mnt->acdirmin = mnt->acdirmax = option;
1120 if (match_int(args, &option) || option < 0) {
1122 nfs_parse_invalid_value("namlen");
1124 mnt->namlen = option;
1127 if (match_int(args, &option) ||
1128 option < 0 || option > USHORT_MAX) {
1130 nfs_parse_invalid_value("mountport");
1132 mnt->mount_server.port = option;
1135 if (match_int(args, &option) ||
1136 option < NFS_MNT_VERSION ||
1137 option > NFS_MNT3_VERSION) {
1139 nfs_parse_invalid_value("mountvers");
1141 mnt->mount_server.version = option;
1144 if (match_int(args, &option)) {
1146 nfs_parse_invalid_value("nfsvers");
1151 mnt->flags &= ~NFS_MOUNT_VER3;
1154 mnt->flags |= NFS_MOUNT_VER3;
1158 nfs_parse_invalid_value("nfsvers");
1163 * options that take text values
1166 string = match_strdup(args);
1169 rc = nfs_parse_security_flavors(string, mnt);
1173 dfprintk(MOUNT, "NFS: unrecognized "
1174 "security flavor\n");
1178 string = match_strdup(args);
1181 token = match_token(string,
1182 nfs_xprt_protocol_tokens, args);
1187 mnt->flags &= ~NFS_MOUNT_TCP;
1188 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1191 mnt->flags |= NFS_MOUNT_TCP;
1192 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1195 /* vector side protocols to TCP */
1196 mnt->flags |= NFS_MOUNT_TCP;
1197 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1201 dfprintk(MOUNT, "NFS: unrecognized "
1202 "transport protocol\n");
1205 case Opt_mountproto:
1206 string = match_strdup(args);
1209 token = match_token(string,
1210 nfs_xprt_protocol_tokens, args);
1215 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
1218 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
1220 case Opt_xprt_rdma: /* not used for side protocols */
1223 dfprintk(MOUNT, "NFS: unrecognized "
1224 "transport protocol\n");
1228 string = match_strdup(args);
1231 nfs_parse_ip_address(string, strlen(string),
1233 &mnt->nfs_server.address,
1234 &mnt->nfs_server.addrlen);
1237 case Opt_clientaddr:
1238 string = match_strdup(args);
1241 kfree(mnt->client_address);
1242 mnt->client_address = string;
1245 string = match_strdup(args);
1248 kfree(mnt->mount_server.hostname);
1249 mnt->mount_server.hostname = string;
1252 string = match_strdup(args);
1255 nfs_parse_ip_address(string, strlen(string),
1257 &mnt->mount_server.address,
1258 &mnt->mount_server.addrlen);
1261 case Opt_lookupcache:
1262 string = match_strdup(args);
1265 token = match_token(string,
1266 nfs_lookupcache_tokens, args);
1269 case Opt_lookupcache_all:
1270 mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
1272 case Opt_lookupcache_positive:
1273 mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
1274 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
1276 case Opt_lookupcache_none:
1277 mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
1281 dfprintk(MOUNT, "NFS: invalid "
1282 "lookupcache argument\n");
1291 dfprintk(MOUNT, "NFS: relaxing parsing rules\n");
1294 case Opt_deprecated:
1295 dfprintk(MOUNT, "NFS: ignoring mount option "
1301 dfprintk(MOUNT, "NFS: unrecognized mount option "
1307 dfprintk(MOUNT, "NFS: parsing encountered %d error%s\n",
1308 errors, (errors == 1 ? "" : "s"));
1315 printk(KERN_INFO "NFS: not enough memory to parse option\n");
1317 out_security_failure:
1318 free_secdata(secdata);
1319 printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
1324 * Use the remote server's MOUNT service to request the NFS file handle
1325 * corresponding to the provided path.
1327 static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1328 struct nfs_fh *root_fh)
1330 struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address;
1334 if (args->mount_server.version == 0) {
1335 if (args->flags & NFS_MOUNT_VER3)
1336 args->mount_server.version = NFS_MNT3_VERSION;
1338 args->mount_server.version = NFS_MNT_VERSION;
1341 if (args->mount_server.hostname)
1342 hostname = args->mount_server.hostname;
1344 hostname = args->nfs_server.hostname;
1347 * Construct the mount server's address.
1349 if (args->mount_server.address.ss_family == AF_UNSPEC) {
1350 memcpy(sap, &args->nfs_server.address,
1351 args->nfs_server.addrlen);
1352 args->mount_server.addrlen = args->nfs_server.addrlen;
1356 * autobind will be used if mount_server.port == 0
1358 nfs_set_port(sap, args->mount_server.port);
1361 * Now ask the mount server to map our export path
1364 status = nfs_mount(sap,
1365 args->mount_server.addrlen,
1367 args->nfs_server.export_path,
1368 args->mount_server.version,
1369 args->mount_server.protocol,
1374 dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
1379 static int nfs_parse_simple_hostname(const char *dev_name,
1380 char **hostname, size_t maxnamlen,
1381 char **export_path, size_t maxpathlen)
1384 char *colon, *comma;
1386 colon = strchr(dev_name, ':');
1388 goto out_bad_devname;
1390 len = colon - dev_name;
1391 if (len > maxnamlen)
1394 /* N.B. caller will free nfs_server.hostname in all cases */
1395 *hostname = kstrndup(dev_name, len, GFP_KERNEL);
1399 /* kill possible hostname list: not supported */
1400 comma = strchr(*hostname, ',');
1401 if (comma != NULL) {
1402 if (comma == *hostname)
1403 goto out_bad_devname;
1408 len = strlen(colon);
1409 if (len > maxpathlen)
1411 *export_path = kstrndup(colon, len, GFP_KERNEL);
1415 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path);
1419 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1423 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1427 dfprintk(MOUNT, "NFS: server hostname too long\n");
1428 return -ENAMETOOLONG;
1431 dfprintk(MOUNT, "NFS: export pathname too long\n");
1432 return -ENAMETOOLONG;
1436 * Hostname has square brackets around it because it contains one or
1437 * more colons. We look for the first closing square bracket, and a
1438 * colon must follow it.
1440 static int nfs_parse_protected_hostname(const char *dev_name,
1441 char **hostname, size_t maxnamlen,
1442 char **export_path, size_t maxpathlen)
1447 start = (char *)(dev_name + 1);
1449 end = strchr(start, ']');
1451 goto out_bad_devname;
1452 if (*(end + 1) != ':')
1453 goto out_bad_devname;
1456 if (len > maxnamlen)
1459 /* N.B. caller will free nfs_server.hostname in all cases */
1460 *hostname = kstrndup(start, len, GFP_KERNEL);
1461 if (*hostname == NULL)
1466 if (len > maxpathlen)
1468 *export_path = kstrndup(end, len, GFP_KERNEL);
1475 dfprintk(MOUNT, "NFS: device name not in host:path format\n");
1479 dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
1483 dfprintk(MOUNT, "NFS: server hostname too long\n");
1484 return -ENAMETOOLONG;
1487 dfprintk(MOUNT, "NFS: export pathname too long\n");
1488 return -ENAMETOOLONG;
1492 * Split "dev_name" into "hostname:export_path".
1494 * The leftmost colon demarks the split between the server's hostname
1495 * and the export path. If the hostname starts with a left square
1496 * bracket, then it may contain colons.
1498 * Note: caller frees hostname and export path, even on error.
1500 static int nfs_parse_devname(const char *dev_name,
1501 char **hostname, size_t maxnamlen,
1502 char **export_path, size_t maxpathlen)
1504 if (*dev_name == '[')
1505 return nfs_parse_protected_hostname(dev_name,
1506 hostname, maxnamlen,
1507 export_path, maxpathlen);
1509 return nfs_parse_simple_hostname(dev_name,
1510 hostname, maxnamlen,
1511 export_path, maxpathlen);
1515 * Validate the NFS2/NFS3 mount data
1516 * - fills in the mount root filehandle
1518 * For option strings, user space handles the following behaviors:
1520 * + DNS: mapping server host name to IP address ("addr=" option)
1522 * + failure mode: how to behave if a mount request can't be handled
1523 * immediately ("fg/bg" option)
1525 * + retry: how often to retry a mount request ("retry=" option)
1527 * + breaking back: trying proto=udp after proto=tcp, v2 after v3,
1528 * mountproto=tcp after mountproto=udp, and so on
1530 static int nfs_validate_mount_data(void *options,
1531 struct nfs_parsed_mount_data *args,
1532 struct nfs_fh *mntfh,
1533 const char *dev_name)
1535 struct nfs_mount_data *data = (struct nfs_mount_data *)options;
1540 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1541 args->rsize = NFS_MAX_FILE_IO_SIZE;
1542 args->wsize = NFS_MAX_FILE_IO_SIZE;
1543 args->acregmin = NFS_DEF_ACREGMIN;
1544 args->acregmax = NFS_DEF_ACREGMAX;
1545 args->acdirmin = NFS_DEF_ACDIRMIN;
1546 args->acdirmax = NFS_DEF_ACDIRMAX;
1547 args->mount_server.port = 0; /* autobind unless user sets port */
1548 args->nfs_server.port = 0; /* autobind unless user sets port */
1549 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1550 args->auth_flavors[0] = RPC_AUTH_UNIX;
1552 switch (data->version) {
1558 if (data->flags & NFS_MOUNT_VER3)
1560 data->root.size = NFS2_FHSIZE;
1561 memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
1563 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1566 memset(data->context, 0, sizeof(data->context));
1568 if (data->flags & NFS_MOUNT_VER3) {
1569 if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
1570 goto out_invalid_fh;
1571 mntfh->size = data->root.size;
1573 mntfh->size = NFS2_FHSIZE;
1576 memcpy(mntfh->data, data->root.data, mntfh->size);
1577 if (mntfh->size < sizeof(mntfh->data))
1578 memset(mntfh->data + mntfh->size, 0,
1579 sizeof(mntfh->data) - mntfh->size);
1582 * Translate to nfs_parsed_mount_data, which nfs_fill_super
1585 args->flags = data->flags & NFS_MOUNT_FLAGMASK;
1586 args->rsize = data->rsize;
1587 args->wsize = data->wsize;
1588 args->timeo = data->timeo;
1589 args->retrans = data->retrans;
1590 args->acregmin = data->acregmin;
1591 args->acregmax = data->acregmax;
1592 args->acdirmin = data->acdirmin;
1593 args->acdirmax = data->acdirmax;
1595 memcpy(&args->nfs_server.address, &data->addr,
1596 sizeof(data->addr));
1597 args->nfs_server.addrlen = sizeof(data->addr);
1598 if (!nfs_verify_server_address((struct sockaddr *)
1599 &args->nfs_server.address))
1600 goto out_no_address;
1602 if (!(data->flags & NFS_MOUNT_TCP))
1603 args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1604 /* N.B. caller will free nfs_server.hostname in all cases */
1605 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1606 args->namlen = data->namlen;
1607 args->bsize = data->bsize;
1609 if (data->flags & NFS_MOUNT_SECFLAVOUR)
1610 args->auth_flavors[0] = data->pseudoflavor;
1611 if (!args->nfs_server.hostname)
1615 * The legacy version 6 binary mount data from userspace has a
1616 * field used only to transport selinux information into the
1617 * the kernel. To continue to support that functionality we
1618 * have a touch of selinux knowledge here in the NFS code. The
1619 * userspace code converted context=blah to just blah so we are
1620 * converting back to the full string selinux understands.
1622 if (data->context[0]){
1623 #ifdef CONFIG_SECURITY_SELINUX
1625 char *opts_str = kmalloc(sizeof(data->context) + 8, GFP_KERNEL);
1628 strcpy(opts_str, "context=");
1629 data->context[NFS_MAX_CONTEXT_LEN] = '\0';
1630 strcat(opts_str, &data->context[0]);
1631 rc = security_sb_parse_opts_str(opts_str, &args->lsm_opts);
1644 if (nfs_parse_mount_options((char *)options, args) == 0)
1647 if (!nfs_verify_server_address((struct sockaddr *)
1648 &args->nfs_server.address))
1649 goto out_no_address;
1651 nfs_set_port((struct sockaddr *)&args->nfs_server.address,
1652 args->nfs_server.port);
1654 nfs_set_mount_transport_protocol(args);
1656 status = nfs_parse_devname(dev_name,
1657 &args->nfs_server.hostname,
1659 &args->nfs_server.export_path,
1662 status = nfs_try_mount(args, mntfh);
1664 kfree(args->nfs_server.export_path);
1665 args->nfs_server.export_path = NULL;
1674 #ifndef CONFIG_NFS_V3
1675 if (args->flags & NFS_MOUNT_VER3)
1676 goto out_v3_not_compiled;
1677 #endif /* !CONFIG_NFS_V3 */
1682 dfprintk(MOUNT, "NFS: mount program didn't pass any mount data\n");
1686 dfprintk(MOUNT, "NFS: nfs_mount_data version %d does not support v3\n",
1691 dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
1694 #ifndef CONFIG_NFS_V3
1695 out_v3_not_compiled:
1696 dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n");
1697 return -EPROTONOSUPPORT;
1698 #endif /* !CONFIG_NFS_V3 */
1701 dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
1705 dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
1709 dfprintk(MOUNT, "NFS: invalid root filehandle\n");
1714 nfs_compare_remount_data(struct nfs_server *nfss,
1715 struct nfs_parsed_mount_data *data)
1717 if (data->flags != nfss->flags ||
1718 data->rsize != nfss->rsize ||
1719 data->wsize != nfss->wsize ||
1720 data->retrans != nfss->client->cl_timeout->to_retries ||
1721 data->auth_flavors[0] != nfss->client->cl_auth->au_flavor ||
1722 data->acregmin != nfss->acregmin / HZ ||
1723 data->acregmax != nfss->acregmax / HZ ||
1724 data->acdirmin != nfss->acdirmin / HZ ||
1725 data->acdirmax != nfss->acdirmax / HZ ||
1726 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
1727 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
1728 memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1729 data->nfs_server.addrlen) != 0)
1736 nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1739 struct nfs_server *nfss = sb->s_fs_info;
1740 struct nfs_parsed_mount_data *data;
1741 struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data;
1742 struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data;
1743 u32 nfsvers = nfss->nfs_client->rpc_ops->version;
1746 * Userspace mount programs that send binary options generally send
1747 * them populated with default values. We have no way to know which
1748 * ones were explicitly specified. Fall back to legacy behavior and
1749 * just return success.
1751 if ((nfsvers == 4 && (!options4 || options4->version == 1)) ||
1752 (nfsvers <= 3 && (!options || (options->version >= 1 &&
1753 options->version <= 6))))
1756 data = kzalloc(sizeof(*data), GFP_KERNEL);
1760 /* fill out struct with values from existing mount */
1761 data->flags = nfss->flags;
1762 data->rsize = nfss->rsize;
1763 data->wsize = nfss->wsize;
1764 data->retrans = nfss->client->cl_timeout->to_retries;
1765 data->auth_flavors[0] = nfss->client->cl_auth->au_flavor;
1766 data->acregmin = nfss->acregmin / HZ;
1767 data->acregmax = nfss->acregmax / HZ;
1768 data->acdirmin = nfss->acdirmin / HZ;
1769 data->acdirmax = nfss->acdirmax / HZ;
1770 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
1771 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
1772 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1773 data->nfs_server.addrlen);
1775 /* overwrite those values with any that were specified */
1776 error = nfs_parse_mount_options((char *)options, data);
1780 /* compare new mount options with old ones */
1781 error = nfs_compare_remount_data(nfss, data);
1788 * Initialise the common bits of the superblock
1790 static inline void nfs_initialise_sb(struct super_block *sb)
1792 struct nfs_server *server = NFS_SB(sb);
1794 sb->s_magic = NFS_SUPER_MAGIC;
1796 /* We probably want something more informative here */
1797 snprintf(sb->s_id, sizeof(sb->s_id),
1798 "%x:%x", MAJOR(sb->s_dev), MINOR(sb->s_dev));
1800 if (sb->s_blocksize == 0)
1801 sb->s_blocksize = nfs_block_bits(server->wsize,
1802 &sb->s_blocksize_bits);
1804 if (server->flags & NFS_MOUNT_NOAC)
1805 sb->s_flags |= MS_SYNCHRONOUS;
1807 nfs_super_set_maxbytes(sb, server->maxfilesize);
1811 * Finish setting up an NFS2/3 superblock
1813 static void nfs_fill_super(struct super_block *sb,
1814 struct nfs_parsed_mount_data *data)
1816 struct nfs_server *server = NFS_SB(sb);
1818 sb->s_blocksize_bits = 0;
1819 sb->s_blocksize = 0;
1821 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
1823 if (server->flags & NFS_MOUNT_VER3) {
1824 /* The VFS shouldn't apply the umask to mode bits. We will do
1825 * so ourselves when necessary.
1827 sb->s_flags |= MS_POSIXACL;
1828 sb->s_time_gran = 1;
1831 sb->s_op = &nfs_sops;
1832 nfs_initialise_sb(sb);
1836 * Finish setting up a cloned NFS2/3 superblock
1838 static void nfs_clone_super(struct super_block *sb,
1839 const struct super_block *old_sb)
1841 struct nfs_server *server = NFS_SB(sb);
1843 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
1844 sb->s_blocksize = old_sb->s_blocksize;
1845 sb->s_maxbytes = old_sb->s_maxbytes;
1847 if (server->flags & NFS_MOUNT_VER3) {
1848 /* The VFS shouldn't apply the umask to mode bits. We will do
1849 * so ourselves when necessary.
1851 sb->s_flags |= MS_POSIXACL;
1852 sb->s_time_gran = 1;
1855 sb->s_op = old_sb->s_op;
1856 nfs_initialise_sb(sb);
1859 #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
1861 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
1863 const struct nfs_server *a = s->s_fs_info;
1864 const struct rpc_clnt *clnt_a = a->client;
1865 const struct rpc_clnt *clnt_b = b->client;
1867 if ((s->s_flags & NFS_MS_MASK) != (flags & NFS_MS_MASK))
1869 if (a->nfs_client != b->nfs_client)
1871 if (a->flags != b->flags)
1873 if (a->wsize != b->wsize)
1875 if (a->rsize != b->rsize)
1877 if (a->acregmin != b->acregmin)
1879 if (a->acregmax != b->acregmax)
1881 if (a->acdirmin != b->acdirmin)
1883 if (a->acdirmax != b->acdirmax)
1885 if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
1892 struct nfs_sb_mountdata {
1893 struct nfs_server *server;
1897 static int nfs_set_super(struct super_block *s, void *data)
1899 struct nfs_sb_mountdata *sb_mntdata = data;
1900 struct nfs_server *server = sb_mntdata->server;
1903 s->s_flags = sb_mntdata->mntflags;
1904 s->s_fs_info = server;
1905 ret = set_anon_super(s, server);
1907 server->s_dev = s->s_dev;
1911 static int nfs_compare_super_address(struct nfs_server *server1,
1912 struct nfs_server *server2)
1914 struct sockaddr *sap1, *sap2;
1916 sap1 = (struct sockaddr *)&server1->nfs_client->cl_addr;
1917 sap2 = (struct sockaddr *)&server2->nfs_client->cl_addr;
1919 if (sap1->sa_family != sap2->sa_family)
1922 switch (sap1->sa_family) {
1924 struct sockaddr_in *sin1 = (struct sockaddr_in *)sap1;
1925 struct sockaddr_in *sin2 = (struct sockaddr_in *)sap2;
1926 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
1928 if (sin1->sin_port != sin2->sin_port)
1933 struct sockaddr_in6 *sin1 = (struct sockaddr_in6 *)sap1;
1934 struct sockaddr_in6 *sin2 = (struct sockaddr_in6 *)sap2;
1935 if (!ipv6_addr_equal(&sin1->sin6_addr, &sin2->sin6_addr))
1937 if (sin1->sin6_port != sin2->sin6_port)
1948 static int nfs_compare_super(struct super_block *sb, void *data)
1950 struct nfs_sb_mountdata *sb_mntdata = data;
1951 struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
1952 int mntflags = sb_mntdata->mntflags;
1954 if (!nfs_compare_super_address(old, server))
1956 /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
1957 if (old->flags & NFS_MOUNT_UNSHARED)
1959 if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
1961 return nfs_compare_mount_options(sb, server, mntflags);
1964 static int nfs_bdi_register(struct nfs_server *server)
1966 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
1969 static int nfs_get_sb(struct file_system_type *fs_type,
1970 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
1972 struct nfs_server *server = NULL;
1973 struct super_block *s;
1974 struct nfs_parsed_mount_data *data;
1975 struct nfs_fh *mntfh;
1976 struct dentry *mntroot;
1977 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
1978 struct nfs_sb_mountdata sb_mntdata = {
1981 int error = -ENOMEM;
1983 data = kzalloc(sizeof(*data), GFP_KERNEL);
1984 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
1985 if (data == NULL || mntfh == NULL)
1988 security_init_mnt_opts(&data->lsm_opts);
1990 /* Validate the mount data */
1991 error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
1995 /* Get a volume representation */
1996 server = nfs_create_server(data, mntfh);
1997 if (IS_ERR(server)) {
1998 error = PTR_ERR(server);
2001 sb_mntdata.server = server;
2003 if (server->flags & NFS_MOUNT_UNSHARED)
2004 compare_super = NULL;
2006 /* Get a superblock - note that we may end up sharing one that already exists */
2007 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
2013 if (s->s_fs_info != server) {
2014 nfs_free_server(server);
2017 error = nfs_bdi_register(server);
2019 goto error_splat_super;
2023 /* initial superblock/root creation */
2024 nfs_fill_super(s, data);
2027 mntroot = nfs_get_root(s, mntfh);
2028 if (IS_ERR(mntroot)) {
2029 error = PTR_ERR(mntroot);
2030 goto error_splat_super;
2033 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
2035 goto error_splat_root;
2037 s->s_flags |= MS_ACTIVE;
2039 mnt->mnt_root = mntroot;
2043 kfree(data->nfs_server.hostname);
2044 kfree(data->mount_server.hostname);
2045 security_free_mnt_opts(&data->lsm_opts);
2052 nfs_free_server(server);
2058 up_write(&s->s_umount);
2059 deactivate_super(s);
2064 * Destroy an NFS2/3 superblock
2066 static void nfs_kill_super(struct super_block *s)
2068 struct nfs_server *server = NFS_SB(s);
2070 bdi_unregister(&server->backing_dev_info);
2072 nfs_free_server(server);
2076 * Clone an NFS2/3 server record on xdev traversal (FSID-change)
2078 static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
2079 const char *dev_name, void *raw_data,
2080 struct vfsmount *mnt)
2082 struct nfs_clone_mount *data = raw_data;
2083 struct super_block *s;
2084 struct nfs_server *server;
2085 struct dentry *mntroot;
2086 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2087 struct nfs_sb_mountdata sb_mntdata = {
2092 dprintk("--> nfs_xdev_get_sb()\n");
2094 /* create a new volume representation */
2095 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
2096 if (IS_ERR(server)) {
2097 error = PTR_ERR(server);
2098 goto out_err_noserver;
2100 sb_mntdata.server = server;
2102 if (server->flags & NFS_MOUNT_UNSHARED)
2103 compare_super = NULL;
2105 /* Get a superblock - note that we may end up sharing one that already exists */
2106 s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2112 if (s->s_fs_info != server) {
2113 nfs_free_server(server);
2116 error = nfs_bdi_register(server);
2118 goto error_splat_super;
2122 /* initial superblock/root creation */
2123 nfs_clone_super(s, data->sb);
2126 mntroot = nfs_get_root(s, data->fh);
2127 if (IS_ERR(mntroot)) {
2128 error = PTR_ERR(mntroot);
2129 goto error_splat_super;
2131 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2134 goto error_splat_super;
2137 s->s_flags |= MS_ACTIVE;
2139 mnt->mnt_root = mntroot;
2141 /* clone any lsm security options from the parent to the new sb */
2142 security_sb_clone_mnt_opts(data->sb, s);
2144 dprintk("<-- nfs_xdev_get_sb() = 0\n");
2148 nfs_free_server(server);
2150 dprintk("<-- nfs_xdev_get_sb() = %d [error]\n", error);
2154 up_write(&s->s_umount);
2155 deactivate_super(s);
2156 dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
2160 #ifdef CONFIG_NFS_V4
2163 * Finish setting up a cloned NFS4 superblock
2165 static void nfs4_clone_super(struct super_block *sb,
2166 const struct super_block *old_sb)
2168 sb->s_blocksize_bits = old_sb->s_blocksize_bits;
2169 sb->s_blocksize = old_sb->s_blocksize;
2170 sb->s_maxbytes = old_sb->s_maxbytes;
2171 sb->s_time_gran = 1;
2172 sb->s_op = old_sb->s_op;
2173 nfs_initialise_sb(sb);
2177 * Set up an NFS4 superblock
2179 static void nfs4_fill_super(struct super_block *sb)
2181 sb->s_time_gran = 1;
2182 sb->s_op = &nfs4_sops;
2183 nfs_initialise_sb(sb);
2187 * Validate NFSv4 mount options
2189 static int nfs4_validate_mount_data(void *options,
2190 struct nfs_parsed_mount_data *args,
2191 const char *dev_name)
2193 struct sockaddr_in *ap;
2194 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
2200 args->rsize = NFS_MAX_FILE_IO_SIZE;
2201 args->wsize = NFS_MAX_FILE_IO_SIZE;
2202 args->acregmin = NFS_DEF_ACREGMIN;
2203 args->acregmax = NFS_DEF_ACREGMAX;
2204 args->acdirmin = NFS_DEF_ACDIRMIN;
2205 args->acdirmax = NFS_DEF_ACDIRMAX;
2206 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
2207 args->auth_flavors[0] = RPC_AUTH_UNIX;
2208 args->auth_flavor_len = 0;
2210 switch (data->version) {
2212 ap = (struct sockaddr_in *)&args->nfs_server.address;
2213 if (data->host_addrlen > sizeof(args->nfs_server.address))
2214 goto out_no_address;
2215 if (data->host_addrlen == 0)
2216 goto out_no_address;
2217 args->nfs_server.addrlen = data->host_addrlen;
2218 if (copy_from_user(ap, data->host_addr, data->host_addrlen))
2220 if (!nfs_verify_server_address((struct sockaddr *)
2221 &args->nfs_server.address))
2222 goto out_no_address;
2224 if (data->auth_flavourlen) {
2225 if (data->auth_flavourlen > 1)
2226 goto out_inval_auth;
2227 if (copy_from_user(&args->auth_flavors[0],
2228 data->auth_flavours,
2229 sizeof(args->auth_flavors[0])))
2233 c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
2236 args->nfs_server.hostname = c;
2238 c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
2241 args->nfs_server.export_path = c;
2242 dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
2244 c = strndup_user(data->client_addr.data, 16);
2247 args->client_address = c;
2250 * Translate to nfs_parsed_mount_data, which nfs4_fill_super
2254 args->flags = data->flags & NFS4_MOUNT_FLAGMASK;
2255 args->rsize = data->rsize;
2256 args->wsize = data->wsize;
2257 args->timeo = data->timeo;
2258 args->retrans = data->retrans;
2259 args->acregmin = data->acregmin;
2260 args->acregmax = data->acregmax;
2261 args->acdirmin = data->acdirmin;
2262 args->acdirmax = data->acdirmax;
2263 args->nfs_server.protocol = data->proto;
2264 nfs_validate_transport_protocol(args);
2270 if (nfs_parse_mount_options((char *)options, args) == 0)
2273 if (!nfs_verify_server_address((struct sockaddr *)
2274 &args->nfs_server.address))
2277 nfs_set_port((struct sockaddr *)&args->nfs_server.address,
2278 args->nfs_server.port);
2280 nfs_validate_transport_protocol(args);
2282 if (args->auth_flavor_len > 1)
2283 goto out_inval_auth;
2285 if (args->client_address == NULL)
2286 goto out_no_client_address;
2288 status = nfs_parse_devname(dev_name,
2289 &args->nfs_server.hostname,
2291 &args->nfs_server.export_path,
2303 dfprintk(MOUNT, "NFS4: mount program didn't pass any mount data\n");
2307 dfprintk(MOUNT, "NFS4: Invalid number of RPC auth flavours %d\n",
2308 data->auth_flavourlen);
2312 dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
2315 out_no_client_address:
2316 dfprintk(MOUNT, "NFS4: mount program didn't pass callback address\n");
2321 * Get the superblock for an NFS4 mountpoint
2323 static int nfs4_get_sb(struct file_system_type *fs_type,
2324 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
2326 struct nfs_parsed_mount_data *data;
2327 struct super_block *s;
2328 struct nfs_server *server;
2329 struct nfs_fh *mntfh;
2330 struct dentry *mntroot;
2331 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2332 struct nfs_sb_mountdata sb_mntdata = {
2335 int error = -ENOMEM;
2337 data = kzalloc(sizeof(*data), GFP_KERNEL);
2338 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2339 if (data == NULL || mntfh == NULL)
2342 security_init_mnt_opts(&data->lsm_opts);
2344 /* Validate the mount data */
2345 error = nfs4_validate_mount_data(raw_data, data, dev_name);
2349 /* Get a volume representation */
2350 server = nfs4_create_server(data, mntfh);
2351 if (IS_ERR(server)) {
2352 error = PTR_ERR(server);
2355 sb_mntdata.server = server;
2357 if (server->flags & NFS4_MOUNT_UNSHARED)
2358 compare_super = NULL;
2360 /* Get a superblock - note that we may end up sharing one that already exists */
2361 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
2367 if (s->s_fs_info != server) {
2368 nfs_free_server(server);
2371 error = nfs_bdi_register(server);
2373 goto error_splat_super;
2377 /* initial superblock/root creation */
2381 mntroot = nfs4_get_root(s, mntfh);
2382 if (IS_ERR(mntroot)) {
2383 error = PTR_ERR(mntroot);
2384 goto error_splat_super;
2387 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
2389 goto error_splat_root;
2391 s->s_flags |= MS_ACTIVE;
2393 mnt->mnt_root = mntroot;
2397 kfree(data->client_address);
2398 kfree(data->nfs_server.export_path);
2399 kfree(data->nfs_server.hostname);
2400 security_free_mnt_opts(&data->lsm_opts);
2407 nfs_free_server(server);
2413 up_write(&s->s_umount);
2414 deactivate_super(s);
2418 static void nfs4_kill_super(struct super_block *sb)
2420 struct nfs_server *server = NFS_SB(sb);
2422 nfs_return_all_delegations(sb);
2423 kill_anon_super(sb);
2425 nfs4_renewd_prepare_shutdown(server);
2426 nfs_free_server(server);
2430 * Clone an NFS4 server record on xdev traversal (FSID-change)
2432 static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2433 const char *dev_name, void *raw_data,
2434 struct vfsmount *mnt)
2436 struct nfs_clone_mount *data = raw_data;
2437 struct super_block *s;
2438 struct nfs_server *server;
2439 struct dentry *mntroot;
2440 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2441 struct nfs_sb_mountdata sb_mntdata = {
2446 dprintk("--> nfs4_xdev_get_sb()\n");
2448 /* create a new volume representation */
2449 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
2450 if (IS_ERR(server)) {
2451 error = PTR_ERR(server);
2452 goto out_err_noserver;
2454 sb_mntdata.server = server;
2456 if (server->flags & NFS4_MOUNT_UNSHARED)
2457 compare_super = NULL;
2459 /* Get a superblock - note that we may end up sharing one that already exists */
2460 s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2466 if (s->s_fs_info != server) {
2467 nfs_free_server(server);
2470 error = nfs_bdi_register(server);
2472 goto error_splat_super;
2476 /* initial superblock/root creation */
2477 nfs4_clone_super(s, data->sb);
2480 mntroot = nfs4_get_root(s, data->fh);
2481 if (IS_ERR(mntroot)) {
2482 error = PTR_ERR(mntroot);
2483 goto error_splat_super;
2485 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2488 goto error_splat_super;
2491 s->s_flags |= MS_ACTIVE;
2493 mnt->mnt_root = mntroot;
2495 security_sb_clone_mnt_opts(data->sb, s);
2497 dprintk("<-- nfs4_xdev_get_sb() = 0\n");
2501 nfs_free_server(server);
2503 dprintk("<-- nfs4_xdev_get_sb() = %d [error]\n", error);
2507 up_write(&s->s_umount);
2508 deactivate_super(s);
2509 dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
2514 * Create an NFS4 server record on referral traversal
2516 static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
2517 const char *dev_name, void *raw_data,
2518 struct vfsmount *mnt)
2520 struct nfs_clone_mount *data = raw_data;
2521 struct super_block *s;
2522 struct nfs_server *server;
2523 struct dentry *mntroot;
2524 struct nfs_fh mntfh;
2525 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2526 struct nfs_sb_mountdata sb_mntdata = {
2531 dprintk("--> nfs4_referral_get_sb()\n");
2533 /* create a new volume representation */
2534 server = nfs4_create_referral_server(data, &mntfh);
2535 if (IS_ERR(server)) {
2536 error = PTR_ERR(server);
2537 goto out_err_noserver;
2539 sb_mntdata.server = server;
2541 if (server->flags & NFS4_MOUNT_UNSHARED)
2542 compare_super = NULL;
2544 /* Get a superblock - note that we may end up sharing one that already exists */
2545 s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2551 if (s->s_fs_info != server) {
2552 nfs_free_server(server);
2555 error = nfs_bdi_register(server);
2557 goto error_splat_super;
2561 /* initial superblock/root creation */
2565 mntroot = nfs4_get_root(s, &mntfh);
2566 if (IS_ERR(mntroot)) {
2567 error = PTR_ERR(mntroot);
2568 goto error_splat_super;
2570 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2573 goto error_splat_super;
2576 s->s_flags |= MS_ACTIVE;
2578 mnt->mnt_root = mntroot;
2580 security_sb_clone_mnt_opts(data->sb, s);
2582 dprintk("<-- nfs4_referral_get_sb() = 0\n");
2586 nfs_free_server(server);
2588 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error);
2592 up_write(&s->s_umount);
2593 deactivate_super(s);
2594 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
2598 #endif /* CONFIG_NFS_V4 */