diff options
Diffstat (limited to 'net/sunrpc/svcsock.c')
-rw-r--r-- | net/sunrpc/svcsock.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 0a7125271d4..f86538e1dec 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c | |||
@@ -215,7 +215,7 @@ static void svc_release_skb(struct svc_rqst *rqstp) | |||
215 | static void | 215 | static void |
216 | svc_sock_enqueue(struct svc_sock *svsk) | 216 | svc_sock_enqueue(struct svc_sock *svsk) |
217 | { | 217 | { |
218 | struct svc_serv *serv = svsk->sk_server; | 218 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
219 | struct svc_pool *pool; | 219 | struct svc_pool *pool; |
220 | struct svc_rqst *rqstp; | 220 | struct svc_rqst *rqstp; |
221 | int cpu; | 221 | int cpu; |
@@ -227,7 +227,7 @@ svc_sock_enqueue(struct svc_sock *svsk) | |||
227 | return; | 227 | return; |
228 | 228 | ||
229 | cpu = get_cpu(); | 229 | cpu = get_cpu(); |
230 | pool = svc_pool_for_cpu(svsk->sk_server, cpu); | 230 | pool = svc_pool_for_cpu(svsk->sk_xprt.xpt_server, cpu); |
231 | put_cpu(); | 231 | put_cpu(); |
232 | 232 | ||
233 | spin_lock_bh(&pool->sp_lock); | 233 | spin_lock_bh(&pool->sp_lock); |
@@ -253,8 +253,8 @@ svc_sock_enqueue(struct svc_sock *svsk) | |||
253 | dprintk("svc: socket %p busy, not enqueued\n", svsk->sk_sk); | 253 | dprintk("svc: socket %p busy, not enqueued\n", svsk->sk_sk); |
254 | goto out_unlock; | 254 | goto out_unlock; |
255 | } | 255 | } |
256 | BUG_ON(svsk->sk_pool != NULL); | 256 | BUG_ON(svsk->sk_xprt.xpt_pool != NULL); |
257 | svsk->sk_pool = pool; | 257 | svsk->sk_xprt.xpt_pool = pool; |
258 | 258 | ||
259 | /* Handle pending connection */ | 259 | /* Handle pending connection */ |
260 | if (test_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags)) | 260 | if (test_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags)) |
@@ -268,7 +268,7 @@ svc_sock_enqueue(struct svc_sock *svsk) | |||
268 | if (!svsk->sk_xprt.xpt_ops->xpo_has_wspace(&svsk->sk_xprt)) { | 268 | if (!svsk->sk_xprt.xpt_ops->xpo_has_wspace(&svsk->sk_xprt)) { |
269 | /* Don't enqueue while not enough space for reply */ | 269 | /* Don't enqueue while not enough space for reply */ |
270 | dprintk("svc: no write space, socket %p not enqueued\n", svsk); | 270 | dprintk("svc: no write space, socket %p not enqueued\n", svsk); |
271 | svsk->sk_pool = NULL; | 271 | svsk->sk_xprt.xpt_pool = NULL; |
272 | clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); | 272 | clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); |
273 | goto out_unlock; | 273 | goto out_unlock; |
274 | } | 274 | } |
@@ -289,12 +289,12 @@ svc_sock_enqueue(struct svc_sock *svsk) | |||
289 | svc_xprt_get(&svsk->sk_xprt); | 289 | svc_xprt_get(&svsk->sk_xprt); |
290 | rqstp->rq_reserved = serv->sv_max_mesg; | 290 | rqstp->rq_reserved = serv->sv_max_mesg; |
291 | atomic_add(rqstp->rq_reserved, &svsk->sk_reserved); | 291 | atomic_add(rqstp->rq_reserved, &svsk->sk_reserved); |
292 | BUG_ON(svsk->sk_pool != pool); | 292 | BUG_ON(svsk->sk_xprt.xpt_pool != pool); |
293 | wake_up(&rqstp->rq_wait); | 293 | wake_up(&rqstp->rq_wait); |
294 | } else { | 294 | } else { |
295 | dprintk("svc: socket %p put into queue\n", svsk->sk_sk); | 295 | dprintk("svc: socket %p put into queue\n", svsk->sk_sk); |
296 | list_add_tail(&svsk->sk_ready, &pool->sp_sockets); | 296 | list_add_tail(&svsk->sk_ready, &pool->sp_sockets); |
297 | BUG_ON(svsk->sk_pool != pool); | 297 | BUG_ON(svsk->sk_xprt.xpt_pool != pool); |
298 | } | 298 | } |
299 | 299 | ||
300 | out_unlock: | 300 | out_unlock: |
@@ -331,7 +331,7 @@ svc_sock_dequeue(struct svc_pool *pool) | |||
331 | static inline void | 331 | static inline void |
332 | svc_sock_received(struct svc_sock *svsk) | 332 | svc_sock_received(struct svc_sock *svsk) |
333 | { | 333 | { |
334 | svsk->sk_pool = NULL; | 334 | svsk->sk_xprt.xpt_pool = NULL; |
335 | clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); | 335 | clear_bit(XPT_BUSY, &svsk->sk_xprt.xpt_flags); |
336 | svc_sock_enqueue(svsk); | 336 | svc_sock_enqueue(svsk); |
337 | } | 337 | } |
@@ -735,7 +735,7 @@ static int | |||
735 | svc_udp_recvfrom(struct svc_rqst *rqstp) | 735 | svc_udp_recvfrom(struct svc_rqst *rqstp) |
736 | { | 736 | { |
737 | struct svc_sock *svsk = rqstp->rq_sock; | 737 | struct svc_sock *svsk = rqstp->rq_sock; |
738 | struct svc_serv *serv = svsk->sk_server; | 738 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
739 | struct sk_buff *skb; | 739 | struct sk_buff *skb; |
740 | union { | 740 | union { |
741 | struct cmsghdr hdr; | 741 | struct cmsghdr hdr; |
@@ -873,7 +873,7 @@ static void svc_udp_prep_reply_hdr(struct svc_rqst *rqstp) | |||
873 | static int svc_udp_has_wspace(struct svc_xprt *xprt) | 873 | static int svc_udp_has_wspace(struct svc_xprt *xprt) |
874 | { | 874 | { |
875 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); | 875 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); |
876 | struct svc_serv *serv = svsk->sk_server; | 876 | struct svc_serv *serv = xprt->xpt_server; |
877 | unsigned long required; | 877 | unsigned long required; |
878 | 878 | ||
879 | /* | 879 | /* |
@@ -920,13 +920,12 @@ static struct svc_xprt_class svc_udp_class = { | |||
920 | .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP, | 920 | .xcl_max_payload = RPCSVC_MAXPAYLOAD_UDP, |
921 | }; | 921 | }; |
922 | 922 | ||
923 | static void | 923 | static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv) |
924 | svc_udp_init(struct svc_sock *svsk) | ||
925 | { | 924 | { |
926 | int one = 1; | 925 | int one = 1; |
927 | mm_segment_t oldfs; | 926 | mm_segment_t oldfs; |
928 | 927 | ||
929 | svc_xprt_init(&svc_udp_class, &svsk->sk_xprt); | 928 | svc_xprt_init(&svc_udp_class, &svsk->sk_xprt, serv); |
930 | svsk->sk_sk->sk_data_ready = svc_udp_data_ready; | 929 | svsk->sk_sk->sk_data_ready = svc_udp_data_ready; |
931 | svsk->sk_sk->sk_write_space = svc_write_space; | 930 | svsk->sk_sk->sk_write_space = svc_write_space; |
932 | 931 | ||
@@ -935,8 +934,8 @@ svc_udp_init(struct svc_sock *svsk) | |||
935 | * svc_udp_recvfrom will re-adjust if necessary | 934 | * svc_udp_recvfrom will re-adjust if necessary |
936 | */ | 935 | */ |
937 | svc_sock_setbufsize(svsk->sk_sock, | 936 | svc_sock_setbufsize(svsk->sk_sock, |
938 | 3 * svsk->sk_server->sv_max_mesg, | 937 | 3 * svsk->sk_xprt.xpt_server->sv_max_mesg, |
939 | 3 * svsk->sk_server->sv_max_mesg); | 938 | 3 * svsk->sk_xprt.xpt_server->sv_max_mesg); |
940 | 939 | ||
941 | set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); /* might have come in before data_ready set up */ | 940 | set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); /* might have come in before data_ready set up */ |
942 | set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags); | 941 | set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags); |
@@ -1041,7 +1040,7 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt) | |||
1041 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); | 1040 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); |
1042 | struct sockaddr_storage addr; | 1041 | struct sockaddr_storage addr; |
1043 | struct sockaddr *sin = (struct sockaddr *) &addr; | 1042 | struct sockaddr *sin = (struct sockaddr *) &addr; |
1044 | struct svc_serv *serv = svsk->sk_server; | 1043 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
1045 | struct socket *sock = svsk->sk_sock; | 1044 | struct socket *sock = svsk->sk_sock; |
1046 | struct socket *newsock; | 1045 | struct socket *newsock; |
1047 | struct svc_sock *newsvsk; | 1046 | struct svc_sock *newsvsk; |
@@ -1122,7 +1121,7 @@ static int | |||
1122 | svc_tcp_recvfrom(struct svc_rqst *rqstp) | 1121 | svc_tcp_recvfrom(struct svc_rqst *rqstp) |
1123 | { | 1122 | { |
1124 | struct svc_sock *svsk = rqstp->rq_sock; | 1123 | struct svc_sock *svsk = rqstp->rq_sock; |
1125 | struct svc_serv *serv = svsk->sk_server; | 1124 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
1126 | int len; | 1125 | int len; |
1127 | struct kvec *vec; | 1126 | struct kvec *vec; |
1128 | int pnum, vlen; | 1127 | int pnum, vlen; |
@@ -1265,7 +1264,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) | |||
1265 | svc_sock_received(svsk); | 1264 | svc_sock_received(svsk); |
1266 | } else { | 1265 | } else { |
1267 | printk(KERN_NOTICE "%s: recvfrom returned errno %d\n", | 1266 | printk(KERN_NOTICE "%s: recvfrom returned errno %d\n", |
1268 | svsk->sk_server->sv_name, -len); | 1267 | svsk->sk_xprt.xpt_server->sv_name, -len); |
1269 | goto err_delete; | 1268 | goto err_delete; |
1270 | } | 1269 | } |
1271 | 1270 | ||
@@ -1295,7 +1294,7 @@ svc_tcp_sendto(struct svc_rqst *rqstp) | |||
1295 | sent = svc_sendto(rqstp, &rqstp->rq_res); | 1294 | sent = svc_sendto(rqstp, &rqstp->rq_res); |
1296 | if (sent != xbufp->len) { | 1295 | if (sent != xbufp->len) { |
1297 | printk(KERN_NOTICE "rpc-srv/tcp: %s: %s %d when sending %d bytes - shutting down socket\n", | 1296 | printk(KERN_NOTICE "rpc-srv/tcp: %s: %s %d when sending %d bytes - shutting down socket\n", |
1298 | rqstp->rq_sock->sk_server->sv_name, | 1297 | rqstp->rq_sock->sk_xprt.xpt_server->sv_name, |
1299 | (sent<0)?"got error":"sent only", | 1298 | (sent<0)?"got error":"sent only", |
1300 | sent, xbufp->len); | 1299 | sent, xbufp->len); |
1301 | set_bit(XPT_CLOSE, &rqstp->rq_sock->sk_xprt.xpt_flags); | 1300 | set_bit(XPT_CLOSE, &rqstp->rq_sock->sk_xprt.xpt_flags); |
@@ -1319,7 +1318,7 @@ static void svc_tcp_prep_reply_hdr(struct svc_rqst *rqstp) | |||
1319 | static int svc_tcp_has_wspace(struct svc_xprt *xprt) | 1318 | static int svc_tcp_has_wspace(struct svc_xprt *xprt) |
1320 | { | 1319 | { |
1321 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); | 1320 | struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); |
1322 | struct svc_serv *serv = svsk->sk_server; | 1321 | struct svc_serv *serv = svsk->sk_xprt.xpt_server; |
1323 | int required; | 1322 | int required; |
1324 | int wspace; | 1323 | int wspace; |
1325 | 1324 | ||
@@ -1378,13 +1377,12 @@ void svc_cleanup_xprt_sock(void) | |||
1378 | svc_unreg_xprt_class(&svc_udp_class); | 1377 | svc_unreg_xprt_class(&svc_udp_class); |
1379 | } | 1378 | } |
1380 | 1379 | ||
1381 | static void | 1380 | static void svc_tcp_init(struct svc_sock *svsk, struct svc_serv *serv) |
1382 | svc_tcp_init(struct svc_sock *svsk) | ||
1383 | { | 1381 | { |
1384 | struct sock *sk = svsk->sk_sk; | 1382 | struct sock *sk = svsk->sk_sk; |
1385 | struct tcp_sock *tp = tcp_sk(sk); | 1383 | struct tcp_sock *tp = tcp_sk(sk); |
1386 | 1384 | ||
1387 | svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt); | 1385 | svc_xprt_init(&svc_tcp_class, &svsk->sk_xprt, serv); |
1388 | 1386 | ||
1389 | if (sk->sk_state == TCP_LISTEN) { | 1387 | if (sk->sk_state == TCP_LISTEN) { |
1390 | dprintk("setting up TCP socket for listening\n"); | 1388 | dprintk("setting up TCP socket for listening\n"); |
@@ -1407,8 +1405,8 @@ svc_tcp_init(struct svc_sock *svsk) | |||
1407 | * svc_tcp_recvfrom will re-adjust if necessary | 1405 | * svc_tcp_recvfrom will re-adjust if necessary |
1408 | */ | 1406 | */ |
1409 | svc_sock_setbufsize(svsk->sk_sock, | 1407 | svc_sock_setbufsize(svsk->sk_sock, |
1410 | 3 * svsk->sk_server->sv_max_mesg, | 1408 | 3 * svsk->sk_xprt.xpt_server->sv_max_mesg, |
1411 | 3 * svsk->sk_server->sv_max_mesg); | 1409 | 3 * svsk->sk_xprt.xpt_server->sv_max_mesg); |
1412 | 1410 | ||
1413 | set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags); | 1411 | set_bit(XPT_CHNGBUF, &svsk->sk_xprt.xpt_flags); |
1414 | set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); | 1412 | set_bit(XPT_DATA, &svsk->sk_xprt.xpt_flags); |
@@ -1588,7 +1586,7 @@ svc_recv(struct svc_rqst *rqstp, long timeout) | |||
1588 | * listener holds a reference too | 1586 | * listener holds a reference too |
1589 | */ | 1587 | */ |
1590 | __module_get(newxpt->xpt_class->xcl_owner); | 1588 | __module_get(newxpt->xpt_class->xcl_owner); |
1591 | svc_check_conn_limits(svsk->sk_server); | 1589 | svc_check_conn_limits(svsk->sk_xprt.xpt_server); |
1592 | } | 1590 | } |
1593 | svc_sock_received(svsk); | 1591 | svc_sock_received(svsk); |
1594 | } else { | 1592 | } else { |
@@ -1756,7 +1754,6 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, | |||
1756 | svsk->sk_ostate = inet->sk_state_change; | 1754 | svsk->sk_ostate = inet->sk_state_change; |
1757 | svsk->sk_odata = inet->sk_data_ready; | 1755 | svsk->sk_odata = inet->sk_data_ready; |
1758 | svsk->sk_owspace = inet->sk_write_space; | 1756 | svsk->sk_owspace = inet->sk_write_space; |
1759 | svsk->sk_server = serv; | ||
1760 | svsk->sk_lastrecv = get_seconds(); | 1757 | svsk->sk_lastrecv = get_seconds(); |
1761 | spin_lock_init(&svsk->sk_lock); | 1758 | spin_lock_init(&svsk->sk_lock); |
1762 | INIT_LIST_HEAD(&svsk->sk_deferred); | 1759 | INIT_LIST_HEAD(&svsk->sk_deferred); |
@@ -1765,9 +1762,9 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, | |||
1765 | 1762 | ||
1766 | /* Initialize the socket */ | 1763 | /* Initialize the socket */ |
1767 | if (sock->type == SOCK_DGRAM) | 1764 | if (sock->type == SOCK_DGRAM) |
1768 | svc_udp_init(svsk); | 1765 | svc_udp_init(svsk, serv); |
1769 | else | 1766 | else |
1770 | svc_tcp_init(svsk); | 1767 | svc_tcp_init(svsk, serv); |
1771 | 1768 | ||
1772 | spin_lock_bh(&serv->sv_lock); | 1769 | spin_lock_bh(&serv->sv_lock); |
1773 | if (is_temporary) { | 1770 | if (is_temporary) { |
@@ -1925,7 +1922,7 @@ svc_delete_socket(struct svc_sock *svsk) | |||
1925 | 1922 | ||
1926 | dprintk("svc: svc_delete_socket(%p)\n", svsk); | 1923 | dprintk("svc: svc_delete_socket(%p)\n", svsk); |
1927 | 1924 | ||
1928 | serv = svsk->sk_server; | 1925 | serv = svsk->sk_xprt.xpt_server; |
1929 | sk = svsk->sk_sk; | 1926 | sk = svsk->sk_sk; |
1930 | 1927 | ||
1931 | svsk->sk_xprt.xpt_ops->xpo_detach(&svsk->sk_xprt); | 1928 | svsk->sk_xprt.xpt_ops->xpo_detach(&svsk->sk_xprt); |