[pnfs] [PATCH] Removes duplicate sequence xdr allocations

Marc Eshel eshel at almaden.ibm.com
Wed Oct 17 12:18:55 EDT 2007


From: Marc Eshel <eshel at almaden.ibm.com>

Here is a quick patch which removes duplicate sequence xdr allocations
from all operations using sessions.  With this patch, our read
performance increases 10x since the data doesn't need to be copied on
the client after it is received.
---

 fs/nfs/nfs4xdr.c |   29 +++++++++++++----------------
 1 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 66ed710..3b860e7 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -60,7 +60,6 @@ #define NFSDBG_FACILITY		NFSDBG_XDR
 
 /* Mapping from NFS error code to "errno" error code. */
 #define errno_NFSERR_IO		EIO
-static int nr_sequence_quads = 0;
 
 static int nfs_stat_to_errno(int);
 
@@ -198,7 +197,7 @@ #define NFS4_enc_readlink_sz	(compound_e
 #define NFS4_dec_readlink_sz	(compound_decode_hdr_maxsz + \
 				decode_sequence_maxsz + \
 				decode_putfh_maxsz + \
-				op_decode_hdr_maxsz)
+				op_decode_hdr_maxsz + 1)
 #define NFS4_enc_readdir_sz	(compound_encode_hdr_maxsz + \
 				encode_sequence_maxsz +\
 				encode_putfh_maxsz + \
@@ -1302,10 +1301,9 @@ static int encode_readdir(struct xdr_str
 	/* set up reply kvec
 	 *    toplevel_status + taglen + rescount + OP_PUTFH + status
 	 *      + OP_READDIR + status + verifer(2)  = 9
-	 *      Add to this the size for the sequence op; 0 if no sessions,
-	 *      11 otherwise
+	 * TODO: Session sequence space is statically added.
 	 */
-	replen = (RPC_REPHDRSIZE + auth->au_rslack + 9 + nr_sequence_quads) << 2;
+	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readdir_sz) << 2;
 	xdr_inline_pages(&req->rq_rcv_buf, replen, readdir->pages,
 			 readdir->pgbase, readdir->count);
 	dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
@@ -1327,9 +1325,9 @@ static int encode_readlink(struct xdr_st
 	/* set up reply kvec
 	 *    toplevel_status + taglen + rescount + OP_PUTFH + status
 	 *      + OP_READLINK + status + string length = 8
-	 *      Similar to readdir, add space for the sequence op
+	 * TODO: Session sequence space is statically added.
 	 */
-	replen = (RPC_REPHDRSIZE + auth->au_rslack + 8 + nr_sequence_quads) << 2;
+	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readlink_sz) << 2;
 	xdr_inline_pages(&req->rq_rcv_buf, replen, readlink->pages,
 			readlink->pgbase, readlink->pglen);
 
@@ -2628,9 +2626,9 @@ static int nfs4_xdr_enc_read(struct rpc_
 	/* set up reply kvec
 	 *    toplevel status + taglen=0 + rescount + OP_PUTFH + status
 	 *       + OP_READ + status + eof + datalen = 9
-	 *       Add space for sequence op too.
+	 * TODO: Session sequence space is statically added.
 	 */
-	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz + nr_sequence_quads) << 2;
+	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz) << 2;
 	xdr_inline_pages(&req->rq_rcv_buf, replen,
 			 args->pages, args->pgbase, args->count);
 out:
@@ -2731,8 +2729,10 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req
 	if (status)
 		goto out;
 	status = encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0);
-	/* set up reply buffer: */
-	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_getacl_sz + nr_sequence_quads) << 2;
+	/* set up reply buffer:
+	 * TODO: Session sequence space is statically added.
+	*/
+	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_getacl_sz) << 2;
 	xdr_inline_pages(&req->rq_rcv_buf, replen,
 		args->acl_pages, args->acl_pgbase, args->acl_len);
 out:
@@ -3248,8 +3248,9 @@ static int nfs4_xdr_enc_fs_locations(str
 	/* set up reply
 	 *   toplevel_status + OP_PUTFH + status
 	 *   + OP_LOOKUP + status + OP_GETATTR + status = 7
+	 * TODO: Session sequence space is statically added.
 	 */
-	replen = (RPC_REPHDRSIZE + auth->au_rslack + 7 + nr_sequence_quads) << 2;
+	replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_fs_locations_sz) << 2;
 	xdr_inline_pages(&req->rq_rcv_buf, replen, &args->page,
 			0, PAGE_SIZE);
 out:
@@ -6763,10 +6764,6 @@ static int nfs41_xdr_dec_create_session(
 
 	status = decode_create_session(&xdr, res);
 
-	if (!status) {
-		/* Decode session succeeded; set nr_sequence_quads */
-		nr_sequence_quads = decode_sequence_maxsz;
-	}
 	return status;
 }
 


More information about the pNFS mailing list