aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r--net/sunrpc/xprt.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 4f9a5d9791fb..7a3999f0a4a2 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -459,7 +459,6 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
459 if (to->to_maxval && req->rq_timeout >= to->to_maxval) 459 if (to->to_maxval && req->rq_timeout >= to->to_maxval)
460 req->rq_timeout = to->to_maxval; 460 req->rq_timeout = to->to_maxval;
461 req->rq_retries++; 461 req->rq_retries++;
462 pprintk("RPC: %lu retrans\n", jiffies);
463 } else { 462 } else {
464 req->rq_timeout = to->to_initval; 463 req->rq_timeout = to->to_initval;
465 req->rq_retries = 0; 464 req->rq_retries = 0;
@@ -468,7 +467,6 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
468 spin_lock_bh(&xprt->transport_lock); 467 spin_lock_bh(&xprt->transport_lock);
469 rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval); 468 rpc_init_rtt(req->rq_task->tk_client->cl_rtt, to->to_initval);
470 spin_unlock_bh(&xprt->transport_lock); 469 spin_unlock_bh(&xprt->transport_lock);
471 pprintk("RPC: %lu timeout\n", jiffies);
472 status = -ETIMEDOUT; 470 status = -ETIMEDOUT;
473 } 471 }
474 472
@@ -892,39 +890,25 @@ void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long i
892 */ 890 */
893struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t size, struct rpc_timeout *to) 891struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t size, struct rpc_timeout *to)
894{ 892{
895 int result;
896 struct rpc_xprt *xprt; 893 struct rpc_xprt *xprt;
897 struct rpc_rqst *req; 894 struct rpc_rqst *req;
898 895
899 if ((xprt = kzalloc(sizeof(struct rpc_xprt), GFP_KERNEL)) == NULL) {
900 dprintk("RPC: xprt_create_transport: no memory\n");
901 return ERR_PTR(-ENOMEM);
902 }
903 if (size <= sizeof(xprt->addr)) {
904 memcpy(&xprt->addr, ap, size);
905 xprt->addrlen = size;
906 } else {
907 kfree(xprt);
908 dprintk("RPC: xprt_create_transport: address too large\n");
909 return ERR_PTR(-EBADF);
910 }
911
912 switch (proto) { 896 switch (proto) {
913 case IPPROTO_UDP: 897 case IPPROTO_UDP:
914 result = xs_setup_udp(xprt, to); 898 xprt = xs_setup_udp(ap, size, to);
915 break; 899 break;
916 case IPPROTO_TCP: 900 case IPPROTO_TCP:
917 result = xs_setup_tcp(xprt, to); 901 xprt = xs_setup_tcp(ap, size, to);
918 break; 902 break;
919 default: 903 default:
920 printk(KERN_ERR "RPC: unrecognized transport protocol: %d\n", 904 printk(KERN_ERR "RPC: unrecognized transport protocol: %d\n",
921 proto); 905 proto);
922 return ERR_PTR(-EIO); 906 return ERR_PTR(-EIO);
923 } 907 }
924 if (result) { 908 if (IS_ERR(xprt)) {
925 kfree(xprt); 909 dprintk("RPC: xprt_create_transport: failed, %ld\n",
926 dprintk("RPC: xprt_create_transport: failed, %d\n", result); 910 -PTR_ERR(xprt));
927 return ERR_PTR(result); 911 return xprt;
928 } 912 }
929 913
930 kref_init(&xprt->kref); 914 kref_init(&xprt->kref);
@@ -970,8 +954,11 @@ static void xprt_destroy(struct kref *kref)
970 dprintk("RPC: destroying transport %p\n", xprt); 954 dprintk("RPC: destroying transport %p\n", xprt);
971 xprt->shutdown = 1; 955 xprt->shutdown = 1;
972 del_timer_sync(&xprt->timer); 956 del_timer_sync(&xprt->timer);
957
958 /*
959 * Tear down transport state and free the rpc_xprt
960 */
973 xprt->ops->destroy(xprt); 961 xprt->ops->destroy(xprt);
974 kfree(xprt);
975} 962}
976 963
977/** 964/**