aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/svcsock.c
diff options
context:
space:
mode:
authorTom Tucker <tom@opengridcomputing.com>2007-12-30 22:08:01 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-02-01 16:42:12 -0500
commita6046f71f2b598af241e7496a8ead90f2979224b (patch)
treebceb453e9c7aac478a86253528ff2a00b0726fcc /net/sunrpc/svcsock.c
parenta50fea26b9d2aa7b66fdd6d9579de10827ec086a (diff)
svc: Change svc_sock_received to svc_xprt_received and export it
All fields touched by svc_sock_received are now transport independent. Change it to use svc_xprt directly. This function is called from transport dependent code, so export it. Update the comment to clearly state the rules for calling this function. Signed-off-by: Tom Tucker <tom@opengridcomputing.com> Acked-by: Neil Brown <neilb@suse.de> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Greg Banks <gnb@sgi.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'net/sunrpc/svcsock.c')
-rw-r--r--net/sunrpc/svcsock.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 2016d9c63f88..5fb537e4d63b 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -325,19 +325,21 @@ svc_sock_dequeue(struct svc_pool *pool)
325} 325}
326 326
327/* 327/*
328 * Having read something from a socket, check whether it 328 * svc_xprt_received conditionally queues the transport for processing
329 * needs to be re-enqueued. 329 * by another thread. The caller must hold the XPT_BUSY bit and must
330 * Note: XPT_DATA only gets cleared when a read-attempt finds 330 * not thereafter touch transport data.
331 * no (or insufficient) data. 331 *
332 * Note: XPT_DATA only gets cleared when a read-attempt finds no (or
333 * insufficient) data.
332 */ 334 */
333static inline void 335void svc_xprt_received(struct svc_xprt *xprt)
334svc_sock_received(struct svc_sock *svsk)
335{ 336{
336 svsk->sk_xprt.xpt_pool = NULL; 337 BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags));
337 clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); 338 xprt->xpt_pool = NULL;
338 svc_xprt_enqueue(&svsk->sk_xprt); 339 clear_bit(XPT_BUSY, &xprt->xpt_flags);
340 svc_xprt_enqueue(xprt);
339} 341}
340 342EXPORT_SYMBOL_GPL(svc_xprt_received);
341 343
342/** 344/**
343 * svc_reserve - change the space reserved for the reply to a request. 345 * svc_reserve - change the space reserved for the reply to a request.
@@ -766,7 +768,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
766 (serv->sv_nrthreads+3) * serv->sv_max_mesg); 768 (serv->sv_nrthreads+3) * serv->sv_max_mesg);
767 769
768 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) { 770 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
769 svc_sock_received(svsk); 771 svc_xprt_received(&svsk->sk_xprt);
770 return svc_deferred_recv(rqstp); 772 return svc_deferred_recv(rqstp);
771 } 773 }
772 774
@@ -783,7 +785,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
783 dprintk("svc: recvfrom returned error %d\n", -err); 785 dprintk("svc: recvfrom returned error %d\n", -err);
784 set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); 786 set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags);
785 } 787 }
786 svc_sock_received(svsk); 788 svc_xprt_received(&svsk->sk_xprt);
787 return -EAGAIN; 789 return -EAGAIN;
788 } 790 }
789 rqstp->rq_addrlen = sizeof(rqstp->rq_addr); 791 rqstp->rq_addrlen = sizeof(rqstp->rq_addr);
@@ -798,7 +800,7 @@ svc_udp_recvfrom(struct svc_rqst *rqstp)
798 /* 800 /*
799 * Maybe more packets - kick another thread ASAP. 801 * Maybe more packets - kick another thread ASAP.
800 */ 802 */
801 svc_sock_received(svsk); 803 svc_xprt_received(&svsk->sk_xprt);
802 804
803 len = skb->len - sizeof(struct udphdr); 805 len = skb->len - sizeof(struct udphdr);
804 rqstp->rq_arg.len = len; 806 rqstp->rq_arg.len = len;
@@ -1104,7 +1106,7 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)
1104 } 1106 }
1105 memcpy(&newsvsk->sk_local, sin, slen); 1107 memcpy(&newsvsk->sk_local, sin, slen);
1106 1108
1107 svc_sock_received(newsvsk); 1109 svc_xprt_received(&newsvsk->sk_xprt);
1108 1110
1109 if (serv->sv_stats) 1111 if (serv->sv_stats)
1110 serv->sv_stats->nettcpconn++; 1112 serv->sv_stats->nettcpconn++;
@@ -1134,7 +1136,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1134 test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags)); 1136 test_bit(XPT_CLOSE, &svsk->sk_xprt.xpt_flags));
1135 1137
1136 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) { 1138 if ((rqstp->rq_deferred = svc_deferred_dequeue(svsk))) {
1137 svc_sock_received(svsk); 1139 svc_xprt_received(&svsk->sk_xprt);
1138 return svc_deferred_recv(rqstp); 1140 return svc_deferred_recv(rqstp);
1139 } 1141 }
1140 1142
@@ -1174,7 +1176,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1174 if (len < want) { 1176 if (len < want) {
1175 dprintk("svc: short recvfrom while reading record length (%d of %lu)\n", 1177 dprintk("svc: short recvfrom while reading record length (%d of %lu)\n",
1176 len, want); 1178 len, want);
1177 svc_sock_received(svsk); 1179 svc_xprt_received(&svsk->sk_xprt);
1178 return -EAGAIN; /* record header not complete */ 1180 return -EAGAIN; /* record header not complete */
1179 } 1181 }
1180 1182
@@ -1210,7 +1212,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1210 if (len < svsk->sk_reclen) { 1212 if (len < svsk->sk_reclen) {
1211 dprintk("svc: incomplete TCP record (%d of %d)\n", 1213 dprintk("svc: incomplete TCP record (%d of %d)\n",
1212 len, svsk->sk_reclen); 1214 len, svsk->sk_reclen);
1213 svc_sock_received(svsk); 1215 svc_xprt_received(&svsk->sk_xprt);
1214 return -EAGAIN; /* record not complete */ 1216 return -EAGAIN; /* record not complete */
1215 } 1217 }
1216 len = svsk->sk_reclen; 1218 len = svsk->sk_reclen;
@@ -1250,7 +1252,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1250 svsk->sk_reclen = 0; 1252 svsk->sk_reclen = 0;
1251 svsk->sk_tcplen = 0; 1253 svsk->sk_tcplen = 0;
1252 1254
1253 svc_sock_received(svsk); 1255 svc_xprt_received(&svsk->sk_xprt);
1254 if (serv->sv_stats) 1256 if (serv->sv_stats)
1255 serv->sv_stats->nettcpcnt++; 1257 serv->sv_stats->nettcpcnt++;
1256 1258
@@ -1263,7 +1265,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp)
1263 error: 1265 error:
1264 if (len == -EAGAIN) { 1266 if (len == -EAGAIN) {
1265 dprintk("RPC: TCP recvfrom got EAGAIN\n"); 1267 dprintk("RPC: TCP recvfrom got EAGAIN\n");
1266 svc_sock_received(svsk); 1268 svc_xprt_received(&svsk->sk_xprt);
1267 } else { 1269 } else {
1268 printk(KERN_NOTICE "%s: recvfrom returned errno %d\n", 1270 printk(KERN_NOTICE "%s: recvfrom returned errno %d\n",
1269 svsk->sk_xprt.xpt_server->sv_name, -len); 1271 svsk->sk_xprt.xpt_server->sv_name, -len);
@@ -1590,7 +1592,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout)
1590 __module_get(newxpt->xpt_class->xcl_owner); 1592 __module_get(newxpt->xpt_class->xcl_owner);
1591 svc_check_conn_limits(svsk->sk_xprt.xpt_server); 1593 svc_check_conn_limits(svsk->sk_xprt.xpt_server);
1592 } 1594 }
1593 svc_sock_received(svsk); 1595 svc_xprt_received(&svsk->sk_xprt);
1594 } else { 1596 } else {
1595 dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n", 1597 dprintk("svc: server %p, pool %u, socket %p, inuse=%d\n",
1596 rqstp, pool->sp_id, svsk, 1598 rqstp, pool->sp_id, svsk,
@@ -1809,7 +1811,7 @@ int svc_addsock(struct svc_serv *serv,
1809 else { 1811 else {
1810 svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS); 1812 svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS);
1811 if (svsk) { 1813 if (svsk) {
1812 svc_sock_received(svsk); 1814 svc_xprt_received(&svsk->sk_xprt);
1813 err = 0; 1815 err = 0;
1814 } 1816 }
1815 } 1817 }
@@ -1865,7 +1867,7 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,
1865 } 1867 }
1866 1868
1867 if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) { 1869 if ((svsk = svc_setup_socket(serv, sock, &error, flags)) != NULL) {
1868 svc_sock_received(svsk); 1870 svc_xprt_received(&svsk->sk_xprt);
1869 return (struct svc_xprt *)svsk; 1871 return (struct svc_xprt *)svsk;
1870 } 1872 }
1871 1873