Lines Matching refs:svsk

115 svc_sock_enqueue(struct svc_sock *svsk)  in svc_sock_enqueue()  argument
117 struct svc_serv *serv = svsk->sk_server; in svc_sock_enqueue()
120 if (!(svsk->sk_flags & in svc_sock_enqueue()
123 if (test_bit(SK_DEAD, &svsk->sk_flags)) in svc_sock_enqueue()
133 if (test_bit(SK_BUSY, &svsk->sk_flags)) { in svc_sock_enqueue()
135 dprintk("svc: socket %p busy, not enqueued\n", svsk->sk_sk); in svc_sock_enqueue()
139 if (((svsk->sk_reserved + serv->sv_bufsz)*2 in svc_sock_enqueue()
140 > sock_wspace(svsk->sk_sk)) in svc_sock_enqueue()
141 && !test_bit(SK_CLOSE, &svsk->sk_flags) in svc_sock_enqueue()
142 && !test_bit(SK_CONN, &svsk->sk_flags)) { in svc_sock_enqueue()
145 svsk->sk_sk, svsk->sk_reserved+serv->sv_bufsz, in svc_sock_enqueue()
146 sock_wspace(svsk->sk_sk)); in svc_sock_enqueue()
154 set_bit(SK_BUSY, &svsk->sk_flags); in svc_sock_enqueue()
161 svsk->sk_sk, rqstp); in svc_sock_enqueue()
167 rqstp->rq_sock = svsk; in svc_sock_enqueue()
168 svsk->sk_inuse++; in svc_sock_enqueue()
170 svsk->sk_reserved += rqstp->rq_reserved; in svc_sock_enqueue()
173 dprintk("svc: socket %p put into queue\n", svsk->sk_sk); in svc_sock_enqueue()
174 list_add_tail(&svsk->sk_ready, &serv->sv_sockets); in svc_sock_enqueue()
175 set_bit(SK_QUED, &svsk->sk_flags); in svc_sock_enqueue()
188 struct svc_sock *svsk; in svc_sock_dequeue() local
193 svsk = list_entry(serv->sv_sockets.next, in svc_sock_dequeue()
195 list_del(&svsk->sk_ready); in svc_sock_dequeue()
198 svsk->sk_sk, svsk->sk_inuse); in svc_sock_dequeue()
199 clear_bit(SK_QUED, &svsk->sk_flags); in svc_sock_dequeue()
201 return svsk; in svc_sock_dequeue()
211 svc_sock_received(struct svc_sock *svsk) in svc_sock_received() argument
213 clear_bit(SK_BUSY, &svsk->sk_flags); in svc_sock_received()
214 svc_sock_enqueue(svsk); in svc_sock_received()
233 struct svc_sock *svsk = rqstp->rq_sock; in svc_reserve() local
234 spin_lock_bh(&svsk->sk_server->sv_lock); in svc_reserve()
235 svsk->sk_reserved -= (rqstp->rq_reserved - space); in svc_reserve()
237 spin_unlock_bh(&svsk->sk_server->sv_lock); in svc_reserve()
239 svc_sock_enqueue(svsk); in svc_reserve()
247 svc_sock_put(struct svc_sock *svsk) in svc_sock_put() argument
249 struct svc_serv *serv = svsk->sk_server; in svc_sock_put()
252 if (!--(svsk->sk_inuse) && test_bit(SK_DEAD, &svsk->sk_flags)) { in svc_sock_put()
255 sock_release(svsk->sk_sock); in svc_sock_put()
256 kfree(svsk); in svc_sock_put()
265 struct svc_sock *svsk = rqstp->rq_sock; in svc_sock_release() local
284 svc_sock_put(svsk); in svc_sock_release()
317 struct svc_sock *svsk = rqstp->rq_sock; in svc_sendto() local
318 struct socket *sock = svsk->sk_sock; in svc_sendto()
367 svc_recv_available(struct svc_sock *svsk) in svc_recv_available() argument
370 struct socket *sock = svsk->sk_sock; in svc_recv_available()
452 struct svc_sock *svsk = (struct svc_sock *)(sk->user_data); in svc_udp_data_ready() local
454 if (!svsk) in svc_udp_data_ready()
457 svsk, sk, count, test_bit(SK_BUSY, &svsk->sk_flags)); in svc_udp_data_ready()
458 set_bit(SK_DATA, &svsk->sk_flags); in svc_udp_data_ready()
459 svc_sock_enqueue(svsk); in svc_udp_data_ready()
471 struct svc_sock *svsk = (struct svc_sock *)(sk->user_data); in svc_write_space() local
473 if (svsk) { in svc_write_space()
475 svsk, sk, test_bit(SK_BUSY, &svsk->sk_flags)); in svc_write_space()
476 svc_sock_enqueue(svsk); in svc_write_space()
489 struct svc_sock *svsk = rqstp->rq_sock; in svc_udp_recvfrom() local
490 struct svc_serv *serv = svsk->sk_server; in svc_udp_recvfrom()
495 if (test_and_clear_bit(SK_CHNGBUF, &svsk->sk_flags)) in svc_udp_recvfrom()
501 svc_sock_setbufsize(svsk->sk_sock, in svc_udp_recvfrom()
505 clear_bit(SK_DATA, &svsk->sk_flags); in svc_udp_recvfrom()
506 while ((skb = skb_recv_datagram(svsk->sk_sk, 0, 1, &err)) == NULL) { in svc_udp_recvfrom()
507 svc_sock_received(svsk); in svc_udp_recvfrom()
513 set_bit(SK_DATA, &svsk->sk_flags); /* there may be more data... */ in svc_udp_recvfrom()
519 svc_sock_received(svsk); in svc_udp_recvfrom()
526 skb_free_datagram(svsk->sk_sk, skb); in svc_udp_recvfrom()
527 svc_sock_received(svsk); in svc_udp_recvfrom()
553 svsk->sk_sk->stamp = skb->stamp; in svc_udp_recvfrom()
554 svc_sock_received(svsk); in svc_udp_recvfrom()
582 svc_udp_init(struct svc_sock *svsk) in svc_udp_init() argument
584 svsk->sk_sk->data_ready = svc_udp_data_ready; in svc_udp_init()
585 svsk->sk_sk->write_space = svc_write_space; in svc_udp_init()
586 svsk->sk_recvfrom = svc_udp_recvfrom; in svc_udp_init()
587 svsk->sk_sendto = svc_udp_sendto; in svc_udp_init()
593 svc_sock_setbufsize(svsk->sk_sock, in svc_udp_init()
594 3 * svsk->sk_server->sv_bufsz, in svc_udp_init()
595 3 * svsk->sk_server->sv_bufsz); in svc_udp_init()
597 set_bit(SK_CHNGBUF, &svsk->sk_flags); in svc_udp_init()
609 struct svc_sock *svsk; in svc_tcp_listen_data_ready() local
627 if (!(svsk = (struct svc_sock *) sk->user_data)) { in svc_tcp_listen_data_ready()
631 set_bit(SK_CONN, &svsk->sk_flags); in svc_tcp_listen_data_ready()
632 svc_sock_enqueue(svsk); in svc_tcp_listen_data_ready()
644 struct svc_sock *svsk; in svc_tcp_state_change() local
649 if (!(svsk = (struct svc_sock *) sk->user_data)) { in svc_tcp_state_change()
653 set_bit(SK_CLOSE, &svsk->sk_flags); in svc_tcp_state_change()
654 svc_sock_enqueue(svsk); in svc_tcp_state_change()
663 struct svc_sock * svsk; in svc_tcp_data_ready() local
667 if (!(svsk = (struct svc_sock *)(sk->user_data))) in svc_tcp_data_ready()
669 set_bit(SK_DATA, &svsk->sk_flags); in svc_tcp_data_ready()
670 svc_sock_enqueue(svsk); in svc_tcp_data_ready()
680 svc_tcp_accept(struct svc_sock *svsk) in svc_tcp_accept() argument
683 struct svc_serv *serv = svsk->sk_server; in svc_tcp_accept()
684 struct socket *sock = svsk->sk_sock; in svc_tcp_accept()
690 dprintk("svc: tcp_accept %p sock %p\n", svsk, sock); in svc_tcp_accept()
703 clear_bit(SK_CONN, &svsk->sk_flags); in svc_tcp_accept()
710 set_bit(SK_CONN, &svsk->sk_flags); in svc_tcp_accept()
711 svc_sock_enqueue(svsk); in svc_tcp_accept()
756 struct svc_sock *svsk = NULL; in svc_tcp_accept() local
760 svsk = list_entry(serv->sv_tempsocks.prev, in svc_tcp_accept()
764 svsk = list_entry(serv->sv_tempsocks.next, in svc_tcp_accept()
767 set_bit(SK_CLOSE, &svsk->sk_flags); in svc_tcp_accept()
768 svsk->sk_inuse ++; in svc_tcp_accept()
772 if (svsk) { in svc_tcp_accept()
773 svc_sock_enqueue(svsk); in svc_tcp_accept()
774 svc_sock_put(svsk); in svc_tcp_accept()
795 struct svc_sock *svsk = rqstp->rq_sock; in svc_tcp_recvfrom() local
796 struct svc_serv *serv = svsk->sk_server; in svc_tcp_recvfrom()
801 svsk, test_bit(SK_DATA, &svsk->sk_flags), in svc_tcp_recvfrom()
802 test_bit(SK_CONN, &svsk->sk_flags), in svc_tcp_recvfrom()
803 test_bit(SK_CLOSE, &svsk->sk_flags)); in svc_tcp_recvfrom()
805 if (test_bit(SK_CLOSE, &svsk->sk_flags)) { in svc_tcp_recvfrom()
806 svc_delete_socket(svsk); in svc_tcp_recvfrom()
810 if (svsk->sk_sk->state == TCP_LISTEN) { in svc_tcp_recvfrom()
811 svc_tcp_accept(svsk); in svc_tcp_recvfrom()
812 svc_sock_received(svsk); in svc_tcp_recvfrom()
816 if (test_and_clear_bit(SK_CHNGBUF, &svsk->sk_flags)) in svc_tcp_recvfrom()
824 svc_sock_setbufsize(svsk->sk_sock, in svc_tcp_recvfrom()
829 clear_bit(SK_DATA, &svsk->sk_flags); in svc_tcp_recvfrom()
835 if (svsk->sk_tcplen < 4) { in svc_tcp_recvfrom()
836 unsigned long want = 4 - svsk->sk_tcplen; in svc_tcp_recvfrom()
839 iov.iov_base = ((char *) &svsk->sk_reclen) + svsk->sk_tcplen; in svc_tcp_recvfrom()
843 svsk->sk_tcplen += len; in svc_tcp_recvfrom()
847 svc_sock_received(svsk); in svc_tcp_recvfrom()
851 svsk->sk_reclen = ntohl(svsk->sk_reclen); in svc_tcp_recvfrom()
852 if (!(svsk->sk_reclen & 0x80000000)) { in svc_tcp_recvfrom()
859 (unsigned long) svsk->sk_reclen); in svc_tcp_recvfrom()
862 svsk->sk_reclen &= 0x7fffffff; in svc_tcp_recvfrom()
863 dprintk("svc: TCP record, %d bytes\n", svsk->sk_reclen); in svc_tcp_recvfrom()
864 if (svsk->sk_reclen > (bufp->buflen<<2)) { in svc_tcp_recvfrom()
866 (unsigned long) svsk->sk_reclen); in svc_tcp_recvfrom()
872 len = svc_recv_available(svsk); in svc_tcp_recvfrom()
876 if (len < svsk->sk_reclen) { in svc_tcp_recvfrom()
878 len, svsk->sk_reclen); in svc_tcp_recvfrom()
879 svc_sock_received(svsk); in svc_tcp_recvfrom()
882 set_bit(SK_DATA, &svsk->sk_flags); in svc_tcp_recvfrom()
889 len = svc_recvfrom(rqstp, bufp->iov, bufp->nriov, svsk->sk_reclen); in svc_tcp_recvfrom()
906 svsk->sk_reclen = 0; in svc_tcp_recvfrom()
907 svsk->sk_tcplen = 0; in svc_tcp_recvfrom()
909 svc_sock_received(svsk); in svc_tcp_recvfrom()
916 svc_delete_socket(svsk); in svc_tcp_recvfrom()
922 svc_sock_received(svsk); in svc_tcp_recvfrom()
925 svsk->sk_server->sv_name, -len); in svc_tcp_recvfrom()
926 svc_sock_received(svsk); in svc_tcp_recvfrom()
964 svc_tcp_init(struct svc_sock *svsk) in svc_tcp_init() argument
966 struct sock *sk = svsk->sk_sk; in svc_tcp_init()
969 svsk->sk_recvfrom = svc_tcp_recvfrom; in svc_tcp_init()
970 svsk->sk_sendto = svc_tcp_sendto; in svc_tcp_init()
981 svsk->sk_reclen = 0; in svc_tcp_init()
982 svsk->sk_tcplen = 0; in svc_tcp_init()
990 svc_sock_setbufsize(svsk->sk_sock, in svc_tcp_init()
991 3 * svsk->sk_server->sv_bufsz, in svc_tcp_init()
992 3 * svsk->sk_server->sv_bufsz); in svc_tcp_init()
994 set_bit(SK_CHNGBUF, &svsk->sk_flags); in svc_tcp_init()
996 set_bit(SK_CLOSE, &svsk->sk_flags); in svc_tcp_init()
1016 struct svc_sock *svsk = in svc_sock_update_bufs() local
1018 set_bit(SK_CHNGBUF, &svsk->sk_flags); in svc_sock_update_bufs()
1021 struct svc_sock *svsk = in svc_sock_update_bufs() local
1023 set_bit(SK_CHNGBUF, &svsk->sk_flags); in svc_sock_update_bufs()
1034 struct svc_sock *svsk =NULL; in svc_recv() local
1059 svsk = list_entry(serv->sv_tempsocks.next, in svc_recv()
1066 if (CURRENT_TIME - svsk->sk_lastrecv < 6*60 in svc_recv()
1067 || test_bit(SK_BUSY, &svsk->sk_flags)) in svc_recv()
1068 svsk = NULL; in svc_recv()
1070 if (svsk) { in svc_recv()
1071 set_bit(SK_BUSY, &svsk->sk_flags); in svc_recv()
1072 set_bit(SK_CLOSE, &svsk->sk_flags); in svc_recv()
1073 rqstp->rq_sock = svsk; in svc_recv()
1074 svsk->sk_inuse++; in svc_recv()
1075 } else if ((svsk = svc_sock_dequeue(serv)) != NULL) { in svc_recv()
1076 rqstp->rq_sock = svsk; in svc_recv()
1077 svsk->sk_inuse++; in svc_recv()
1079 svsk->sk_reserved += rqstp->rq_reserved; in svc_recv()
1097 if (!(svsk = rqstp->rq_sock)) { in svc_recv()
1107 rqstp, svsk, svsk->sk_inuse); in svc_recv()
1108 len = svsk->sk_recvfrom(rqstp); in svc_recv()
1116 svsk->sk_lastrecv = CURRENT_TIME; in svc_recv()
1117 if (test_bit(SK_TEMP, &svsk->sk_flags)) { in svc_recv()
1120 list_del(&svsk->sk_list); in svc_recv()
1121 list_add_tail(&svsk->sk_list, &serv->sv_tempsocks); in svc_recv()
1156 struct svc_sock *svsk; in svc_send() local
1159 if ((svsk = rqstp->rq_sock) == NULL) { in svc_send()
1168 len = svsk->sk_sendto(rqstp); in svc_send()
1184 struct svc_sock *svsk; in svc_setup_socket() local
1188 if (!(svsk = kmalloc(sizeof(*svsk), GFP_KERNEL))) { in svc_setup_socket()
1192 memset(svsk, 0, sizeof(*svsk)); in svc_setup_socket()
1195 inet->user_data = svsk; in svc_setup_socket()
1196 svsk->sk_sock = sock; in svc_setup_socket()
1197 svsk->sk_sk = inet; in svc_setup_socket()
1198 svsk->sk_ostate = inet->state_change; in svc_setup_socket()
1199 svsk->sk_odata = inet->data_ready; in svc_setup_socket()
1200 svsk->sk_owspace = inet->write_space; in svc_setup_socket()
1201 svsk->sk_server = serv; in svc_setup_socket()
1202 svsk->sk_lastrecv = CURRENT_TIME; in svc_setup_socket()
1206 *errp = svc_udp_init(svsk); in svc_setup_socket()
1208 *errp = svc_tcp_init(svsk); in svc_setup_socket()
1209 if (svsk->sk_sk == NULL) in svc_setup_socket()
1218 kfree(svsk); in svc_setup_socket()
1225 set_bit(SK_TEMP, &svsk->sk_flags); in svc_setup_socket()
1226 list_add(&svsk->sk_list, &serv->sv_tempsocks); in svc_setup_socket()
1229 clear_bit(SK_TEMP, &svsk->sk_flags); in svc_setup_socket()
1230 list_add(&svsk->sk_list, &serv->sv_permsocks); in svc_setup_socket()
1235 svsk, svsk->sk_sk); in svc_setup_socket()
1236 return svsk; in svc_setup_socket()
1245 struct svc_sock *svsk; in svc_create_socket() local
1279 if ((svsk = svc_setup_socket(serv, sock, &error, 1)) != NULL) in svc_create_socket()
1292 svc_delete_socket(struct svc_sock *svsk) in svc_delete_socket() argument
1297 dprintk("svc: svc_delete_socket(%p)\n", svsk); in svc_delete_socket()
1299 if (test_and_set_bit(SK_DEAD, &svsk->sk_flags)) in svc_delete_socket()
1302 serv = svsk->sk_server; in svc_delete_socket()
1303 sk = svsk->sk_sk; in svc_delete_socket()
1305 sk->state_change = svsk->sk_ostate; in svc_delete_socket()
1306 sk->data_ready = svsk->sk_odata; in svc_delete_socket()
1307 sk->write_space = svsk->sk_owspace; in svc_delete_socket()
1311 list_del(&svsk->sk_list); in svc_delete_socket()
1312 if (test_bit(SK_TEMP, &svsk->sk_flags)) in svc_delete_socket()
1314 if (test_bit(SK_QUED, &svsk->sk_flags)) in svc_delete_socket()
1315 list_del(&svsk->sk_ready); in svc_delete_socket()
1318 if (!svsk->sk_inuse) { in svc_delete_socket()
1320 sock_release(svsk->sk_sock); in svc_delete_socket()
1321 kfree(svsk); in svc_delete_socket()