Pull hotplug into release branch
[sfrench/cifs-2.6.git] / fs / nfs / super.c
index 3804aadc18c409e165a836d0562c8adfdd2480c8..2426e713b77f19567f82824c39126acacb59721d 100644 (file)
@@ -33,6 +33,8 @@
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/stats.h>
 #include <linux/sunrpc/metrics.h>
+#include <linux/sunrpc/xprtsock.h>
+#include <linux/sunrpc/xprtrdma.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
 #include <linux/nfs4_mount.h>
@@ -67,7 +69,7 @@ enum {
        Opt_ac, Opt_noac,
        Opt_lock, Opt_nolock,
        Opt_v2, Opt_v3,
-       Opt_udp, Opt_tcp,
+       Opt_udp, Opt_tcp, Opt_rdma,
        Opt_acl, Opt_noacl,
        Opt_rdirplus, Opt_nordirplus,
        Opt_sharecache, Opt_nosharecache,
@@ -113,6 +115,7 @@ static match_table_t nfs_mount_option_tokens = {
        { Opt_v3, "v3" },
        { Opt_udp, "udp" },
        { Opt_tcp, "tcp" },
+       { Opt_rdma, "rdma" },
        { Opt_acl, "acl" },
        { Opt_noacl, "noacl" },
        { Opt_rdirplus, "rdirplus" },
@@ -152,7 +155,7 @@ static match_table_t nfs_mount_option_tokens = {
 };
 
 enum {
-       Opt_xprt_udp, Opt_xprt_tcp,
+       Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma,
 
        Opt_xprt_err
 };
@@ -160,6 +163,7 @@ enum {
 static match_table_t nfs_xprt_protocol_tokens = {
        { Opt_xprt_udp, "udp" },
        { Opt_xprt_tcp, "tcp" },
+       { Opt_xprt_rdma, "rdma" },
 
        { Opt_xprt_err, NULL }
 };
@@ -420,7 +424,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
                const char *nostr;
        } nfs_info[] = {
                { NFS_MOUNT_SOFT, ",soft", ",hard" },
-               { NFS_MOUNT_INTR, ",intr", "" },
+               { NFS_MOUNT_INTR, ",intr", ",nointr" },
                { NFS_MOUNT_NOCTO, ",nocto", "" },
                { NFS_MOUNT_NOAC, ",noac", "" },
                { NFS_MOUNT_NONLM, ",nolock", "" },
@@ -431,8 +435,6 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
        };
        const struct proc_nfs_info *nfs_infop;
        struct nfs_client *clp = nfss->nfs_client;
-       char buf[12];
-       const char *proto;
 
        seq_printf(m, ",vers=%d", clp->rpc_ops->version);
        seq_printf(m, ",rsize=%d", nfss->rsize);
@@ -451,18 +453,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
                else
                        seq_puts(m, nfs_infop->nostr);
        }
-       switch (nfss->client->cl_xprt->prot) {
-               case IPPROTO_TCP:
-                       proto = "tcp";
-                       break;
-               case IPPROTO_UDP:
-                       proto = "udp";
-                       break;
-               default:
-                       snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot);
-                       proto = buf;
-       }
-       seq_printf(m, ",proto=%s", proto);
+       seq_printf(m, ",proto=%s",
+                  rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
        seq_printf(m, ",timeo=%lu", 10U * clp->retrans_timeo / HZ);
        seq_printf(m, ",retrans=%u", clp->retrans_count);
        seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
@@ -669,13 +661,19 @@ static int nfs_parse_mount_options(char *raw,
                        break;
                case Opt_udp:
                        mnt->flags &= ~NFS_MOUNT_TCP;
-                       mnt->nfs_server.protocol = IPPROTO_UDP;
+                       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 = IPPROTO_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;
                        break;
@@ -884,13 +882,20 @@ static int nfs_parse_mount_options(char *raw,
                        switch (token) {
                        case Opt_xprt_udp:
                                mnt->flags &= ~NFS_MOUNT_TCP;
-                               mnt->nfs_server.protocol = IPPROTO_UDP;
+                               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 = IPPROTO_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;
                                break;
@@ -908,11 +913,12 @@ static int nfs_parse_mount_options(char *raw,
 
                        switch (token) {
                        case Opt_xprt_udp:
-                               mnt->mount_server.protocol = IPPROTO_UDP;
+                               mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
                                break;
                        case Opt_xprt_tcp:
-                               mnt->mount_server.protocol = IPPROTO_TCP;
+                               mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
                                break;
+                       case Opt_xprt_rdma: /* not used for side protocols */
                        default:
                                goto out_unrec_xprt;
                        }
@@ -1048,10 +1054,11 @@ static int nfs_validate_mount_data(void *options,
 {
        struct nfs_mount_data *data = (struct nfs_mount_data *)options;
 
+       memset(args, 0, sizeof(*args));
+
        if (data == NULL)
                goto out_no_data;
 
-       memset(args, 0, sizeof(*args));
        args->flags             = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
        args->rsize             = NFS_MAX_FILE_IO_SIZE;
        args->wsize             = NFS_MAX_FILE_IO_SIZE;
@@ -1061,9 +1068,9 @@ static int nfs_validate_mount_data(void *options,
        args->acregmax          = 60;
        args->acdirmin          = 30;
        args->acdirmax          = 60;
-       args->mount_server.protocol = IPPROTO_UDP;
+       args->mount_server.protocol = XPRT_TRANSPORT_UDP;
        args->mount_server.program = NFS_MNT_PROGRAM;
-       args->nfs_server.protocol = IPPROTO_TCP;
+       args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
        args->nfs_server.program = NFS_PROGRAM;
 
        switch (data->version) {
@@ -1094,6 +1101,10 @@ static int nfs_validate_mount_data(void *options,
                if (mntfh->size < sizeof(mntfh->data))
                        memset(mntfh->data + mntfh->size, 0,
                               sizeof(mntfh->data) - mntfh->size);
+
+               if (!nfs_verify_server_address((struct sockaddr *) &data->addr))
+                       goto out_no_address;
+
                /*
                 * Translate to nfs_parsed_mount_data, which nfs_fill_super
                 * can deal with.
@@ -1110,7 +1121,7 @@ static int nfs_validate_mount_data(void *options,
                args->acdirmax          = data->acdirmax;
                args->nfs_server.address = data->addr;
                if (!(data->flags & NFS_MOUNT_TCP))
-                       args->nfs_server.protocol = IPPROTO_UDP;
+                       args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
                /* N.B. caller will free nfs_server.hostname in all cases */
                args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
                args->namlen            = data->namlen;
@@ -1125,6 +1136,10 @@ static int nfs_validate_mount_data(void *options,
                if (nfs_parse_mount_options((char *)options, args) == 0)
                        return -EINVAL;
 
+               if (!nfs_verify_server_address((struct sockaddr *)
+                                               &args->nfs_server.address))
+                       goto out_no_address;
+
                c = strchr(dev_name, ':');
                if (c == NULL)
                        return -EINVAL;
@@ -1153,10 +1168,6 @@ static int nfs_validate_mount_data(void *options,
                goto out_v3_not_compiled;
 #endif /* !CONFIG_NFS_V3 */
 
-       if (!nfs_verify_server_address((struct sockaddr *)
-                                               &args->nfs_server.address))
-               goto out_no_address;
-
        return 0;
 
 out_no_data:
@@ -1464,6 +1475,11 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
                error = PTR_ERR(mntroot);
                goto error_splat_super;
        }
+       if (mntroot->d_inode->i_op != &nfs_dir_inode_operations) {
+               dput(mntroot);
+               error = -ESTALE;
+               goto error_splat_super;
+       }
 
        s->s_flags |= MS_ACTIVE;
        mnt->mnt_sb = s;
@@ -1521,10 +1537,11 @@ static int nfs4_validate_mount_data(void *options,
        struct nfs4_mount_data *data = (struct nfs4_mount_data *)options;
        char *c;
 
+       memset(args, 0, sizeof(*args));
+
        if (data == NULL)
                goto out_no_data;
 
-       memset(args, 0, sizeof(*args));
        args->rsize             = NFS_MAX_FILE_IO_SIZE;
        args->wsize             = NFS_MAX_FILE_IO_SIZE;
        args->timeo             = 600;
@@ -1533,7 +1550,7 @@ static int nfs4_validate_mount_data(void *options,
        args->acregmax          = 60;
        args->acdirmin          = 30;
        args->acdirmax          = 60;
-       args->nfs_server.protocol = IPPROTO_TCP;
+       args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
 
        switch (data->version) {
        case 1: