Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d50e6136 authored by J. Bruce Fields's avatar J. Bruce Fields
Browse files

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: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 068c34c0
Loading
Loading
Loading
Loading
+10 −6
Original line number Original line Diff line number Diff line
@@ -2058,7 +2058,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
	u32 bmval1 = bmval[1];
	u32 bmval1 = bmval[1];
	u32 bmval2 = bmval[2];
	u32 bmval2 = bmval[2];
	struct kstat stat;
	struct kstat stat;
	struct svc_fh tempfh;
	struct svc_fh *tempfh = NULL;
	struct kstatfs statfs;
	struct kstatfs statfs;
	int buflen = count << 2;
	int buflen = count << 2;
	__be32 *attrlenp;
	__be32 *attrlenp;
@@ -2105,11 +2105,15 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
			goto out_nfserr;
			goto out_nfserr;
	}
	}
	if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) {
	if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) {
		fh_init(&tempfh, NFS4_FHSIZE);
		tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
		status = fh_compose(&tempfh, exp, dentry, NULL);
		status = nfserr_jukebox;
		if (!tempfh)
			goto out;
		fh_init(tempfh, NFS4_FHSIZE);
		status = fh_compose(tempfh, exp, dentry, NULL);
		if (status)
		if (status)
			goto out;
			goto out;
		fhp = &tempfh;
		fhp = tempfh;
	}
	}
	if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT
	if (bmval0 & (FATTR4_WORD0_ACL | FATTR4_WORD0_ACLSUPPORT
			| FATTR4_WORD0_SUPPORTED_ATTRS)) {
			| FATTR4_WORD0_SUPPORTED_ATTRS)) {
@@ -2495,8 +2499,8 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
		security_release_secctx(context, contextlen);
		security_release_secctx(context, contextlen);
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
	kfree(acl);
	kfree(acl);
	if (fhp == &tempfh)
	if (tempfh)
		fh_put(&tempfh);
		fh_put(tempfh);
	return status;
	return status;
out_nfserr:
out_nfserr:
	status = nfserrno(err);
	status = nfserrno(err);