aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
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 /drivers/md
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 'drivers/md')
-rw-r--r--drivers/md/dm-bio-prison.c3
-rw-r--r--drivers/md/dm-bufio.c3
-rw-r--r--drivers/md/dm-snap.c3
-rw-r--r--drivers/md/persistent-data/dm-transaction-manager.c7
-rw-r--r--drivers/md/raid5.c3
5 files changed, 7 insertions, 12 deletions
diff --git a/drivers/md/dm-bio-prison.c b/drivers/md/dm-bio-prison.c
index aefb78e3cbf9..d9d3f1c7b662 100644
--- a/drivers/md/dm-bio-prison.c
+++ b/drivers/md/dm-bio-prison.c
@@ -106,9 +106,8 @@ static struct dm_bio_prison_cell *__search_bucket(struct hlist_head *bucket,
106 struct dm_cell_key *key) 106 struct dm_cell_key *key)
107{ 107{
108 struct dm_bio_prison_cell *cell; 108 struct dm_bio_prison_cell *cell;
109 struct hlist_node *tmp;
110 109
111 hlist_for_each_entry(cell, tmp, bucket, list) 110 hlist_for_each_entry(cell, bucket, list)
112 if (keys_equal(&cell->key, key)) 111 if (keys_equal(&cell->key, key))
113 return cell; 112 return cell;
114 113
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 651ca79881dd..93205e32a004 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -859,9 +859,8 @@ static void __check_watermark(struct dm_bufio_client *c)
859static struct dm_buffer *__find(struct dm_bufio_client *c, sector_t block) 859static struct dm_buffer *__find(struct dm_bufio_client *c, sector_t block)
860{ 860{
861 struct dm_buffer *b; 861 struct dm_buffer *b;
862 struct hlist_node *hn;
863 862
864 hlist_for_each_entry(b, hn, &c->cache_hash[DM_BUFIO_HASH(block)], 863 hlist_for_each_entry(b, &c->cache_hash[DM_BUFIO_HASH(block)],
865 hash_list) { 864 hash_list) {
866 dm_bufio_cond_resched(); 865 dm_bufio_cond_resched();
867 if (b->block == block) 866 if (b->block == block)
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 59fc18ae52c2..10079e07edf4 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -227,12 +227,11 @@ static void stop_tracking_chunk(struct dm_snapshot *s, struct bio *bio)
227static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk) 227static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk)
228{ 228{
229 struct dm_snap_tracked_chunk *c; 229 struct dm_snap_tracked_chunk *c;
230 struct hlist_node *hn;
231 int found = 0; 230 int found = 0;
232 231
233 spin_lock_irq(&s->tracked_chunk_lock); 232 spin_lock_irq(&s->tracked_chunk_lock);
234 233
235 hlist_for_each_entry(c, hn, 234 hlist_for_each_entry(c,
236 &s->tracked_chunk_hash[DM_TRACKED_CHUNK_HASH(chunk)], node) { 235 &s->tracked_chunk_hash[DM_TRACKED_CHUNK_HASH(chunk)], node) {
237 if (c->chunk == chunk) { 236 if (c->chunk == chunk) {
238 found = 1; 237 found = 1;
diff --git a/drivers/md/persistent-data/dm-transaction-manager.c b/drivers/md/persistent-data/dm-transaction-manager.c
index 7b17a1fdeaf9..81da1a26042e 100644
--- a/drivers/md/persistent-data/dm-transaction-manager.c
+++ b/drivers/md/persistent-data/dm-transaction-manager.c
@@ -46,10 +46,9 @@ static int is_shadow(struct dm_transaction_manager *tm, dm_block_t b)
46 int r = 0; 46 int r = 0;
47 unsigned bucket = dm_hash_block(b, DM_HASH_MASK); 47 unsigned bucket = dm_hash_block(b, DM_HASH_MASK);
48 struct shadow_info *si; 48 struct shadow_info *si;
49 struct hlist_node *n;
50 49
51 spin_lock(&tm->lock); 50 spin_lock(&tm->lock);
52 hlist_for_each_entry(si, n, tm->buckets + bucket, hlist) 51 hlist_for_each_entry(si, tm->buckets + bucket, hlist)
53 if (si->where == b) { 52 if (si->where == b) {
54 r = 1; 53 r = 1;
55 break; 54 break;
@@ -81,14 +80,14 @@ static void insert_shadow(struct dm_transaction_manager *tm, dm_block_t b)
81static void wipe_shadow_table(struct dm_transaction_manager *tm) 80static void wipe_shadow_table(struct dm_transaction_manager *tm)
82{ 81{
83 struct shadow_info *si; 82 struct shadow_info *si;
84 struct hlist_node *n, *tmp; 83 struct hlist_node *tmp;
85 struct hlist_head *bucket; 84 struct hlist_head *bucket;
86 int i; 85 int i;
87 86
88 spin_lock(&tm->lock); 87 spin_lock(&tm->lock);
89 for (i = 0; i < DM_HASH_SIZE; i++) { 88 for (i = 0; i < DM_HASH_SIZE; i++) {
90 bucket = tm->buckets + i; 89 bucket = tm->buckets + i;
91 hlist_for_each_entry_safe(si, n, tmp, bucket, hlist) 90 hlist_for_each_entry_safe(si, tmp, bucket, hlist)
92 kfree(si); 91 kfree(si);
93 92
94 INIT_HLIST_HEAD(bucket); 93 INIT_HLIST_HEAD(bucket);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 19d77a026639..697f026cb318 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -365,10 +365,9 @@ static struct stripe_head *__find_stripe(struct r5conf *conf, sector_t sector,
365 short generation) 365 short generation)
366{ 366{
367 struct stripe_head *sh; 367 struct stripe_head *sh;
368 struct hlist_node *hn;
369 368
370 pr_debug("__find_stripe, sector %llu\n", (unsigned long long)sector); 369 pr_debug("__find_stripe, sector %llu\n", (unsigned long long)sector);
371 hlist_for_each_entry(sh, hn, stripe_hash(conf, sector), hash) 370 hlist_for_each_entry(sh, stripe_hash(conf, sector), hash)
372 if (sh->sector == sector && sh->generation == generation) 371 if (sh->sector == sector && sh->generation == generation)
373 return sh; 372 return sh;
374 pr_debug("__stripe %llu not in cache\n", (unsigned long long)sector); 373 pr_debug("__stripe %llu not in cache\n", (unsigned long long)sector);