diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-05 12:55:57 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-22 23:25:01 -0400 |
commit | 6b6ca86b77b62b798cf9ca2599036420abce7796 (patch) | |
tree | cf631a3c293be45fa4bed54bca5dcbfc96a57df1 /net/sunrpc/xprt.c | |
parent | da45828e2835057045150b318c4fbe9bb91f18dd (diff) |
SUNRPC: Add refcounting to the struct rpc_xprt
In a subsequent patch, this will allow the portmapper to take a reference
to the rpc_xprt for which it is updating the port number, fixing an Oops.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r-- | net/sunrpc/xprt.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index a85f82baefc1..1f786f68729d 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -926,6 +926,7 @@ struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t si | |||
926 | return ERR_PTR(result); | 926 | return ERR_PTR(result); |
927 | } | 927 | } |
928 | 928 | ||
929 | kref_init(&xprt->kref); | ||
929 | spin_lock_init(&xprt->transport_lock); | 930 | spin_lock_init(&xprt->transport_lock); |
930 | spin_lock_init(&xprt->reserve_lock); | 931 | spin_lock_init(&xprt->reserve_lock); |
931 | 932 | ||
@@ -958,16 +959,37 @@ struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t si | |||
958 | 959 | ||
959 | /** | 960 | /** |
960 | * xprt_destroy - destroy an RPC transport, killing off all requests. | 961 | * xprt_destroy - destroy an RPC transport, killing off all requests. |
961 | * @xprt: transport to destroy | 962 | * @kref: kref for the transport to destroy |
962 | * | 963 | * |
963 | */ | 964 | */ |
964 | int xprt_destroy(struct rpc_xprt *xprt) | 965 | static void xprt_destroy(struct kref *kref) |
965 | { | 966 | { |
967 | struct rpc_xprt *xprt = container_of(kref, struct rpc_xprt, kref); | ||
968 | |||
966 | dprintk("RPC: destroying transport %p\n", xprt); | 969 | dprintk("RPC: destroying transport %p\n", xprt); |
967 | xprt->shutdown = 1; | 970 | xprt->shutdown = 1; |
968 | del_timer_sync(&xprt->timer); | 971 | del_timer_sync(&xprt->timer); |
969 | xprt->ops->destroy(xprt); | 972 | xprt->ops->destroy(xprt); |
970 | kfree(xprt); | 973 | kfree(xprt); |
974 | } | ||
971 | 975 | ||
972 | return 0; | 976 | /** |
977 | * xprt_put - release a reference to an RPC transport. | ||
978 | * @xprt: pointer to the transport | ||
979 | * | ||
980 | */ | ||
981 | void xprt_put(struct rpc_xprt *xprt) | ||
982 | { | ||
983 | kref_put(&xprt->kref, xprt_destroy); | ||
984 | } | ||
985 | |||
986 | /** | ||
987 | * xprt_get - return a reference to an RPC transport. | ||
988 | * @xprt: pointer to the transport | ||
989 | * | ||
990 | */ | ||
991 | struct rpc_xprt *xprt_get(struct rpc_xprt *xprt) | ||
992 | { | ||
993 | kref_get(&xprt->kref); | ||
994 | return xprt; | ||
973 | } | 995 | } |