diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-20 06:57:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-20 16:16:24 -0400 |
commit | 6cca7289d5cba80d61da711205cd230fc637e2e3 (patch) | |
tree | 4bf46b5a809bd839c4948282140f2b45a9b89b61 /net/tipc | |
parent | b182aa6e967e8272a3ba718a89697f661915be7a (diff) |
tipc: Use inlined rhashtable interface
This patch converts tipc to the inlined rhashtable interface.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/socket.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index c03a3d33806f..73c2f518a7c0 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -133,6 +133,8 @@ static const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = { | |||
133 | [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG } | 133 | [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG } |
134 | }; | 134 | }; |
135 | 135 | ||
136 | static const struct rhashtable_params tsk_rht_params; | ||
137 | |||
136 | /* | 138 | /* |
137 | * Revised TIPC socket locking policy: | 139 | * Revised TIPC socket locking policy: |
138 | * | 140 | * |
@@ -2245,7 +2247,7 @@ static struct tipc_sock *tipc_sk_lookup(struct net *net, u32 portid) | |||
2245 | struct tipc_sock *tsk; | 2247 | struct tipc_sock *tsk; |
2246 | 2248 | ||
2247 | rcu_read_lock(); | 2249 | rcu_read_lock(); |
2248 | tsk = rhashtable_lookup(&tn->sk_rht, &portid); | 2250 | tsk = rhashtable_lookup_fast(&tn->sk_rht, &portid, tsk_rht_params); |
2249 | if (tsk) | 2251 | if (tsk) |
2250 | sock_hold(&tsk->sk); | 2252 | sock_hold(&tsk->sk); |
2251 | rcu_read_unlock(); | 2253 | rcu_read_unlock(); |
@@ -2267,7 +2269,8 @@ static int tipc_sk_insert(struct tipc_sock *tsk) | |||
2267 | portid = TIPC_MIN_PORT; | 2269 | portid = TIPC_MIN_PORT; |
2268 | tsk->portid = portid; | 2270 | tsk->portid = portid; |
2269 | sock_hold(&tsk->sk); | 2271 | sock_hold(&tsk->sk); |
2270 | if (rhashtable_lookup_insert(&tn->sk_rht, &tsk->node)) | 2272 | if (!rhashtable_lookup_insert_fast(&tn->sk_rht, &tsk->node, |
2273 | tsk_rht_params)) | ||
2271 | return 0; | 2274 | return 0; |
2272 | sock_put(&tsk->sk); | 2275 | sock_put(&tsk->sk); |
2273 | } | 2276 | } |
@@ -2280,26 +2283,27 @@ static void tipc_sk_remove(struct tipc_sock *tsk) | |||
2280 | struct sock *sk = &tsk->sk; | 2283 | struct sock *sk = &tsk->sk; |
2281 | struct tipc_net *tn = net_generic(sock_net(sk), tipc_net_id); | 2284 | struct tipc_net *tn = net_generic(sock_net(sk), tipc_net_id); |
2282 | 2285 | ||
2283 | if (rhashtable_remove(&tn->sk_rht, &tsk->node)) { | 2286 | if (!rhashtable_remove_fast(&tn->sk_rht, &tsk->node, tsk_rht_params)) { |
2284 | WARN_ON(atomic_read(&sk->sk_refcnt) == 1); | 2287 | WARN_ON(atomic_read(&sk->sk_refcnt) == 1); |
2285 | __sock_put(sk); | 2288 | __sock_put(sk); |
2286 | } | 2289 | } |
2287 | } | 2290 | } |
2288 | 2291 | ||
2292 | static const struct rhashtable_params tsk_rht_params = { | ||
2293 | .nelem_hint = 192, | ||
2294 | .head_offset = offsetof(struct tipc_sock, node), | ||
2295 | .key_offset = offsetof(struct tipc_sock, portid), | ||
2296 | .key_len = sizeof(u32), /* portid */ | ||
2297 | .hashfn = jhash, | ||
2298 | .max_size = 1048576, | ||
2299 | .min_size = 256, | ||
2300 | }; | ||
2301 | |||
2289 | int tipc_sk_rht_init(struct net *net) | 2302 | int tipc_sk_rht_init(struct net *net) |
2290 | { | 2303 | { |
2291 | struct tipc_net *tn = net_generic(net, tipc_net_id); | 2304 | struct tipc_net *tn = net_generic(net, tipc_net_id); |
2292 | struct rhashtable_params rht_params = { | 2305 | |
2293 | .nelem_hint = 192, | 2306 | return rhashtable_init(&tn->sk_rht, &tsk_rht_params); |
2294 | .head_offset = offsetof(struct tipc_sock, node), | ||
2295 | .key_offset = offsetof(struct tipc_sock, portid), | ||
2296 | .key_len = sizeof(u32), /* portid */ | ||
2297 | .hashfn = jhash, | ||
2298 | .max_size = 1048576, | ||
2299 | .min_size = 256, | ||
2300 | }; | ||
2301 | |||
2302 | return rhashtable_init(&tn->sk_rht, &rht_params); | ||
2303 | } | 2307 | } |
2304 | 2308 | ||
2305 | void tipc_sk_rht_destroy(struct net *net) | 2309 | void tipc_sk_rht_destroy(struct net *net) |