2007-05-23 14:34:14

by Greg Banks

[permalink] [raw]
Subject: [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.

Signed-off-by: Greg Banks <[email protected]>
---

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(-)

Index: linux-2.6.16/net/sunrpc/svc_rdma_marshal.c
===================================================================
--- linux-2.6.16.orig/net/sunrpc/svc_rdma_marshal.c 2007-05-23 23:52:47.570678914 +1000
+++ linux-2.6.16/net/sunrpc/svc_rdma_marshal.c 2007-05-23 23:52:54.533766827 +1000
@@ -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;
}

Index: linux-2.6.16/include/linux/sunrpc/svc_rdma.h
===================================================================
--- linux-2.6.16.orig/include/linux/sunrpc/svc_rdma.h 2007-05-23 23:52:52.306058630 +1000
+++ linux-2.6.16/include/linux/sunrpc/svc_rdma.h 2007-05-23 23:52:54.545765256 +1000
@@ -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);
Index: linux-2.6.16/net/sunrpc/svc_rdma_recvfrom.c
===================================================================
--- linux-2.6.16.orig/net/sunrpc/svc_rdma_recvfrom.c 2007-05-23 23:52:52.182074871 +1000
+++ linux-2.6.16/net/sunrpc/svc_rdma_recvfrom.c 2007-05-24 00:25:19.034648728 +1000
@@ -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) {
Index: linux-2.6.16/net/sunrpc/svc_rdma_sendto.c
===================================================================
--- linux-2.6.16.orig/net/sunrpc/svc_rdma_sendto.c 2007-05-23 23:52:52.310058107 +1000
+++ linux-2.6.16/net/sunrpc/svc_rdma_sendto.c 2007-05-23 23:52:54.549764732 +1000
@@ -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 */
--
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