All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC,PATCH 00/20] svc: sunrpc server side transport switch
@ 2007-07-10  5:27 Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 01/20] svc: Add svc_sock_ops Tom Tucker
                   ` (19 more replies)
  0 siblings, 20 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:27 UTC (permalink / raw)
  To: nfs

This patchset implements a sunrpc server side pluggable transport switch.
It includes recommendations from SGI and others and supports dynamically 
registered transports. 

The knfsd daemon has also been modified to allow user-mode programs to add a 
new listening endpoint by writing a string to the portlist file. The 
format of the string is as follows:

<transport-name> <port>

For example,

# echo rdma 2050 > /proc/fs/nfsd/portlist

causes the knfsd daemon to to add a listening endpoint on 
port 2050 using the 'rdma' transport.

Transports register themselves with the transport switch using a
new API that has the following synopsis:

void svc_register_transport(struct svc_sock_ops *xprt)

A new sunrpc export has been added to take a transport name instead of 
an IP protocol number to specify the transport on which the listening 
endpoint is to be created. This function is defined as follows:

int svc_create_svcsock(struct svc_serv, char *transport_name, 
		       unsigned short port, int flags);

The existing svc_makesock interface was left to avoid impacts to existing 
servers. It has been modified to map IP protocol numbers to transport 
strings.

This transport switch has been tested wth the recently posted RDMA transport 
driver. A git tree is available with the server side transport and RMDA 
transport driver at: git://linux-nfs.org/~tomtucker/nfs-rdma-dev-2.6.git

The git tree and this patchset are based on 2.6.22-rc6.

-- 
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>

-------------------------------------------------------------------------
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] 30+ messages in thread

* [RFC,PATCH 01/20] svc: Add svc_sock_ops
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 02/20] svc: sko_detach and sko_free Tom Tucker
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Start moving to a transport switch for knfsd.  Add a svc_sock_ops
operations vector and move the sk_sendto and sk_recvfrom function
pointers into it.

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

 include/linux/sunrpc/svcsock.h |    9 +++++++--
 net/sunrpc/svcsock.c           |   22 ++++++++++++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index e21dd93..3c926b9 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -11,6 +11,12 @@ #define SUNRPC_SVCSOCK_H
 
 #include <linux/sunrpc/svc.h>
 
+struct svc_sock_ops {
+	const char		*sko_name;
+	int			(*sko_recvfrom)(struct svc_rqst *rqstp);
+	int			(*sko_sendto)(struct svc_rqst *rqstp);
+};
+
 /*
  * RPC server socket.
  */
@@ -43,8 +49,7 @@ #define	SK_DETACHED	10			/* detached fro
 						 * be revisted */
 	struct mutex		sk_mutex;	/* to serialize sending data */
 
-	int			(*sk_recvfrom)(struct svc_rqst *rqstp);
-	int			(*sk_sendto)(struct svc_rqst *rqstp);
+	const struct svc_sock_ops *sk_ops;
 
 	/* We keep the old state_change and data_ready CB's here */
 	void			(*sk_ostate)(struct sock *);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 5baf48d..ce325f2 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -885,6 +885,12 @@ svc_udp_sendto(struct svc_rqst *rqstp)
 	return error;
 }
 
+static const struct svc_sock_ops svc_udp_ops = {
+	.sko_name = "udp",
+	.sko_recvfrom = svc_udp_recvfrom,
+	.sko_sendto = svc_udp_sendto
+};
+
 static void
 svc_udp_init(struct svc_sock *svsk)
 {
@@ -893,8 +899,7 @@ svc_udp_init(struct svc_sock *svsk)
 
 	svsk->sk_sk->sk_data_ready = svc_udp_data_ready;
 	svsk->sk_sk->sk_write_space = svc_write_space;
-	svsk->sk_recvfrom = svc_udp_recvfrom;
-	svsk->sk_sendto = svc_udp_sendto;
+	svsk->sk_ops = &svc_udp_ops;
 
 	/* initialise setting must have enough space to
 	 * receive and respond to one request.
@@ -1322,14 +1327,19 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 	return sent;
 }
 
+static const struct svc_sock_ops svc_tcp_ops = {
+	.sko_name = "tcp",
+	.sko_recvfrom = svc_tcp_recvfrom,
+	.sko_sendto = svc_tcp_sendto
+};
+
 static void
 svc_tcp_init(struct svc_sock *svsk)
 {
 	struct sock	*sk = svsk->sk_sk;
 	struct tcp_sock *tp = tcp_sk(sk);
 
-	svsk->sk_recvfrom = svc_tcp_recvfrom;
-	svsk->sk_sendto = svc_tcp_sendto;
+	svsk->sk_ops = &svc_tcp_ops;
 
 	if (sk->sk_state == TCP_LISTEN) {
 		dprintk("setting up TCP socket for listening\n");
@@ -1477,7 +1487,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
 
 	dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
 		 rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse));
-	len = svsk->sk_recvfrom(rqstp);
+	len = svsk->sk_ops->sko_recvfrom(rqstp);
 	dprintk("svc: got len=%d\n", len);
 
 	/* No data, incomplete (TCP) read, or accept() */
@@ -1537,7 +1547,7 @@ svc_send(struct svc_rqst *rqstp)
 	if (test_bit(SK_DEAD, &svsk->sk_flags))
 		len = -ENOTCONN;
 	else
-		len = svsk->sk_sendto(rqstp);
+		len = svsk->sk_ops->sko_sendto(rqstp);
 	mutex_unlock(&svsk->sk_mutex);
 	svc_sock_release(rqstp);
 

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 02/20] svc: sko_detach and sko_free
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 01/20] svc: Add svc_sock_ops Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 03/20] svc: svc_prep_reply_hdr Tom Tucker
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add sko_detach and sko_free methods to svc_sock_ops and
change svc_delete_socket() and svc_sock_put() to use them.

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

 include/linux/sunrpc/svcsock.h |   12 +++++++++
 net/sunrpc/svcsock.c           |   54 ++++++++++++++++++++++++++++++++--------
 2 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 3c926b9..72beb7b 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -15,6 +15,18 @@ struct svc_sock_ops {
 	const char		*sko_name;
 	int			(*sko_recvfrom)(struct svc_rqst *rqstp);
 	int			(*sko_sendto)(struct svc_rqst *rqstp);
+	/*
+	 * Detach the svc_sock from it's socket, so that the
+	 * svc_sock will not be enqueued any more.  This is
+	 * the first stage in the destruction of a svc_sock.
+	 */
+	void			(*sko_detach)(struct svc_sock *);
+	/*
+	 * Release all network-level resources held by the svc_sock,
+	 * and the svc_sock itself.  This is the final stage in the
+	 * destruction of a svc_sock.
+	 */
+	void			(*sko_free)(struct svc_sock *);
 };
 
 /*
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index ce325f2..da7e5ea 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -84,6 +84,8 @@ static void		svc_udp_data_ready(struct s
 static int		svc_udp_recvfrom(struct svc_rqst *);
 static int		svc_udp_sendto(struct svc_rqst *);
 static void		svc_close_socket(struct svc_sock *svsk);
+static void		svc_tcpip_detach(struct svc_sock *);
+static void		svc_tcpip_free(struct svc_sock *);
 
 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
 static int svc_deferred_recv(struct svc_rqst *rqstp);
@@ -378,14 +380,9 @@ svc_sock_put(struct svc_sock *svsk)
 	if (atomic_dec_and_test(&svsk->sk_inuse)) {
 		BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
 
-		dprintk("svc: releasing dead socket\n");
-		if (svsk->sk_sock->file)
-			sockfd_put(svsk->sk_sock);
-		else
-			sock_release(svsk->sk_sock);
 		if (svsk->sk_info_authunix != NULL)
 			svcauth_unix_info_release(svsk->sk_info_authunix);
-		kfree(svsk);
+    	    	svsk->sk_ops->sko_free(svsk);
 	}
 }
 
@@ -888,7 +885,9 @@ svc_udp_sendto(struct svc_rqst *rqstp)
 static const struct svc_sock_ops svc_udp_ops = {
 	.sko_name = "udp",
 	.sko_recvfrom = svc_udp_recvfrom,
-	.sko_sendto = svc_udp_sendto
+	.sko_sendto = svc_udp_sendto,
+	.sko_detach = svc_tcpip_detach,
+	.sko_free = svc_tcpip_free
 };
 
 static void
@@ -1330,7 +1329,9 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 static const struct svc_sock_ops svc_tcp_ops = {
 	.sko_name = "tcp",
 	.sko_recvfrom = svc_tcp_recvfrom,
-	.sko_sendto = svc_tcp_sendto
+	.sko_sendto = svc_tcp_sendto,
+	.sko_detach = svc_tcpip_detach,
+	.sko_free = svc_tcpip_free
 };
 
 static void
@@ -1770,6 +1771,38 @@ bummer:
 }
 
 /*
+ * Detach the svc_sock from the socket so that no
+ * more callbacks occur.
+ */
+static void
+svc_tcpip_detach(struct svc_sock *svsk)
+{
+	struct sock *sk = svsk->sk_sk;
+
+	dprintk("svc: svc_sock_detach(%p)\n", svsk);
+
+	/* put back the old socket callbacks */
+	sk->sk_state_change = svsk->sk_ostate;
+	sk->sk_data_ready = svsk->sk_odata;
+	sk->sk_write_space = svsk->sk_owspace;
+}
+
+/*
+ * Free the svc_sock's socket resources and the svc_sock itself.
+ */
+static void
+svc_tcpip_free(struct svc_sock *svsk)
+{
+	dprintk("svc: svc_sock_free(%p)\n", svsk);
+
+	if (svsk->sk_sock->file)
+		sockfd_put(svsk->sk_sock);
+	else
+		sock_release(svsk->sk_sock);
+	kfree(svsk);
+}
+
+/*
  * Remove a dead socket
  */
 static void
@@ -1783,9 +1816,8 @@ svc_delete_socket(struct svc_sock *svsk)
 	serv = svsk->sk_server;
 	sk = svsk->sk_sk;
 
-	sk->sk_state_change = svsk->sk_ostate;
-	sk->sk_data_ready = svsk->sk_odata;
-	sk->sk_write_space = svsk->sk_owspace;
+	if (svsk->sk_ops->sko_detach)
+		svsk->sk_ops->sko_detach(svsk);
 
 	spin_lock_bh(&serv->sv_lock);
 

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 03/20] svc: svc_prep_reply_hdr
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 01/20] svc: Add svc_sock_ops Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 02/20] svc: sko_detach and sko_free Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 04/20] svc: sko_has_wspace Tom Tucker
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add a sock method that prepares the transport specific header for 
RPC replies. UDP has none, TCP has a 4B record length. This will
allow the RDMA transport to prepare it's variable length reply
header as well.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svc.c               |    8 +++++---
 net/sunrpc/svcsock.c           |   17 ++++++++++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 72beb7b..fa92f3f 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -27,6 +27,10 @@ struct svc_sock_ops {
 	 * destruction of a svc_sock.
 	 */
 	void			(*sko_free)(struct svc_sock *);
+	/*
+	 * Prepare any transport-specific RPC header.
+	 */
+	int                     (*sko_prep_reply_hdr)(struct svc_rqst *);
 };
 
 /*
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index e673ef9..f852587 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -815,9 +815,11 @@ svc_process(struct svc_rqst *rqstp)
 	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 header. */
+	if (rqstp->rq_sock->sk_ops->sko_prep_reply_hdr &&
+	    rqstp->rq_sock->sk_ops->sko_prep_reply_hdr(rqstp))
+		goto dropit;
 
 	rqstp->rq_xid = svc_getu32(argv);
 	svc_putu32(resv, rqstp->rq_xid);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index da7e5ea..4ff1a62 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1326,12 +1326,27 @@ svc_tcp_sendto(struct svc_rqst *rqstp)
 	return sent;
 }
 
+/*
+ * Setup response header. TCP has a 4B record length field.
+ */
+static int
+svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp)
+{
+	struct kvec *resv = &rqstp->rq_res.head[0];
+
+	/* 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_prep_reply_hdr = svc_tcp_prep_reply_hdr
 };
 
 static void

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 04/20] svc: sko_has_wspace
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (2 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 03/20] svc: svc_prep_reply_hdr Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 05/20] svc: svc_max_payload Tom Tucker
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Move the code in svc_sock_enqueue() that checks for available
write space on the socket, into a new sko_has_wspace method
in svc_sock_ops.

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

 include/linux/sunrpc/svcsock.h |    4 ++
 net/sunrpc/svcsock.c           |   79 +++++++++++++++++++++++++---------------
 2 files changed, 54 insertions(+), 29 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index fa92f3f..e4f2936 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -31,6 +31,10 @@ struct svc_sock_ops {
 	 * Prepare any transport-specific RPC header.
 	 */
 	int                     (*sko_prep_reply_hdr)(struct svc_rqst *);
+	/*
+	 * Return 1 if sufficient space to write reply to network.
+	 */
+	int			(*sko_has_wspace)(struct svc_sock *);
 };
 
 /*
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 4ff1a62..a959824 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -205,22 +205,6 @@ svc_release_skb(struct svc_rqst *rqstp)
 }
 
 /*
- * Any space to write?
- */
-static inline unsigned long
-svc_sock_wspace(struct svc_sock *svsk)
-{
-	int wspace;
-
-	if (svsk->sk_sock->type == SOCK_STREAM)
-		wspace = sk_stream_wspace(svsk->sk_sk);
-	else
-		wspace = sock_wspace(svsk->sk_sk);
-
-	return wspace;
-}
-
-/*
  * Queue up a socket with data pending. If there are idle nfsd
  * processes, wake 'em up.
  *
@@ -269,21 +253,13 @@ svc_sock_enqueue(struct svc_sock *svsk)
 	BUG_ON(svsk->sk_pool != NULL);
 	svsk->sk_pool = pool;
 
-	set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
-	if (((atomic_read(&svsk->sk_reserved) + serv->sv_max_mesg)*2
-	     > svc_sock_wspace(svsk))
-	    && !test_bit(SK_CLOSE, &svsk->sk_flags)
-	    && !test_bit(SK_CONN, &svsk->sk_flags)) {
-		/* Don't enqueue while not enough space for reply */
-		dprintk("svc: socket %p  no space, %d*2 > %ld, not enqueued\n",
-			svsk->sk_sk, atomic_read(&svsk->sk_reserved)+serv->sv_max_mesg,
-			svc_sock_wspace(svsk));
+	if (!test_bit(SK_CLOSE, &svsk->sk_flags)
+	    && !test_bit(SK_CONN, &svsk->sk_flags)
+	    && !svsk->sk_ops->sko_has_wspace(svsk)) {
 		svsk->sk_pool = NULL;
 		clear_bit(SK_BUSY, &svsk->sk_flags);
 		goto out_unlock;
 	}
-	clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
-
 
 	if (!list_empty(&pool->sp_threads)) {
 		rqstp = list_entry(pool->sp_threads.next,
@@ -882,12 +858,45 @@ svc_udp_sendto(struct svc_rqst *rqstp)
 	return error;
 }
 
+/**
+ * svc_sock_has_write_space - Checks if there is enough space
+ * to send the reply on the socket.
+ * @svsk: the svc_sock to write on
+ * @wspace: the number of bytes available for writing
+ */
+static int svc_sock_has_write_space(struct svc_sock *svsk, int wspace)
+{
+	struct svc_serv	*serv = svsk->sk_server;
+	int required = atomic_read(&svsk->sk_reserved) + serv->sv_max_mesg;
+
+	if (required*2 > wspace) {
+		/* Don't enqueue while not enough space for reply */
+		dprintk("svc: socket %p  no space, %d*2 > %d, not enqueued\n",
+			svsk->sk_sk, required, wspace);
+		return 0;
+	}
+	clear_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+	return 1;
+}
+
+static int
+svc_udp_has_wspace(struct svc_sock *svsk)
+{
+	/* 
+	 * Set the SOCK_NOSPACE flag before checking the available
+	 * sock space. 
+	 */
+	set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+	return svc_sock_has_write_space(svsk, sock_wspace(svsk->sk_sk));
+}
+
 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_has_wspace = svc_udp_has_wspace
 };
 
 static void
@@ -1340,13 +1349,25 @@ svc_tcp_prep_reply_hdr(struct svc_rqst *
 	return 0;
 }
 
+static int
+svc_tcp_has_wspace(struct svc_sock *svsk)
+{
+	/* 
+	 * Set the SOCK_NOSPACE flag before checking the available
+	 * sock space. 
+	 */
+	set_bit(SOCK_NOSPACE, &svsk->sk_sock->flags);
+	return svc_sock_has_write_space(svsk, sk_stream_wspace(svsk->sk_sk));
+}
+
 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_prep_reply_hdr = svc_tcp_prep_reply_hdr
+	.sko_prep_reply_hdr = svc_tcp_prep_reply_hdr,
+	.sko_has_wspace = svc_tcp_has_wspace
 };
 
 static void

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 05/20] svc: svc_max_payload
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (3 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 04/20] svc: sko_has_wspace Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received Tom Tucker
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Store the svc_max_payload delegate in svc_sock_ops
instead of reaching into the socket (beause later the NFS/RDMA
transport will not even have a socket).

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

 include/linux/sunrpc/svcsock.h |    6 ++++++
 net/sunrpc/svc.c               |    5 ++---
 net/sunrpc/svcsock.c           |    6 ++++--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index e4f2936..ce93b10 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -35,6 +35,12 @@ struct svc_sock_ops {
 	 * Return 1 if sufficient space to write reply to network.
 	 */
 	int			(*sko_has_wspace)(struct svc_sock *);
+	/*
+	 * Stores the largest payload (i.e. READ, WRITE or READDIR
+	 * data length not including NFS headers) supported by the
+	 * svc_sock.
+	 */
+	u32			sko_max_payload;
 };
 
 /*
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index f852587..eea0439 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1036,10 +1036,9 @@ err_bad:
  */
 u32 svc_max_payload(const struct svc_rqst *rqstp)
 {
-	int max = RPCSVC_MAXPAYLOAD_TCP;
+	struct svc_sock *svsk = rqstp->rq_sock;
+	int max = svsk->sk_ops->sko_max_payload;
 
-	if (rqstp->rq_sock->sk_sock->type == SOCK_DGRAM)
-		max = RPCSVC_MAXPAYLOAD_UDP;
 	if (rqstp->rq_server->sv_max_payload < max)
 		max = rqstp->rq_server->sv_max_payload;
 	return max;
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index a959824..1a6a933 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -896,7 +896,8 @@ static const struct svc_sock_ops svc_udp
 	.sko_sendto = svc_udp_sendto,
 	.sko_detach = svc_tcpip_detach,
 	.sko_free = svc_tcpip_free,
-	.sko_has_wspace = svc_udp_has_wspace
+	.sko_has_wspace = svc_udp_has_wspace,
+	.sko_max_payload = RPCSVC_MAXPAYLOAD_UDP
 };
 
 static void
@@ -1367,7 +1368,8 @@ static const struct svc_sock_ops svc_tcp
 	.sko_detach = svc_tcpip_detach,
 	.sko_free = svc_tcpip_free,
 	.sko_prep_reply_hdr = svc_tcp_prep_reply_hdr,
-	.sko_has_wspace = svc_tcp_has_wspace
+	.sko_has_wspace = svc_tcp_has_wspace,
+	.sko_max_payload = RPCSVC_MAXPAYLOAD_TCP
 };
 
 static void

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (4 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 05/20] svc: svc_max_payload Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10 23:08   ` Trond Myklebust
  2007-07-10  5:34 ` [RFC,PATCH 07/20] svc: centralise close handling Tom Tucker
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Export svc_sock_enqueue() and svc_sock_received() so they
can be used by sunrpc server transport implementations
(even future modular ones).

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

 include/linux/sunrpc/svcsock.h |    2 ++
 net/sunrpc/svcsock.c           |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index ce93b10..9fa4321 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -108,6 +108,8 @@ int		svc_addsock(struct svc_serv *serv,
 			    int fd,
 			    char *name_return,
 			    int *proto);
+void		svc_sock_enqueue(struct svc_sock *svsk);
+void		svc_sock_received(struct svc_sock *svsk);
 
 /*
  * svc_makesock socket characteristics
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 1a6a933..f09c4b4 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -209,7 +209,7 @@ svc_release_skb(struct svc_rqst *rqstp)
  * processes, wake 'em up.
  *
  */
-static void
+void
 svc_sock_enqueue(struct svc_sock *svsk)
 {
 	struct svc_serv	*serv = svsk->sk_server;
@@ -287,6 +287,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
 out_unlock:
 	spin_unlock_bh(&pool->sp_lock);
 }
+EXPORT_SYMBOL(svc_sock_enqueue);
 
 /*
  * Dequeue the first socket.  Must be called with the pool->sp_lock held.
@@ -315,14 +316,14 @@ svc_sock_dequeue(struct svc_pool *pool)
  * Note: SK_DATA only gets cleared when a read-attempt finds
  * no (or insufficient) data.
  */
-static inline void
+void
 svc_sock_received(struct svc_sock *svsk)
 {
 	svsk->sk_pool = NULL;
 	clear_bit(SK_BUSY, &svsk->sk_flags);
 	svc_sock_enqueue(svsk);
 }
-
+EXPORT_SYMBOL(svc_sock_received);
 
 /**
  * svc_reserve - change the space reserved for the reply to a request.

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 07/20] svc: centralise close handling
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (5 preceding siblings ...)
  2007-07-10  5:34 ` [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 08/20] svc: centralise accept handling Tom Tucker
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Centralise the handling of the SK_CLOSE bit to that future
sunrpc server transport implementations will be easier to
write correctly. The sko_recvfrom method does not 
need to check for SK_CLOSE anymore, that's handled in 
core code.

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

 net/sunrpc/svcsock.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index f09c4b4..75fae77 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -756,11 +756,6 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
 		return svc_deferred_recv(rqstp);
 	}
 
-	if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
-		svc_delete_socket(svsk);
-		return 0;
-	}
-
 	clear_bit(SK_DATA, &svsk->sk_flags);
 	skb = NULL;
 	err = kernel_recvmsg(svsk->sk_sock, &msg, NULL,
@@ -1158,11 +1153,6 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
 		return svc_deferred_recv(rqstp);
 	}
 
-	if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
-		svc_delete_socket(svsk);
-		return 0;
-	}
-
 	if (svsk->sk_sk->sk_state == TCP_LISTEN) {
 		svc_tcp_accept(svsk);
 		svc_sock_received(svsk);
@@ -1406,8 +1396,10 @@ svc_tcp_init(struct svc_sock *svsk)
 
 		set_bit(SK_CHNGBUF, &svsk->sk_flags);
 		set_bit(SK_DATA, &svsk->sk_flags);
-		if (sk->sk_state != TCP_ESTABLISHED)
+		if (sk->sk_state != TCP_ESTABLISHED) {
+			/* note: caller calls svc_sock_enqueue() */
 			set_bit(SK_CLOSE, &svsk->sk_flags);
+		}
 	}
 }
 
@@ -1525,10 +1517,16 @@ svc_recv(struct svc_rqst *rqstp, long ti
 	}
 	spin_unlock_bh(&pool->sp_lock);
 
-	dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
-		 rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse));
-	len = svsk->sk_ops->sko_recvfrom(rqstp);
-	dprintk("svc: got len=%d\n", len);
+	len = 0;
+	if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
+		dprintk("svc_recv: found SK_CLOSE\n");
+		svc_delete_socket(svsk);
+	} else {
+		dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
+			 rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse));
+		len = svsk->sk_ops->sko_recvfrom(rqstp);
+		dprintk("svc: got len=%d\n", len);
+	}
 
 	/* No data, incomplete (TCP) read, or accept() */
 	if (len == 0 || len == -EAGAIN) {

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 08/20] svc: centralise accept handling
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (6 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 07/20] svc: centralise close handling Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 09/20] svc: Add SK_LISTENER sock flag Tom Tucker
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Centralise the handling of the SK_CONN bit to that future
sunrpc server transport implementations will be easier to
write correctly.  Also, the sko_recvfrom method does not 
need to check for SK_CONN anymore, that's handled in core 
code which calls a new sko_accept method.

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

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svcsock.c           |   26 ++++++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 9fa4321..c4eb40c 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -41,6 +41,10 @@ struct svc_sock_ops {
 	 * svc_sock.
 	 */
 	u32			sko_max_payload;
+	/*
+	 * Accept a pending connection, for connection-oriented transports
+	 */
+	int			(*sko_accept)(struct svc_sock *svsk);
 };
 
 /*
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 75fae77..2ef3013 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1012,7 +1012,7 @@ static inline int svc_port_is_privileged
 /*
  * Accept a TCP connection
  */
-static void
+static int
 svc_tcp_accept(struct svc_sock *svsk)
 {
 	struct sockaddr_storage addr;
@@ -1021,12 +1021,12 @@ svc_tcp_accept(struct svc_sock *svsk)
 	struct socket	*sock = svsk->sk_sock;
 	struct socket	*newsock;
 	struct svc_sock	*newsvsk;
-	int		err, slen;
+	int		err = 0, slen;
 	char		buf[RPC_MAX_ADDRBUFLEN];
 
 	dprintk("svc: tcp_accept %p sock %p\n", svsk, sock);
 	if (!sock)
-		return;
+		return -EINVAL;
 
 	clear_bit(SK_CONN, &svsk->sk_flags);
 	err = kernel_accept(sock, &newsock, O_NONBLOCK);
@@ -1037,9 +1037,8 @@ svc_tcp_accept(struct svc_sock *svsk)
 		else if (err != -EAGAIN && net_ratelimit())
 			printk(KERN_WARNING "%s: accept failed (err %d)!\n",
 				   serv->sv_name, -err);
-		return;
+		return err;
 	}
-
 	set_bit(SK_CONN, &svsk->sk_flags);
 	svc_sock_enqueue(svsk);
 
@@ -1124,11 +1123,11 @@ svc_tcp_accept(struct svc_sock *svsk)
 	if (serv->sv_stats)
 		serv->sv_stats->nettcpconn++;
 
-	return;
+	return 0;
 
 failed:
 	sock_release(newsock);
-	return;
+	return err;
 }
 
 /*
@@ -1153,12 +1152,6 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
 		return svc_deferred_recv(rqstp);
 	}
 
-	if (svsk->sk_sk->sk_state == TCP_LISTEN) {
-		svc_tcp_accept(svsk);
-		svc_sock_received(svsk);
-		return 0;
-	}
-
 	if (test_and_clear_bit(SK_CHNGBUF, &svsk->sk_flags))
 		/* sndbuf needs to have room for one request
 		 * per thread, otherwise we can stall even when the
@@ -1360,7 +1353,8 @@ static const struct svc_sock_ops svc_tcp
 	.sko_free = svc_tcpip_free,
 	.sko_prep_reply_hdr = svc_tcp_prep_reply_hdr,
 	.sko_has_wspace = svc_tcp_has_wspace,
-	.sko_max_payload = RPCSVC_MAXPAYLOAD_TCP
+	.sko_max_payload = RPCSVC_MAXPAYLOAD_TCP,
+	.sko_accept = svc_tcp_accept
 };
 
 static void
@@ -1521,6 +1515,9 @@ svc_recv(struct svc_rqst *rqstp, long ti
 	if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
 		dprintk("svc_recv: found SK_CLOSE\n");
 		svc_delete_socket(svsk);
+	} else if (svsk->sk_sk->sk_state == TCP_LISTEN) {
+		svsk->sk_ops->sko_accept(svsk);
+		svc_sock_received(svsk);
 	} else {
 		dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
 			 rqstp, pool->sp_id, svsk, atomic_read(&svsk->sk_inuse));
@@ -1660,6 +1657,7 @@ static struct svc_sock *svc_setup_socket
 	int		is_temporary = flags & SVC_SOCK_TEMPORARY;
 
 	dprintk("svc: svc_setup_socket %p\n", sock);
+	*errp = 0;
 	if (!(svsk = kzalloc(sizeof(*svsk), GFP_KERNEL))) {
 		*errp = -ENOMEM;
 		return NULL;

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 09/20] svc: Add SK_LISTENER sock flag
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (7 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 08/20] svc: centralise accept handling Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 10/20] svc: Add generic refcount services Tom Tucker
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Use a new svc_sock flag SK_LISTENER which is permanently set on
listener sockets, use that to test for listeners in a way which
is not TCP-specific and does not assume the presence of a socket.

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

 include/linux/sunrpc/svcsock.h |    1 +
 net/sunrpc/svcsock.c           |    4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index c4eb40c..a52c9fd 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -70,6 +70,7 @@ #define	SK_CHNGBUF	7			/* need to change
 #define	SK_DEFERRED	8			/* request on sk_deferred */
 #define	SK_OLD		9			/* used for temp socket aging mark+sweep */
 #define	SK_DETACHED	10			/* detached from tempsocks list */
+#define	SK_LISTENER	11			/* listener (e.g. TCP) socket */
 
 	atomic_t    	    	sk_reserved;	/* space on outq that is reserved */
 
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 2ef3013..59c6b35 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1368,6 +1368,8 @@ svc_tcp_init(struct svc_sock *svsk)
 	if (sk->sk_state == TCP_LISTEN) {
 		dprintk("setting up TCP socket for listening\n");
 		sk->sk_data_ready = svc_tcp_listen_data_ready;
+
+		set_bit(SK_LISTENER, &svsk->sk_flags);
 		set_bit(SK_CONN, &svsk->sk_flags);
 	} else {
 		dprintk("setting up TCP socket for reading\n");
@@ -1515,7 +1517,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
 	if (test_bit(SK_CLOSE, &svsk->sk_flags)) {
 		dprintk("svc_recv: found SK_CLOSE\n");
 		svc_delete_socket(svsk);
-	} else if (svsk->sk_sk->sk_state == TCP_LISTEN) {
+	} else if (test_bit(SK_LISTENER, &svsk->sk_flags)) {
 		svsk->sk_ops->sko_accept(svsk);
 		svc_sock_received(svsk);
 	} else {

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 10/20] svc: Add generic refcount services
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (8 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 09/20] svc: Add SK_LISTENER sock flag Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 11/20] svc: cleanup svc_sock initialization Tom Tucker
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add inline svc_sock_get() so that service transport code will not
need to manipulate sk_inuse directly.  Also, make svc_sock_put()
available so that transport code outside svcsock.c can use it.

Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |   15 +++++++++++++++
 net/sunrpc/svcsock.c           |   29 ++++++++++++++---------------
 2 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index a52c9fd..e455783 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -115,6 +115,7 @@ int		svc_addsock(struct svc_serv *serv,
 			    int *proto);
 void		svc_sock_enqueue(struct svc_sock *svsk);
 void		svc_sock_received(struct svc_sock *svsk);
+void	    	__svc_sock_put(struct svc_sock *svsk);
 
 /*
  * svc_makesock socket characteristics
@@ -123,4 +124,18 @@ #define SVC_SOCK_DEFAULTS	(0U)
 #define SVC_SOCK_ANONYMOUS	(1U << 0)	/* don't register with pmap */
 #define SVC_SOCK_TEMPORARY	(1U << 1)	/* flag socket as temporary */
 
+/*
+ * Take and drop a temporary reference count on the svc_sock.
+ */
+static inline void svc_sock_get(struct svc_sock *svsk)
+{
+	atomic_inc(&svsk->sk_inuse);
+}
+
+static inline void svc_sock_put(struct svc_sock *svsk)
+{
+	if (atomic_dec_and_test(&svsk->sk_inuse))
+	    __svc_sock_put(svsk);
+}
+
 #endif /* SUNRPC_SVCSOCK_H */
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 59c6b35..0193f54 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -273,7 +273,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
 				"svc_sock_enqueue: server %p, rq_sock=%p!\n",
 				rqstp, rqstp->rq_sock);
 		rqstp->rq_sock = svsk;
-		atomic_inc(&svsk->sk_inuse);
+		svc_sock_get(svsk);
 		rqstp->rq_reserved = serv->sv_max_mesg;
 		atomic_add(rqstp->rq_reserved, &svsk->sk_reserved);
 		BUG_ON(svsk->sk_pool != pool);
@@ -351,17 +351,16 @@ void svc_reserve(struct svc_rqst *rqstp,
 /*
  * Release a socket after use.
  */
-static inline void
-svc_sock_put(struct svc_sock *svsk)
+void
+__svc_sock_put(struct svc_sock *svsk)
 {
-	if (atomic_dec_and_test(&svsk->sk_inuse)) {
-		BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
+	BUG_ON(! test_bit(SK_DEAD, &svsk->sk_flags));
 
-		if (svsk->sk_info_authunix != NULL)
-			svcauth_unix_info_release(svsk->sk_info_authunix);
-    	    	svsk->sk_ops->sko_free(svsk);
-	}
+	if (svsk->sk_info_authunix != NULL)
+		svcauth_unix_info_release(svsk->sk_info_authunix);
+    	svsk->sk_ops->sko_free(svsk);
 }
+EXPORT_SYMBOL(__svc_sock_put);
 
 static void
 svc_sock_release(struct svc_rqst *rqstp)
@@ -1109,7 +1108,7 @@ svc_tcp_accept(struct svc_sock *svsk)
 					  struct svc_sock,
 					  sk_list);
 			set_bit(SK_CLOSE, &svsk->sk_flags);
-			atomic_inc(&svsk->sk_inuse);
+			svc_sock_get(svsk);
 		}
 		spin_unlock_bh(&serv->sv_lock);
 
@@ -1482,7 +1481,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
 	spin_lock_bh(&pool->sp_lock);
 	if ((svsk = svc_sock_dequeue(pool)) != NULL) {
 		rqstp->rq_sock = svsk;
-		atomic_inc(&svsk->sk_inuse);
+		svc_sock_get(svsk);
 		rqstp->rq_reserved = serv->sv_max_mesg;
 		atomic_add(rqstp->rq_reserved, &svsk->sk_reserved);
 	} else {
@@ -1621,7 +1620,7 @@ svc_age_temp_sockets(unsigned long closu
 			continue;
 		if (atomic_read(&svsk->sk_inuse) || test_bit(SK_BUSY, &svsk->sk_flags))
 			continue;
-		atomic_inc(&svsk->sk_inuse);
+		svc_sock_get(svsk);
 		list_move(le, &to_be_aged);
 		set_bit(SK_CLOSE, &svsk->sk_flags);
 		set_bit(SK_DETACHED, &svsk->sk_flags);
@@ -1869,7 +1868,7 @@ svc_delete_socket(struct svc_sock *svsk)
 	 */
 	if (!test_and_set_bit(SK_DEAD, &svsk->sk_flags)) {
 		BUG_ON(atomic_read(&svsk->sk_inuse)<2);
-		atomic_dec(&svsk->sk_inuse);
+		svc_sock_put(svsk);
 		if (test_bit(SK_TEMP, &svsk->sk_flags))
 			serv->sv_tmpcnt--;
 	}
@@ -1884,7 +1883,7 @@ static void svc_close_socket(struct svc_
 		/* someone else will have to effect the close */
 		return;
 
-	atomic_inc(&svsk->sk_inuse);
+	svc_sock_get(svsk);
 	svc_delete_socket(svsk);
 	clear_bit(SK_BUSY, &svsk->sk_flags);
 	svc_sock_put(svsk);
@@ -1977,7 +1976,7 @@ svc_defer(struct cache_req *req)
 		dr->argslen = rqstp->rq_arg.len >> 2;
 		memcpy(dr->args, rqstp->rq_arg.head[0].iov_base-skip, dr->argslen<<2);
 	}
-	atomic_inc(&rqstp->rq_sock->sk_inuse);
+	svc_sock_get(rqstp->rq_sock);
 	dr->svsk = rqstp->rq_sock;
 
 	dr->handle.revisit = svc_revisit;

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 11/20] svc: cleanup svc_sock initialization
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (9 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 10/20] svc: Add generic refcount services Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC, PATCH 12/20] scv: Create transport neutral debug bit RPCDBG_SVCTRANS Tom Tucker
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Reorganise the svc_sock initialisation code so that new service
transport code can use it without duplicating lots of code
that futzes with internal transport details (for example the
SK_BUSY bit).  Transport code should now call svc_sock_init() to
initialise the svc_sock structure, then one of svc_sock_add_listener
sock_add_connection or svc_sock_add_connectionless, and finally
svc_sock_received.

Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |   10 +++
 net/sunrpc/svcsock.c           |  143 ++++++++++++++++++++++++++--------------
 2 files changed, 102 insertions(+), 51 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index e455783..0e7307c 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -116,6 +116,16 @@ int		svc_addsock(struct svc_serv *serv,
 void		svc_sock_enqueue(struct svc_sock *svsk);
 void		svc_sock_received(struct svc_sock *svsk);
 void	    	__svc_sock_put(struct svc_sock *svsk);
+/* Initialise a newly allocated svc_sock.   The transport code needs
+ * to call svc_sock_received() when transport-specific initialisation
+ * is complete and one of the svc_add_*() functions has been called.  */
+void		svc_sock_init(struct svc_sock *, struct svc_serv *);
+/* Add an initialised connection svc_sock to the server */
+void		svc_sock_add_connection(struct svc_sock *);
+/* Add an initialised listener svc_sock to the server */
+void		svc_sock_add_listener(struct svc_sock *);
+/* Add an initialised connectionless svc_sock to the server */
+void		svc_sock_add_connectionless(struct svc_sock *);
 
 /*
  * svc_makesock socket characteristics
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 0193f54..57fefea 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1357,45 +1357,48 @@ static const struct svc_sock_ops svc_tcp
 };
 
 static void
-svc_tcp_init(struct svc_sock *svsk)
+svc_tcp_init_listener(struct svc_sock *svsk)
 {
 	struct sock	*sk = svsk->sk_sk;
-	struct tcp_sock *tp = tcp_sk(sk);
 
 	svsk->sk_ops = &svc_tcp_ops;
 
-	if (sk->sk_state == TCP_LISTEN) {
-		dprintk("setting up TCP socket for listening\n");
-		sk->sk_data_ready = svc_tcp_listen_data_ready;
+	dprintk("setting up TCP socket for listening\n");
+	sk->sk_data_ready = svc_tcp_listen_data_ready;
+	set_bit(SK_LISTENER, &svsk->sk_flags);
+	set_bit(SK_CONN, &svsk->sk_flags);
+}
 
-		set_bit(SK_LISTENER, &svsk->sk_flags);
-		set_bit(SK_CONN, &svsk->sk_flags);
-	} else {
-		dprintk("setting up TCP socket for reading\n");
-		sk->sk_state_change = svc_tcp_state_change;
-		sk->sk_data_ready = svc_tcp_data_ready;
-		sk->sk_write_space = svc_write_space;
+static void
+svc_tcp_init_connection(struct svc_sock *svsk)
+{
+	struct sock	*sk = svsk->sk_sk;
+	struct tcp_sock *tp = tcp_sk(sk);
 
-		svsk->sk_reclen = 0;
-		svsk->sk_tcplen = 0;
+	svsk->sk_ops = &svc_tcp_ops;
 
-		tp->nonagle = 1;        /* disable Nagle's algorithm */
+	dprintk("setting up TCP socket for reading\n");
+	sk->sk_state_change = svc_tcp_state_change;
+	sk->sk_data_ready = svc_tcp_data_ready;
+	sk->sk_write_space = svc_write_space;
 
-		/* initialise setting must have enough space to
-		 * receive and respond to one request.
-		 * svc_tcp_recvfrom will re-adjust if necessary
-		 */
-		svc_sock_setbufsize(svsk->sk_sock,
-				    3 * svsk->sk_server->sv_max_mesg,
-				    3 * svsk->sk_server->sv_max_mesg);
+	svsk->sk_reclen = 0;
+	svsk->sk_tcplen = 0;
 
-		set_bit(SK_CHNGBUF, &svsk->sk_flags);
-		set_bit(SK_DATA, &svsk->sk_flags);
-		if (sk->sk_state != TCP_ESTABLISHED) {
-			/* note: caller calls svc_sock_enqueue() */
-			set_bit(SK_CLOSE, &svsk->sk_flags);
-		}
-	}
+	tp->nonagle = 1;        /* disable Nagle's algorithm */
+
+	/* initialise setting must have enough space to
+	 * receive and respond to one request.
+	 * svc_tcp_recvfrom will re-adjust if necessary
+	 */
+	svc_sock_setbufsize(svsk->sk_sock,
+			    3 * svsk->sk_server->sv_max_mesg,
+			    3 * svsk->sk_server->sv_max_mesg);
+
+	set_bit(SK_CHNGBUF, &svsk->sk_flags);
+	set_bit(SK_DATA, &svsk->sk_flags);
+	if (sk->sk_state != TCP_ESTABLISHED)
+		set_bit(SK_CLOSE, &svsk->sk_flags);
 }
 
 void
@@ -1683,6 +1686,29 @@ static struct svc_sock *svc_setup_socket
 	svsk->sk_ostate = inet->sk_state_change;
 	svsk->sk_odata = inet->sk_data_ready;
 	svsk->sk_owspace = inet->sk_write_space;
+	svc_sock_init(svsk, serv);
+
+	/* Initialize the socket */
+	if (sock->type == SOCK_DGRAM) {
+		svc_udp_init(svsk);
+		svc_sock_add_connectionless(svsk);
+	} else if (inet->sk_state == TCP_LISTEN) {
+		BUG_ON(is_temporary);
+		svc_tcp_init_listener(svsk);
+		svc_sock_add_listener(svsk);
+	} else {
+		BUG_ON(!is_temporary);
+		svc_tcp_init_connection(svsk);
+		svc_sock_add_connection(svsk);
+	}
+
+	dprintk("svc: svc_setup_socket created %p (inet %p)\n",
+				svsk, svsk->sk_sk);
+	return svsk;
+}
+
+void svc_sock_init(struct svc_sock *svsk, struct svc_serv *serv)
+{
 	svsk->sk_server = serv;
 	atomic_set(&svsk->sk_inuse, 1);
 	svsk->sk_lastrecv = get_seconds();
@@ -1690,36 +1716,51 @@ static struct svc_sock *svc_setup_socket
 	INIT_LIST_HEAD(&svsk->sk_deferred);
 	INIT_LIST_HEAD(&svsk->sk_ready);
 	mutex_init(&svsk->sk_mutex);
+}
+EXPORT_SYMBOL(svc_sock_init);
 
-	/* Initialize the socket */
-	if (sock->type == SOCK_DGRAM)
-		svc_udp_init(svsk);
-	else
-		svc_tcp_init(svsk);
+void svc_sock_add_connection(struct svc_sock *svsk)
+{
+	struct svc_serv *serv = svsk->sk_server;
 
 	spin_lock_bh(&serv->sv_lock);
-	if (is_temporary) {
-		set_bit(SK_TEMP, &svsk->sk_flags);
-		list_add(&svsk->sk_list, &serv->sv_tempsocks);
-		serv->sv_tmpcnt++;
-		if (serv->sv_temptimer.function == NULL) {
-			/* setup timer to age temp sockets */
-			setup_timer(&serv->sv_temptimer, svc_age_temp_sockets,
-					(unsigned long)serv);
-			mod_timer(&serv->sv_temptimer,
-					jiffies + svc_conn_age_period * HZ);
-		}
-	} else {
-		clear_bit(SK_TEMP, &svsk->sk_flags);
-		list_add(&svsk->sk_list, &serv->sv_permsocks);
+
+	set_bit(SK_TEMP, &svsk->sk_flags);
+	list_add(&svsk->sk_list, &serv->sv_tempsocks);
+	serv->sv_tmpcnt++;
+	if (serv->sv_temptimer.function == NULL) {
+		/* setup timer to age temp sockets */
+		setup_timer(&serv->sv_temptimer, svc_age_temp_sockets,
+				(unsigned long)serv);
+		mod_timer(&serv->sv_temptimer,
+				jiffies + svc_conn_age_period * HZ);
 	}
+
 	spin_unlock_bh(&serv->sv_lock);
+}
+EXPORT_SYMBOL(svc_sock_add_connection);
 
-	dprintk("svc: svc_setup_socket created %p (inet %p)\n",
-				svsk, svsk->sk_sk);
+static void svc_sock_add_permanent(struct svc_sock *svsk)
+{
+	struct svc_serv *serv = svsk->sk_server;
 
-	return svsk;
+	BUG_ON(test_bit(SK_TEMP, &svsk->sk_flags));
+	spin_lock_bh(&serv->sv_lock);
+	list_add(&svsk->sk_list, &serv->sv_permsocks);
+	spin_unlock_bh(&serv->sv_lock);
+}
+
+void svc_sock_add_listener(struct svc_sock *svsk)
+{
+	svc_sock_add_permanent(svsk);
+}
+EXPORT_SYMBOL(svc_sock_add_listener);
+
+void svc_sock_add_connectionless(struct svc_sock *svsk)
+{
+	svc_sock_add_permanent(svsk);
 }
+EXPORT_SYMBOL(svc_sock_add_connectionless);
 
 int svc_addsock(struct svc_serv *serv,
 		int fd,

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC, PATCH 12/20] scv: Create transport neutral debug bit RPCDBG_SVCTRANS
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (10 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 11/20] svc: cleanup svc_sock initialization Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 13/20] svc: Add svc_[un]register_transport Tom Tucker
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Make the RPCDBG_SVCSOCK debug bit generic for service side
transports.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/debug.h |    2 +-
 net/sunrpc/svcsock.c         |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index 3912cf1..d5edad6 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -20,7 +20,7 @@ #define RPCDBG_AUTH		0x0010
 #define RPCDBG_BIND		0x0020
 #define RPCDBG_SCHED		0x0040
 #define RPCDBG_TRANS		0x0080
-#define RPCDBG_SVCSOCK		0x0100
+#define RPCDBG_SVCTRANS		0x0100
 #define RPCDBG_SVCDSP		0x0200
 #define RPCDBG_MISC		0x0400
 #define RPCDBG_CACHE		0x0800
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 57fefea..b88e3d2 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -74,7 +74,7 @@ #include <linux/sunrpc/stats.h>
  *
  */
 
-#define RPCDBG_FACILITY	RPCDBG_SVCSOCK
+#define RPCDBG_FACILITY	RPCDBG_SVCTRANS
 
 
 static struct svc_sock *svc_setup_socket(struct svc_serv *, struct socket *,

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 13/20] svc: Add svc_[un]register_transport
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (11 preceding siblings ...)
  2007-07-10  5:34 ` [RFC, PATCH 12/20] scv: Create transport neutral debug bit RPCDBG_SVCTRANS Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 14/20] svc: Register TCP/UDP Transports Tom Tucker
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add an exported function for transport modules to [un]register themselves
with the sunrpc server side transport switch.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |    7 ++++++
 net/sunrpc/svcsock.c           |   50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 0e7307c..d132dd5 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -13,6 +13,7 @@ #include <linux/sunrpc/svc.h>
 
 struct svc_sock_ops {
 	const char		*sko_name;
+	struct module		*sko_owner;
 	int			(*sko_recvfrom)(struct svc_rqst *rqstp);
 	int			(*sko_sendto)(struct svc_rqst *rqstp);
 	/*
@@ -45,7 +46,11 @@ struct svc_sock_ops {
 	 * Accept a pending connection, for connection-oriented transports
 	 */
 	int			(*sko_accept)(struct svc_sock *svsk);
+
+	/* Transport list link */
+	struct list_head	sko_list;
 };
+extern struct list_head svc_transport_list;
 
 /*
  * RPC server socket.
@@ -102,6 +107,8 @@ #define	SK_LISTENER	11			/* listener (e.
 /*
  * Function prototypes.
  */
+int 		svc_register_transport(struct svc_sock_ops *xprt);
+int 		svc_unregister_transport(struct svc_sock_ops *xprt);
 int		svc_makesock(struct svc_serv *, int, unsigned short, int flags);
 void		svc_force_close_socket(struct svc_sock *);
 int		svc_recv(struct svc_rqst *, long);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index b88e3d2..ec0ad0e 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -91,6 +91,54 @@ static struct svc_deferred_req *svc_defe
 static int svc_deferred_recv(struct svc_rqst *rqstp);
 static struct cache_deferred_req *svc_defer(struct cache_req *req);
 
+/* List of registered transports */
+static spinlock_t svc_transport_lock = SPIN_LOCK_UNLOCKED;
+LIST_HEAD(svc_transport_list);
+
+int svc_register_transport(struct svc_sock_ops *xprt)
+{
+	struct svc_sock_ops *ops;
+	int res;
+
+	dprintk("svc: Adding svc transport '%s'\n",
+		xprt->sko_name);
+	
+	res = -EEXIST;
+	INIT_LIST_HEAD(&xprt->sko_list);
+	spin_lock(&svc_transport_lock);
+	list_for_each_entry(ops, &svc_transport_list, sko_list) {
+		if (xprt == ops)
+			goto out;
+	}
+	list_add_tail(&xprt->sko_list, &svc_transport_list);
+	res = 0;
+out:
+	spin_unlock(&svc_transport_lock);
+	return res;
+}
+EXPORT_SYMBOL(svc_register_transport);
+
+int svc_unregister_transport(struct svc_sock_ops *xprt)
+{
+	struct svc_sock_ops *ops;
+	int res = 0;
+
+	dprintk("svc: Removing svc transport '%s'\n", xprt->sko_name);
+
+	spin_lock(&svc_transport_lock);
+	list_for_each_entry(ops, &svc_transport_list, sko_list) {
+		if (xprt == ops) {
+			list_del_init(&ops->sko_list);
+			goto out;
+		}
+	}
+	res = -ENOENT;
+ out:
+	spin_unlock(&svc_transport_lock);
+	return res;
+}
+EXPORT_SYMBOL(svc_unregister_transport);
+
 /* apparently the "standard" is that clients close
  * idle connections after 5 minutes, servers after
  * 6 minutes
@@ -887,6 +935,7 @@ svc_udp_has_wspace(struct svc_sock *svsk
 
 static const struct svc_sock_ops svc_udp_ops = {
 	.sko_name = "udp",
+	.sko_owner = THIS_MODULE,
 	.sko_recvfrom = svc_udp_recvfrom,
 	.sko_sendto = svc_udp_sendto,
 	.sko_detach = svc_tcpip_detach,
@@ -1346,6 +1395,7 @@ svc_tcp_has_wspace(struct svc_sock *svsk
 
 static const struct svc_sock_ops svc_tcp_ops = {
 	.sko_name = "tcp",
+	.sko_owner = THIS_MODULE,
 	.sko_recvfrom = svc_tcp_recvfrom,
 	.sko_sendto = svc_tcp_sendto,
 	.sko_detach = svc_tcpip_detach,

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 14/20] svc: Register TCP/UDP Transports
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (12 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 13/20] svc: Add svc_[un]register_transport Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 15/20] svc: transport file implementation Tom Tucker
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add a call to svc_register_transport for the built
in transports UDP and TCP. The registration is done in the 
sunrpc module initialization logic.
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 net/sunrpc/sunrpc_syms.c |    2 ++
 net/sunrpc/svcsock.c     |   10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index 73075de..c68577b 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -134,6 +134,7 @@ EXPORT_SYMBOL(nfsd_debug);
 EXPORT_SYMBOL(nlm_debug);
 #endif
 
+extern void init_svc_xprt(void);
 extern struct cache_detail ip_map_cache, unix_gid_cache;
 
 static int __init
@@ -156,6 +157,7 @@ #endif
 	cache_register(&ip_map_cache);
 	cache_register(&unix_gid_cache);
 	init_socket_xprt();
+	init_svc_xprt();
 out:
 	return err;
 }
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index ec0ad0e..2583623 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -933,7 +933,7 @@ svc_udp_has_wspace(struct svc_sock *svsk
 	return svc_sock_has_write_space(svsk, sock_wspace(svsk->sk_sk));
 }
 
-static const struct svc_sock_ops svc_udp_ops = {
+static struct svc_sock_ops svc_udp_ops = {
 	.sko_name = "udp",
 	.sko_owner = THIS_MODULE,
 	.sko_recvfrom = svc_udp_recvfrom,
@@ -1393,7 +1393,7 @@ svc_tcp_has_wspace(struct svc_sock *svsk
 	return svc_sock_has_write_space(svsk, sk_stream_wspace(svsk->sk_sk));
 }
 
-static const struct svc_sock_ops svc_tcp_ops = {
+static struct svc_sock_ops svc_tcp_ops = {
 	.sko_name = "tcp",
 	.sko_owner = THIS_MODULE,
 	.sko_recvfrom = svc_tcp_recvfrom,
@@ -1406,6 +1406,12 @@ static const struct svc_sock_ops svc_tcp
 	.sko_accept = svc_tcp_accept
 };
 
+void init_svc_xprt(void) 
+{
+	svc_register_transport(&svc_udp_ops);
+	svc_register_transport(&svc_tcp_ops);
+}
+	
 static void
 svc_tcp_init_listener(struct svc_sock *svsk)
 {

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 15/20] svc: transport file implementation
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (13 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 14/20] svc: Register TCP/UDP Transports Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10 23:30   ` Trond Myklebust
  2007-07-10  5:34 ` [RFC,PATCH 16/20] svc: sko_create_svc Tom Tucker
                   ` (4 subsequent siblings)
  19 siblings, 1 reply; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Create a proc/sys/sunrpc/transport file that contains information 
about the currently registered transports.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/debug.h |    1 +
 net/sunrpc/svcsock.c         |   28 ++++++++++++++++++++++++++++
 net/sunrpc/sysctl.c          |   40 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index d5edad6..4c847d4 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -88,6 +88,7 @@ enum {
 	CTL_SLOTTABLE_TCP,
 	CTL_MIN_RESVPORT,
 	CTL_MAX_RESVPORT,
+	CTL_TRANSPORTS,
 };
 
 #endif /* _LINUX_SUNRPC_DEBUG_H_ */
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 2583623..33aff99 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -139,6 +139,34 @@ int svc_unregister_transport(struct svc_
 }
 EXPORT_SYMBOL(svc_unregister_transport);
 
+/* 
+ * Format the transport list for printing
+ */
+int svc_print_transports(char *buf, int maxlen) 
+{
+	struct list_head *le;
+	char tmpstr[80];
+	int len = 0;
+	buf[0] = '\0';
+
+	spin_lock(&svc_transport_lock);
+	list_for_each(le, &svc_transport_list) {
+		int slen;
+		struct svc_sock_ops *op = 
+			list_entry(le, struct svc_sock_ops, sko_list);
+		
+		sprintf(tmpstr, "%s %d\n", op->sko_name, op->sko_max_payload);
+		slen = strlen(tmpstr);
+		if (len + slen > maxlen)
+			break;
+		len += slen;
+		strcat(buf, tmpstr);
+	}
+	spin_unlock(&svc_transport_lock);
+
+	return len;
+}
+
 /* apparently the "standard" is that clients close
  * idle connections after 5 minutes, servers after
  * 6 minutes
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index 738db32..683cf90 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -27,6 +27,9 @@ unsigned int	nfs_debug;
 unsigned int	nfsd_debug;
 unsigned int	nlm_debug;
 
+/* Transport string */
+char 		xprt_buf[128];
+
 #ifdef RPC_DEBUG
 
 static struct ctl_table_header *sunrpc_table_header;
@@ -48,6 +51,34 @@ rpc_unregister_sysctl(void)
 	}
 }
 
+int svc_print_transports(char *buf, int maxlen);
+static int proc_do_xprt(ctl_table *table, int write, struct file *file,
+			void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+	char tmpbuf[128];
+	int len;
+	if ((*ppos && !write) || !*lenp) {
+		*lenp = 0;
+		return 0;
+	}
+
+	if (write) 
+		return -EINVAL;
+	else {
+
+		len = svc_print_transports(tmpbuf, 128);
+		if (!access_ok(VERIFY_WRITE, buffer, len))
+			return -EFAULT;
+
+		if (__copy_to_user(buffer, tmpbuf, len))
+			return -EFAULT;
+	}
+
+	*lenp -= len;
+	*ppos += len;
+	return 0;
+}
+
 static int
 proc_dodebug(ctl_table *table, int write, struct file *file,
 				void __user *buffer, size_t *lenp, loff_t *ppos)
@@ -111,7 +142,6 @@ done:
 	return 0;
 }
 
-
 static ctl_table debug_table[] = {
 	{
 		.ctl_name	= CTL_RPCDEBUG,
@@ -145,6 +175,14 @@ static ctl_table debug_table[] = {
 		.mode		= 0644,
 		.proc_handler	= &proc_dodebug
 	},
+	{
+		.ctl_name	= CTL_TRANSPORTS,
+		.procname	= "transports",
+		.data		= xprt_buf,
+		.maxlen		= sizeof(xprt_buf),
+		.mode		= 0444,
+		.proc_handler	= &proc_do_xprt,
+	},
 	{ .ctl_name = 0 }
 };
 

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 16/20] svc: sko_create_svc
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (14 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 15/20] svc: transport file implementation Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 17/20] svc: Add sko_get_name service Tom Tucker
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add an sko function that makes the creation of a listening endpoint 
transport independent.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |    5 +++
 net/sunrpc/svcsock.c           |   64 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index d132dd5..383ac4f 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -14,6 +14,10 @@ #include <linux/sunrpc/svc.h>
 struct svc_sock_ops {
 	const char		*sko_name;
 	struct module		*sko_owner;
+	/* Create an svc socket for this transport */
+	int			(*sko_create_svc)(struct svc_serv *,
+						  struct sockaddr *,
+						  int);
 	int			(*sko_recvfrom)(struct svc_rqst *rqstp);
 	int			(*sko_sendto)(struct svc_rqst *rqstp);
 	/*
@@ -110,6 +114,7 @@ #define	SK_LISTENER	11			/* listener (e.
 int 		svc_register_transport(struct svc_sock_ops *xprt);
 int 		svc_unregister_transport(struct svc_sock_ops *xprt);
 int		svc_makesock(struct svc_serv *, int, unsigned short, int flags);
+int		svc_create_svcsock(struct svc_serv *, char *, unsigned short, int);
 void		svc_force_close_socket(struct svc_sock *);
 int		svc_recv(struct svc_rqst *, long);
 int		svc_send(struct svc_rqst *);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 33aff99..b14dc46 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -87,6 +87,8 @@ static void		svc_close_socket(struct svc
 static void		svc_tcpip_detach(struct svc_sock *);
 static void		svc_tcpip_free(struct svc_sock *);
 
+static int
+svc_create_socket(struct svc_serv *, int, struct sockaddr *, int, int);
 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_sock *svsk);
 static int svc_deferred_recv(struct svc_rqst *rqstp);
 static struct cache_deferred_req *svc_defer(struct cache_req *req);
@@ -434,6 +436,7 @@ __svc_sock_put(struct svc_sock *svsk)
 
 	if (svsk->sk_info_authunix != NULL)
 		svcauth_unix_info_release(svsk->sk_info_authunix);
+	module_put(svsk->sk_ops->sko_owner);
     	svsk->sk_ops->sko_free(svsk);
 }
 EXPORT_SYMBOL(__svc_sock_put);
@@ -961,9 +964,17 @@ svc_udp_has_wspace(struct svc_sock *svsk
 	return svc_sock_has_write_space(svsk, sock_wspace(svsk->sk_sk));
 }
 
+static int
+svc_udp_create_svc(struct svc_serv *serv, struct sockaddr *sa, int flags)
+{
+	return svc_create_socket(serv, IPPROTO_UDP, sa,
+				 sizeof(struct sockaddr_in), flags);
+}
+
 static struct svc_sock_ops svc_udp_ops = {
 	.sko_name = "udp",
 	.sko_owner = THIS_MODULE,
+	.sko_create_svc = svc_udp_create_svc,
 	.sko_recvfrom = svc_udp_recvfrom,
 	.sko_sendto = svc_udp_sendto,
 	.sko_detach = svc_tcpip_detach,
@@ -1421,9 +1432,17 @@ svc_tcp_has_wspace(struct svc_sock *svsk
 	return svc_sock_has_write_space(svsk, sk_stream_wspace(svsk->sk_sk));
 }
 
+static int
+svc_tcp_create_svc(struct svc_serv *serv, struct sockaddr *sa, int flags)
+{
+	return svc_create_socket(serv, IPPROTO_TCP, sa,
+				 sizeof(struct sockaddr_in), flags);
+}
+
 static struct svc_sock_ops svc_tcp_ops = {
 	.sko_name = "tcp",
 	.sko_owner = THIS_MODULE,
+	.sko_create_svc = svc_tcp_create_svc,
 	.sko_recvfrom = svc_tcp_recvfrom,
 	.sko_sendto = svc_tcp_sendto,
 	.sko_detach = svc_tcpip_detach,
@@ -1605,6 +1624,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
 		svc_delete_socket(svsk);
 	} else if (test_bit(SK_LISTENER, &svsk->sk_flags)) {
 		svsk->sk_ops->sko_accept(svsk);
+		__module_get(svsk->sk_ops->sko_owner);
 		svc_sock_received(svsk);
 	} else {
 		dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
@@ -1884,7 +1904,7 @@ EXPORT_SYMBOL_GPL(svc_addsock);
  * Create socket for RPC service.
  */
 static int svc_create_socket(struct svc_serv *serv, int protocol,
-				struct sockaddr *sin, int len, int flags)
+			     struct sockaddr *sin, int len, int flags)
 {
 	struct svc_sock	*svsk;
 	struct socket	*sock;
@@ -2036,17 +2056,51 @@ void svc_force_close_socket(struct svc_s
  *
  */
 int svc_makesock(struct svc_serv *serv, int protocol, unsigned short port,
-			int flags)
+		 int flags)
 {
+	dprintk("svc: creating socket proto = %d\n", protocol);
+	switch (protocol) {
+	case IPPROTO_TCP:
+		return svc_create_svcsock(serv, "tcp", port, flags);
+	case IPPROTO_UDP:
+		return svc_create_svcsock(serv, "udp", port, flags);
+	default:
+		return -EINVAL;
+	}
+}
+
+int svc_create_svcsock(struct svc_serv *serv, char *transport, unsigned short port,
+		       int flags)
+{
+	int ret = -ENOENT;
+	struct list_head *le;
 	struct sockaddr_in sin = {
 		.sin_family		= AF_INET,
 		.sin_addr.s_addr	= INADDR_ANY,
 		.sin_port		= htons(port),
 	};
+	dprintk("svc: creating transport socket %s[%d]\n", transport, port);
+	spin_lock(&svc_transport_lock);
+	list_for_each(le, &svc_transport_list) {
+		struct svc_sock_ops *op = 
+			list_entry(le, struct svc_sock_ops, sko_list);
 
-	dprintk("svc: creating socket proto = %d\n", protocol);
-	return svc_create_socket(serv, protocol, (struct sockaddr *) &sin,
-							sizeof(sin), flags);
+		if (strcmp(transport, op->sko_name)==0) {
+			spin_unlock(&svc_transport_lock);
+			if (try_module_get(op->sko_owner)) {
+				ret = op->sko_create_svc(serv, 
+							 (struct sockaddr*)&sin, 
+							 flags);
+				if (ret < 0)
+					module_put(op->sko_owner);
+				goto out;
+			}
+		}
+	}
+	spin_unlock(&svc_transport_lock);
+	dprintk("svc: transport %s not found\n", transport);
+ out:
+	return ret;
 }
 
 /*

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 17/20] svc: Add sko_get_name service
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (15 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 16/20] svc: sko_create_svc Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:34 ` [RFC,PATCH 18/20] svc: Add sko_defer routine Tom Tucker
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


Add an sko function to return a formatted socket name. This is used
by knfsd when satisfying reads to the portlist file.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |    1 +
 net/sunrpc/svcsock.c           |   17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 383ac4f..5c272db 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -18,6 +18,7 @@ struct svc_sock_ops {
 	int			(*sko_create_svc)(struct svc_serv *,
 						  struct sockaddr *,
 						  int);
+	int			(*sko_get_name)(char *, struct svc_sock*);
 	int			(*sko_recvfrom)(struct svc_rqst *rqstp);
 	int			(*sko_sendto)(struct svc_rqst *rqstp);
 	/*
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index b14dc46..6bd6169 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -622,10 +622,7 @@ out:
 	return len;
 }
 
-/*
- * Report socket names for nfsdfs
- */
-static int one_sock_name(char *buf, struct svc_sock *svsk)
+static int svc_tcpip_get_name(char *buf, struct svc_sock *svsk)
 {
 	int len;
 
@@ -639,11 +636,19 @@ static int one_sock_name(char *buf, stru
 		break;
 	default:
 		len = sprintf(buf, "*unknown-%d*\n",
-			       svsk->sk_sk->sk_family);
+                              svsk->sk_sk->sk_family);
 	}
 	return len;
 }
 
+/*
+ * Report socket names for nfsdfs
+ */
+static int one_sock_name(char *buf, struct svc_sock *svsk)
+{
+	return svsk->sk_ops->sko_get_name(buf,svsk);
+}
+
 int
 svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
 {
@@ -975,6 +980,7 @@ static struct svc_sock_ops svc_udp_ops =
 	.sko_name = "udp",
 	.sko_owner = THIS_MODULE,
 	.sko_create_svc = svc_udp_create_svc,
+	.sko_get_name = svc_tcpip_get_name,
 	.sko_recvfrom = svc_udp_recvfrom,
 	.sko_sendto = svc_udp_sendto,
 	.sko_detach = svc_tcpip_detach,
@@ -1443,6 +1449,7 @@ static struct svc_sock_ops svc_tcp_ops =
 	.sko_name = "tcp",
 	.sko_owner = THIS_MODULE,
 	.sko_create_svc = svc_tcp_create_svc,
+	.sko_get_name = svc_tcpip_get_name,
 	.sko_recvfrom = svc_tcp_recvfrom,
 	.sko_sendto = svc_tcp_sendto,
 	.sko_detach = svc_tcpip_detach,

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 18/20] svc: Add sko_defer routine
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (16 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 17/20] svc: Add sko_get_name service Tom Tucker
@ 2007-07-10  5:34 ` Tom Tucker
  2007-07-10  5:35 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker
  2007-07-10  5:35 ` [RFC,PATCH 20/20] knfsd: create listener via portlist write Tom Tucker
  19 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:34 UTC (permalink / raw)
  To: nfs


The RDMA transport includes an ONCRDMA header that precedes the RPC 
message. This header needs to be saved in addition to the RPC message 
itself. The RPC transport uses page swapping to implement copy avoidance.
These transport dependencies are hidden in the sko_defer routine allowing
the bulk of the deferral processing to remain in transport independent 
code.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svcsock.c           |   11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index 5c272db..b815f36 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -52,6 +52,9 @@ struct svc_sock_ops {
 	 */
 	int			(*sko_accept)(struct svc_sock *svsk);
 
+	/* RPC defer routine. */
+	struct cache_deferred_req *(*sko_defer)(struct cache_req *req);
+
 	/* Transport list link */
 	struct list_head	sko_list;
 };
@@ -139,6 +142,7 @@ void		svc_sock_add_connection(struct svc
 void		svc_sock_add_listener(struct svc_sock *);
 /* Add an initialised connectionless svc_sock to the server */
 void		svc_sock_add_connectionless(struct svc_sock *);
+void 		svc_revisit(struct cache_deferred_req *dreq, int too_many);
 
 /*
  * svc_makesock socket characteristics
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 6bd6169..b0e1b61 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -986,7 +986,8 @@ static struct svc_sock_ops svc_udp_ops =
 	.sko_detach = svc_tcpip_detach,
 	.sko_free = svc_tcpip_free,
 	.sko_has_wspace = svc_udp_has_wspace,
-	.sko_max_payload = RPCSVC_MAXPAYLOAD_UDP
+	.sko_max_payload = RPCSVC_MAXPAYLOAD_UDP,
+	.sko_defer = svc_defer
 };
 
 static void
@@ -1457,7 +1458,8 @@ static struct svc_sock_ops svc_tcp_ops =
 	.sko_prep_reply_hdr = svc_tcp_prep_reply_hdr,
 	.sko_has_wspace = svc_tcp_has_wspace,
 	.sko_max_payload = RPCSVC_MAXPAYLOAD_TCP,
-	.sko_accept = svc_tcp_accept
+	.sko_accept = svc_tcp_accept,
+	.sko_defer = svc_defer
 };
 
 void init_svc_xprt(void) 
@@ -1650,7 +1652,7 @@ svc_recv(struct svc_rqst *rqstp, long ti
 	clear_bit(SK_OLD, &svsk->sk_flags);
 
 	rqstp->rq_secure = svc_port_is_privileged(svc_addr(rqstp));
-	rqstp->rq_chandle.defer = svc_defer;
+	rqstp->rq_chandle.defer = svsk->sk_ops->sko_defer;
 
 	if (serv->sv_stats)
 		serv->sv_stats->netcnt++;
@@ -2114,7 +2116,7 @@ int svc_create_svcsock(struct svc_serv *
  * Handle defer and revisit of requests
  */
 
-static void svc_revisit(struct cache_deferred_req *dreq, int too_many)
+void svc_revisit(struct cache_deferred_req *dreq, int too_many)
 {
 	struct svc_deferred_req *dr = container_of(dreq, struct svc_deferred_req, handle);
 	struct svc_sock *svsk;
@@ -2134,6 +2136,7 @@ static void svc_revisit(struct cache_def
 	svc_sock_enqueue(svsk);
 	svc_sock_put(svsk);
 }
+EXPORT_SYMBOL(svc_revisit);
 
 static struct cache_deferred_req *
 svc_defer(struct cache_req *req)

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 19/20] knfsd: call svc_create_svcsock
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (17 preceding siblings ...)
  2007-07-10  5:34 ` [RFC,PATCH 18/20] svc: Add sko_defer routine Tom Tucker
@ 2007-07-10  5:35 ` Tom Tucker
  2007-07-10 23:32   ` Trond Myklebust
  2007-07-10  5:35 ` [RFC,PATCH 20/20] knfsd: create listener via portlist write Tom Tucker
  19 siblings, 1 reply; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:35 UTC (permalink / raw)
  To: nfs


Change the call to the socket specific svc_makesock to a call to the
transport independent svc_create_svcsock function. This avoids 
conditional #ifdef's for the rdma transport in the nfsd code. 

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 fs/nfsd/nfssvc.c     |    8 ++++----
 net/sunrpc/svcsock.c |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index ff55950..1499beb 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -235,8 +235,8 @@ static int nfsd_init_socks(int port)
 
 	error = lockd_up(IPPROTO_UDP);
 	if (error >= 0) {
-		error = svc_makesock(nfsd_serv, IPPROTO_UDP, port,
-					SVC_SOCK_DEFAULTS);
+		error = svc_create_svcsock(nfsd_serv, "udp", port,
+					   SVC_SOCK_DEFAULTS);
 		if (error < 0)
 			lockd_down();
 	}
@@ -246,8 +246,8 @@ static int nfsd_init_socks(int port)
 #ifdef CONFIG_NFSD_TCP
 	error = lockd_up(IPPROTO_TCP);
 	if (error >= 0) {
-		error = svc_makesock(nfsd_serv, IPPROTO_TCP, port,
-					SVC_SOCK_DEFAULTS);
+		error = svc_create_svcsock(nfsd_serv, "tcp", port,
+					   SVC_SOCK_DEFAULTS);
 		if (error < 0)
 			lockd_down();
 	}
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index b0e1b61..67a1d59 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -2111,6 +2111,7 @@ int svc_create_svcsock(struct svc_serv *
  out:
 	return ret;
 }
+EXPORT_SYMBOL(svc_create_svcsock);
 
 /*
  * Handle defer and revisit of requests

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* [RFC,PATCH 20/20] knfsd: create listener via portlist write
  2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
                   ` (18 preceding siblings ...)
  2007-07-10  5:35 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker
@ 2007-07-10  5:35 ` Tom Tucker
  2007-07-10 23:36   ` [RFC, PATCH " Trond Myklebust
  19 siblings, 1 reply; 30+ messages in thread
From: Tom Tucker @ 2007-07-10  5:35 UTC (permalink / raw)
  To: nfs


Update the write handler for the portlist file to allow creating new 
listening endpoints on a transport. The general form of the string is:

<transport_name><space><port number>

For example:

tcp 2049

This is intended to support the creation of a listening endpoint for
RDMA transports without adding #ifdef code to the nfssvc.c file.
The "built-in" transports UDP/TCP were left in the nfssvc initialization
code to avoid having to change rpc.nfsd, etc...

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 fs/nfsd/nfsctl.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 71c686d..b72514d 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -555,6 +555,22 @@ static ssize_t write_ports(struct file *
 		kfree(toclose);
 		return len;
 	}
+	/* This implements the ability to add a transport by writing
+	 * it's transport name to the portlist file
+	 */
+	if (isalnum(buf[0])) {
+		int err;
+		char transport[16];
+		int port;
+		sscanf(buf, "%15s %4d", transport, &port);
+		err = nfsd_create_serv();
+		if (!err)
+			err = svc_create_svcsock(nfsd_serv,
+						 transport, port,
+						 SVC_SOCK_ANONYMOUS);
+		return err < 0 ? err : 0;
+	}
+	
 	return -EINVAL;
 }
 

-------------------------------------------------------------------------
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 related	[flat|nested] 30+ messages in thread

* Re: [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received
  2007-07-10  5:34 ` [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received Tom Tucker
@ 2007-07-10 23:08   ` Trond Myklebust
  2007-07-11  0:45     ` Tom Tucker
  0 siblings, 1 reply; 30+ messages in thread
From: Trond Myklebust @ 2007-07-10 23:08 UTC (permalink / raw)
  To: Tom Tucker; +Cc: nfs

On Tue, 2007-07-10 at 00:34 -0500, Tom Tucker wrote:
> Export svc_sock_enqueue() and svc_sock_received() so they
> can be used by sunrpc server transport implementations
> (even future modular ones).
> 
> Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
> Signed-off-by: Peter Leckie <pleckie@melbourne.sgi.com>
> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> ---
> 
>  include/linux/sunrpc/svcsock.h |    2 ++
>  net/sunrpc/svcsock.c           |    7 ++++---
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
> index ce93b10..9fa4321 100644
> --- a/include/linux/sunrpc/svcsock.h
> +++ b/include/linux/sunrpc/svcsock.h
> @@ -108,6 +108,8 @@ int		svc_addsock(struct svc_serv *serv,
>  			    int fd,
>  			    char *name_return,
>  			    int *proto);
> +void		svc_sock_enqueue(struct svc_sock *svsk);
> +void		svc_sock_received(struct svc_sock *svsk);
>  
>  /*
>   * svc_makesock socket characteristics
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 1a6a933..f09c4b4 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -209,7 +209,7 @@ svc_release_skb(struct svc_rqst *rqstp)
>   * processes, wake 'em up.
>   *
>   */
> -static void
> +void
>  svc_sock_enqueue(struct svc_sock *svsk)
>  {
>  	struct svc_serv	*serv = svsk->sk_server;
> @@ -287,6 +287,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
>  out_unlock:
>  	spin_unlock_bh(&pool->sp_lock);
>  }
> +EXPORT_SYMBOL(svc_sock_enqueue);

EXPORT_SYMBOL_GPL(), please. This is definitely not something we want to
encourage out-of-tree modules to use.

>  
>  /*
>   * Dequeue the first socket.  Must be called with the pool->sp_lock held.
> @@ -315,14 +316,14 @@ svc_sock_dequeue(struct svc_pool *pool)
>   * Note: SK_DATA only gets cleared when a read-attempt finds
>   * no (or insufficient) data.
>   */
> -static inline void
> +void
>  svc_sock_received(struct svc_sock *svsk)
>  {
>  	svsk->sk_pool = NULL;
>  	clear_bit(SK_BUSY, &svsk->sk_flags);
>  	svc_sock_enqueue(svsk);
>  }
> -
> +EXPORT_SYMBOL(svc_sock_received);

ditto...
>  
>  /**
>   * svc_reserve - change the space reserved for the reply to a request.
> 
> -------------------------------------------------------------------------
> 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


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC,PATCH 15/20] svc: transport file implementation
  2007-07-10  5:34 ` [RFC,PATCH 15/20] svc: transport file implementation Tom Tucker
@ 2007-07-10 23:30   ` Trond Myklebust
  0 siblings, 0 replies; 30+ messages in thread
From: Trond Myklebust @ 2007-07-10 23:30 UTC (permalink / raw)
  To: Tom Tucker; +Cc: nfs

On Tue, 2007-07-10 at 00:34 -0500, Tom Tucker wrote:
> Create a proc/sys/sunrpc/transport file that contains information 
> about the currently registered transports.
> 
> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> ---
> 
>  include/linux/sunrpc/debug.h |    1 +
>  net/sunrpc/svcsock.c         |   28 ++++++++++++++++++++++++++++
>  net/sunrpc/sysctl.c          |   40 +++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 68 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
> index d5edad6..4c847d4 100644
> --- a/include/linux/sunrpc/debug.h
> +++ b/include/linux/sunrpc/debug.h
> @@ -88,6 +88,7 @@ enum {
>  	CTL_SLOTTABLE_TCP,
>  	CTL_MIN_RESVPORT,
>  	CTL_MAX_RESVPORT,
> +	CTL_TRANSPORTS,
>  };
>  
>  #endif /* _LINUX_SUNRPC_DEBUG_H_ */
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 2583623..33aff99 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -139,6 +139,34 @@ int svc_unregister_transport(struct svc_
>  }
>  EXPORT_SYMBOL(svc_unregister_transport);
>  
> +/* 
> + * Format the transport list for printing
> + */
> +int svc_print_transports(char *buf, int maxlen) 
> +{
> +	struct list_head *le;
> +	char tmpstr[80];
> +	int len = 0;
> +	buf[0] = '\0';
> +
> +	spin_lock(&svc_transport_lock);
> +	list_for_each(le, &svc_transport_list) {
> +		int slen;
> +		struct svc_sock_ops *op = 
> +			list_entry(le, struct svc_sock_ops, sko_list);
> +		
> +		sprintf(tmpstr, "%s %d\n", op->sko_name, op->sko_max_payload);
> +		slen = strlen(tmpstr);
> +		if (len + slen > maxlen)
> +			break;
> +		len += slen;
> +		strcat(buf, tmpstr);
> +	}
> +	spin_unlock(&svc_transport_lock);
> +
> +	return len;
> +}

You're probably better off doing this using a seq_file.

> +
>  /* apparently the "standard" is that clients close
>   * idle connections after 5 minutes, servers after
>   * 6 minutes
> diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
> index 738db32..683cf90 100644
> --- a/net/sunrpc/sysctl.c
> +++ b/net/sunrpc/sysctl.c
> @@ -27,6 +27,9 @@ unsigned int	nfs_debug;
>  unsigned int	nfsd_debug;
>  unsigned int	nlm_debug;
>  
> +/* Transport string */
> +char 		xprt_buf[128];
> +
>  #ifdef RPC_DEBUG
>  
>  static struct ctl_table_header *sunrpc_table_header;
> @@ -48,6 +51,34 @@ rpc_unregister_sysctl(void)
>  	}
>  }
>  
> +int svc_print_transports(char *buf, int maxlen);
> +static int proc_do_xprt(ctl_table *table, int write, struct file *file,
> +			void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> +	char tmpbuf[128];
> +	int len;
> +	if ((*ppos && !write) || !*lenp) {
> +		*lenp = 0;
> +		return 0;
> +	}
> +
> +	if (write) 
> +		return -EINVAL;
> +	else {
> +
> +		len = svc_print_transports(tmpbuf, 128);
> +		if (!access_ok(VERIFY_WRITE, buffer, len))
> +			return -EFAULT;
> +
> +		if (__copy_to_user(buffer, tmpbuf, len))
> +			return -EFAULT;
> +	}
> +
> +	*lenp -= len;
> +	*ppos += len;
> +	return 0;
> +}
> +
>  static int
>  proc_dodebug(ctl_table *table, int write, struct file *file,
>  				void __user *buffer, size_t *lenp, loff_t *ppos)
> @@ -111,7 +142,6 @@ done:
>  	return 0;
>  }
>  
> -
>  static ctl_table debug_table[] = {
>  	{
>  		.ctl_name	= CTL_RPCDEBUG,
> @@ -145,6 +175,14 @@ static ctl_table debug_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= &proc_dodebug
>  	},
> +	{
> +		.ctl_name	= CTL_TRANSPORTS,
> +		.procname	= "transports",
> +		.data		= xprt_buf,
> +		.maxlen		= sizeof(xprt_buf),
> +		.mode		= 0444,
> +		.proc_handler	= &proc_do_xprt,
> +	},
>  	{ .ctl_name = 0 }
>  };
>  
> 
> -------------------------------------------------------------------------
> 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


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock
  2007-07-10  5:35 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker
@ 2007-07-10 23:32   ` Trond Myklebust
  2007-07-11  0:48     ` Tom Tucker
  2007-07-11  0:59     ` Tom Tucker
  0 siblings, 2 replies; 30+ messages in thread
From: Trond Myklebust @ 2007-07-10 23:32 UTC (permalink / raw)
  To: Tom Tucker; +Cc: nfs

On Tue, 2007-07-10 at 00:35 -0500, Tom Tucker wrote:
> Change the call to the socket specific svc_makesock to a call to the
> transport independent svc_create_svcsock function. This avoids 
> conditional #ifdef's for the rdma transport in the nfsd code. 
> 
> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> ---
> 
>  fs/nfsd/nfssvc.c     |    8 ++++----
>  net/sunrpc/svcsock.c |    1 +
>  2 files changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> index ff55950..1499beb 100644
> --- a/fs/nfsd/nfssvc.c
> +++ b/fs/nfsd/nfssvc.c
> @@ -235,8 +235,8 @@ static int nfsd_init_socks(int port)
>  
>  	error = lockd_up(IPPROTO_UDP);
>  	if (error >= 0) {
> -		error = svc_makesock(nfsd_serv, IPPROTO_UDP, port,
> -					SVC_SOCK_DEFAULTS);
> +		error = svc_create_svcsock(nfsd_serv, "udp", port,
> +					   SVC_SOCK_DEFAULTS);
>  		if (error < 0)
>  			lockd_down();
>  	}
> @@ -246,8 +246,8 @@ static int nfsd_init_socks(int port)
>  #ifdef CONFIG_NFSD_TCP
>  	error = lockd_up(IPPROTO_TCP);
>  	if (error >= 0) {
> -		error = svc_makesock(nfsd_serv, IPPROTO_TCP, port,
> -					SVC_SOCK_DEFAULTS);
> +		error = svc_create_svcsock(nfsd_serv, "tcp", port,
> +					   SVC_SOCK_DEFAULTS);
>  		if (error < 0)
>  			lockd_down();
>  	}
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index b0e1b61..67a1d59 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -2111,6 +2111,7 @@ int svc_create_svcsock(struct svc_serv *
>   out:
>  	return ret;
>  }
> +EXPORT_SYMBOL(svc_create_svcsock);

...again. Really wants to be an EXPORT_SYMBOL_GPL().

>  /*
>   * Handle defer and revisit of requests
> 
> -------------------------------------------------------------------------
> 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


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC, PATCH 20/20] knfsd: create listener via portlist write
  2007-07-10  5:35 ` [RFC,PATCH 20/20] knfsd: create listener via portlist write Tom Tucker
@ 2007-07-10 23:36   ` Trond Myklebust
  2007-07-11  1:04     ` Tom Tucker
  0 siblings, 1 reply; 30+ messages in thread
From: Trond Myklebust @ 2007-07-10 23:36 UTC (permalink / raw)
  To: Tom Tucker; +Cc: nfs

On Tue, 2007-07-10 at 00:35 -0500, Tom Tucker wrote:
> Update the write handler for the portlist file to allow creating new 
> listening endpoints on a transport. The general form of the string is:
> 
> <transport_name><space><port number>
> 
> For example:
> 
> tcp 2049
> 
> This is intended to support the creation of a listening endpoint for
> RDMA transports without adding #ifdef code to the nfssvc.c file.
> The "built-in" transports UDP/TCP were left in the nfssvc initialization
> code to avoid having to change rpc.nfsd, etc...
> 
> Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> ---
> 
>  fs/nfsd/nfsctl.c |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 71c686d..b72514d 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -555,6 +555,22 @@ static ssize_t write_ports(struct file *
>  		kfree(toclose);
>  		return len;
>  	}
> +	/* This implements the ability to add a transport by writing
> +	 * it's transport name to the portlist file
> +	 */
> +	if (isalnum(buf[0])) {
> +		int err;
> +		char transport[16];
> +		int port;
> +		sscanf(buf, "%15s %4d", transport, &port);

Hmm... This looks dodgy to me. You are not initialising transport and
port nor even checking the return value of sscanf()?

> +		err = nfsd_create_serv();
> +		if (!err)
> +			err = svc_create_svcsock(nfsd_serv,
> +						 transport, port,
> +						 SVC_SOCK_ANONYMOUS);
> +		return err < 0 ? err : 0;
> +	}
> +	
>  	return -EINVAL;
>  }
>  
> 
> -------------------------------------------------------------------------
> 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


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received
  2007-07-10 23:08   ` Trond Myklebust
@ 2007-07-11  0:45     ` Tom Tucker
  0 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-11  0:45 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs


See below....

On Tue, 2007-07-10 at 19:08 -0400, Trond Myklebust wrote:
> On Tue, 2007-07-10 at 00:34 -0500, Tom Tucker wrote:
> > Export svc_sock_enqueue() and svc_sock_received() so they
> > can be used by sunrpc server transport implementations
> > (even future modular ones).
> > 
> > Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
> > Signed-off-by: Peter Leckie <pleckie@melbourne.sgi.com>
> > Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> > ---
> > 
> >  include/linux/sunrpc/svcsock.h |    2 ++
> >  net/sunrpc/svcsock.c           |    7 ++++---
> >  2 files changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
> > index ce93b10..9fa4321 100644
> > --- a/include/linux/sunrpc/svcsock.h
> > +++ b/include/linux/sunrpc/svcsock.h
> > @@ -108,6 +108,8 @@ int		svc_addsock(struct svc_serv *serv,
> >  			    int fd,
> >  			    char *name_return,
> >  			    int *proto);
> > +void		svc_sock_enqueue(struct svc_sock *svsk);
> > +void		svc_sock_received(struct svc_sock *svsk);
> >  
> >  /*
> >   * svc_makesock socket characteristics
> > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> > index 1a6a933..f09c4b4 100644
> > --- a/net/sunrpc/svcsock.c
> > +++ b/net/sunrpc/svcsock.c
> > @@ -209,7 +209,7 @@ svc_release_skb(struct svc_rqst *rqstp)
> >   * processes, wake 'em up.
> >   *
> >   */
> > -static void
> > +void
> >  svc_sock_enqueue(struct svc_sock *svsk)
> >  {
> >  	struct svc_serv	*serv = svsk->sk_server;
> > @@ -287,6 +287,7 @@ svc_sock_enqueue(struct svc_sock *svsk)
> >  out_unlock:
> >  	spin_unlock_bh(&pool->sp_lock);
> >  }
> > +EXPORT_SYMBOL(svc_sock_enqueue);
> 
> EXPORT_SYMBOL_GPL(), please. This is definitely not something we want to
> encourage out-of-tree modules to use.

Ok, done. Note that svc_sock_names is currently EXPORT_SYMBOL.

> 
> >  
> >  /*
> >   * Dequeue the first socket.  Must be called with the pool->sp_lock held.
> > @@ -315,14 +316,14 @@ svc_sock_dequeue(struct svc_pool *pool)
> >   * Note: SK_DATA only gets cleared when a read-attempt finds
> >   * no (or insufficient) data.
> >   */
> > -static inline void
> > +void
> >  svc_sock_received(struct svc_sock *svsk)
> >  {
> >  	svsk->sk_pool = NULL;
> >  	clear_bit(SK_BUSY, &svsk->sk_flags);
> >  	svc_sock_enqueue(svsk);
> >  }
> > -
> > +EXPORT_SYMBOL(svc_sock_received);
> 
> ditto...

Done.

> >  
> >  /**
> >   * svc_reserve - change the space reserved for the reply to a request.
> > 
> > -------------------------------------------------------------------------
> > 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
> 


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock
  2007-07-10 23:32   ` Trond Myklebust
@ 2007-07-11  0:48     ` Tom Tucker
  2007-07-11  0:59     ` Tom Tucker
  1 sibling, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-11  0:48 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs

Changed to EXPORT_SYMBOL_GPL.

On Tue, 2007-07-10 at 19:32 -0400, Trond Myklebust wrote:
> On Tue, 2007-07-10 at 00:35 -0500, Tom Tucker wrote:
> > Change the call to the socket specific svc_makesock to a call to the
> > transport independent svc_create_svcsock function. This avoids 
> > conditional #ifdef's for the rdma transport in the nfsd code. 
> > 
> > Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
> > ---
> > 
> >  fs/nfsd/nfssvc.c     |    8 ++++----
> >  net/sunrpc/svcsock.c |    1 +
> >  2 files changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> > index ff55950..1499beb 100644
> > --- a/fs/nfsd/nfssvc.c
> > +++ b/fs/nfsd/nfssvc.c
> > @@ -235,8 +235,8 @@ static int nfsd_init_socks(int port)
> >  
> >  	error = lockd_up(IPPROTO_UDP);
> >  	if (error >= 0) {
> > -		error = svc_makesock(nfsd_serv, IPPROTO_UDP, port,
> > -					SVC_SOCK_DEFAULTS);
> > +		error = svc_create_svcsock(nfsd_serv, "udp", port,
> > +					   SVC_SOCK_DEFAULTS);
> >  		if (error < 0)
> >  			lockd_down();
> >  	}
> > @@ -246,8 +246,8 @@ static int nfsd_init_socks(int port)
> >  #ifdef CONFIG_NFSD_TCP
> >  	error = lockd_up(IPPROTO_TCP);
> >  	if (error >= 0) {
> > -		error = svc_makesock(nfsd_serv, IPPROTO_TCP, port,
> > -					SVC_SOCK_DEFAULTS);
> > +		error = svc_create_svcsock(nfsd_serv, "tcp", port,
> > +					   SVC_SOCK_DEFAULTS);
> >  		if (error < 0)
> >  			lockd_down();
> >  	}
> > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> > index b0e1b61..67a1d59 100644
> > --- a/net/sunrpc/svcsock.c
> > +++ b/net/sunrpc/svcsock.c
> > @@ -2111,6 +2111,7 @@ int svc_create_svcsock(struct svc_serv *
> >   out:
> >  	return ret;
> >  }
> > +EXPORT_SYMBOL(svc_create_svcsock);
> 
> ...again. Really wants to be an EXPORT_SYMBOL_GPL().
> 
> >  /*
> >   * Handle defer and revisit of requests
> > 
> > -------------------------------------------------------------------------
> > 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
> 


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock
  2007-07-10 23:32   ` Trond Myklebust
  2007-07-11  0:48     ` Tom Tucker
@ 2007-07-11  0:59     ` Tom Tucker
  1 sibling, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-11  0:59 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs

[...snip...]

> >  			lockd_down();
> >  	}
> > diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> > index b0e1b61..67a1d59 100644
> > --- a/net/sunrpc/svcsock.c
> > +++ b/net/sunrpc/svcsock.c
> > @@ -2111,6 +2111,7 @@ int svc_create_svcsock(struct svc_serv *
> >   out:
> >  	return ret;
> >  }
> > +EXPORT_SYMBOL(svc_create_svcsock);
> 
> ...again. Really wants to be an EXPORT_SYMBOL_GPL().

Yes, and this needs to be exported in the patch that defined the new
function. Fixed.

> 
> >  /*
> >   * Handle defer and revisit of requests
> > 
> > -------------------------------------------------------------------------
> > 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
> 


-------------------------------------------------------------------------
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] 30+ messages in thread

* Re: [RFC, PATCH 20/20] knfsd: create listener via portlist write
  2007-07-10 23:36   ` [RFC, PATCH " Trond Myklebust
@ 2007-07-11  1:04     ` Tom Tucker
  0 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-07-11  1:04 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs

[...snip...]

> > +	/* This implements the ability to add a transport by writing
> > +	 * it's transport name to the portlist file
> > +	 */
> > +	if (isalnum(buf[0])) {
> > +		int err;
> > +		char transport[16];
> > +		int port;
> > +		sscanf(buf, "%15s %4d", transport, &port);
> 
> Hmm... This looks dodgy to me. You are not initialising transport and
> port nor even checking the return value of sscanf()?
> 

Agreed, lazy code, but I think all I should do here is check that sscanf
got two parameters that met the format spec, i.e. no need to initialize
the port and transport variables.

> > +		err = nfsd_create_serv();
> > +		if (!err)
> > +			err = svc_create_svcsock(nfsd_serv,
> > +						 transport, port,
> > +						 SVC_SOCK_ANONYMOUS);
> > +		return err < 0 ? err : 0;
> > +	}
> > +	
> >  	return -EINVAL;
> >  }
> >  
> > 
> > -------------------------------------------------------------------------
> > 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
> 


-------------------------------------------------------------------------
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] 30+ messages in thread

* [RFC,PATCH 19/20] knfsd: call svc_create_svcsock
  2007-08-20 16:20 [RFC,PATCH 00/20] svc: Server Side Transport Switch Tom Tucker
@ 2007-08-20 16:24 ` Tom Tucker
  0 siblings, 0 replies; 30+ messages in thread
From: Tom Tucker @ 2007-08-20 16:24 UTC (permalink / raw)
  To: nfs


Change the call to the socket specific svc_makesock to a call to the
transport independent svc_create_svcsock function. This avoids 
conditional #ifdef's for the rdma transport in the nfsd code. 

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 fs/nfsd/nfssvc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index ff55950..1499beb 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -235,8 +235,8 @@ static int nfsd_init_socks(int port)
 
 	error = lockd_up(IPPROTO_UDP);
 	if (error >= 0) {
-		error = svc_makesock(nfsd_serv, IPPROTO_UDP, port,
-					SVC_SOCK_DEFAULTS);
+		error = svc_create_svcsock(nfsd_serv, "udp", port,
+					   SVC_SOCK_DEFAULTS);
 		if (error < 0)
 			lockd_down();
 	}
@@ -246,8 +246,8 @@ static int nfsd_init_socks(int port)
 #ifdef CONFIG_NFSD_TCP
 	error = lockd_up(IPPROTO_TCP);
 	if (error >= 0) {
-		error = svc_makesock(nfsd_serv, IPPROTO_TCP, port,
-					SVC_SOCK_DEFAULTS);
+		error = svc_create_svcsock(nfsd_serv, "tcp", port,
+					   SVC_SOCK_DEFAULTS);
 		if (error < 0)
 			lockd_down();
 	}

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

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

end of thread, other threads:[~2007-08-20 16:24 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10  5:27 [RFC,PATCH 00/20] svc: sunrpc server side transport switch Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 01/20] svc: Add svc_sock_ops Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 02/20] svc: sko_detach and sko_free Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 03/20] svc: svc_prep_reply_hdr Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 04/20] svc: sko_has_wspace Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 05/20] svc: svc_max_payload Tom Tucker
2007-07-10  5:34 ` [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received Tom Tucker
2007-07-10 23:08   ` Trond Myklebust
2007-07-11  0:45     ` Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 07/20] svc: centralise close handling Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 08/20] svc: centralise accept handling Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 09/20] svc: Add SK_LISTENER sock flag Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 10/20] svc: Add generic refcount services Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 11/20] svc: cleanup svc_sock initialization Tom Tucker
2007-07-10  5:34 ` [RFC, PATCH 12/20] scv: Create transport neutral debug bit RPCDBG_SVCTRANS Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 13/20] svc: Add svc_[un]register_transport Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 14/20] svc: Register TCP/UDP Transports Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 15/20] svc: transport file implementation Tom Tucker
2007-07-10 23:30   ` Trond Myklebust
2007-07-10  5:34 ` [RFC,PATCH 16/20] svc: sko_create_svc Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 17/20] svc: Add sko_get_name service Tom Tucker
2007-07-10  5:34 ` [RFC,PATCH 18/20] svc: Add sko_defer routine Tom Tucker
2007-07-10  5:35 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker
2007-07-10 23:32   ` Trond Myklebust
2007-07-11  0:48     ` Tom Tucker
2007-07-11  0:59     ` Tom Tucker
2007-07-10  5:35 ` [RFC,PATCH 20/20] knfsd: create listener via portlist write Tom Tucker
2007-07-10 23:36   ` [RFC, PATCH " Trond Myklebust
2007-07-11  1:04     ` Tom Tucker
  -- strict thread matches above, loose matches on Subject: below --
2007-08-20 16:20 [RFC,PATCH 00/20] svc: Server Side Transport Switch Tom Tucker
2007-08-20 16:24 ` [RFC,PATCH 19/20] knfsd: call svc_create_svcsock Tom Tucker

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.