diff options
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r-- | net/sunrpc/xprt.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index fb92f51405c5..cfcade906a56 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -501,9 +501,10 @@ EXPORT_SYMBOL_GPL(xprt_set_retrans_timeout_def); | |||
501 | void xprt_set_retrans_timeout_rtt(struct rpc_task *task) | 501 | void xprt_set_retrans_timeout_rtt(struct rpc_task *task) |
502 | { | 502 | { |
503 | int timer = task->tk_msg.rpc_proc->p_timer; | 503 | int timer = task->tk_msg.rpc_proc->p_timer; |
504 | struct rpc_rtt *rtt = task->tk_client->cl_rtt; | 504 | struct rpc_clnt *clnt = task->tk_client; |
505 | struct rpc_rtt *rtt = clnt->cl_rtt; | ||
505 | struct rpc_rqst *req = task->tk_rqstp; | 506 | struct rpc_rqst *req = task->tk_rqstp; |
506 | unsigned long max_timeout = req->rq_xprt->timeout.to_maxval; | 507 | unsigned long max_timeout = clnt->cl_timeout->to_maxval; |
507 | 508 | ||
508 | task->tk_timeout = rpc_calc_rto(rtt, timer); | 509 | task->tk_timeout = rpc_calc_rto(rtt, timer); |
509 | task->tk_timeout <<= rpc_ntimeo(rtt, timer) + req->rq_retries; | 510 | task->tk_timeout <<= rpc_ntimeo(rtt, timer) + req->rq_retries; |
@@ -514,7 +515,7 @@ EXPORT_SYMBOL_GPL(xprt_set_retrans_timeout_rtt); | |||
514 | 515 | ||
515 | static void xprt_reset_majortimeo(struct rpc_rqst *req) | 516 | static void xprt_reset_majortimeo(struct rpc_rqst *req) |
516 | { | 517 | { |
517 | struct rpc_timeout *to = &req->rq_xprt->timeout; | 518 | const struct rpc_timeout *to = req->rq_task->tk_client->cl_timeout; |
518 | 519 | ||
519 | req->rq_majortimeo = req->rq_timeout; | 520 | req->rq_majortimeo = req->rq_timeout; |
520 | if (to->to_exponential) | 521 | if (to->to_exponential) |
@@ -534,7 +535,7 @@ static void xprt_reset_majortimeo(struct rpc_rqst *req) | |||
534 | int xprt_adjust_timeout(struct rpc_rqst *req) | 535 | int xprt_adjust_timeout(struct rpc_rqst *req) |
535 | { | 536 | { |
536 | struct rpc_xprt *xprt = req->rq_xprt; | 537 | struct rpc_xprt *xprt = req->rq_xprt; |
537 | struct rpc_timeout *to = &xprt->timeout; | 538 | const struct rpc_timeout *to = req->rq_task->tk_client->cl_timeout; |
538 | int status = 0; | 539 | int status = 0; |
539 | 540 | ||
540 | if (time_before(jiffies, req->rq_majortimeo)) { | 541 | if (time_before(jiffies, req->rq_majortimeo)) { |
@@ -568,17 +569,17 @@ static void xprt_autoclose(struct work_struct *work) | |||
568 | struct rpc_xprt *xprt = | 569 | struct rpc_xprt *xprt = |
569 | container_of(work, struct rpc_xprt, task_cleanup); | 570 | container_of(work, struct rpc_xprt, task_cleanup); |
570 | 571 | ||
571 | xprt_disconnect(xprt); | ||
572 | xprt->ops->close(xprt); | 572 | xprt->ops->close(xprt); |
573 | clear_bit(XPRT_CLOSE_WAIT, &xprt->state); | ||
573 | xprt_release_write(xprt, NULL); | 574 | xprt_release_write(xprt, NULL); |
574 | } | 575 | } |
575 | 576 | ||
576 | /** | 577 | /** |
577 | * xprt_disconnect - mark a transport as disconnected | 578 | * xprt_disconnect_done - mark a transport as disconnected |
578 | * @xprt: transport to flag for disconnect | 579 | * @xprt: transport to flag for disconnect |
579 | * | 580 | * |
580 | */ | 581 | */ |
581 | void xprt_disconnect(struct rpc_xprt *xprt) | 582 | void xprt_disconnect_done(struct rpc_xprt *xprt) |
582 | { | 583 | { |
583 | dprintk("RPC: disconnected transport %p\n", xprt); | 584 | dprintk("RPC: disconnected transport %p\n", xprt); |
584 | spin_lock_bh(&xprt->transport_lock); | 585 | spin_lock_bh(&xprt->transport_lock); |
@@ -586,7 +587,26 @@ void xprt_disconnect(struct rpc_xprt *xprt) | |||
586 | xprt_wake_pending_tasks(xprt, -ENOTCONN); | 587 | xprt_wake_pending_tasks(xprt, -ENOTCONN); |
587 | spin_unlock_bh(&xprt->transport_lock); | 588 | spin_unlock_bh(&xprt->transport_lock); |
588 | } | 589 | } |
589 | EXPORT_SYMBOL_GPL(xprt_disconnect); | 590 | EXPORT_SYMBOL_GPL(xprt_disconnect_done); |
591 | |||
592 | /** | ||
593 | * xprt_force_disconnect - force a transport to disconnect | ||
594 | * @xprt: transport to disconnect | ||
595 | * | ||
596 | */ | ||
597 | void xprt_force_disconnect(struct rpc_xprt *xprt) | ||
598 | { | ||
599 | /* Don't race with the test_bit() in xprt_clear_locked() */ | ||
600 | spin_lock_bh(&xprt->transport_lock); | ||
601 | set_bit(XPRT_CLOSE_WAIT, &xprt->state); | ||
602 | /* Try to schedule an autoclose RPC call */ | ||
603 | if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) | ||
604 | queue_work(rpciod_workqueue, &xprt->task_cleanup); | ||
605 | else if (xprt->snd_task != NULL) | ||
606 | rpc_wake_up_task(xprt->snd_task); | ||
607 | spin_unlock_bh(&xprt->transport_lock); | ||
608 | } | ||
609 | EXPORT_SYMBOL_GPL(xprt_force_disconnect); | ||
590 | 610 | ||
591 | static void | 611 | static void |
592 | xprt_init_autodisconnect(unsigned long data) | 612 | xprt_init_autodisconnect(unsigned long data) |
@@ -909,7 +929,7 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) | |||
909 | { | 929 | { |
910 | struct rpc_rqst *req = task->tk_rqstp; | 930 | struct rpc_rqst *req = task->tk_rqstp; |
911 | 931 | ||
912 | req->rq_timeout = xprt->timeout.to_initval; | 932 | req->rq_timeout = task->tk_client->cl_timeout->to_initval; |
913 | req->rq_task = task; | 933 | req->rq_task = task; |
914 | req->rq_xprt = xprt; | 934 | req->rq_xprt = xprt; |
915 | req->rq_buffer = NULL; | 935 | req->rq_buffer = NULL; |
@@ -959,22 +979,6 @@ void xprt_release(struct rpc_task *task) | |||
959 | } | 979 | } |
960 | 980 | ||
961 | /** | 981 | /** |
962 | * xprt_set_timeout - set constant RPC timeout | ||
963 | * @to: RPC timeout parameters to set up | ||
964 | * @retr: number of retries | ||
965 | * @incr: amount of increase after each retry | ||
966 | * | ||
967 | */ | ||
968 | void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr) | ||
969 | { | ||
970 | to->to_initval = | ||
971 | to->to_increment = incr; | ||
972 | to->to_maxval = to->to_initval + (incr * retr); | ||
973 | to->to_retries = retr; | ||
974 | to->to_exponential = 0; | ||
975 | } | ||
976 | |||
977 | /** | ||
978 | * xprt_create_transport - create an RPC transport | 982 | * xprt_create_transport - create an RPC transport |
979 | * @args: rpc transport creation arguments | 983 | * @args: rpc transport creation arguments |
980 | * | 984 | * |