aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2013-02-27 20:06:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:24 -0500
commitb67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch)
tree3d465aea12b97683f26ffa38eba8744469de9997 /net/rds
parent1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (diff)
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived list_for_each_entry(pos, head, member) The hlist ones were greedy and wanted an extra parameter: hlist_for_each_entry(tpos, pos, head, member) Why did they need an extra pos parameter? I'm not quite sure. Not only they don't really need it, it also prevents the iterator from looking exactly like the list iterator, which is unfortunate. Besides the semantic patch, there was some manual work required: - Fix up the actual hlist iterators in linux/list.h - Fix up the declaration of other iterators based on the hlist ones. - A very small amount of places were using the 'node' parameter, this was modified to use 'obj->member' instead. - Coccinelle didn't handle the hlist_for_each_entry_safe iterator properly, so those had to be fixed up manually. The semantic patch which is mostly the work of Peter Senna Tschudin is here: @@ iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host; type T; expression a,c,d,e; identifier b; statement S; @@ -T b; <+... when != b ( hlist_for_each_entry(a, - b, c, d) S | hlist_for_each_entry_continue(a, - b, c) S | hlist_for_each_entry_from(a, - b, c) S | hlist_for_each_entry_rcu(a, - b, c, d) S | hlist_for_each_entry_rcu_bh(a, - b, c, d) S | hlist_for_each_entry_continue_rcu_bh(a, - b, c) S | for_each_busy_worker(a, c, - b, d) S | ax25_uid_for_each(a, - b, c) S | ax25_for_each(a, - b, c) S | inet_bind_bucket_for_each(a, - b, c) S | sctp_for_each_hentry(a, - b, c) S | sk_for_each(a, - b, c) S | sk_for_each_rcu(a, - b, c) S | sk_for_each_from -(a, b) +(a) S + sk_for_each_from(a) S | sk_for_each_safe(a, - b, c, d) S | sk_for_each_bound(a, - b, c) S | hlist_for_each_entry_safe(a, - b, c, d, e) S | hlist_for_each_entry_continue_rcu(a, - b, c) S | nr_neigh_for_each(a, - b, c) S | nr_neigh_for_each_safe(a, - b, c, d) S | nr_node_for_each(a, - b, c) S | nr_node_for_each_safe(a, - b, c, d) S | - for_each_gfn_sp(a, c, d, b) S + for_each_gfn_sp(a, c, d) S | - for_each_gfn_indirect_valid_sp(a, c, d, b) S + for_each_gfn_indirect_valid_sp(a, c, d) S | for_each_host(a, - b, c) S | for_each_host_safe(a, - b, c, d) S | for_each_mesh_entry(a, - b, c, d) S ) ...+> [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c] [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c] [akpm@linux-foundation.org: checkpatch fixes] [akpm@linux-foundation.org: fix warnings] [akpm@linux-foudnation.org: redo intrusive kvm changes] Tested-by: Peter Senna Tschudin <peter.senna@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/rds')
-rw-r--r--net/rds/bind.c3
-rw-r--r--net/rds/connection.c9
2 files changed, 4 insertions, 8 deletions
diff --git a/net/rds/bind.c b/net/rds/bind.c
index 637bde56c9db..b5ad65a0067e 100644
--- a/net/rds/bind.c
+++ b/net/rds/bind.c
@@ -52,13 +52,12 @@ static struct rds_sock *rds_bind_lookup(__be32 addr, __be16 port,
52 struct rds_sock *insert) 52 struct rds_sock *insert)
53{ 53{
54 struct rds_sock *rs; 54 struct rds_sock *rs;
55 struct hlist_node *node;
56 struct hlist_head *head = hash_to_bucket(addr, port); 55 struct hlist_head *head = hash_to_bucket(addr, port);
57 u64 cmp; 56 u64 cmp;
58 u64 needle = ((u64)be32_to_cpu(addr) << 32) | be16_to_cpu(port); 57 u64 needle = ((u64)be32_to_cpu(addr) << 32) | be16_to_cpu(port);
59 58
60 rcu_read_lock(); 59 rcu_read_lock();
61 hlist_for_each_entry_rcu(rs, node, head, rs_bound_node) { 60 hlist_for_each_entry_rcu(rs, head, rs_bound_node) {
62 cmp = ((u64)be32_to_cpu(rs->rs_bound_addr) << 32) | 61 cmp = ((u64)be32_to_cpu(rs->rs_bound_addr) << 32) |
63 be16_to_cpu(rs->rs_bound_port); 62 be16_to_cpu(rs->rs_bound_port);
64 63
diff --git a/net/rds/connection.c b/net/rds/connection.c
index 9e07c756d1f9..642ad42c416b 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -69,9 +69,8 @@ static struct rds_connection *rds_conn_lookup(struct hlist_head *head,
69 struct rds_transport *trans) 69 struct rds_transport *trans)
70{ 70{
71 struct rds_connection *conn, *ret = NULL; 71 struct rds_connection *conn, *ret = NULL;
72 struct hlist_node *pos;
73 72
74 hlist_for_each_entry_rcu(conn, pos, head, c_hash_node) { 73 hlist_for_each_entry_rcu(conn, head, c_hash_node) {
75 if (conn->c_faddr == faddr && conn->c_laddr == laddr && 74 if (conn->c_faddr == faddr && conn->c_laddr == laddr &&
76 conn->c_trans == trans) { 75 conn->c_trans == trans) {
77 ret = conn; 76 ret = conn;
@@ -376,7 +375,6 @@ static void rds_conn_message_info(struct socket *sock, unsigned int len,
376 int want_send) 375 int want_send)
377{ 376{
378 struct hlist_head *head; 377 struct hlist_head *head;
379 struct hlist_node *pos;
380 struct list_head *list; 378 struct list_head *list;
381 struct rds_connection *conn; 379 struct rds_connection *conn;
382 struct rds_message *rm; 380 struct rds_message *rm;
@@ -390,7 +388,7 @@ static void rds_conn_message_info(struct socket *sock, unsigned int len,
390 388
391 for (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash); 389 for (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash);
392 i++, head++) { 390 i++, head++) {
393 hlist_for_each_entry_rcu(conn, pos, head, c_hash_node) { 391 hlist_for_each_entry_rcu(conn, head, c_hash_node) {
394 if (want_send) 392 if (want_send)
395 list = &conn->c_send_queue; 393 list = &conn->c_send_queue;
396 else 394 else
@@ -439,7 +437,6 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len,
439{ 437{
440 uint64_t buffer[(item_len + 7) / 8]; 438 uint64_t buffer[(item_len + 7) / 8];
441 struct hlist_head *head; 439 struct hlist_head *head;
442 struct hlist_node *pos;
443 struct rds_connection *conn; 440 struct rds_connection *conn;
444 size_t i; 441 size_t i;
445 442
@@ -450,7 +447,7 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len,
450 447
451 for (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash); 448 for (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash);
452 i++, head++) { 449 i++, head++) {
453 hlist_for_each_entry_rcu(conn, pos, head, c_hash_node) { 450 hlist_for_each_entry_rcu(conn, head, c_hash_node) {
454 451
455 /* XXX no c_lock usage.. */ 452 /* XXX no c_lock usage.. */
456 if (!visitor(conn, buffer)) 453 if (!visitor(conn, buffer))