Skip to contentSkip to conversation

svc: sunrpc server side transport switch

RFC PATCH In review Tom Tucker 2 participants 29 messages Jul 10, 2007 – Jul 11, 2007

Subsystems (3)
lore
Share & tools
lore

Tom Tucker

author
#0 lore raw

cover svc: sunrpc server side transport switch

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.

Signature · 10 lines
Signed-off-by: Tom Tucker <[email protected]>

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

RFC PATCH 1/20 svc: Add svc_sock_ops

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.

---

 include/linux/sunrpc/svcsock.h |    9 +++++++--
 net/sunrpc/svcsock.c           |   22 ++++++++++++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)
include/linux/sunrpc/svcsock.h +7 -2
index e21dd93..3c926b9 100644
@@ -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 *);
net/sunrpc/svcsock.c +16 -6
index 5baf48d..ce325f2 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#2 lore raw

RFC PATCH 2/20 svc: sko_detach and sko_free

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |   12 +++++++++
 net/sunrpc/svcsock.c           |   54 ++++++++++++++++++++++++++++++++--------
 2 files changed, 55 insertions(+), 11 deletions(-)
include/linux/sunrpc/svcsock.h +12 -0
index 3c926b9..72beb7b 100644
@@ -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 *);
 };
 
 /*
net/sunrpc/svcsock.c +43 -11

92 lines not on this page · raw message

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

author
#3 lore raw

RFC PATCH 3/20 svc: svc_prep_reply_hdr

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svc.c               |    8 +++++---
 net/sunrpc/svcsock.c           |   17 ++++++++++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)
include/linux/sunrpc/svcsock.h +4 -0
index 72beb7b..fa92f3f 100644
@@ -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 *);
 };
 
 /*
net/sunrpc/svc.c +5 -3
index e673ef9..f852587 100644
@@ -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);
net/sunrpc/svcsock.c +16 -1
index da7e5ea..4ff1a62 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#4 lore raw

RFC PATCH 4/20 svc: sko_has_wspace

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |    4 ++
 net/sunrpc/svcsock.c           |   79 +++++++++++++++++++++++++---------------
 2 files changed, 54 insertions(+), 29 deletions(-)
include/linux/sunrpc/svcsock.h +4 -0
index fa92f3f..e4f2936 100644
@@ -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 *);
 };
 
 /*
net/sunrpc/svcsock.c +50 -29

118 lines not on this page · raw message

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

author
#9 lore raw

RFC PATCH 7/20 svc: centralise close handling

In reply to Tom Tucker

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.

---

 net/sunrpc/svcsock.c |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)
net/sunrpc/svcsock.c +13 -15
index f09c4b4..75fae77 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#5 lore raw

RFC PATCH 5/20 svc: svc_max_payload

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    6 ++++++
 net/sunrpc/svc.c               |    5 ++---
 net/sunrpc/svcsock.c           |    6 ++++--
 3 files changed, 12 insertions(+), 5 deletions(-)
include/linux/sunrpc/svcsock.h +6 -0
index e4f2936..ce93b10 100644
@@ -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;
 };
 
 /*
net/sunrpc/svc.c +2 -3
index f852587..eea0439 100644
@@ -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;
net/sunrpc/svcsock.c +4 -2
index a959824..1a6a933 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#10 lore raw

RFC PATCH 8/20 svc: centralise accept handling

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svcsock.c           |   26 ++++++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)
include/linux/sunrpc/svcsock.h +4 -0
index 9fa4321..c4eb40c 100644
@@ -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);
 };
 
 /*
net/sunrpc/svcsock.c +12 -14
index 75fae77..2ef3013 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#6 lore raw

RFC PATCH 6/20 svc: export svc_sock_enqueue, svc_sock_received

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    2 ++
 net/sunrpc/svcsock.c           |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
include/linux/sunrpc/svcsock.h +2 -0
index ce93b10..9fa4321 100644
@@ -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
net/sunrpc/svcsock.c +4 -3
index 1a6a933..f09c4b4 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#11 lore raw

RFC PATCH 9/20 svc: Add SK_LISTENER sock flag

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |    1 +
 net/sunrpc/svcsock.c           |    4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)
include/linux/sunrpc/svcsock.h +1 -0
index c4eb40c..a52c9fd 100644
@@ -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 */
 
net/sunrpc/svcsock.c +3 -1
index 2ef3013..59c6b35 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#12 lore raw

RFC PATCH 10/20 svc: Add generic refcount services

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |   15 +++++++++++++++
 net/sunrpc/svcsock.c           |   29 ++++++++++++++---------------
 2 files changed, 29 insertions(+), 15 deletions(-)
include/linux/sunrpc/svcsock.h +15 -0
index a52c9fd..e455783 100644
@@ -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 */
net/sunrpc/svcsock.c +14 -15
index 59c6b35..0193f54 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#13 lore raw

RFC PATCH 11/20 svc: cleanup svc_sock initialization

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |   10 +++
 net/sunrpc/svcsock.c           |  143 ++++++++++++++++++++++++++--------------
 2 files changed, 102 insertions(+), 51 deletions(-)
include/linux/sunrpc/svcsock.h +10 -0
index e455783..0e7307c 100644
@@ -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
net/sunrpc/svcsock.c +92 -51

179 lines not on this page · raw message

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

author
#15 lore raw

RFC PATCH 13/20 svc: Add svc_[un]register_transport

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    7 ++++++
 net/sunrpc/svcsock.c           |   50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
include/linux/sunrpc/svcsock.h +7 -0
index 0e7307c..d132dd5 100644
@@ -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);
net/sunrpc/svcsock.c +50 -0

68 lines not on this page · raw message

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

author
#14 lore raw

RFC PATCH 12/20 scv: Create transport neutral debug bit RPCDBG_SVCTRANS

In reply to Tom Tucker

Make the RPCDBG_SVCSOCK debug bit generic for service side transports.

---

 include/linux/sunrpc/debug.h |    2 +-
 net/sunrpc/svcsock.c         |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/sunrpc/debug.h +1 -1
index 3912cf1..d5edad6 100644
@@ -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
net/sunrpc/svcsock.c +1 -1
index 57fefea..b88e3d2 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#16 lore raw

RFC PATCH 14/20 svc: Register TCP/UDP Transports

In reply to Tom Tucker

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.

---

 net/sunrpc/sunrpc_syms.c |    2 ++
 net/sunrpc/svcsock.c     |   10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
net/sunrpc/sunrpc_syms.c +2 -0
index 73075de..c68577b 100644
@@ -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;
 }
net/sunrpc/svcsock.c +8 -2
index ec0ad0e..2583623 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#20 lore raw

RFC PATCH 17/20 svc: Add sko_get_name service

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    1 +
 net/sunrpc/svcsock.c           |   17 ++++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)
include/linux/sunrpc/svcsock.h +1 -0
index 383ac4f..5c272db 100644
@@ -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);
 	/*
net/sunrpc/svcsock.c +12 -5
index b14dc46..6bd6169 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#19 lore raw

RFC PATCH 16/20 svc: sko_create_svc

In reply to Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    5 +++
 net/sunrpc/svcsock.c           |   64 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 64 insertions(+), 5 deletions(-)
include/linux/sunrpc/svcsock.h +5 -0
index d132dd5..383ac4f 100644
@@ -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 *);
net/sunrpc/svcsock.c +59 -5

119 lines not on this page · raw message

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

author
#17 lore raw

RFC PATCH 15/20 svc: transport file implementation

In reply to Tom Tucker

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

---

 include/linux/sunrpc/debug.h |    1 +
 net/sunrpc/svcsock.c         |   28 ++++++++++++++++++++++++++++
 net/sunrpc/sysctl.c          |   40 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletions(-)
include/linux/sunrpc/debug.h +1 -0
index d5edad6..4c847d4 100644
@@ -88,6 +88,7 @@ enum {
 	CTL_SLOTTABLE_TCP,
 	CTL_MIN_RESVPORT,
 	CTL_MAX_RESVPORT,
+	CTL_TRANSPORTS,
 };
 
 #endif /* _LINUX_SUNRPC_DEBUG_H_ */
net/sunrpc/svcsock.c +28 -0
index 2583623..33aff99 100644
@@ -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
net/sunrpc/sysctl.c +39 -1
index 738db32..683cf90 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#21 lore raw

RFC PATCH 18/20 svc: Add sko_defer routine

In reply to Tom Tucker

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.

---

 include/linux/sunrpc/svcsock.h |    4 ++++
 net/sunrpc/svcsock.c           |   11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
include/linux/sunrpc/svcsock.h +4 -0
index 5c272db..b815f36 100644
@@ -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
net/sunrpc/svcsock.c +7 -4
index 6bd6169..b0e1b61 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#22 lore raw

RFC PATCH 19/20 knfsd: call svc_create_svcsock

In reply to Tom Tucker

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.

---

 fs/nfsd/nfssvc.c     |    8 ++++----
 net/sunrpc/svcsock.c |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
fs/nfsd/nfssvc.c +4 -4
index ff55950..1499beb 100644
@@ -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();
 	}
net/sunrpc/svcsock.c +1 -0
index b0e1b61..67a1d59 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#26 lore raw

RFC PATCH 20/20 knfsd: create listener via portlist write

In reply to Tom Tucker

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...

---

 fs/nfsd/nfsctl.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
fs/nfsd/nfsctl.c +16 -0
index 71c686d..b72514d 100644
@@ -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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#7 lore raw

Re: [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received

In reply to Tom Tucker
Quoted 40 lines · Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    2 ++
 net/sunrpc/svcsock.c           |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
include/linux/sunrpc/svcsock.h +2 -0
index ce93b10..9fa4321 100644
@@ -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
net/sunrpc/svcsock.c +1 -1
index 1a6a933..f09c4b4 100644
@@ -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;

net/sunrpc/svcsock.c svc_sock_enqueue(struct svc_sock *svsk) · line 290

Quoted 4 lines
net/sunrpc/svcsock.c +1 -0
@@ -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.

Quoted 7 lines
net/sunrpc/svcsock.c +0 -0
 /*
  * 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.
  */

net/sunrpc/svcsock.c svc_sock_dequeue(struct svc_pool *pool) · line 326

Quoted 10 lines
net/sunrpc/svcsock.c +2 -2
-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...

Quoted 5 lines
net/sunrpc/svcsock.c +0 -1
 /**
  * svc_reserve - change the space reserved for the reply to a request.
 
-------------------------------------------------------------------------
Quoted 7 lines

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

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

#18 lore raw

Re: [RFC,PATCH 15/20] svc: transport file implementation

In reply to Tom Tucker
Quoted 48 lines · Tom Tucker

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

---

 include/linux/sunrpc/debug.h |    1 +
 net/sunrpc/svcsock.c         |   28 ++++++++++++++++++++++++++++
 net/sunrpc/sysctl.c          |   40 +++++++++++++++++++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 1 deletions(-)
include/linux/sunrpc/debug.h +1 -0
index d5edad6..4c847d4 100644
@@ -88,6 +88,7 @@ enum {
 	CTL_SLOTTABLE_TCP,
 	CTL_MIN_RESVPORT,
 	CTL_MAX_RESVPORT,
+	CTL_TRANSPORTS,
 };
 
 #endif /* _LINUX_SUNRPC_DEBUG_H_ */
net/sunrpc/svcsock.c +17 -0
index 2583623..33aff99 100644
@@ -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);

net/sunrpc/svcsock.c int svc_unregister_transport(struct svc_ · line 168

Quoted 10 lines
net/sunrpc/svcsock.c +10 -0
+		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.

Quoted 78 lines
net/sunrpc/svcsock.c +1 -0
+
 /* apparently the "standard" is that clients close
  * idle connections after 5 minutes, servers after
  * 6 minutes
net/sunrpc/sysctl.c +39 -2
index 738db32..683cf90 100644
@@ -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 }
 };
 
 
-------------------------------------------------------------------------
Quoted 7 lines

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

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

#23 lore raw

Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock

In reply to Tom Tucker
Quoted 42 lines · Tom Tucker

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.

---

 fs/nfsd/nfssvc.c     |    8 ++++----
 net/sunrpc/svcsock.c |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
fs/nfsd/nfssvc.c +4 -4
index ff55950..1499beb 100644
@@ -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();
 	}
net/sunrpc/svcsock.c +0 -0
index b0e1b61..67a1d59 100644

net/sunrpc/svcsock.c int svc_create_svcsock(struct svc_serv * · line 2114

Quoted 4 lines
net/sunrpc/svcsock.c +1 -0
@@ -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().

Quoted 11 lines
net/sunrpc/svcsock.c +0 -1
 /*
  * 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 - [email protected]
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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#27 lore raw

Re: [RFC, PATCH 20/20] knfsd: create listener via portlist write

In reply to Tom Tucker
Quoted 26 lines · Tom Tucker

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...

---

 fs/nfsd/nfsctl.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
fs/nfsd/nfsctl.c +0 -0
index 71c686d..b72514d 100644
@@ -555,6 +555,22 @@ static ssize_t write_ports(struct file *
 		kfree(toclose);

fs/nfsd/nfsctl.c static ssize_t write_ports(struct file * · line 565

Quoted 10 lines
fs/nfsd/nfsctl.c +8 -0
 		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()?

Quoted 13 lines
fs/nfsd/nfsctl.c +8 -1
+		err = nfsd_create_serv();
+		if (!err)
+			err = svc_create_svcsock(nfsd_serv,
+						 transport, port,
+						 SVC_SOCK_ANONYMOUS);
+		return err < 0 ? err : 0;
+	}
+	
 	return -EINVAL;
 }
 
 
-------------------------------------------------------------------------
Quoted 7 lines

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

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

author
#8 lore raw

Re: [RFC, PATCH 06/20] svc: export svc_sock_enqueue, svc_sock_received

In reply to Trond Myklebust

See below....

Quoted 40 lines · Trond Myklebust
Quoted 39 lines · Tom Tucker

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

---

 include/linux/sunrpc/svcsock.h |    2 ++
 net/sunrpc/svcsock.c           |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
include/linux/sunrpc/svcsock.h +2 -0
index ce93b10..9fa4321 100644
@@ -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
net/sunrpc/svcsock.c +1 -1
index 1a6a933..f09c4b4 100644
@@ -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;
Quoted 8 lines

net/sunrpc/svcsock.c svc_sock_enqueue(struct svc_sock *svsk) · line 290

Quoted 5 lines
net/sunrpc/svcsock.c +1 -0
@@ -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.

Quoted 12 lines
Quoted 12 lines
net/sunrpc/svcsock.c +1 -1
 /*
  * 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)
 {
Quoted 8 lines

net/sunrpc/svcsock.c svc_sock_dequeue(struct svc_pool *pool) · line 326

Quoted 6 lines
net/sunrpc/svcsock.c +1 -1
 	svsk->sk_pool = NULL;
 	clear_bit(SK_BUSY, &svsk->sk_flags);
 	svc_sock_enqueue(svsk);
 }
-
+EXPORT_SYMBOL(svc_sock_received);

ditto...

Done.

Quoted 4 lines
Quoted 4 lines
net/sunrpc/svcsock.c +0 -0
 /**
  * svc_reserve - change the space reserved for the reply to a request.
 
Quoted 9 lines
Quoted 8 lines

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

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

author
#24 lore raw

Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock

In reply to Trond Myklebust

Changed to EXPORT_SYMBOL_GPL.

Quoted 41 lines · Trond Myklebust
Quoted 40 lines · Tom Tucker

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.

---

 fs/nfsd/nfssvc.c     |    8 ++++----
 net/sunrpc/svcsock.c |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
fs/nfsd/nfssvc.c +4 -4
index ff55950..1499beb 100644
@@ -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();
 	}
net/sunrpc/svcsock.c +0 -1
index b0e1b61..67a1d59 100644
--- a/net/sunrpc/svcsock.c
Quoted 21 lines

net/sunrpc/svcsock.c int svc_create_svcsock(struct svc_serv * · line 2114

Quoted 6 lines

+++ b/net/sunrpc/svcsock.c

net/sunrpc/svcsock.c +1 -0
@@ -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().

Quoted 11 lines
net/sunrpc/svcsock.c +0 -1
 /*
  * 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 - [email protected]
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 - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#25 lore raw

Re: [RFC,PATCH 19/20] knfsd: call svc_create_svcsock

In reply to Trond Myklebust

[...snip...]

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
 			lockd_down();
 	}
net/sunrpc/svcsock.c +0 -1
index b0e1b61..67a1d59 100644
--- a/net/sunrpc/svcsock.c
Quoted 8 lines

net/sunrpc/svcsock.c int svc_create_svcsock(struct svc_serv * · line 2114

Quoted 6 lines

+++ b/net/sunrpc/svcsock.c

net/sunrpc/svcsock.c +1 -0
@@ -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.

Quoted 4 lines
Quoted 4 lines
net/sunrpc/svcsock.c +0 -0
 /*
  * Handle defer and revisit of requests
 
Quoted 9 lines
Quoted 8 lines

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

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

author
#28 lore raw

Re: [RFC, PATCH 20/20] knfsd: create listener via portlist write

In reply to Trond Myklebust

[...snip...]

Quoted 12 lines

fs/nfsd/nfsctl.c static ssize_t write_ports(struct file * · line 565

Quoted 8 lines
fs/nfsd/nfsctl.c +8 -0
+	/* 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.

Quoted 12 lines
Quoted 12 lines
fs/nfsd/nfsctl.c +8 -0
+		err = nfsd_create_serv();
+		if (!err)
+			err = svc_create_svcsock(nfsd_serv,
+						 transport, port,
+						 SVC_SOCK_ANONYMOUS);
+		return err < 0 ? err : 0;
+	}
+	
 	return -EINVAL;
 }
Quoted 9 lines
Quoted 8 lines

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

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