]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/nfs/nfs4namespace.c
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux.git] / fs / nfs / nfs4namespace.c
index a1a0c4c53ce13728fc2ae2ec3cd83e8a051a954d..84026e7b8a5f3fe528d9f95968a2b43947b5762e 100644 (file)
@@ -130,12 +130,16 @@ static int nfs4_validate_fspath(struct dentry *dentry,
                                const struct nfs4_fs_locations *locations,
                                struct nfs_fs_context *ctx)
 {
-       const char *path, *fs_path;
-       char *buf;
+       const char *path;
+       char *fs_path;
        unsigned short len;
+       char *buf;
        int n;
 
        buf = kmalloc(4096, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
        path = nfs4_path(dentry, buf, 4096);
        if (IS_ERR(path)) {
                kfree(buf);
@@ -278,7 +282,6 @@ nfs4_negotiate_security(struct rpc_clnt *clnt, struct inode *inode,
 static int try_location(struct fs_context *fc,
                        const struct nfs4_fs_location *location)
 {
-       const size_t addr_bufsize = sizeof(struct sockaddr_storage);
        struct nfs_fs_context *ctx = nfs_fc2context(fc);
        unsigned int len, s;
        char *export_path, *source, *p;
@@ -314,29 +317,24 @@ static int try_location(struct fs_context *fc,
 
        kfree(fc->source);
        fc->source = source;
-
-       ctx->clone_data.addr = kmalloc(addr_bufsize, GFP_KERNEL);
-       if (ctx->clone_data.addr == NULL)
-               return -ENOMEM;
        for (s = 0; s < location->nservers; s++) {
                const struct nfs4_string *buf = &location->servers[s];
 
                if (memchr(buf->data, IPV6_SCOPE_DELIMITER, buf->len))
                        continue;
 
-               ctx->clone_data.addrlen =
+               ctx->nfs_server.addrlen =
                        nfs_parse_server_name(buf->data, buf->len,
-                                             ctx->clone_data.addr,
-                                             addr_bufsize,
+                                             &ctx->nfs_server.address,
+                                             sizeof(ctx->nfs_server._address),
                                              fc->net_ns);
-               if (ctx->clone_data.addrlen == 0)
+               if (ctx->nfs_server.addrlen == 0)
                        continue;
 
-               rpc_set_port(ctx->clone_data.addr, NFS_PORT);
+               rpc_set_port(&ctx->nfs_server.address, NFS_PORT);
 
                memcpy(ctx->nfs_server.hostname, buf->data, buf->len);
                ctx->nfs_server.hostname[buf->len] = '\0';
-               ctx->clone_data.hostname = ctx->nfs_server.hostname;
 
                p = source;
                memcpy(p, buf->data, buf->len);
@@ -444,12 +442,11 @@ int nfs4_submount(struct fs_context *fc, struct nfs_server *server)
        struct dentry *dentry = ctx->clone_data.dentry;
        struct dentry *parent = dget_parent(dentry);
        struct inode *dir = d_inode(parent);
-       const struct qstr *name = &dentry->d_name;
        struct rpc_clnt *client;
        int ret;
 
        /* Look it up again to get its attributes and sec flavor */
-       client = nfs4_proc_lookup_mountpoint(dir, name, ctx->mount_info.mntfh,
+       client = nfs4_proc_lookup_mountpoint(dir, dentry, ctx->mntfh,
                                             ctx->clone_data.fattr);
        dput(parent);
        if (IS_ERR(client))
@@ -504,7 +501,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
                rpc_set_port(sap, NFS_PORT);
 
                error = -ENOMEM;
-               hostname = kstrndup(buf->data, buf->len, GFP_KERNEL);
+               hostname = kmemdup_nul(buf->data, buf->len, GFP_KERNEL);
                if (hostname == NULL)
                        break;