Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd4: remove nfs4_acl_new

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>

+10 -12
+1 -1
fs/nfsd/acl.h
··· 47 47 #define NFS4_ACL_MAX ((PAGE_SIZE - sizeof(struct nfs4_acl)) \ 48 48 / sizeof(struct nfs4_ace)) 49 49 50 - struct nfs4_acl *nfs4_acl_new(int); 50 + int nfs4_acl_bytes(int entries); 51 51 int nfs4_acl_get_whotype(char *, u32); 52 52 __be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who); 53 53
+8 -10
fs/nfsd/nfs4acl.c
··· 161 161 size += 2 * dpacl->a_count; 162 162 } 163 163 164 - *acl = nfs4_acl_new(size); 164 + *acl = kmalloc(nfs4_acl_bytes(size), GFP_KERNEL); 165 165 if (*acl == NULL) { 166 166 error = -ENOMEM; 167 167 goto out; 168 168 } 169 + (*acl)->naces = 0; 169 170 170 171 _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT); 171 172 ··· 873 872 return -1; 874 873 } 875 874 876 - struct nfs4_acl * 877 - nfs4_acl_new(int n) 875 + /* 876 + * return the size of the struct nfs4_acl required to represent an acl 877 + * with @entries entries. 878 + */ 879 + int nfs4_acl_bytes(int entries) 878 880 { 879 - struct nfs4_acl *acl; 880 - 881 - acl = kmalloc(sizeof(*acl) + n*sizeof(struct nfs4_ace), GFP_KERNEL); 882 - if (acl == NULL) 883 - return NULL; 884 - acl->naces = 0; 885 - return acl; 881 + return sizeof(struct nfs4_acl) + entries * sizeof(struct nfs4_ace); 886 882 } 887 883 888 884 static struct {
+1 -1
fs/nfsd/nfs4xdr.c
··· 309 309 if (nace > NFS4_ACL_MAX) 310 310 return nfserr_fbig; 311 311 312 - *acl = nfs4_acl_new(nace); 312 + *acl = kmalloc(nfs4_acl_bytes(nace), GFP_KERNEL); 313 313 if (*acl == NULL) 314 314 return nfserr_jukebox; 315 315