Commit d50e61361c68a05a9cd7d54617522f99f278ac8a
1 parent
068c34c0ce
Exists in
master
and in
16 other branches
nfsd4: decrease nfsd4_encode_fattr stack usage
A struct svc_fh is 320 bytes on x86_64, it'd be better not to have these on the stack. kmalloc'ing them probably isn't ideal either, but this is the simplest thing to do. If it turns out to be a problem in the readdir case then we could add a svc_fh to nfsd4_readdir and pass that in. Acked-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Showing 1 changed file with 10 additions and 6 deletions Side-by-side Diff
fs/nfsd/nfs4xdr.c
... | ... | @@ -2058,7 +2058,7 @@ |
2058 | 2058 | u32 bmval1 = bmval[1]; |
2059 | 2059 | u32 bmval2 = bmval[2]; |
2060 | 2060 | struct kstat stat; |
2061 | - struct svc_fh tempfh; | |
2061 | + struct svc_fh *tempfh = NULL; | |
2062 | 2062 | struct kstatfs statfs; |
2063 | 2063 | int buflen = count << 2; |
2064 | 2064 | __be32 *attrlenp; |
2065 | 2065 | |
... | ... | @@ -2105,11 +2105,15 @@ |
2105 | 2105 | goto out_nfserr; |
2106 | 2106 | } |
2107 | 2107 | if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) { |
2108 | - fh_init(&tempfh, NFS4_FHSIZE); | |
2109 | - status = fh_compose(&tempfh, exp, dentry, NULL); | |
2108 | + tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL); | |
2109 | + status = nfserr_jukebox; | |
2110 | + if (!tempfh) | |
2111 | + goto out; | |
2112 | + fh_init(tempfh, NFS4_FHSIZE); | |
2113 | + status = fh_compose(tempfh, exp, dentry, NULL); | |
2110 | 2114 | if (status) |
2111 | 2115 | goto out; |
2112 | - fhp = &tempfh; | |
2116 | + fhp = tempfh; | |
2113 | 2117 | } |
2114 | 2118 | if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT |
2115 | 2119 | | FATTR4_WORD0_SUPPORTED_ATTRS)) { |
... | ... | @@ -2495,8 +2499,8 @@ |
2495 | 2499 | security_release_secctx(context, contextlen); |
2496 | 2500 | #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ |
2497 | 2501 | kfree(acl); |
2498 | - if (fhp == &tempfh) | |
2499 | - fh_put(&tempfh); | |
2502 | + if (tempfh) | |
2503 | + fh_put(tempfh); | |
2500 | 2504 | return status; |
2501 | 2505 | out_nfserr: |
2502 | 2506 | status = nfserrno(err); |