aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/raid
diff options
context:
space:
mode:
authorCheng Renquan <crquan@gmail.com>2009-01-08 16:31:08 -0500
committerNeilBrown <neilb@suse.de>2009-01-08 16:31:08 -0500
commit159ec1fc060ab22b157a62364045f5e98749c4d3 (patch)
tree1de0edfd782245b271d2898e36ae76c00e1e1b6d /include/linux/raid
parentccacc7d2cf03114a24ab903f710118e9e5d43273 (diff)
md: use list_for_each_entry macro directly
The rdev_for_each macro defined in <linux/raid/md_k.h> is identical to list_for_each_entry_safe, from <linux/list.h>, it should be defined to use list_for_each_entry_safe, instead of reinventing the wheel. But some calls to each_entry_safe don't really need a safe version, just a direct list_for_each_entry is enough, this could save a temp variable (tmp) in every function that used rdev_for_each. In this patch, most rdev_for_each loops are replaced by list_for_each_entry, totally save many tmp vars; and only in the other situations that will call list_del to delete an entry, the safe version is used. Signed-off-by: Cheng Renquan <crquan@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'include/linux/raid')
-rw-r--r--include/linux/raid/md_k.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 663803eaf0de..8f9a54c1fb0e 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -335,17 +335,14 @@ static inline char * mdname (mddev_t * mddev)
335 * iterates through some rdev ringlist. It's safe to remove the 335 * iterates through some rdev ringlist. It's safe to remove the
336 * current 'rdev'. Dont touch 'tmp' though. 336 * current 'rdev'. Dont touch 'tmp' though.
337 */ 337 */
338#define rdev_for_each_list(rdev, tmp, list) \ 338#define rdev_for_each_list(rdev, tmp, head) \
339 \ 339 list_for_each_entry_safe(rdev, tmp, head, same_set)
340 for ((tmp) = (list).next; \ 340
341 (rdev) = (list_entry((tmp), mdk_rdev_t, same_set)), \
342 (tmp) = (tmp)->next, (tmp)->prev != &(list) \
343 ; )
344/* 341/*
345 * iterates through the 'same array disks' ringlist 342 * iterates through the 'same array disks' ringlist
346 */ 343 */
347#define rdev_for_each(rdev, tmp, mddev) \ 344#define rdev_for_each(rdev, tmp, mddev) \
348 rdev_for_each_list(rdev, tmp, (mddev)->disks) 345 list_for_each_entry_safe(rdev, tmp, &((mddev)->disks), same_set)
349 346
350#define rdev_for_each_rcu(rdev, mddev) \ 347#define rdev_for_each_rcu(rdev, mddev) \
351 list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set) 348 list_for_each_entry_rcu(rdev, &((mddev)->disks), same_set)