diff options
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r-- | net/sunrpc/xprt.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 856274d7e85c..9494c3767356 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -202,10 +202,9 @@ int xprt_reserve_xprt(struct rpc_task *task) | |||
202 | goto out_sleep; | 202 | goto out_sleep; |
203 | } | 203 | } |
204 | xprt->snd_task = task; | 204 | xprt->snd_task = task; |
205 | if (req) { | 205 | req->rq_bytes_sent = 0; |
206 | req->rq_bytes_sent = 0; | 206 | req->rq_ntrans++; |
207 | req->rq_ntrans++; | 207 | |
208 | } | ||
209 | return 1; | 208 | return 1; |
210 | 209 | ||
211 | out_sleep: | 210 | out_sleep: |
@@ -213,7 +212,7 @@ out_sleep: | |||
213 | task->tk_pid, xprt); | 212 | task->tk_pid, xprt); |
214 | task->tk_timeout = 0; | 213 | task->tk_timeout = 0; |
215 | task->tk_status = -EAGAIN; | 214 | task->tk_status = -EAGAIN; |
216 | if (req && req->rq_ntrans) | 215 | if (req->rq_ntrans) |
217 | rpc_sleep_on(&xprt->resend, task, NULL); | 216 | rpc_sleep_on(&xprt->resend, task, NULL); |
218 | else | 217 | else |
219 | rpc_sleep_on(&xprt->sending, task, NULL); | 218 | rpc_sleep_on(&xprt->sending, task, NULL); |
@@ -965,7 +964,7 @@ struct rpc_xprt *xprt_alloc(struct net *net, int size, int max_req) | |||
965 | xprt = kzalloc(size, GFP_KERNEL); | 964 | xprt = kzalloc(size, GFP_KERNEL); |
966 | if (xprt == NULL) | 965 | if (xprt == NULL) |
967 | goto out; | 966 | goto out; |
968 | kref_init(&xprt->kref); | 967 | atomic_set(&xprt->count, 1); |
969 | 968 | ||
970 | xprt->max_reqs = max_req; | 969 | xprt->max_reqs = max_req; |
971 | xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL); | 970 | xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL); |
@@ -1145,13 +1144,11 @@ found: | |||
1145 | 1144 | ||
1146 | /** | 1145 | /** |
1147 | * xprt_destroy - destroy an RPC transport, killing off all requests. | 1146 | * xprt_destroy - destroy an RPC transport, killing off all requests. |
1148 | * @kref: kref for the transport to destroy | 1147 | * @xprt: transport to destroy |
1149 | * | 1148 | * |
1150 | */ | 1149 | */ |
1151 | static void xprt_destroy(struct kref *kref) | 1150 | static void xprt_destroy(struct rpc_xprt *xprt) |
1152 | { | 1151 | { |
1153 | struct rpc_xprt *xprt = container_of(kref, struct rpc_xprt, kref); | ||
1154 | |||
1155 | dprintk("RPC: destroying transport %p\n", xprt); | 1152 | dprintk("RPC: destroying transport %p\n", xprt); |
1156 | xprt->shutdown = 1; | 1153 | xprt->shutdown = 1; |
1157 | del_timer_sync(&xprt->timer); | 1154 | del_timer_sync(&xprt->timer); |
@@ -1175,7 +1172,8 @@ static void xprt_destroy(struct kref *kref) | |||
1175 | */ | 1172 | */ |
1176 | void xprt_put(struct rpc_xprt *xprt) | 1173 | void xprt_put(struct rpc_xprt *xprt) |
1177 | { | 1174 | { |
1178 | kref_put(&xprt->kref, xprt_destroy); | 1175 | if (atomic_dec_and_test(&xprt->count)) |
1176 | xprt_destroy(xprt); | ||
1179 | } | 1177 | } |
1180 | 1178 | ||
1181 | /** | 1179 | /** |
@@ -1185,6 +1183,7 @@ void xprt_put(struct rpc_xprt *xprt) | |||
1185 | */ | 1183 | */ |
1186 | struct rpc_xprt *xprt_get(struct rpc_xprt *xprt) | 1184 | struct rpc_xprt *xprt_get(struct rpc_xprt *xprt) |
1187 | { | 1185 | { |
1188 | kref_get(&xprt->kref); | 1186 | if (atomic_inc_not_zero(&xprt->count)) |
1189 | return xprt; | 1187 | return xprt; |
1188 | return NULL; | ||
1190 | } | 1189 | } |