Switch open_exec() and sys_uselib() to do_open_filp()
[safe/jmp/linux-2.6] / fs / nfs / super.c
index c4ee8b3..d2d6778 100644 (file)
@@ -5,7 +5,7 @@
  *
  *  nfs superblock handling functions
  *
- *  Modularised by Alan Cox <Alan.Cox@linux.org>, while hacking some
+ *  Modularised by Alan Cox <alan@lxorguk.ukuu.org.uk>, while hacking some
  *  experimental NFS changes. Modularisation taken straight from SYS5 fs.
  *
  *  Change to nfs_read_super() to permit NFS mounts to multi-homed hosts.
@@ -47,6 +47,7 @@
 #include <linux/inet.h>
 #include <linux/in6.h>
 #include <net/ipv6.h>
+#include <linux/netdevice.h>
 #include <linux/nfs_xdr.h>
 #include <linux/magic.h>
 #include <linux/parser.h>
@@ -59,6 +60,7 @@
 #include "delegation.h"
 #include "iostat.h"
 #include "internal.h"
+#include "fscache.h"
 
 #define NFSDBG_FACILITY                NFSDBG_VFS
 
@@ -74,6 +76,8 @@ enum {
        Opt_acl, Opt_noacl,
        Opt_rdirplus, Opt_nordirplus,
        Opt_sharecache, Opt_nosharecache,
+       Opt_resvport, Opt_noresvport,
+       Opt_fscache, Opt_nofscache,
 
        /* Mount options that take integer arguments */
        Opt_port,
@@ -90,18 +94,22 @@ enum {
        /* Mount options that take string arguments */
        Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
        Opt_addr, Opt_mountaddr, Opt_clientaddr,
+       Opt_lookupcache,
+       Opt_fscache_uniq,
 
-       /* Mount options that are ignored */
-       Opt_userspace, Opt_deprecated,
+       /* Special mount options */
+       Opt_userspace, Opt_deprecated, Opt_sloppy,
 
        Opt_err
 };
 
-static match_table_t nfs_mount_option_tokens = {
+static const match_table_t nfs_mount_option_tokens = {
        { Opt_userspace, "bg" },
        { Opt_userspace, "fg" },
        { Opt_userspace, "retry=%s" },
 
+       { Opt_sloppy, "sloppy" },
+
        { Opt_soft, "soft" },
        { Opt_hard, "hard" },
        { Opt_deprecated, "intr" },
@@ -125,6 +133,11 @@ static match_table_t nfs_mount_option_tokens = {
        { Opt_nordirplus, "nordirplus" },
        { Opt_sharecache, "sharecache" },
        { Opt_nosharecache, "nosharecache" },
+       { Opt_resvport, "resvport" },
+       { Opt_noresvport, "noresvport" },
+       { Opt_fscache, "fsc" },
+       { Opt_fscache_uniq, "fsc=%s" },
+       { Opt_nofscache, "nofsc" },
 
        { Opt_port, "port=%u" },
        { Opt_rsize, "rsize=%u" },
@@ -151,6 +164,8 @@ static match_table_t nfs_mount_option_tokens = {
        { Opt_mounthost, "mounthost=%s" },
        { Opt_mountaddr, "mountaddr=%s" },
 
+       { Opt_lookupcache, "lookupcache=%s" },
+
        { Opt_err, NULL }
 };
 
@@ -160,7 +175,7 @@ enum {
        Opt_xprt_err
 };
 
-static match_table_t nfs_xprt_protocol_tokens = {
+static const match_table_t nfs_xprt_protocol_tokens = {
        { Opt_xprt_udp, "udp" },
        { Opt_xprt_tcp, "tcp" },
        { Opt_xprt_rdma, "rdma" },
@@ -177,7 +192,7 @@ enum {
        Opt_sec_err
 };
 
-static match_table_t nfs_secflavor_tokens = {
+static const match_table_t nfs_secflavor_tokens = {
        { Opt_sec_none, "none" },
        { Opt_sec_none, "null" },
        { Opt_sec_sys, "sys" },
@@ -197,6 +212,22 @@ static match_table_t nfs_secflavor_tokens = {
        { Opt_sec_err, NULL }
 };
 
+enum {
+       Opt_lookupcache_all, Opt_lookupcache_positive,
+       Opt_lookupcache_none,
+
+       Opt_lookupcache_err
+};
+
+static match_table_t nfs_lookupcache_tokens = {
+       { Opt_lookupcache_all, "all" },
+       { Opt_lookupcache_positive, "pos" },
+       { Opt_lookupcache_positive, "positive" },
+       { Opt_lookupcache_none, "none" },
+
+       { Opt_lookupcache_err, NULL }
+};
+
 
 static void nfs_umount_begin(struct super_block *);
 static int  nfs_statfs(struct dentry *, struct kstatfs *);
@@ -206,7 +237,6 @@ static int nfs_get_sb(struct file_system_type *, int, const char *, void *, stru
 static int nfs_xdev_get_sb(struct file_system_type *fs_type,
                int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt);
 static void nfs_kill_super(struct super_block *);
-static void nfs_put_super(struct super_block *);
 static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
 
 static struct file_system_type nfs_fs_type = {
@@ -229,7 +259,6 @@ static const struct super_operations nfs_sops = {
        .alloc_inode    = nfs_alloc_inode,
        .destroy_inode  = nfs_destroy_inode,
        .write_inode    = nfs_write_inode,
-       .put_super      = nfs_put_super,
        .statfs         = nfs_statfs,
        .clear_inode    = nfs_clear_inode,
        .umount_begin   = nfs_umount_begin,
@@ -334,26 +363,20 @@ void __exit unregister_nfs_fs(void)
        unregister_filesystem(&nfs_fs_type);
 }
 
-void nfs_sb_active(struct nfs_server *server)
+void nfs_sb_active(struct super_block *sb)
 {
-       atomic_inc(&server->active);
-}
+       struct nfs_server *server = NFS_SB(sb);
 
-void nfs_sb_deactive(struct nfs_server *server)
-{
-       if (atomic_dec_and_test(&server->active))
-               wake_up(&server->active_wq);
+       if (atomic_inc_return(&server->active) == 1)
+               atomic_inc(&sb->s_active);
 }
 
-static void nfs_put_super(struct super_block *sb)
+void nfs_sb_deactive(struct super_block *sb)
 {
        struct nfs_server *server = NFS_SB(sb);
-       /*
-        * Make sure there are no outstanding ops to this server.
-        * If so, wait for them to finish before allowing the
-        * unmount to continue.
-        */
-       wait_event(server->active_wq, atomic_read(&server->active) == 0);
+
+       if (atomic_dec_and_test(&server->active))
+               deactivate_super(sb);
 }
 
 /*
@@ -371,8 +394,6 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
        };
        int error;
 
-       lock_kernel();
-
        error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
        if (error < 0)
                goto out_err;
@@ -404,12 +425,10 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 
        buf->f_namelen = server->namelen;
 
-       unlock_kernel();
        return 0;
 
  out_err:
        dprintk("%s: statfs error = %d\n", __func__, -error);
-       unlock_kernel();
        return error;
 }
 
@@ -452,14 +471,12 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
        switch (sap->sa_family) {
        case AF_INET: {
                struct sockaddr_in *sin = (struct sockaddr_in *)sap;
-               seq_printf(m, ",mountaddr=" NIPQUAD_FMT,
-                               NIPQUAD(sin->sin_addr.s_addr));
+               seq_printf(m, ",mountaddr=%pI4", &sin->sin_addr.s_addr);
                break;
        }
        case AF_INET6: {
                struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
-               seq_printf(m, ",mountaddr=" NIP6_FMT,
-                               NIP6(sin6->sin6_addr));
+               seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr);
                break;
        }
        default:
@@ -504,7 +521,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
                { NFS_MOUNT_NONLM, ",nolock", "" },
                { NFS_MOUNT_NOACL, ",noacl", "" },
                { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
-               { NFS_MOUNT_UNSHARED, ",nosharecache", ""},
+               { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
+               { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
                { 0, NULL, NULL }
        };
        const struct proc_nfs_info *nfs_infop;
@@ -517,13 +535,13 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
        if (nfss->bsize != 0)
                seq_printf(m, ",bsize=%u", nfss->bsize);
        seq_printf(m, ",namlen=%u", nfss->namelen);
-       if (nfss->acregmin != 3*HZ || showdefaults)
+       if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults)
                seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
-       if (nfss->acregmax != 60*HZ || showdefaults)
+       if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults)
                seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
-       if (nfss->acdirmin != 30*HZ || showdefaults)
+       if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults)
                seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
-       if (nfss->acdirmax != 60*HZ || showdefaults)
+       if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults)
                seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
        for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
                if (nfss->flags & nfs_infop->flag)
@@ -551,6 +569,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
        if (clp->rpc_ops->version == 4)
                seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
 #endif
+       if (nfss->options & NFS_OPTION_FSCACHE)
+               seq_printf(m, ",fsc");
 }
 
 /*
@@ -629,6 +649,10 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
                        totals.events[i] += stats->events[i];
                for (i = 0; i < __NFSIOS_BYTESMAX; i++)
                        totals.bytes[i] += stats->bytes[i];
+#ifdef CONFIG_NFS_FSCACHE
+               for (i = 0; i < __NFSIOS_FSCACHEMAX; i++)
+                       totals.fscache[i] += stats->fscache[i];
+#endif
 
                preempt_enable();
        }
@@ -639,6 +663,13 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
        seq_printf(m, "\n\tbytes:\t");
        for (i = 0; i < __NFSIOS_BYTESMAX; i++)
                seq_printf(m, "%Lu ", totals.bytes[i]);
+#ifdef CONFIG_NFS_FSCACHE
+       if (nfss->options & NFS_OPTION_FSCACHE) {
+               seq_printf(m, "\n\tfsc:\t");
+               for (i = 0; i < __NFSIOS_FSCACHEMAX; i++)
+                       seq_printf(m, "%Lu ", totals.bytes[i]);
+       }
+#endif
        seq_printf(m, "\n");
 
        rpc_print_iostats(m, nfss->client);
@@ -652,9 +683,12 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
  */
 static void nfs_umount_begin(struct super_block *sb)
 {
-       struct nfs_server *server = NFS_SB(sb);
+       struct nfs_server *server;
        struct rpc_clnt *rpc;
 
+       lock_kernel();
+
+       server = NFS_SB(sb);
        /* -EIO all pending I/O */
        rpc = server->client_acl;
        if (!IS_ERR(rpc))
@@ -662,25 +696,8 @@ static void nfs_umount_begin(struct super_block *sb)
        rpc = server->client;
        if (!IS_ERR(rpc))
                rpc_killall_tasks(rpc);
-}
 
-/*
- * Set the port number in an address.  Be agnostic about the address family.
- */
-static void nfs_set_port(struct sockaddr *sap, unsigned short port)
-{
-       switch (sap->sa_family) {
-       case AF_INET: {
-               struct sockaddr_in *ap = (struct sockaddr_in *)sap;
-               ap->sin_port = htons(port);
-               break;
-       }
-       case AF_INET6: {
-               struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
-               ap->sin6_port = htons(port);
-               break;
-       }
-       }
+       unlock_kernel();
 }
 
 /*
@@ -705,49 +722,243 @@ static int nfs_verify_server_address(struct sockaddr *addr)
        return 0;
 }
 
+static void nfs_parse_ipv4_address(char *string, size_t str_len,
+                                  struct sockaddr *sap, size_t *addr_len)
+{
+       struct sockaddr_in *sin = (struct sockaddr_in *)sap;
+       u8 *addr = (u8 *)&sin->sin_addr.s_addr;
+
+       if (str_len <= INET_ADDRSTRLEN) {
+               dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n",
+                               (int)str_len, string);
+
+               sin->sin_family = AF_INET;
+               *addr_len = sizeof(*sin);
+               if (in4_pton(string, str_len, addr, '\0', NULL))
+                       return;
+       }
+
+       sap->sa_family = AF_UNSPEC;
+       *addr_len = 0;
+}
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+static int nfs_parse_ipv6_scope_id(const char *string, const size_t str_len,
+                                  const char *delim,
+                                  struct sockaddr_in6 *sin6)
+{
+       char *p;
+       size_t len;
+
+       if ((string + str_len) == delim)
+               return 1;
+
+       if (*delim != IPV6_SCOPE_DELIMITER)
+               return 0;
+
+       if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL))
+               return 0;
+
+       len = (string + str_len) - delim - 1;
+       p = kstrndup(delim + 1, len, GFP_KERNEL);
+       if (p) {
+               unsigned long scope_id = 0;
+               struct net_device *dev;
+
+               dev = dev_get_by_name(&init_net, p);
+               if (dev != NULL) {
+                       scope_id = dev->ifindex;
+                       dev_put(dev);
+               } else {
+                       if (strict_strtoul(p, 10, &scope_id) == 0) {
+                               kfree(p);
+                               return 0;
+                       }
+               }
+
+               kfree(p);
+
+               sin6->sin6_scope_id = scope_id;
+               dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id);
+               return 1;
+       }
+
+       return 0;
+}
+
+static void nfs_parse_ipv6_address(char *string, size_t str_len,
+                                  struct sockaddr *sap, size_t *addr_len)
+{
+       struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
+       u8 *addr = (u8 *)&sin6->sin6_addr.in6_u;
+       const char *delim;
+
+       if (str_len <= INET6_ADDRSTRLEN) {
+               dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n",
+                               (int)str_len, string);
+
+               sin6->sin6_family = AF_INET6;
+               *addr_len = sizeof(*sin6);
+               if (in6_pton(string, str_len, addr,
+                                       IPV6_SCOPE_DELIMITER, &delim) != 0) {
+                       if (nfs_parse_ipv6_scope_id(string, str_len,
+                                                       delim, sin6) != 0)
+                               return;
+               }
+       }
+
+       sap->sa_family = AF_UNSPEC;
+       *addr_len = 0;
+}
+#else
+static void nfs_parse_ipv6_address(char *string, size_t str_len,
+                                  struct sockaddr *sap, size_t *addr_len)
+{
+       sap->sa_family = AF_UNSPEC;
+       *addr_len = 0;
+}
+#endif
+
 /*
- * Parse string addresses passed in via a mount option,
- * and construct a sockaddr based on the result.
+ * Construct a sockaddr based on the contents of a string that contains
+ * an IP address in presentation format.
  *
- * If address parsing fails, set the sockaddr's address
- * family to AF_UNSPEC to force nfs_verify_server_address()
- * to punt the mount.
+ * If there is a problem constructing the new sockaddr, set the address
+ * family to AF_UNSPEC.
  */
-static void nfs_parse_server_address(char *value,
-                                    struct sockaddr *sap,
-                                    size_t *len)
+void nfs_parse_ip_address(char *string, size_t str_len,
+                                struct sockaddr *sap, size_t *addr_len)
 {
-       if (strchr(value, ':')) {
-               struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
-               u8 *addr = (u8 *)&ap->sin6_addr.in6_u;
+       unsigned int i, colons;
 
-               ap->sin6_family = AF_INET6;
-               *len = sizeof(*ap);
-               if (in6_pton(value, -1, addr, '\0', NULL))
-                       return;
-       } else {
-               struct sockaddr_in *ap = (struct sockaddr_in *)sap;
-               u8 *addr = (u8 *)&ap->sin_addr.s_addr;
+       colons = 0;
+       for (i = 0; i < str_len; i++)
+               if (string[i] == ':')
+                       colons++;
 
-               ap->sin_family = AF_INET;
-               *len = sizeof(*ap);
-               if (in4_pton(value, -1, addr, '\0', NULL))
+       if (colons >= 2)
+               nfs_parse_ipv6_address(string, str_len, sap, addr_len);
+       else
+               nfs_parse_ipv4_address(string, str_len, sap, addr_len);
+}
+
+/*
+ * Sanity check the NFS transport protocol.
+ *
+ */
+static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
+{
+       switch (mnt->nfs_server.protocol) {
+       case XPRT_TRANSPORT_UDP:
+       case XPRT_TRANSPORT_TCP:
+       case XPRT_TRANSPORT_RDMA:
+               break;
+       default:
+               mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
+       }
+}
+
+/*
+ * For text based NFSv2/v3 mounts, the mount protocol transport default
+ * settings should depend upon the specified NFS transport.
+ */
+static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
+{
+       nfs_validate_transport_protocol(mnt);
+
+       if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
+           mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
                        return;
+       switch (mnt->nfs_server.protocol) {
+       case XPRT_TRANSPORT_UDP:
+               mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
+               break;
+       case XPRT_TRANSPORT_TCP:
+       case XPRT_TRANSPORT_RDMA:
+               mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
        }
+}
 
-       sap->sa_family = AF_UNSPEC;
-       *len = 0;
+/*
+ * Parse the value of the 'sec=' option.
+ *
+ * The flavor_len setting is for v4 mounts.
+ */
+static int nfs_parse_security_flavors(char *value,
+                                     struct nfs_parsed_mount_data *mnt)
+{
+       substring_t args[MAX_OPT_ARGS];
+
+       dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value);
+
+       switch (match_token(value, nfs_secflavor_tokens, args)) {
+       case Opt_sec_none:
+               mnt->auth_flavor_len = 0;
+               mnt->auth_flavors[0] = RPC_AUTH_NULL;
+               break;
+       case Opt_sec_sys:
+               mnt->auth_flavor_len = 0;
+               mnt->auth_flavors[0] = RPC_AUTH_UNIX;
+               break;
+       case Opt_sec_krb5:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
+               break;
+       case Opt_sec_krb5i:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
+               break;
+       case Opt_sec_krb5p:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
+               break;
+       case Opt_sec_lkey:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
+               break;
+       case Opt_sec_lkeyi:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
+               break;
+       case Opt_sec_lkeyp:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
+               break;
+       case Opt_sec_spkm:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
+               break;
+       case Opt_sec_spkmi:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
+               break;
+       case Opt_sec_spkmp:
+               mnt->auth_flavor_len = 1;
+               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
+               break;
+       default:
+               return 0;
+       }
+
+       return 1;
+}
+
+static void nfs_parse_invalid_value(const char *option)
+{
+       dfprintk(MOUNT, "NFS:   bad value specified for %s option\n", option);
 }
 
 /*
  * Error-check and convert a string of mount options from user space into
- * a data structure
+ * a data structure.  The whole mount string is processed; bad options are
+ * skipped as they are encountered.  If there were no errors, return 1;
+ * otherwise return 0 (zero).
  */
 static int nfs_parse_mount_options(char *raw,
                                   struct nfs_parsed_mount_data *mnt)
 {
        char *p, *string, *secdata;
-       int rc;
+       int rc, sloppy = 0, errors = 0;
 
        if (!raw) {
                dfprintk(MOUNT, "NFS: mount options string was NULL.\n");
@@ -780,6 +991,10 @@ static int nfs_parse_mount_options(char *raw,
 
                token = match_token(p, nfs_mount_option_tokens, args);
                switch (token) {
+
+               /*
+                * boolean options:  foo/nofoo
+                */
                case Opt_soft:
                        mnt->flags |= NFS_MOUNT_SOFT;
                        break;
@@ -819,20 +1034,15 @@ static int nfs_parse_mount_options(char *raw,
                case Opt_udp:
                        mnt->flags &= ~NFS_MOUNT_TCP;
                        mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
-                       mnt->timeo = 7;
-                       mnt->retrans = 5;
                        break;
                case Opt_tcp:
                        mnt->flags |= NFS_MOUNT_TCP;
                        mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
-                       mnt->timeo = 600;
-                       mnt->retrans = 2;
                        break;
                case Opt_rdma:
                        mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
                        mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
-                       mnt->timeo = 600;
-                       mnt->retrans = 2;
+                       xprt_load_transport(p);
                        break;
                case Opt_acl:
                        mnt->flags &= ~NFS_MOUNT_NOACL;
@@ -852,166 +1062,169 @@ static int nfs_parse_mount_options(char *raw,
                case Opt_nosharecache:
                        mnt->flags |= NFS_MOUNT_UNSHARED;
                        break;
+               case Opt_resvport:
+                       mnt->flags &= ~NFS_MOUNT_NORESVPORT;
+                       break;
+               case Opt_noresvport:
+                       mnt->flags |= NFS_MOUNT_NORESVPORT;
+                       break;
+               case Opt_fscache:
+                       mnt->options |= NFS_OPTION_FSCACHE;
+                       kfree(mnt->fscache_uniq);
+                       mnt->fscache_uniq = NULL;
+                       break;
+               case Opt_nofscache:
+                       mnt->options &= ~NFS_OPTION_FSCACHE;
+                       kfree(mnt->fscache_uniq);
+                       mnt->fscache_uniq = NULL;
+                       break;
+               case Opt_fscache_uniq:
+                       string = match_strdup(args);
+                       if (!string)
+                               goto out_nomem;
+                       kfree(mnt->fscache_uniq);
+                       mnt->fscache_uniq = string;
+                       mnt->options |= NFS_OPTION_FSCACHE;
+                       break;
 
+               /*
+                * options that take numeric values
+                */
                case Opt_port:
-                       if (match_int(args, &option))
-                               return 0;
-                       if (option < 0 || option > 65535)
-                               return 0;
-                       mnt->nfs_server.port = option;
+                       if (match_int(args, &option) ||
+                           option < 0 || option > USHORT_MAX) {
+                               errors++;
+                               nfs_parse_invalid_value("port");
+                       } else
+                               mnt->nfs_server.port = option;
                        break;
                case Opt_rsize:
-                       if (match_int(args, &mnt->rsize))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("rsize");
+                       } else
+                               mnt->rsize = option;
                        break;
                case Opt_wsize:
-                       if (match_int(args, &mnt->wsize))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("wsize");
+                       } else
+                               mnt->wsize = option;
                        break;
                case Opt_bsize:
-                       if (match_int(args, &option))
-                               return 0;
-                       if (option < 0)
-                               return 0;
-                       mnt->bsize = option;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("bsize");
+                       } else
+                               mnt->bsize = option;
                        break;
                case Opt_timeo:
-                       if (match_int(args, &mnt->timeo))
-                               return 0;
+                       if (match_int(args, &option) || option <= 0) {
+                               errors++;
+                               nfs_parse_invalid_value("timeo");
+                       } else
+                               mnt->timeo = option;
                        break;
                case Opt_retrans:
-                       if (match_int(args, &mnt->retrans))
-                               return 0;
+                       if (match_int(args, &option) || option <= 0) {
+                               errors++;
+                               nfs_parse_invalid_value("retrans");
+                       } else
+                               mnt->retrans = option;
                        break;
                case Opt_acregmin:
-                       if (match_int(args, &mnt->acregmin))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("acregmin");
+                       } else
+                               mnt->acregmin = option;
                        break;
                case Opt_acregmax:
-                       if (match_int(args, &mnt->acregmax))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("acregmax");
+                       } else
+                               mnt->acregmax = option;
                        break;
                case Opt_acdirmin:
-                       if (match_int(args, &mnt->acdirmin))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("acdirmin");
+                       } else
+                               mnt->acdirmin = option;
                        break;
                case Opt_acdirmax:
-                       if (match_int(args, &mnt->acdirmax))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("acdirmax");
+                       } else
+                               mnt->acdirmax = option;
                        break;
                case Opt_actimeo:
-                       if (match_int(args, &option))
-                               return 0;
-                       if (option < 0)
-                               return 0;
-                       mnt->acregmin =
-                       mnt->acregmax =
-                       mnt->acdirmin =
-                       mnt->acdirmax = option;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("actimeo");
+                       } else
+                               mnt->acregmin = mnt->acregmax =
+                               mnt->acdirmin = mnt->acdirmax = option;
                        break;
                case Opt_namelen:
-                       if (match_int(args, &mnt->namlen))
-                               return 0;
+                       if (match_int(args, &option) || option < 0) {
+                               errors++;
+                               nfs_parse_invalid_value("namlen");
+                       } else
+                               mnt->namlen = option;
                        break;
                case Opt_mountport:
-                       if (match_int(args, &option))
-                               return 0;
-                       if (option < 0 || option > 65535)
-                               return 0;
-                       mnt->mount_server.port = option;
+                       if (match_int(args, &option) ||
+                           option < 0 || option > USHORT_MAX) {
+                               errors++;
+                               nfs_parse_invalid_value("mountport");
+                       } else
+                               mnt->mount_server.port = option;
                        break;
                case Opt_mountvers:
-                       if (match_int(args, &option))
-                               return 0;
-                       if (option < 0)
-                               return 0;
-                       mnt->mount_server.version = option;
+                       if (match_int(args, &option) ||
+                           option < NFS_MNT_VERSION ||
+                           option > NFS_MNT3_VERSION) {
+                               errors++;
+                               nfs_parse_invalid_value("mountvers");
+                       } else
+                               mnt->mount_server.version = option;
                        break;
                case Opt_nfsvers:
-                       if (match_int(args, &option))
-                               return 0;
+                       if (match_int(args, &option)) {
+                               errors++;
+                               nfs_parse_invalid_value("nfsvers");
+                               break;
+                       }
                        switch (option) {
-                       case 2:
+                       case NFS2_VERSION:
                                mnt->flags &= ~NFS_MOUNT_VER3;
                                break;
-                       case 3:
+                       case NFS3_VERSION:
                                mnt->flags |= NFS_MOUNT_VER3;
                                break;
                        default:
-                               goto out_unrec_vers;
+                               errors++;
+                               nfs_parse_invalid_value("nfsvers");
                        }
                        break;
 
+               /*
+                * options that take text values
+                */
                case Opt_sec:
                        string = match_strdup(args);
                        if (string == NULL)
                                goto out_nomem;
-                       token = match_token(string, nfs_secflavor_tokens, args);
+                       rc = nfs_parse_security_flavors(string, mnt);
                        kfree(string);
-
-                       /*
-                        * The flags setting is for v2/v3.  The flavor_len
-                        * setting is for v4.  v2/v3 also need to know the
-                        * difference between NULL and UNIX.
-                        */
-                       switch (token) {
-                       case Opt_sec_none:
-                               mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 0;
-                               mnt->auth_flavors[0] = RPC_AUTH_NULL;
-                               break;
-                       case Opt_sec_sys:
-                               mnt->flags &= ~NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 0;
-                               mnt->auth_flavors[0] = RPC_AUTH_UNIX;
-                               break;
-                       case Opt_sec_krb5:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5;
-                               break;
-                       case Opt_sec_krb5i:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I;
-                               break;
-                       case Opt_sec_krb5p:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P;
-                               break;
-                       case Opt_sec_lkey:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY;
-                               break;
-                       case Opt_sec_lkeyi:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI;
-                               break;
-                       case Opt_sec_lkeyp:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP;
-                               break;
-                       case Opt_sec_spkm:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM;
-                               break;
-                       case Opt_sec_spkmi:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI;
-                               break;
-                       case Opt_sec_spkmp:
-                               mnt->flags |= NFS_MOUNT_SECFLAVOUR;
-                               mnt->auth_flavor_len = 1;
-                               mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP;
-                               break;
-                       default:
-                               goto out_unrec_sec;
+                       if (!rc) {
+                               errors++;
+                               dfprintk(MOUNT, "NFS:   unrecognized "
+                                               "security flavor\n");
                        }
                        break;
                case Opt_proto:
@@ -1020,31 +1233,28 @@ static int nfs_parse_mount_options(char *raw,
                                goto out_nomem;
                        token = match_token(string,
                                            nfs_xprt_protocol_tokens, args);
-                       kfree(string);
 
                        switch (token) {
                        case Opt_xprt_udp:
                                mnt->flags &= ~NFS_MOUNT_TCP;
                                mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
-                               mnt->timeo = 7;
-                               mnt->retrans = 5;
                                break;
                        case Opt_xprt_tcp:
                                mnt->flags |= NFS_MOUNT_TCP;
                                mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
-                               mnt->timeo = 600;
-                               mnt->retrans = 2;
                                break;
                        case Opt_xprt_rdma:
                                /* vector side protocols to TCP */
                                mnt->flags |= NFS_MOUNT_TCP;
                                mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
-                               mnt->timeo = 600;
-                               mnt->retrans = 2;
+                               xprt_load_transport(string);
                                break;
                        default:
-                               goto out_unrec_xprt;
+                               errors++;
+                               dfprintk(MOUNT, "NFS:   unrecognized "
+                                               "transport protocol\n");
                        }
+                       kfree(string);
                        break;
                case Opt_mountproto:
                        string = match_strdup(args);
@@ -1063,16 +1273,19 @@ static int nfs_parse_mount_options(char *raw,
                                break;
                        case Opt_xprt_rdma: /* not used for side protocols */
                        default:
-                               goto out_unrec_xprt;
+                               errors++;
+                               dfprintk(MOUNT, "NFS:   unrecognized "
+                                               "transport protocol\n");
                        }
                        break;
                case Opt_addr:
                        string = match_strdup(args);
                        if (string == NULL)
                                goto out_nomem;
-                       nfs_parse_server_address(string, (struct sockaddr *)
-                                                &mnt->nfs_server.address,
-                                                &mnt->nfs_server.addrlen);
+                       nfs_parse_ip_address(string, strlen(string),
+                                            (struct sockaddr *)
+                                               &mnt->nfs_server.address,
+                                            &mnt->nfs_server.addrlen);
                        kfree(string);
                        break;
                case Opt_clientaddr:
@@ -1093,12 +1306,44 @@ static int nfs_parse_mount_options(char *raw,
                        string = match_strdup(args);
                        if (string == NULL)
                                goto out_nomem;
-                       nfs_parse_server_address(string, (struct sockaddr *)
-                                                &mnt->mount_server.address,
-                                                &mnt->mount_server.addrlen);
+                       nfs_parse_ip_address(string, strlen(string),
+                                            (struct sockaddr *)
+                                               &mnt->mount_server.address,
+                                            &mnt->mount_server.addrlen);
+                       kfree(string);
+                       break;
+               case Opt_lookupcache:
+                       string = match_strdup(args);
+                       if (string == NULL)
+                               goto out_nomem;
+                       token = match_token(string,
+                                       nfs_lookupcache_tokens, args);
                        kfree(string);
+                       switch (token) {
+                               case Opt_lookupcache_all:
+                                       mnt->flags &= ~(NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE);
+                                       break;
+                               case Opt_lookupcache_positive:
+                                       mnt->flags &= ~NFS_MOUNT_LOOKUP_CACHE_NONE;
+                                       mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG;
+                                       break;
+                               case Opt_lookupcache_none:
+                                       mnt->flags |= NFS_MOUNT_LOOKUP_CACHE_NONEG|NFS_MOUNT_LOOKUP_CACHE_NONE;
+                                       break;
+                               default:
+                                       errors++;
+                                       dfprintk(MOUNT, "NFS:   invalid "
+                                                       "lookupcache argument\n");
+                       };
                        break;
 
+               /*
+                * Special options
+                */
+               case Opt_sloppy:
+                       sloppy = 1;
+                       dfprintk(MOUNT, "NFS:   relaxing parsing rules\n");
+                       break;
                case Opt_userspace:
                case Opt_deprecated:
                        dfprintk(MOUNT, "NFS:   ignoring mount option "
@@ -1106,13 +1351,18 @@ static int nfs_parse_mount_options(char *raw,
                        break;
 
                default:
-                       goto out_unknown;
+                       errors++;
+                       dfprintk(MOUNT, "NFS:   unrecognized mount option "
+                                       "'%s'\n", p);
                }
        }
 
-       nfs_set_port((struct sockaddr *)&mnt->nfs_server.address,
-                               mnt->nfs_server.port);
-
+       if (errors > 0) {
+               dfprintk(MOUNT, "NFS: parsing encountered %d error%s\n",
+                               errors, (errors == 1 ? "" : "s"));
+               if (!sloppy)
+                       return 0;
+       }
        return 1;
 
 out_nomem:
@@ -1122,21 +1372,6 @@ out_security_failure:
        free_secdata(secdata);
        printk(KERN_INFO "NFS: security options invalid: %d\n", rc);
        return 0;
-out_unrec_vers:
-       printk(KERN_INFO "NFS: unrecognized NFS version number\n");
-       return 0;
-
-out_unrec_xprt:
-       printk(KERN_INFO "NFS: unrecognized transport protocol\n");
-       return 0;
-
-out_unrec_sec:
-       printk(KERN_INFO "NFS: unrecognized security flavor\n");
-       return 0;
-
-out_unknown:
-       printk(KERN_INFO "NFS: unknown mount option: %s\n", p);
-       return 0;
 }
 
 /*
@@ -1146,8 +1381,14 @@ out_unknown:
 static int nfs_try_mount(struct nfs_parsed_mount_data *args,
                         struct nfs_fh *root_fh)
 {
-       struct sockaddr *sap = (struct sockaddr *)&args->mount_server.address;
-       char *hostname;
+       struct nfs_mount_request request = {
+               .sap            = (struct sockaddr *)
+                                               &args->mount_server.address,
+               .dirpath        = args->nfs_server.export_path,
+               .protocol       = args->mount_server.protocol,
+               .fh             = root_fh,
+               .noresvport     = args->flags & NFS_MOUNT_NORESVPORT,
+       };
        int status;
 
        if (args->mount_server.version == 0) {
@@ -1156,53 +1397,44 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
                else
                        args->mount_server.version = NFS_MNT_VERSION;
        }
+       request.version = args->mount_server.version;
 
        if (args->mount_server.hostname)
-               hostname = args->mount_server.hostname;
+               request.hostname = args->mount_server.hostname;
        else
-               hostname = args->nfs_server.hostname;
+               request.hostname = args->nfs_server.hostname;
 
        /*
         * Construct the mount server's address.
         */
        if (args->mount_server.address.ss_family == AF_UNSPEC) {
-               memcpy(sap, &args->nfs_server.address,
+               memcpy(request.sap, &args->nfs_server.address,
                       args->nfs_server.addrlen);
                args->mount_server.addrlen = args->nfs_server.addrlen;
        }
+       request.salen = args->mount_server.addrlen;
 
        /*
         * autobind will be used if mount_server.port == 0
         */
-       nfs_set_port(sap, args->mount_server.port);
+       nfs_set_port(request.sap, args->mount_server.port);
 
        /*
         * Now ask the mount server to map our export path
         * to a file handle.
         */
-       status = nfs_mount(sap,
-                          args->mount_server.addrlen,
-                          hostname,
-                          args->nfs_server.export_path,
-                          args->mount_server.version,
-                          args->mount_server.protocol,
-                          root_fh);
+       status = nfs_mount(&request);
        if (status == 0)
                return 0;
 
        dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n",
-                       hostname, status);
+                       request.hostname, status);
        return status;
 }
 
-/*
- * Split "dev_name" into "hostname:export_path".
- *
- * Note: caller frees hostname and export path, even on error.
- */
-static int nfs_parse_devname(const char *dev_name,
-                            char **hostname, size_t maxnamlen,
-                            char **export_path, size_t maxpathlen)
+static int nfs_parse_simple_hostname(const char *dev_name,
+                                    char **hostname, size_t maxnamlen,
+                                    char **export_path, size_t maxpathlen)
 {
        size_t len;
        char *colon, *comma;
@@ -1257,6 +1489,85 @@ out_path:
 }
 
 /*
+ * Hostname has square brackets around it because it contains one or
+ * more colons.  We look for the first closing square bracket, and a
+ * colon must follow it.
+ */
+static int nfs_parse_protected_hostname(const char *dev_name,
+                                       char **hostname, size_t maxnamlen,
+                                       char **export_path, size_t maxpathlen)
+{
+       size_t len;
+       char *start, *end;
+
+       start = (char *)(dev_name + 1);
+
+       end = strchr(start, ']');
+       if (end == NULL)
+               goto out_bad_devname;
+       if (*(end + 1) != ':')
+               goto out_bad_devname;
+
+       len = end - start;
+       if (len > maxnamlen)
+               goto out_hostname;
+
+       /* N.B. caller will free nfs_server.hostname in all cases */
+       *hostname = kstrndup(start, len, GFP_KERNEL);
+       if (*hostname == NULL)
+               goto out_nomem;
+
+       end += 2;
+       len = strlen(end);
+       if (len > maxpathlen)
+               goto out_path;
+       *export_path = kstrndup(end, len, GFP_KERNEL);
+       if (!*export_path)
+               goto out_nomem;
+
+       return 0;
+
+out_bad_devname:
+       dfprintk(MOUNT, "NFS: device name not in host:path format\n");
+       return -EINVAL;
+
+out_nomem:
+       dfprintk(MOUNT, "NFS: not enough memory to parse device name\n");
+       return -ENOMEM;
+
+out_hostname:
+       dfprintk(MOUNT, "NFS: server hostname too long\n");
+       return -ENAMETOOLONG;
+
+out_path:
+       dfprintk(MOUNT, "NFS: export pathname too long\n");
+       return -ENAMETOOLONG;
+}
+
+/*
+ * Split "dev_name" into "hostname:export_path".
+ *
+ * The leftmost colon demarks the split between the server's hostname
+ * and the export path.  If the hostname starts with a left square
+ * bracket, then it may contain colons.
+ *
+ * Note: caller frees hostname and export path, even on error.
+ */
+static int nfs_parse_devname(const char *dev_name,
+                            char **hostname, size_t maxnamlen,
+                            char **export_path, size_t maxpathlen)
+{
+       if (*dev_name == '[')
+               return nfs_parse_protected_hostname(dev_name,
+                                                   hostname, maxnamlen,
+                                                   export_path, maxpathlen);
+
+       return nfs_parse_simple_hostname(dev_name,
+                                        hostname, maxnamlen,
+                                        export_path, maxpathlen);
+}
+
+/*
  * Validate the NFS2/NFS3 mount data
  * - fills in the mount root filehandle
  *
@@ -1285,16 +1596,14 @@ static int nfs_validate_mount_data(void *options,
        args->flags             = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
        args->rsize             = NFS_MAX_FILE_IO_SIZE;
        args->wsize             = NFS_MAX_FILE_IO_SIZE;
-       args->timeo             = 600;
-       args->retrans           = 2;
-       args->acregmin          = 3;
-       args->acregmax          = 60;
-       args->acdirmin          = 30;
-       args->acdirmax          = 60;
+       args->acregmin          = NFS_DEF_ACREGMIN;
+       args->acregmax          = NFS_DEF_ACREGMAX;
+       args->acdirmin          = NFS_DEF_ACDIRMIN;
+       args->acdirmax          = NFS_DEF_ACDIRMAX;
        args->mount_server.port = 0;    /* autobind unless user sets port */
-       args->mount_server.protocol = XPRT_TRANSPORT_UDP;
        args->nfs_server.port   = 0;    /* autobind unless user sets port */
        args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
+       args->auth_flavors[0]   = RPC_AUTH_UNIX;
 
        switch (data->version) {
        case 1:
@@ -1329,7 +1638,7 @@ static int nfs_validate_mount_data(void *options,
                 * Translate to nfs_parsed_mount_data, which nfs_fill_super
                 * can deal with.
                 */
-               args->flags             = data->flags;
+               args->flags             = data->flags & NFS_MOUNT_FLAGMASK;
                args->rsize             = data->rsize;
                args->wsize             = data->wsize;
                args->timeo             = data->timeo;
@@ -1352,7 +1661,9 @@ static int nfs_validate_mount_data(void *options,
                args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
                args->namlen            = data->namlen;
                args->bsize             = data->bsize;
-               args->auth_flavors[0]   = data->pseudoflavor;
+
+               if (data->flags & NFS_MOUNT_SECFLAVOUR)
+                       args->auth_flavors[0] = data->pseudoflavor;
                if (!args->nfs_server.hostname)
                        goto out_nomem;
 
@@ -1393,6 +1704,11 @@ static int nfs_validate_mount_data(void *options,
                                                &args->nfs_server.address))
                        goto out_no_address;
 
+               nfs_set_port((struct sockaddr *)&args->nfs_server.address,
+                               args->nfs_server.port);
+
+               nfs_set_mount_transport_protocol(args);
+
                status = nfs_parse_devname(dev_name,
                                           &args->nfs_server.hostname,
                                           PAGE_SIZE,
@@ -1411,9 +1727,6 @@ static int nfs_validate_mount_data(void *options,
                }
        }
 
-       if (!(args->flags & NFS_MOUNT_SECFLAVOUR))
-               args->auth_flavors[0] = RPC_AUTH_UNIX;
-
 #ifndef CONFIG_NFS_V3
        if (args->flags & NFS_MOUNT_VER3)
                goto out_v3_not_compiled;
@@ -1491,9 +1804,9 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
         * ones were explicitly specified. Fall back to legacy behavior and
         * just return success.
         */
-       if ((nfsvers == 4 && options4->version == 1) ||
-           (nfsvers <= 3 && options->version >= 1 &&
-            options->version <= 6))
+       if ((nfsvers == 4 && (!options4 || options4->version == 1)) ||
+           (nfsvers <= 3 && (!options || (options->version >= 1 &&
+                                          options->version <= 6))))
                return 0;
 
        data = kzalloc(sizeof(*data), GFP_KERNEL);
@@ -1599,8 +1912,6 @@ static void nfs_clone_super(struct super_block *sb,
        nfs_initialise_sb(sb);
 }
 
-#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
-
 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
 {
        const struct nfs_server *a = s->s_fs_info;
@@ -1765,6 +2076,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
        if (!s->s_root) {
                /* initial superblock/root creation */
                nfs_fill_super(s, data);
+               nfs_fscache_get_super_cookie(s, data);
        }
 
        mntroot = nfs_get_root(s, mntfh);
@@ -1785,6 +2097,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
 out:
        kfree(data->nfs_server.hostname);
        kfree(data->mount_server.hostname);
+       kfree(data->fscache_uniq);
        security_free_mnt_opts(&data->lsm_opts);
 out_free_fh:
        kfree(mntfh);
@@ -1798,8 +2111,7 @@ out_err_nosb:
 error_splat_root:
        dput(mntroot);
 error_splat_super:
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        goto out;
 }
 
@@ -1812,6 +2124,7 @@ static void nfs_kill_super(struct super_block *s)
 
        bdi_unregister(&server->backing_dev_info);
        kill_anon_super(s);
+       nfs_fscache_release_super_cookie(s);
        nfs_free_server(server);
 }
 
@@ -1894,8 +2207,7 @@ out_err_noserver:
        return error;
 
 error_splat_super:
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        dprintk("<-- nfs_xdev_get_sb() = %d [splat]\n", error);
        return error;
 }
@@ -1942,14 +2254,13 @@ static int nfs4_validate_mount_data(void *options,
 
        args->rsize             = NFS_MAX_FILE_IO_SIZE;
        args->wsize             = NFS_MAX_FILE_IO_SIZE;
-       args->timeo             = 600;
-       args->retrans           = 2;
-       args->acregmin          = 3;
-       args->acregmax          = 60;
-       args->acdirmin          = 30;
-       args->acdirmax          = 60;
+       args->acregmin          = NFS_DEF_ACREGMIN;
+       args->acregmax          = NFS_DEF_ACREGMAX;
+       args->acdirmin          = NFS_DEF_ACDIRMIN;
+       args->acdirmax          = NFS_DEF_ACDIRMAX;
        args->nfs_server.port   = NFS_PORT; /* 2049 unless user set port= */
-       args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
+       args->auth_flavors[0]   = RPC_AUTH_UNIX;
+       args->auth_flavor_len   = 0;
 
        switch (data->version) {
        case 1:
@@ -1965,18 +2276,13 @@ static int nfs4_validate_mount_data(void *options,
                                                &args->nfs_server.address))
                        goto out_no_address;
 
-               switch (data->auth_flavourlen) {
-               case 0:
-                       args->auth_flavors[0] = RPC_AUTH_UNIX;
-                       break;
-               case 1:
+               if (data->auth_flavourlen) {
+                       if (data->auth_flavourlen > 1)
+                               goto out_inval_auth;
                        if (copy_from_user(&args->auth_flavors[0],
                                           data->auth_flavours,
                                           sizeof(args->auth_flavors[0])))
                                return -EFAULT;
-                       break;
-               default:
-                       goto out_inval_auth;
                }
 
                c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
@@ -2010,6 +2316,7 @@ static int nfs4_validate_mount_data(void *options,
                args->acdirmin  = data->acdirmin;
                args->acdirmax  = data->acdirmax;
                args->nfs_server.protocol = data->proto;
+               nfs_validate_transport_protocol(args);
 
                break;
        default: {
@@ -2022,15 +2329,13 @@ static int nfs4_validate_mount_data(void *options,
                                                &args->nfs_server.address))
                        return -EINVAL;
 
-               switch (args->auth_flavor_len) {
-               case 0:
-                       args->auth_flavors[0] = RPC_AUTH_UNIX;
-                       break;
-               case 1:
-                       break;
-               default:
+               nfs_set_port((struct sockaddr *)&args->nfs_server.address,
+                               args->nfs_server.port);
+
+               nfs_validate_transport_protocol(args);
+
+               if (args->auth_flavor_len > 1)
                        goto out_inval_auth;
-               }
 
                if (args->client_address == NULL)
                        goto out_no_client_address;
@@ -2126,6 +2431,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
        if (!s->s_root) {
                /* initial superblock/root creation */
                nfs4_fill_super(s);
+               nfs_fscache_get_super_cookie(s, data);
        }
 
        mntroot = nfs4_get_root(s, mntfh);
@@ -2147,6 +2453,7 @@ out:
        kfree(data->client_address);
        kfree(data->nfs_server.export_path);
        kfree(data->nfs_server.hostname);
+       kfree(data->fscache_uniq);
        security_free_mnt_opts(&data->lsm_opts);
 out_free_fh:
        kfree(mntfh);
@@ -2160,8 +2467,7 @@ out_free:
 error_splat_root:
        dput(mntroot);
 error_splat_super:
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        goto out;
 }
 
@@ -2169,10 +2475,11 @@ static void nfs4_kill_super(struct super_block *sb)
 {
        struct nfs_server *server = NFS_SB(sb);
 
-       nfs_return_all_delegations(sb);
+       nfs_super_return_all_delegations(sb);
        kill_anon_super(sb);
 
        nfs4_renewd_prepare_shutdown(server);
+       nfs_fscache_release_super_cookie(sb);
        nfs_free_server(server);
 }
 
@@ -2207,7 +2514,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
+       s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
@@ -2254,8 +2561,7 @@ out_err_noserver:
        return error;
 
 error_splat_super:
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        dprintk("<-- nfs4_xdev_get_sb() = %d [splat]\n", error);
        return error;
 }
@@ -2292,7 +2598,7 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
+       s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
@@ -2339,8 +2645,7 @@ out_err_noserver:
        return error;
 
 error_splat_super:
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
        return error;
 }