Skip to contentSkip to conversation

knfsd: nfsrdma arranges to preserve chunk header across deferrals

RFC PATCH New Greg Banks 1 participant 1 message May 23, 2007

Subsystems (3)
lore
Share & tools
lore

Greg Banks

author
#0 lore raw

RFC PATCH 4/5 knfsd: nfsrdma arranges to preserve chunk header across deferrals

Make the NFS/RDMA transport code pass enough information to the generic code that the generic code can defer and revisit calls over NFS/RDMA correctly, preserving the chunking header.

---

 include/linux/sunrpc/svc_rdma.h |   10 +++++++++-
 net/sunrpc/svc_rdma_marshal.c   |    9 +++++----
 net/sunrpc/svc_rdma_recvfrom.c  |    5 +++--
 net/sunrpc/svc_rdma_sendto.c    |    2 +-
 4 files changed, 18 insertions(+), 8 deletions(-)
net/sunrpc/svc_rdma_marshal.c +5 -4
Index: linux-2.6.16/net/sunrpc/svc_rdma_marshal.c
===================================================================
@@ -201,7 +201,7 @@ static u32 *decode_reply_array(u32 *va, 
 	return (u32*)&ary->wc_array[ch_no];
 }
 
-int svc_rdma_xdr_decode_req(struct rpcrdma_msg **rdma_req, struct svc_rqst *rqstp)
+int svc_rdma_xdr_decode_req(struct svc_rqst *rqstp)
 {
 	struct rpcrdma_msg *rmsgp = NULL;
 	u32 *va;
@@ -238,8 +238,8 @@ int svc_rdma_xdr_decode_req(struct rpcrd
 		rqstp->rq_arg.head[0].iov_base = va;
 		hdrlen = (u32)((unsigned long)va - (unsigned long)rmsgp);
 		rqstp->rq_arg.head[0].iov_len -= hdrlen;
-		if (hdrlen > rqstp->rq_arg.len)
-			return -EINVAL;
+		BUG_ON(hdrlen > rqstp->rq_arg.len);
+		rqstp->rq_arg.len -= hdrlen;
 		return hdrlen;
 	}
 
@@ -261,8 +261,9 @@ int svc_rdma_xdr_decode_req(struct rpcrd
 	rqstp->rq_arg.head[0].iov_base = va;
 	hdr_len = (unsigned long)va - (unsigned long)rmsgp;
 	rqstp->rq_arg.head[0].iov_len -= hdr_len;
+	rqstp->rq_arg.len -= hdr_len;
+	rqstp->rq_arg.trans_header = hdr_len;
 
-	*rdma_req = rmsgp;
 	return hdr_len;
 }
 
include/linux/sunrpc/svc_rdma.h +9 -1
Index: linux-2.6.16/include/linux/sunrpc/svc_rdma.h
===================================================================
@@ -136,9 +136,17 @@ struct svcxprt_rdma {
 #define RPCRDMA_MAX_REQUESTS    2048
 #define RPCRDMA_MAX_REQ_SIZE    4096
 
+static inline struct rpcrdma_msg *
+svc_rdma_get_chunk_header(struct svc_rqst *rqstp)
+{
+	struct xdr_buf *a = &rqstp->rq_arg;
+	return (struct rpcrdma_msg *)
+		(((char *)a->head[0].iov_base) - a->trans_header);
+}
+
 /* svc_rdma_marshal.c */
 extern void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *, int *, int *);
-extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg**, struct svc_rqst *);
+extern int svc_rdma_xdr_decode_req(struct svc_rqst *);
 extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma*, struct rpcrdma_msg*,
 				     enum rpcrdma_errcode, u32*);
 extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int);
net/sunrpc/svc_rdma_recvfrom.c +3 -2
Index: linux-2.6.16/net/sunrpc/svc_rdma_recvfrom.c
===================================================================
@@ -479,8 +479,9 @@ int svc_rdma_recvfrom(struct svc_rqst *r
 	svc_rdma_put_context(ctxt, 0);
 
 	/* Decode the RDMA header. */
-	len = svc_rdma_xdr_decode_req(&rmsgp, rqstp);
-	DBG_DUMP_RDMAHDR(__FUNCTION__, page_address(rqstp->rq_argpages[0]));
+	len = svc_rdma_xdr_decode_req(rqstp);
+	rmsgp = svc_rdma_get_chunk_header(rqstp);
+	DBG_DUMP_RDMAHDR(__FUNCTION__, rmsgp);
 
 	/* If the request is invalid, reply with an error */
 	if (len < 0) {
net/sunrpc/svc_rdma_sendto.c +1 -1
Index: linux-2.6.16/net/sunrpc/svc_rdma_sendto.c
===================================================================
@@ -469,7 +469,7 @@ int svc_rdma_sendto(struct svc_rqst *rqs
 	(void)svc_rdma_post_recv(rdma);
 
 	/* Get the RDMA request header. */
-	rdma_argp = page_address(rqstp->rq_argpages[0]);
+	rdma_argp = svc_rdma_get_chunk_header(rqstp);
 	DBG_DUMP_RDMAHDR(__FUNCTION__, rdma_argp);
 
 	/* Build an SGE for the XDR */
Signature · 12 lines
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
Apparently, I'm Bedevere.  Which MPHG character are you?
I don't speak for SGI.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs