diff options
author | Cheng Renquan <crquan@gmail.com> | 2009-01-08 16:31:08 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-01-08 16:31:08 -0500 |
commit | 159ec1fc060ab22b157a62364045f5e98749c4d3 (patch) | |
tree | 1de0edfd782245b271d2898e36ae76c00e1e1b6d /drivers/md/raid0.c | |
parent | ccacc7d2cf03114a24ab903f710118e9e5d43273 (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 'drivers/md/raid0.c')
-rw-r--r-- | drivers/md/raid0.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 90f5b24f6e6c..c605ba805586 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -57,7 +57,6 @@ static int create_strip_zones (mddev_t *mddev) | |||
57 | sector_t min_spacing; | 57 | sector_t min_spacing; |
58 | raid0_conf_t *conf = mddev_to_conf(mddev); | 58 | raid0_conf_t *conf = mddev_to_conf(mddev); |
59 | mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev; | 59 | mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev; |
60 | struct list_head *tmp1, *tmp2; | ||
61 | struct strip_zone *zone; | 60 | struct strip_zone *zone; |
62 | int cnt; | 61 | int cnt; |
63 | char b[BDEVNAME_SIZE]; | 62 | char b[BDEVNAME_SIZE]; |
@@ -67,11 +66,11 @@ static int create_strip_zones (mddev_t *mddev) | |||
67 | */ | 66 | */ |
68 | conf->nr_strip_zones = 0; | 67 | conf->nr_strip_zones = 0; |
69 | 68 | ||
70 | rdev_for_each(rdev1, tmp1, mddev) { | 69 | list_for_each_entry(rdev1, &mddev->disks, same_set) { |
71 | printk(KERN_INFO "raid0: looking at %s\n", | 70 | printk(KERN_INFO "raid0: looking at %s\n", |
72 | bdevname(rdev1->bdev,b)); | 71 | bdevname(rdev1->bdev,b)); |
73 | c = 0; | 72 | c = 0; |
74 | rdev_for_each(rdev2, tmp2, mddev) { | 73 | list_for_each_entry(rdev2, &mddev->disks, same_set) { |
75 | printk(KERN_INFO "raid0: comparing %s(%llu)", | 74 | printk(KERN_INFO "raid0: comparing %s(%llu)", |
76 | bdevname(rdev1->bdev,b), | 75 | bdevname(rdev1->bdev,b), |
77 | (unsigned long long)rdev1->size); | 76 | (unsigned long long)rdev1->size); |
@@ -120,7 +119,7 @@ static int create_strip_zones (mddev_t *mddev) | |||
120 | cnt = 0; | 119 | cnt = 0; |
121 | smallest = NULL; | 120 | smallest = NULL; |
122 | zone->dev = conf->devlist; | 121 | zone->dev = conf->devlist; |
123 | rdev_for_each(rdev1, tmp1, mddev) { | 122 | list_for_each_entry(rdev1, &mddev->disks, same_set) { |
124 | int j = rdev1->raid_disk; | 123 | int j = rdev1->raid_disk; |
125 | 124 | ||
126 | if (j < 0 || j >= mddev->raid_disks) { | 125 | if (j < 0 || j >= mddev->raid_disks) { |
@@ -268,7 +267,6 @@ static int raid0_run (mddev_t *mddev) | |||
268 | s64 sectors; | 267 | s64 sectors; |
269 | raid0_conf_t *conf; | 268 | raid0_conf_t *conf; |
270 | mdk_rdev_t *rdev; | 269 | mdk_rdev_t *rdev; |
271 | struct list_head *tmp; | ||
272 | 270 | ||
273 | if (mddev->chunk_size == 0) { | 271 | if (mddev->chunk_size == 0) { |
274 | printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); | 272 | printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); |
@@ -294,7 +292,7 @@ static int raid0_run (mddev_t *mddev) | |||
294 | 292 | ||
295 | /* calculate array device size */ | 293 | /* calculate array device size */ |
296 | mddev->array_sectors = 0; | 294 | mddev->array_sectors = 0; |
297 | rdev_for_each(rdev, tmp, mddev) | 295 | list_for_each_entry(rdev, &mddev->disks, same_set) |
298 | mddev->array_sectors += rdev->size * 2; | 296 | mddev->array_sectors += rdev->size * 2; |
299 | 297 | ||
300 | printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", | 298 | printk(KERN_INFO "raid0 : md_size is %llu sectors.\n", |