All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC,PATCH 3/14] knfsd: prepare reply per transport
@ 2007-05-16 19:20 Greg Banks
  2007-05-16 20:53 ` J. Bruce Fields
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Greg Banks @ 2007-05-16 19:20 UTC (permalink / raw)
  To: Tom Tucker; +Cc: Linux NFS Mailing List, Thomas Talpey, Peter Leckie


Move the code at the beginning of svc_process() that sets up
page buffers for the reply, into a new sko_prepape_reply
method in svc_sock_ops.

Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
Signed-off-by: Peter Leckie <pleckie@melbourne.sgi.com>
---

 include/linux/sunrpc/svcsock.h |    6 +++
 net/sunrpc/svc.c               |   22 ++------------
 net/sunrpc/svcsock.c           |   46 ++++++++++++++++++++++++++++--
 3 files changed, 54 insertions(+), 20 deletions(-)

Index: linux/net/sunrpc/svcsock.c
===================================================================
--- linux.orig/net/sunrpc/svcsock.c	2007-05-17 00:16:39.911496313 +1000
+++ linux/net/sunrpc/svcsock.c	2007-05-17 00:36:20.381217499 +1000
@@ -880,12 +880,37 @@ svc_udp_sendto(struct svc_rqst *rqstp)
 	return error;
 }
 
+/*
+ * Setup response xdr_buf.  Initially it has just one page.
+ */
+static int
+svc_tcpip_prepare_reply(struct svc_rqst *rqstp)
+{
+	struct kvec *resv = &rqstp->rq_res.head[0];
+
+	rqstp->rq_resused = 1;
+	resv->iov_base = page_address(rqstp->rq_respages[0]);
+	resv->iov_len = 0;
+	rqstp->rq_res.pages = rqstp->rq_respages + 1;
+	rqstp->rq_res.len = 0;
+	rqstp->rq_res.page_base = 0;
+	rqstp->rq_res.page_len = 0;
+	rqstp->rq_res.buflen = PAGE_SIZE;
+	rqstp->rq_res.tail[0].iov_base = NULL;
+	rqstp->rq_res.tail[0].iov_len = 0;
+	/* Will be turned off only in gss privacy case: */
+	rqstp->rq_sendfile_ok = 1;
+
+	return 0;
+}
+
 static const struct svc_sock_ops svc_udp_ops = {
 	.sko_name = "udp",
 	.sko_recvfrom = svc_udp_recvfrom,
 	.sko_sendto = svc_udp_sendto,
 	.sko_detach = svc_tcpip_detach,
-	.sko_free = svc_tcpip_free
+	.sko_free = svc_tcpip_free,
+	.sko_prepare_reply = svc_tcpip_prepare_reply
 };
 
 static void
@@ -1324,12 +1349,29 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 	return sent;
 }
 
+/*
+ * Setup response xdr_buf.  Initially it has just one page.
+ */
+static int
+svc_tcp_prepare_reply(struct svc_rqst *rqstp)
+{
+	struct kvec *resv = &rqstp->rq_res.head[0];
+
+	svc_tcpip_prepare_reply(rqstp);
+
+	/* tcp needs a space for the record length... */
+	svc_putnl(resv, 0);
+
+	return 0;
+}
+
 static const struct svc_sock_ops svc_tcp_ops = {
 	.sko_name = "tcp",
 	.sko_recvfrom = svc_tcp_recvfrom,
 	.sko_sendto = svc_tcp_sendto,
 	.sko_detach = svc_tcpip_detach,
-	.sko_free = svc_tcpip_free
+	.sko_free = svc_tcpip_free,
+	.sko_prepare_reply = svc_tcp_prepare_reply
 };
 
 static void
Index: linux/include/linux/sunrpc/svcsock.h
===================================================================
--- linux.orig/include/linux/sunrpc/svcsock.h	2007-05-17 00:12:50.074342601 +1000
+++ linux/include/linux/sunrpc/svcsock.h	2007-05-17 00:36:20.553194321 +1000
@@ -27,6 +27,12 @@ struct svc_sock_ops {
 	 * destruction of a svc_sock.
 	 */
 	void			(*sko_free)(struct svc_sock *);
+	/*
+	 * Perform any transport-specific work necessary to setup
+	 * the reply buffer before the reply is encoded.  May
+	 * fail, e.g. due to memory allocation.
+	 */
+	int                     (*sko_prepare_reply)(struct svc_rqst *);
 };
 
 /*
Index: linux/net/sunrpc/svc.c
===================================================================
--- linux.orig/net/sunrpc/svc.c	2007-04-26 13:08:32.000000000 +1000
+++ linux/net/sunrpc/svc.c	2007-05-17 00:36:20.557193782 +1000
@@ -800,24 +800,10 @@ svc_process(struct svc_rqst *rqstp)
 	if (argv->iov_len < 6*4)
 		goto err_short_len;
 
-	/* setup response xdr_buf.
-	 * Initially it has just one page
-	 */
-	rqstp->rq_resused = 1;
-	resv->iov_base = page_address(rqstp->rq_respages[0]);
-	resv->iov_len = 0;
-	rqstp->rq_res.pages = rqstp->rq_respages + 1;
-	rqstp->rq_res.len = 0;
-	rqstp->rq_res.page_base = 0;
-	rqstp->rq_res.page_len = 0;
-	rqstp->rq_res.buflen = PAGE_SIZE;
-	rqstp->rq_res.tail[0].iov_base = NULL;
-	rqstp->rq_res.tail[0].iov_len = 0;
-	/* Will be turned off only in gss privacy case: */
-	rqstp->rq_sendfile_ok = 1;
-	/* tcp needs a space for the record length... */
-	if (rqstp->rq_prot == IPPROTO_TCP)
-		svc_putnl(resv, 0);
+	/* setup response xdr_buf. */
+	if (rqstp->rq_sock->sk_ops->sko_prepare_reply &&
+	    rqstp->rq_sock->sk_ops->sko_prepare_reply(rqstp))
+		goto dropit;
 
 	rqstp->rq_xid = svc_getu32(argv);
 	svc_putu32(resv, rqstp->rq_xid);
-- 
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  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

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

end of thread, other threads:[~2007-05-18 14:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-16 19:20 [RFC,PATCH 3/14] knfsd: prepare reply per transport Greg Banks
2007-05-16 20:53 ` J. Bruce Fields
2007-05-17  7:01   ` Greg Banks
2007-05-16 21:35 ` Tom Tucker
2007-05-17  7:53   ` Greg Banks
2007-05-17  9:16     ` Iyer, Rahul
2007-05-17 15:26       ` Tom Tucker
2007-05-18  3:16       ` Greg Banks
2007-05-18  4:01         ` J. Bruce Fields
2007-05-18  4:08           ` J. Bruce Fields
2007-05-18 14:42         ` Trond Myklebust
2007-05-17 10:48 ` Neil Brown
2007-05-18  6:00   ` Greg Banks

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.