diff options
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r-- | net/sunrpc/xprt.c | 147 |
1 files changed, 72 insertions, 75 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 4342acf4d1cd..589195e630ef 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -227,9 +227,6 @@ xprt_adjust_cwnd(struct rpc_xprt *xprt, int result) | |||
227 | xprt->cwnd = cwnd; | 227 | xprt->cwnd = cwnd; |
228 | } | 228 | } |
229 | 229 | ||
230 | /* | ||
231 | * Reset the major timeout value | ||
232 | */ | ||
233 | static void xprt_reset_majortimeo(struct rpc_rqst *req) | 230 | static void xprt_reset_majortimeo(struct rpc_rqst *req) |
234 | { | 231 | { |
235 | struct rpc_timeout *to = &req->rq_xprt->timeout; | 232 | struct rpc_timeout *to = &req->rq_xprt->timeout; |
@@ -244,8 +241,10 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req) | |||
244 | req->rq_majortimeo += jiffies; | 241 | req->rq_majortimeo += jiffies; |
245 | } | 242 | } |
246 | 243 | ||
247 | /* | 244 | /** |
248 | * Adjust timeout values etc for next retransmit | 245 | * xprt_adjust_timeout - adjust timeout values for next retransmit |
246 | * @req: RPC request containing parameters to use for the adjustment | ||
247 | * | ||
249 | */ | 248 | */ |
250 | int xprt_adjust_timeout(struct rpc_rqst *req) | 249 | int xprt_adjust_timeout(struct rpc_rqst *req) |
251 | { | 250 | { |
@@ -291,8 +290,10 @@ xprt_socket_autoclose(void *args) | |||
291 | xprt_release_write(xprt, NULL); | 290 | xprt_release_write(xprt, NULL); |
292 | } | 291 | } |
293 | 292 | ||
294 | /* | 293 | /** |
295 | * Mark a transport as disconnected | 294 | * xprt_disconnect - mark a transport as disconnected |
295 | * @xprt: transport to flag for disconnect | ||
296 | * | ||
296 | */ | 297 | */ |
297 | void xprt_disconnect(struct rpc_xprt *xprt) | 298 | void xprt_disconnect(struct rpc_xprt *xprt) |
298 | { | 299 | { |
@@ -303,9 +304,6 @@ void xprt_disconnect(struct rpc_xprt *xprt) | |||
303 | spin_unlock_bh(&xprt->sock_lock); | 304 | spin_unlock_bh(&xprt->sock_lock); |
304 | } | 305 | } |
305 | 306 | ||
306 | /* | ||
307 | * Used to allow disconnection when we've been idle | ||
308 | */ | ||
309 | static void | 307 | static void |
310 | xprt_init_autodisconnect(unsigned long data) | 308 | xprt_init_autodisconnect(unsigned long data) |
311 | { | 309 | { |
@@ -327,8 +325,9 @@ out_abort: | |||
327 | spin_unlock(&xprt->sock_lock); | 325 | spin_unlock(&xprt->sock_lock); |
328 | } | 326 | } |
329 | 327 | ||
330 | /* | 328 | /** |
331 | * Attempt to connect a TCP socket. | 329 | * xprt_connect - schedule a transport connect operation |
330 | * @task: RPC task that is requesting the connect | ||
332 | * | 331 | * |
333 | */ | 332 | */ |
334 | void xprt_connect(struct rpc_task *task) | 333 | void xprt_connect(struct rpc_task *task) |
@@ -361,11 +360,7 @@ void xprt_connect(struct rpc_task *task) | |||
361 | return; | 360 | return; |
362 | } | 361 | } |
363 | 362 | ||
364 | /* | 363 | static void xprt_connect_status(struct rpc_task *task) |
365 | * We arrive here when awoken from waiting on connection establishment. | ||
366 | */ | ||
367 | static void | ||
368 | xprt_connect_status(struct rpc_task *task) | ||
369 | { | 364 | { |
370 | struct rpc_xprt *xprt = task->tk_xprt; | 365 | struct rpc_xprt *xprt = task->tk_xprt; |
371 | 366 | ||
@@ -404,8 +399,11 @@ xprt_connect_status(struct rpc_task *task) | |||
404 | } | 399 | } |
405 | } | 400 | } |
406 | 401 | ||
407 | /* | 402 | /** |
408 | * Look up the RPC request corresponding to a reply, and then lock it. | 403 | * xprt_lookup_rqst - find an RPC request corresponding to an XID |
404 | * @xprt: transport on which the original request was transmitted | ||
405 | * @xid: RPC XID of incoming reply | ||
406 | * | ||
409 | */ | 407 | */ |
410 | struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) | 408 | struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) |
411 | { | 409 | { |
@@ -422,9 +420,12 @@ struct rpc_rqst *xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid) | |||
422 | return req; | 420 | return req; |
423 | } | 421 | } |
424 | 422 | ||
425 | /* | 423 | /** |
426 | * Complete reply received. | 424 | * xprt_complete_rqst - called when reply processing is complete |
427 | * The TCP code relies on us to remove the request from xprt->pending. | 425 | * @xprt: controlling transport |
426 | * @req: RPC request that just completed | ||
427 | * @copied: actual number of bytes received from the transport | ||
428 | * | ||
428 | */ | 429 | */ |
429 | void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied) | 430 | void xprt_complete_rqst(struct rpc_xprt *xprt, struct rpc_rqst *req, int copied) |
430 | { | 431 | { |
@@ -498,12 +499,12 @@ out: | |||
498 | spin_unlock(&xprt->sock_lock); | 499 | spin_unlock(&xprt->sock_lock); |
499 | } | 500 | } |
500 | 501 | ||
501 | /* | 502 | /** |
502 | * Place the actual RPC call. | 503 | * xprt_prepare_transmit - reserve the transport before sending a request |
503 | * We have to copy the iovec because sendmsg fiddles with its contents. | 504 | * @task: RPC task about to send a request |
505 | * | ||
504 | */ | 506 | */ |
505 | int | 507 | int xprt_prepare_transmit(struct rpc_task *task) |
506 | xprt_prepare_transmit(struct rpc_task *task) | ||
507 | { | 508 | { |
508 | struct rpc_rqst *req = task->tk_rqstp; | 509 | struct rpc_rqst *req = task->tk_rqstp; |
509 | struct rpc_xprt *xprt = req->rq_xprt; | 510 | struct rpc_xprt *xprt = req->rq_xprt; |
@@ -533,8 +534,13 @@ out_unlock: | |||
533 | return err; | 534 | return err; |
534 | } | 535 | } |
535 | 536 | ||
536 | void | 537 | /** |
537 | xprt_transmit(struct rpc_task *task) | 538 | * xprt_transmit - send an RPC request on a transport |
539 | * @task: controlling RPC task | ||
540 | * | ||
541 | * We have to copy the iovec because sendmsg fiddles with its contents. | ||
542 | */ | ||
543 | void xprt_transmit(struct rpc_task *task) | ||
538 | { | 544 | { |
539 | struct rpc_clnt *clnt = task->tk_client; | 545 | struct rpc_clnt *clnt = task->tk_client; |
540 | struct rpc_rqst *req = task->tk_rqstp; | 546 | struct rpc_rqst *req = task->tk_rqstp; |
@@ -604,11 +610,7 @@ xprt_transmit(struct rpc_task *task) | |||
604 | spin_unlock_bh(&xprt->sock_lock); | 610 | spin_unlock_bh(&xprt->sock_lock); |
605 | } | 611 | } |
606 | 612 | ||
607 | /* | 613 | static inline void do_xprt_reserve(struct rpc_task *task) |
608 | * Reserve an RPC call slot. | ||
609 | */ | ||
610 | static inline void | ||
611 | do_xprt_reserve(struct rpc_task *task) | ||
612 | { | 614 | { |
613 | struct rpc_xprt *xprt = task->tk_xprt; | 615 | struct rpc_xprt *xprt = task->tk_xprt; |
614 | 616 | ||
@@ -628,8 +630,14 @@ do_xprt_reserve(struct rpc_task *task) | |||
628 | rpc_sleep_on(&xprt->backlog, task, NULL, NULL); | 630 | rpc_sleep_on(&xprt->backlog, task, NULL, NULL); |
629 | } | 631 | } |
630 | 632 | ||
631 | void | 633 | /** |
632 | xprt_reserve(struct rpc_task *task) | 634 | * xprt_reserve - allocate an RPC request slot |
635 | * @task: RPC task requesting a slot allocation | ||
636 | * | ||
637 | * If no more slots are available, place the task on the transport's | ||
638 | * backlog queue. | ||
639 | */ | ||
640 | void xprt_reserve(struct rpc_task *task) | ||
633 | { | 641 | { |
634 | struct rpc_xprt *xprt = task->tk_xprt; | 642 | struct rpc_xprt *xprt = task->tk_xprt; |
635 | 643 | ||
@@ -641,9 +649,6 @@ xprt_reserve(struct rpc_task *task) | |||
641 | } | 649 | } |
642 | } | 650 | } |
643 | 651 | ||
644 | /* | ||
645 | * Allocate a 'unique' XID | ||
646 | */ | ||
647 | static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) | 652 | static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) |
648 | { | 653 | { |
649 | return xprt->xid++; | 654 | return xprt->xid++; |
@@ -654,11 +659,7 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt) | |||
654 | get_random_bytes(&xprt->xid, sizeof(xprt->xid)); | 659 | get_random_bytes(&xprt->xid, sizeof(xprt->xid)); |
655 | } | 660 | } |
656 | 661 | ||
657 | /* | 662 | static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) |
658 | * Initialize RPC request | ||
659 | */ | ||
660 | static void | ||
661 | xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) | ||
662 | { | 663 | { |
663 | struct rpc_rqst *req = task->tk_rqstp; | 664 | struct rpc_rqst *req = task->tk_rqstp; |
664 | 665 | ||
@@ -670,11 +671,12 @@ xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) | |||
670 | req, ntohl(req->rq_xid)); | 671 | req, ntohl(req->rq_xid)); |
671 | } | 672 | } |
672 | 673 | ||
673 | /* | 674 | /** |
674 | * Release an RPC call slot | 675 | * xprt_release - release an RPC request slot |
676 | * @task: task which is finished with the slot | ||
677 | * | ||
675 | */ | 678 | */ |
676 | void | 679 | void xprt_release(struct rpc_task *task) |
677 | xprt_release(struct rpc_task *task) | ||
678 | { | 680 | { |
679 | struct rpc_xprt *xprt = task->tk_xprt; | 681 | struct rpc_xprt *xprt = task->tk_xprt; |
680 | struct rpc_rqst *req; | 682 | struct rpc_rqst *req; |
@@ -702,11 +704,14 @@ xprt_release(struct rpc_task *task) | |||
702 | spin_unlock(&xprt->xprt_lock); | 704 | spin_unlock(&xprt->xprt_lock); |
703 | } | 705 | } |
704 | 706 | ||
705 | /* | 707 | /** |
706 | * Set constant timeout | 708 | * xprt_set_timeout - set constant RPC timeout |
709 | * @to: RPC timeout parameters to set up | ||
710 | * @retr: number of retries | ||
711 | * @incr: amount of increase after each retry | ||
712 | * | ||
707 | */ | 713 | */ |
708 | void | 714 | void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) |
709 | xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) | ||
710 | { | 715 | { |
711 | to->to_initval = | 716 | to->to_initval = |
712 | to->to_increment = incr; | 717 | to->to_increment = incr; |
@@ -715,11 +720,7 @@ xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) | |||
715 | to->to_exponential = 0; | 720 | to->to_exponential = 0; |
716 | } | 721 | } |
717 | 722 | ||
718 | /* | 723 | static struct rpc_xprt *xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to) |
719 | * Initialize an RPC client | ||
720 | */ | ||
721 | static struct rpc_xprt * | ||
722 | xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to) | ||
723 | { | 724 | { |
724 | int result; | 725 | int result; |
725 | struct rpc_xprt *xprt; | 726 | struct rpc_xprt *xprt; |
@@ -778,11 +779,14 @@ xprt_setup(int proto, struct sockaddr_in *ap, struct rpc_timeout *to) | |||
778 | return xprt; | 779 | return xprt; |
779 | } | 780 | } |
780 | 781 | ||
781 | /* | 782 | /** |
782 | * Create an RPC client transport given the protocol and peer address. | 783 | * xprt_create_proto - create an RPC client transport |
784 | * @proto: requested transport protocol | ||
785 | * @sap: remote peer's address | ||
786 | * @to: timeout parameters for new transport | ||
787 | * | ||
783 | */ | 788 | */ |
784 | struct rpc_xprt * | 789 | struct rpc_xprt *xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to) |
785 | xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to) | ||
786 | { | 790 | { |
787 | struct rpc_xprt *xprt; | 791 | struct rpc_xprt *xprt; |
788 | 792 | ||
@@ -794,11 +798,7 @@ xprt_create_proto(int proto, struct sockaddr_in *sap, struct rpc_timeout *to) | |||
794 | return xprt; | 798 | return xprt; |
795 | } | 799 | } |
796 | 800 | ||
797 | /* | 801 | static void xprt_shutdown(struct rpc_xprt *xprt) |
798 | * Prepare for transport shutdown. | ||
799 | */ | ||
800 | static void | ||
801 | xprt_shutdown(struct rpc_xprt *xprt) | ||
802 | { | 802 | { |
803 | xprt->shutdown = 1; | 803 | xprt->shutdown = 1; |
804 | rpc_wake_up(&xprt->sending); | 804 | rpc_wake_up(&xprt->sending); |
@@ -809,21 +809,18 @@ xprt_shutdown(struct rpc_xprt *xprt) | |||
809 | del_timer_sync(&xprt->timer); | 809 | del_timer_sync(&xprt->timer); |
810 | } | 810 | } |
811 | 811 | ||
812 | /* | 812 | static int xprt_clear_backlog(struct rpc_xprt *xprt) { |
813 | * Clear the xprt backlog queue | ||
814 | */ | ||
815 | static int | ||
816 | xprt_clear_backlog(struct rpc_xprt *xprt) { | ||
817 | rpc_wake_up_next(&xprt->backlog); | 813 | rpc_wake_up_next(&xprt->backlog); |
818 | wake_up(&xprt->cong_wait); | 814 | wake_up(&xprt->cong_wait); |
819 | return 1; | 815 | return 1; |
820 | } | 816 | } |
821 | 817 | ||
822 | /* | 818 | /** |
823 | * Destroy an RPC transport, killing off all requests. | 819 | * xprt_destroy - destroy an RPC transport, killing off all requests. |
820 | * @xprt: transport to destroy | ||
821 | * | ||
824 | */ | 822 | */ |
825 | int | 823 | int xprt_destroy(struct rpc_xprt *xprt) |
826 | xprt_destroy(struct rpc_xprt *xprt) | ||
827 | { | 824 | { |
828 | dprintk("RPC: destroying transport %p\n", xprt); | 825 | dprintk("RPC: destroying transport %p\n", xprt); |
829 | xprt_shutdown(xprt); | 826 | xprt_shutdown(xprt); |