nfsd4: remove nfs4_acl_new
authorJ. Bruce Fields <bfields@redhat.com>
Tue, 24 Jun 2014 21:51:21 +0000 (17:51 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 8 Jul 2014 21:14:27 +0000 (17:14 -0400)
This is a not-that-useful kmalloc wrapper.  And I'd like one of the
callers to actually use something other than kmalloc.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/acl.h
fs/nfsd/nfs4acl.c
fs/nfsd/nfs4xdr.c

index a986ceb..4cd7c69 100644 (file)
@@ -47,7 +47,7 @@ struct svc_rqst;
 #define NFS4_ACL_MAX ((PAGE_SIZE - sizeof(struct nfs4_acl)) \
                        / sizeof(struct nfs4_ace))
 
-struct nfs4_acl *nfs4_acl_new(int);
+int nfs4_acl_bytes(int entries);
 int nfs4_acl_get_whotype(char *, u32);
 __be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who);
 
index b0cf00d..acf6974 100644 (file)
@@ -161,11 +161,12 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
                        size += 2 * dpacl->a_count;
        }
 
-       *acl = nfs4_acl_new(size);
+       *acl = kmalloc(nfs4_acl_bytes(size), GFP_KERNEL);
        if (*acl == NULL) {
                error = -ENOMEM;
                goto out;
        }
+       (*acl)->naces = 0;
 
        _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
 
@@ -872,16 +873,13 @@ ace2type(struct nfs4_ace *ace)
        return -1;
 }
 
-struct nfs4_acl *
-nfs4_acl_new(int n)
+/*
+ * return the size of the struct nfs4_acl required to represent an acl
+ * with @entries entries.
+ */
+int nfs4_acl_bytes(int entries)
 {
-       struct nfs4_acl *acl;
-
-       acl = kmalloc(sizeof(*acl) + n*sizeof(struct nfs4_ace), GFP_KERNEL);
-       if (acl == NULL)
-               return NULL;
-       acl->naces = 0;
-       return acl;
+       return sizeof(struct nfs4_acl) + entries * sizeof(struct nfs4_ace);
 }
 
 static struct {
index 8fb0f37..fea4104 100644 (file)
@@ -309,7 +309,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
                if (nace > NFS4_ACL_MAX)
                        return nfserr_fbig;
 
-               *acl = nfs4_acl_new(nace);
+               *acl = kmalloc(nfs4_acl_bytes(nace), GFP_KERNEL);
                if (*acl == NULL)
                        return nfserr_jukebox;