diff options
-rw-r--r-- | include/linux/sunrpc/xprt.h | 3 | ||||
-rw-r--r-- | net/sunrpc/xprt.c | 16 |
2 files changed, 9 insertions, 10 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index bef0f535f746..a0f998c07c65 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/uio.h> | 12 | #include <linux/uio.h> |
13 | #include <linux/socket.h> | 13 | #include <linux/socket.h> |
14 | #include <linux/in.h> | 14 | #include <linux/in.h> |
15 | #include <linux/kref.h> | ||
16 | #include <linux/ktime.h> | 15 | #include <linux/ktime.h> |
17 | #include <linux/sunrpc/sched.h> | 16 | #include <linux/sunrpc/sched.h> |
18 | #include <linux/sunrpc/xdr.h> | 17 | #include <linux/sunrpc/xdr.h> |
@@ -146,7 +145,7 @@ enum xprt_transports { | |||
146 | }; | 145 | }; |
147 | 146 | ||
148 | struct rpc_xprt { | 147 | struct rpc_xprt { |
149 | struct kref kref; /* Reference count */ | 148 | atomic_t count; /* Reference count */ |
150 | struct rpc_xprt_ops * ops; /* transport methods */ | 149 | struct rpc_xprt_ops * ops; /* transport methods */ |
151 | 150 | ||
152 | const struct rpc_timeout *timeout; /* timeout parms */ | 151 | const struct rpc_timeout *timeout; /* timeout parms */ |
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 8bdcdbe07b98..4499b5a51763 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -964,7 +964,7 @@ struct rpc_xprt *xprt_alloc(struct net *net, int size, int max_req) | |||
964 | xprt = kzalloc(size, GFP_KERNEL); | 964 | xprt = kzalloc(size, GFP_KERNEL); |
965 | if (xprt == NULL) | 965 | if (xprt == NULL) |
966 | goto out; | 966 | goto out; |
967 | kref_init(&xprt->kref); | 967 | atomic_set(&xprt->count, 1); |
968 | 968 | ||
969 | xprt->max_reqs = max_req; | 969 | xprt->max_reqs = max_req; |
970 | xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL); | 970 | xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL); |
@@ -1144,13 +1144,11 @@ found: | |||
1144 | 1144 | ||
1145 | /** | 1145 | /** |
1146 | * xprt_destroy - destroy an RPC transport, killing off all requests. | 1146 | * xprt_destroy - destroy an RPC transport, killing off all requests. |
1147 | * @kref: kref for the transport to destroy | 1147 | * @xprt: transport to destroy |
1148 | * | 1148 | * |
1149 | */ | 1149 | */ |
1150 | static void xprt_destroy(struct kref *kref) | 1150 | static void xprt_destroy(struct rpc_xprt *xprt) |
1151 | { | 1151 | { |
1152 | struct rpc_xprt *xprt = container_of(kref, struct rpc_xprt, kref); | ||
1153 | |||
1154 | dprintk("RPC: destroying transport %p\n", xprt); | 1152 | dprintk("RPC: destroying transport %p\n", xprt); |
1155 | xprt->shutdown = 1; | 1153 | xprt->shutdown = 1; |
1156 | del_timer_sync(&xprt->timer); | 1154 | del_timer_sync(&xprt->timer); |
@@ -1174,7 +1172,8 @@ static void xprt_destroy(struct kref *kref) | |||
1174 | */ | 1172 | */ |
1175 | void xprt_put(struct rpc_xprt *xprt) | 1173 | void xprt_put(struct rpc_xprt *xprt) |
1176 | { | 1174 | { |
1177 | kref_put(&xprt->kref, xprt_destroy); | 1175 | if (atomic_dec_and_test(&xprt->count)) |
1176 | xprt_destroy(xprt); | ||
1178 | } | 1177 | } |
1179 | 1178 | ||
1180 | /** | 1179 | /** |
@@ -1184,6 +1183,7 @@ void xprt_put(struct rpc_xprt *xprt) | |||
1184 | */ | 1183 | */ |
1185 | struct rpc_xprt *xprt_get(struct rpc_xprt *xprt) | 1184 | struct rpc_xprt *xprt_get(struct rpc_xprt *xprt) |
1186 | { | 1185 | { |
1187 | kref_get(&xprt->kref); | 1186 | if (atomic_inc_not_zero(&xprt->count)) |
1188 | return xprt; | 1187 | return xprt; |
1188 | return NULL; | ||
1189 | } | 1189 | } |