diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2013-02-27 20:06:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:24 -0500 |
commit | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch) | |
tree | 3d465aea12b97683f26ffa38eba8744469de9997 /fs/notify/inode_mark.c | |
parent | 1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (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 'fs/notify/inode_mark.c')
-rw-r--r-- | fs/notify/inode_mark.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index f31e90fc050d..74825be65b7b 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c | |||
@@ -36,12 +36,11 @@ | |||
36 | static void fsnotify_recalc_inode_mask_locked(struct inode *inode) | 36 | static void fsnotify_recalc_inode_mask_locked(struct inode *inode) |
37 | { | 37 | { |
38 | struct fsnotify_mark *mark; | 38 | struct fsnotify_mark *mark; |
39 | struct hlist_node *pos; | ||
40 | __u32 new_mask = 0; | 39 | __u32 new_mask = 0; |
41 | 40 | ||
42 | assert_spin_locked(&inode->i_lock); | 41 | assert_spin_locked(&inode->i_lock); |
43 | 42 | ||
44 | hlist_for_each_entry(mark, pos, &inode->i_fsnotify_marks, i.i_list) | 43 | hlist_for_each_entry(mark, &inode->i_fsnotify_marks, i.i_list) |
45 | new_mask |= mark->mask; | 44 | new_mask |= mark->mask; |
46 | inode->i_fsnotify_mask = new_mask; | 45 | inode->i_fsnotify_mask = new_mask; |
47 | } | 46 | } |
@@ -87,11 +86,11 @@ void fsnotify_destroy_inode_mark(struct fsnotify_mark *mark) | |||
87 | void fsnotify_clear_marks_by_inode(struct inode *inode) | 86 | void fsnotify_clear_marks_by_inode(struct inode *inode) |
88 | { | 87 | { |
89 | struct fsnotify_mark *mark, *lmark; | 88 | struct fsnotify_mark *mark, *lmark; |
90 | struct hlist_node *pos, *n; | 89 | struct hlist_node *n; |
91 | LIST_HEAD(free_list); | 90 | LIST_HEAD(free_list); |
92 | 91 | ||
93 | spin_lock(&inode->i_lock); | 92 | spin_lock(&inode->i_lock); |
94 | hlist_for_each_entry_safe(mark, pos, n, &inode->i_fsnotify_marks, i.i_list) { | 93 | hlist_for_each_entry_safe(mark, n, &inode->i_fsnotify_marks, i.i_list) { |
95 | list_add(&mark->i.free_i_list, &free_list); | 94 | list_add(&mark->i.free_i_list, &free_list); |
96 | hlist_del_init_rcu(&mark->i.i_list); | 95 | hlist_del_init_rcu(&mark->i.i_list); |
97 | fsnotify_get_mark(mark); | 96 | fsnotify_get_mark(mark); |
@@ -129,11 +128,10 @@ static struct fsnotify_mark *fsnotify_find_inode_mark_locked( | |||
129 | struct inode *inode) | 128 | struct inode *inode) |
130 | { | 129 | { |
131 | struct fsnotify_mark *mark; | 130 | struct fsnotify_mark *mark; |
132 | struct hlist_node *pos; | ||
133 | 131 | ||
134 | assert_spin_locked(&inode->i_lock); | 132 | assert_spin_locked(&inode->i_lock); |
135 | 133 | ||
136 | hlist_for_each_entry(mark, pos, &inode->i_fsnotify_marks, i.i_list) { | 134 | hlist_for_each_entry(mark, &inode->i_fsnotify_marks, i.i_list) { |
137 | if (mark->group == group) { | 135 | if (mark->group == group) { |
138 | fsnotify_get_mark(mark); | 136 | fsnotify_get_mark(mark); |
139 | return mark; | 137 | return mark; |
@@ -194,8 +192,7 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
194 | struct fsnotify_group *group, struct inode *inode, | 192 | struct fsnotify_group *group, struct inode *inode, |
195 | int allow_dups) | 193 | int allow_dups) |
196 | { | 194 | { |
197 | struct fsnotify_mark *lmark; | 195 | struct fsnotify_mark *lmark, *last = NULL; |
198 | struct hlist_node *node, *last = NULL; | ||
199 | int ret = 0; | 196 | int ret = 0; |
200 | 197 | ||
201 | mark->flags |= FSNOTIFY_MARK_FLAG_INODE; | 198 | mark->flags |= FSNOTIFY_MARK_FLAG_INODE; |
@@ -214,8 +211,8 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
214 | } | 211 | } |
215 | 212 | ||
216 | /* should mark be in the middle of the current list? */ | 213 | /* should mark be in the middle of the current list? */ |
217 | hlist_for_each_entry(lmark, node, &inode->i_fsnotify_marks, i.i_list) { | 214 | hlist_for_each_entry(lmark, &inode->i_fsnotify_marks, i.i_list) { |
218 | last = node; | 215 | last = lmark; |
219 | 216 | ||
220 | if ((lmark->group == group) && !allow_dups) { | 217 | if ((lmark->group == group) && !allow_dups) { |
221 | ret = -EEXIST; | 218 | ret = -EEXIST; |
@@ -235,7 +232,7 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark, | |||
235 | 232 | ||
236 | BUG_ON(last == NULL); | 233 | BUG_ON(last == NULL); |
237 | /* mark should be the last entry. last is the current last entry */ | 234 | /* mark should be the last entry. last is the current last entry */ |
238 | hlist_add_after_rcu(last, &mark->i.i_list); | 235 | hlist_add_after_rcu(&last->i.i_list, &mark->i.i_list); |
239 | out: | 236 | out: |
240 | fsnotify_recalc_inode_mask_locked(inode); | 237 | fsnotify_recalc_inode_mask_locked(inode); |
241 | spin_unlock(&inode->i_lock); | 238 | spin_unlock(&inode->i_lock); |