aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprt.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-04-16 16:37:01 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-05-14 15:09:29 -0400
commitee5ebe851ed60206f150d3f189416f9c63245b66 (patch)
treeb73f04713c9ae381d40ad136cb60f9f3129d80f6 /net/sunrpc/xprt.c
parentfd86dfd2637db1aef9ebf96ba41aeedb87521e78 (diff)
SUNRPC: Clean up xprt_release()
Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r--net/sunrpc/xprt.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 42f09ade0044..18415cc37c01 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -62,7 +62,6 @@
62 * Local functions 62 * Local functions
63 */ 63 */
64static void xprt_request_init(struct rpc_task *, struct rpc_xprt *); 64static void xprt_request_init(struct rpc_task *, struct rpc_xprt *);
65static inline void do_xprt_reserve(struct rpc_task *);
66static void xprt_connect_status(struct rpc_task *task); 65static void xprt_connect_status(struct rpc_task *task);
67static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *); 66static int __xprt_get_cong(struct rpc_xprt *, struct rpc_task *);
68 67
@@ -935,7 +934,7 @@ void xprt_transmit(struct rpc_task *task)
935 spin_unlock_bh(&xprt->transport_lock); 934 spin_unlock_bh(&xprt->transport_lock);
936} 935}
937 936
938static inline void do_xprt_reserve(struct rpc_task *task) 937static void xprt_alloc_slot(struct rpc_task *task)
939{ 938{
940 struct rpc_xprt *xprt = task->tk_xprt; 939 struct rpc_xprt *xprt = task->tk_xprt;
941 940
@@ -955,6 +954,16 @@ static inline void do_xprt_reserve(struct rpc_task *task)
955 rpc_sleep_on(&xprt->backlog, task, NULL); 954 rpc_sleep_on(&xprt->backlog, task, NULL);
956} 955}
957 956
957static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
958{
959 memset(req, 0, sizeof(*req)); /* mark unused */
960
961 spin_lock(&xprt->reserve_lock);
962 list_add(&req->rq_list, &xprt->free);
963 rpc_wake_up_next(&xprt->backlog);
964 spin_unlock(&xprt->reserve_lock);
965}
966
958/** 967/**
959 * xprt_reserve - allocate an RPC request slot 968 * xprt_reserve - allocate an RPC request slot
960 * @task: RPC task requesting a slot allocation 969 * @task: RPC task requesting a slot allocation
@@ -968,7 +977,7 @@ void xprt_reserve(struct rpc_task *task)
968 977
969 task->tk_status = -EIO; 978 task->tk_status = -EIO;
970 spin_lock(&xprt->reserve_lock); 979 spin_lock(&xprt->reserve_lock);
971 do_xprt_reserve(task); 980 xprt_alloc_slot(task);
972 spin_unlock(&xprt->reserve_lock); 981 spin_unlock(&xprt->reserve_lock);
973} 982}
974 983
@@ -1006,14 +1015,10 @@ void xprt_release(struct rpc_task *task)
1006{ 1015{
1007 struct rpc_xprt *xprt; 1016 struct rpc_xprt *xprt;
1008 struct rpc_rqst *req; 1017 struct rpc_rqst *req;
1009 int is_bc_request;
1010 1018
1011 if (!(req = task->tk_rqstp)) 1019 if (!(req = task->tk_rqstp))
1012 return; 1020 return;
1013 1021
1014 /* Preallocated backchannel request? */
1015 is_bc_request = bc_prealloc(req);
1016
1017 xprt = req->rq_xprt; 1022 xprt = req->rq_xprt;
1018 rpc_count_iostats(task); 1023 rpc_count_iostats(task);
1019 spin_lock_bh(&xprt->transport_lock); 1024 spin_lock_bh(&xprt->transport_lock);
@@ -1027,21 +1032,16 @@ void xprt_release(struct rpc_task *task)
1027 mod_timer(&xprt->timer, 1032 mod_timer(&xprt->timer,
1028 xprt->last_used + xprt->idle_timeout); 1033 xprt->last_used + xprt->idle_timeout);
1029 spin_unlock_bh(&xprt->transport_lock); 1034 spin_unlock_bh(&xprt->transport_lock);
1030 if (!bc_prealloc(req)) 1035 if (req->rq_buffer)
1031 xprt->ops->buf_free(req->rq_buffer); 1036 xprt->ops->buf_free(req->rq_buffer);
1032 task->tk_rqstp = NULL; 1037 task->tk_rqstp = NULL;
1033 if (req->rq_release_snd_buf) 1038 if (req->rq_release_snd_buf)
1034 req->rq_release_snd_buf(req); 1039 req->rq_release_snd_buf(req);
1035 1040
1036 dprintk("RPC: %5u release request %p\n", task->tk_pid, req); 1041 dprintk("RPC: %5u release request %p\n", task->tk_pid, req);
1037 if (likely(!is_bc_request)) { 1042 if (likely(!bc_prealloc(req)))
1038 memset(req, 0, sizeof(*req)); /* mark unused */ 1043 xprt_free_slot(xprt, req);
1039 1044 else
1040 spin_lock(&xprt->reserve_lock);
1041 list_add(&req->rq_list, &xprt->free);
1042 rpc_wake_up_next(&xprt->backlog);
1043 spin_unlock(&xprt->reserve_lock);
1044 } else
1045 xprt_free_bc_request(req); 1045 xprt_free_bc_request(req);
1046} 1046}
1047 1047