public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* fix encode_entryplus_baggage stack usage
@ 2014-01-09 21:33 J. Bruce Fields
  2014-01-10  0:19 ` Jeff Layton
  0 siblings, 1 reply; 4+ messages in thread
From: J. Bruce Fields @ 2014-01-09 21:33 UTC (permalink / raw)
  To: linux-nfs; +Cc: sandeen, jlayton

Eric ran across an excessive stack with this (and a bunch of xfs code)
to blame.  Untested.  I don't know whether it's worth the minor extra
work here to avoid the alloc/free on each entry.

nfsd4_encode_fattr will need the same treatment.

--b.

commit 5b35a1f99f999555e82420e687e9d079ae796547
Author: J. Bruce Fields <bfields@redhat.com>
Date:   Thu Jan 9 16:24:35 2014 -0500

    nfsd: fix encode_entryplus_baggage stack usage
    
    We stick an extra svc_fh in nfsd3_readdirres to save the need to
    kmalloc, though maybe it would be fine to kmalloc instead.
    
    Signed-off-by: J. Bruce Fields <bfields@redhat.com>

diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 1ee6bae..de6e39e 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -842,21 +842,21 @@ out:
 
 static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
 {
-	struct svc_fh	fh;
+	struct svc_fh	*fh = &cd->scratch;
 	__be32 err;
 
-	fh_init(&fh, NFS3_FHSIZE);
-	err = compose_entry_fh(cd, &fh, name, namlen);
+	fh_init(fh, NFS3_FHSIZE);
+	err = compose_entry_fh(cd, fh, name, namlen);
 	if (err) {
 		*p++ = 0;
 		*p++ = 0;
 		goto out;
 	}
-	p = encode_post_op_attr(cd->rqstp, p, &fh);
+	p = encode_post_op_attr(cd->rqstp, p, fh);
 	*p++ = xdr_one;			/* yes, a file handle follows */
-	p = encode_fh(p, &fh);
+	p = encode_fh(p, fh);
 out:
-	fh_put(&fh);
+	fh_put(fh);
 	return p;
 }
 
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index b6d5542..335e04a 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -174,6 +174,9 @@ struct nfsd3_linkres {
 struct nfsd3_readdirres {
 	__be32			status;
 	struct svc_fh		fh;
+	/* Just to save kmalloc on every readdirplus entry (svc_fh is a
+	 * little large for the stack): */
+	struct svc_fh		scratch;
 	int			count;
 	__be32			verf[2];
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-23 23:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-09 21:33 fix encode_entryplus_baggage stack usage J. Bruce Fields
2014-01-10  0:19 ` Jeff Layton
2014-01-23 18:53   ` [PATCH] nfsd4: decrease nfsd4_encode_fattr " J. Bruce Fields
2014-01-23 23:07     ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox