aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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 /drivers
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 'drivers')
-rw-r--r--drivers/md/bitmap.c3
-rw-r--r--drivers/md/faulty.c3
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c107
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c10
-rw-r--r--drivers/md/raid1.c3
-rw-r--r--drivers/md/raid10.c3
-rw-r--r--drivers/md/raid5.c8
9 files changed, 56 insertions, 87 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 666b7ba47ec5..719943763391 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -215,7 +215,6 @@ static struct page *read_sb_page(mddev_t *mddev, long offset,
215 /* choose a good rdev and read the page from there */ 215 /* choose a good rdev and read the page from there */
216 216
217 mdk_rdev_t *rdev; 217 mdk_rdev_t *rdev;
218 struct list_head *tmp;
219 sector_t target; 218 sector_t target;
220 219
221 if (!page) 220 if (!page)
@@ -223,7 +222,7 @@ static struct page *read_sb_page(mddev_t *mddev, long offset,
223 if (!page) 222 if (!page)
224 return ERR_PTR(-ENOMEM); 223 return ERR_PTR(-ENOMEM);
225 224
226 rdev_for_each(rdev, tmp, mddev) { 225 list_for_each_entry(rdev, &mddev->disks, same_set) {
227 if (! test_bit(In_sync, &rdev->flags) 226 if (! test_bit(In_sync, &rdev->flags)
228 || test_bit(Faulty, &rdev->flags)) 227 || test_bit(Faulty, &rdev->flags))
229 continue; 228 continue;
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index f26c1f9a475b..86d9adf90e79 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -283,7 +283,6 @@ static int reconfig(mddev_t *mddev, int layout, int chunk_size)
283static int run(mddev_t *mddev) 283static int run(mddev_t *mddev)
284{ 284{
285 mdk_rdev_t *rdev; 285 mdk_rdev_t *rdev;
286 struct list_head *tmp;
287 int i; 286 int i;
288 287
289 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL); 288 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL);
@@ -296,7 +295,7 @@ static int run(mddev_t *mddev)
296 } 295 }
297 conf->nfaults = 0; 296 conf->nfaults = 0;
298 297
299 rdev_for_each(rdev, tmp, mddev) 298 list_for_each_entry(rdev, &mddev->disks, same_set)
300 conf->rdev = rdev; 299 conf->rdev = rdev;
301 300
302 mddev->array_sectors = mddev->size * 2; 301 mddev->array_sectors = mddev->size * 2;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 3b90c5c924ec..1e3aea9eecf1 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -105,7 +105,6 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
105 int i, nb_zone, cnt; 105 int i, nb_zone, cnt;
106 sector_t min_sectors; 106 sector_t min_sectors;
107 sector_t curr_sector; 107 sector_t curr_sector;
108 struct list_head *tmp;
109 108
110 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t), 109 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t),
111 GFP_KERNEL); 110 GFP_KERNEL);
@@ -115,7 +114,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
115 cnt = 0; 114 cnt = 0;
116 conf->array_sectors = 0; 115 conf->array_sectors = 0;
117 116
118 rdev_for_each(rdev, tmp, mddev) { 117 list_for_each_entry(rdev, &mddev->disks, same_set) {
119 int j = rdev->raid_disk; 118 int j = rdev->raid_disk;
120 dev_info_t *disk = conf->disks + j; 119 dev_info_t *disk = conf->disks + j;
121 120
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ee759b193e9a..58be665bb46b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -307,25 +307,23 @@ static inline void mddev_unlock(mddev_t * mddev)
307 307
308static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) 308static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr)
309{ 309{
310 mdk_rdev_t * rdev; 310 mdk_rdev_t *rdev;
311 struct list_head *tmp;
312 311
313 rdev_for_each(rdev, tmp, mddev) { 312 list_for_each_entry(rdev, &mddev->disks, same_set)
314 if (rdev->desc_nr == nr) 313 if (rdev->desc_nr == nr)
315 return rdev; 314 return rdev;
316 } 315
317 return NULL; 316 return NULL;
318} 317}
319 318
320static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev) 319static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev)
321{ 320{
322 struct list_head *tmp;
323 mdk_rdev_t *rdev; 321 mdk_rdev_t *rdev;
324 322
325 rdev_for_each(rdev, tmp, mddev) { 323 list_for_each_entry(rdev, &mddev->disks, same_set)
326 if (rdev->bdev->bd_dev == dev) 324 if (rdev->bdev->bd_dev == dev)
327 return rdev; 325 return rdev;
328 } 326
329 return NULL; 327 return NULL;
330} 328}
331 329
@@ -861,7 +859,6 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
861static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) 859static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
862{ 860{
863 mdp_super_t *sb; 861 mdp_super_t *sb;
864 struct list_head *tmp;
865 mdk_rdev_t *rdev2; 862 mdk_rdev_t *rdev2;
866 int next_spare = mddev->raid_disks; 863 int next_spare = mddev->raid_disks;
867 864
@@ -933,7 +930,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
933 sb->state |= (1<<MD_SB_BITMAP_PRESENT); 930 sb->state |= (1<<MD_SB_BITMAP_PRESENT);
934 931
935 sb->disks[0].state = (1<<MD_DISK_REMOVED); 932 sb->disks[0].state = (1<<MD_DISK_REMOVED);
936 rdev_for_each(rdev2, tmp, mddev) { 933 list_for_each_entry(rdev2, &mddev->disks, same_set) {
937 mdp_disk_t *d; 934 mdp_disk_t *d;
938 int desc_nr; 935 int desc_nr;
939 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags) 936 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags)
@@ -1259,7 +1256,6 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1259static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) 1256static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1260{ 1257{
1261 struct mdp_superblock_1 *sb; 1258 struct mdp_superblock_1 *sb;
1262 struct list_head *tmp;
1263 mdk_rdev_t *rdev2; 1259 mdk_rdev_t *rdev2;
1264 int max_dev, i; 1260 int max_dev, i;
1265 /* make rdev->sb match mddev and rdev data. */ 1261 /* make rdev->sb match mddev and rdev data. */
@@ -1307,7 +1303,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1307 } 1303 }
1308 1304
1309 max_dev = 0; 1305 max_dev = 0;
1310 rdev_for_each(rdev2, tmp, mddev) 1306 list_for_each_entry(rdev2, &mddev->disks, same_set)
1311 if (rdev2->desc_nr+1 > max_dev) 1307 if (rdev2->desc_nr+1 > max_dev)
1312 max_dev = rdev2->desc_nr+1; 1308 max_dev = rdev2->desc_nr+1;
1313 1309
@@ -1316,7 +1312,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1316 for (i=0; i<max_dev;i++) 1312 for (i=0; i<max_dev;i++)
1317 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1313 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1318 1314
1319 rdev_for_each(rdev2, tmp, mddev) { 1315 list_for_each_entry(rdev2, &mddev->disks, same_set) {
1320 i = rdev2->desc_nr; 1316 i = rdev2->desc_nr;
1321 if (test_bit(Faulty, &rdev2->flags)) 1317 if (test_bit(Faulty, &rdev2->flags))
1322 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1318 sb->dev_roles[i] = cpu_to_le16(0xfffe);
@@ -1571,8 +1567,7 @@ static void kick_rdev_from_array(mdk_rdev_t * rdev)
1571 1567
1572static void export_array(mddev_t *mddev) 1568static void export_array(mddev_t *mddev)
1573{ 1569{
1574 struct list_head *tmp; 1570 mdk_rdev_t *rdev, *tmp;
1575 mdk_rdev_t *rdev;
1576 1571
1577 rdev_for_each(rdev, tmp, mddev) { 1572 rdev_for_each(rdev, tmp, mddev) {
1578 if (!rdev->mddev) { 1573 if (!rdev->mddev) {
@@ -1643,7 +1638,7 @@ static void print_rdev(mdk_rdev_t *rdev)
1643 1638
1644static void md_print_devices(void) 1639static void md_print_devices(void)
1645{ 1640{
1646 struct list_head *tmp, *tmp2; 1641 struct list_head *tmp;
1647 mdk_rdev_t *rdev; 1642 mdk_rdev_t *rdev;
1648 mddev_t *mddev; 1643 mddev_t *mddev;
1649 char b[BDEVNAME_SIZE]; 1644 char b[BDEVNAME_SIZE];
@@ -1658,11 +1653,11 @@ static void md_print_devices(void)
1658 bitmap_print_sb(mddev->bitmap); 1653 bitmap_print_sb(mddev->bitmap);
1659 else 1654 else
1660 printk("%s: ", mdname(mddev)); 1655 printk("%s: ", mdname(mddev));
1661 rdev_for_each(rdev, tmp2, mddev) 1656 list_for_each_entry(rdev, &mddev->disks, same_set)
1662 printk("<%s>", bdevname(rdev->bdev,b)); 1657 printk("<%s>", bdevname(rdev->bdev,b));
1663 printk("\n"); 1658 printk("\n");
1664 1659
1665 rdev_for_each(rdev, tmp2, mddev) 1660 list_for_each_entry(rdev, &mddev->disks, same_set)
1666 print_rdev(rdev); 1661 print_rdev(rdev);
1667 } 1662 }
1668 printk("md: **********************************\n"); 1663 printk("md: **********************************\n");
@@ -1679,9 +1674,8 @@ static void sync_sbs(mddev_t * mddev, int nospares)
1679 * with the rest of the array) 1674 * with the rest of the array)
1680 */ 1675 */
1681 mdk_rdev_t *rdev; 1676 mdk_rdev_t *rdev;
1682 struct list_head *tmp;
1683 1677
1684 rdev_for_each(rdev, tmp, mddev) { 1678 list_for_each_entry(rdev, &mddev->disks, same_set) {
1685 if (rdev->sb_events == mddev->events || 1679 if (rdev->sb_events == mddev->events ||
1686 (nospares && 1680 (nospares &&
1687 rdev->raid_disk < 0 && 1681 rdev->raid_disk < 0 &&
@@ -1699,7 +1693,6 @@ static void sync_sbs(mddev_t * mddev, int nospares)
1699 1693
1700static void md_update_sb(mddev_t * mddev, int force_change) 1694static void md_update_sb(mddev_t * mddev, int force_change)
1701{ 1695{
1702 struct list_head *tmp;
1703 mdk_rdev_t *rdev; 1696 mdk_rdev_t *rdev;
1704 int sync_req; 1697 int sync_req;
1705 int nospares = 0; 1698 int nospares = 0;
@@ -1790,7 +1783,7 @@ repeat:
1790 mdname(mddev),mddev->in_sync); 1783 mdname(mddev),mddev->in_sync);
1791 1784
1792 bitmap_update_sb(mddev->bitmap); 1785 bitmap_update_sb(mddev->bitmap);
1793 rdev_for_each(rdev, tmp, mddev) { 1786 list_for_each_entry(rdev, &mddev->disks, same_set) {
1794 char b[BDEVNAME_SIZE]; 1787 char b[BDEVNAME_SIZE];
1795 dprintk(KERN_INFO "md: "); 1788 dprintk(KERN_INFO "md: ");
1796 if (rdev->sb_loaded != 1) 1789 if (rdev->sb_loaded != 1)
@@ -1999,7 +1992,6 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1999 md_wakeup_thread(rdev->mddev->thread); 1992 md_wakeup_thread(rdev->mddev->thread);
2000 } else if (rdev->mddev->pers) { 1993 } else if (rdev->mddev->pers) {
2001 mdk_rdev_t *rdev2; 1994 mdk_rdev_t *rdev2;
2002 struct list_head *tmp;
2003 /* Activating a spare .. or possibly reactivating 1995 /* Activating a spare .. or possibly reactivating
2004 * if we every get bitmaps working here. 1996 * if we every get bitmaps working here.
2005 */ 1997 */
@@ -2010,7 +2002,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2010 if (rdev->mddev->pers->hot_add_disk == NULL) 2002 if (rdev->mddev->pers->hot_add_disk == NULL)
2011 return -EINVAL; 2003 return -EINVAL;
2012 2004
2013 rdev_for_each(rdev2, tmp, rdev->mddev) 2005 list_for_each_entry(rdev2, &rdev->mddev->disks, same_set)
2014 if (rdev2->raid_disk == slot) 2006 if (rdev2->raid_disk == slot)
2015 return -EEXIST; 2007 return -EEXIST;
2016 2008
@@ -2125,14 +2117,14 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2125 */ 2117 */
2126 mddev_t *mddev; 2118 mddev_t *mddev;
2127 int overlap = 0; 2119 int overlap = 0;
2128 struct list_head *tmp, *tmp2; 2120 struct list_head *tmp;
2129 2121
2130 mddev_unlock(my_mddev); 2122 mddev_unlock(my_mddev);
2131 for_each_mddev(mddev, tmp) { 2123 for_each_mddev(mddev, tmp) {
2132 mdk_rdev_t *rdev2; 2124 mdk_rdev_t *rdev2;
2133 2125
2134 mddev_lock(mddev); 2126 mddev_lock(mddev);
2135 rdev_for_each(rdev2, tmp2, mddev) 2127 list_for_each_entry(rdev2, &mddev->disks, same_set)
2136 if (test_bit(AllReserved, &rdev2->flags) || 2128 if (test_bit(AllReserved, &rdev2->flags) ||
2137 (rdev->bdev == rdev2->bdev && 2129 (rdev->bdev == rdev2->bdev &&
2138 rdev != rdev2 && 2130 rdev != rdev2 &&
@@ -2328,8 +2320,7 @@ abort_free:
2328static void analyze_sbs(mddev_t * mddev) 2320static void analyze_sbs(mddev_t * mddev)
2329{ 2321{
2330 int i; 2322 int i;
2331 struct list_head *tmp; 2323 mdk_rdev_t *rdev, *freshest, *tmp;
2332 mdk_rdev_t *rdev, *freshest;
2333 char b[BDEVNAME_SIZE]; 2324 char b[BDEVNAME_SIZE];
2334 2325
2335 freshest = NULL; 2326 freshest = NULL;
@@ -3501,7 +3492,6 @@ static int do_md_run(mddev_t * mddev)
3501{ 3492{
3502 int err; 3493 int err;
3503 int chunk_size; 3494 int chunk_size;
3504 struct list_head *tmp;
3505 mdk_rdev_t *rdev; 3495 mdk_rdev_t *rdev;
3506 struct gendisk *disk; 3496 struct gendisk *disk;
3507 struct mdk_personality *pers; 3497 struct mdk_personality *pers;
@@ -3540,7 +3530,7 @@ static int do_md_run(mddev_t * mddev)
3540 } 3530 }
3541 3531
3542 /* devices must have minimum size of one chunk */ 3532 /* devices must have minimum size of one chunk */
3543 rdev_for_each(rdev, tmp, mddev) { 3533 list_for_each_entry(rdev, &mddev->disks, same_set) {
3544 if (test_bit(Faulty, &rdev->flags)) 3534 if (test_bit(Faulty, &rdev->flags))
3545 continue; 3535 continue;
3546 if (rdev->size < chunk_size / 1024) { 3536 if (rdev->size < chunk_size / 1024) {
@@ -3565,7 +3555,7 @@ static int do_md_run(mddev_t * mddev)
3565 * the only valid external interface is through the md 3555 * the only valid external interface is through the md
3566 * device. 3556 * device.
3567 */ 3557 */
3568 rdev_for_each(rdev, tmp, mddev) { 3558 list_for_each_entry(rdev, &mddev->disks, same_set) {
3569 if (test_bit(Faulty, &rdev->flags)) 3559 if (test_bit(Faulty, &rdev->flags))
3570 continue; 3560 continue;
3571 sync_blockdev(rdev->bdev); 3561 sync_blockdev(rdev->bdev);
@@ -3630,10 +3620,10 @@ static int do_md_run(mddev_t * mddev)
3630 */ 3620 */
3631 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; 3621 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
3632 mdk_rdev_t *rdev2; 3622 mdk_rdev_t *rdev2;
3633 struct list_head *tmp2;
3634 int warned = 0; 3623 int warned = 0;
3635 rdev_for_each(rdev, tmp, mddev) { 3624
3636 rdev_for_each(rdev2, tmp2, mddev) { 3625 list_for_each_entry(rdev, &mddev->disks, same_set)
3626 list_for_each_entry(rdev2, &mddev->disks, same_set) {
3637 if (rdev < rdev2 && 3627 if (rdev < rdev2 &&
3638 rdev->bdev->bd_contains == 3628 rdev->bdev->bd_contains ==
3639 rdev2->bdev->bd_contains) { 3629 rdev2->bdev->bd_contains) {
@@ -3647,7 +3637,7 @@ static int do_md_run(mddev_t * mddev)
3647 warned = 1; 3637 warned = 1;
3648 } 3638 }
3649 } 3639 }
3650 } 3640
3651 if (warned) 3641 if (warned)
3652 printk(KERN_WARNING 3642 printk(KERN_WARNING
3653 "True protection against single-disk" 3643 "True protection against single-disk"
@@ -3695,7 +3685,7 @@ static int do_md_run(mddev_t * mddev)
3695 mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */ 3685 mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */
3696 mddev->in_sync = 1; 3686 mddev->in_sync = 1;
3697 3687
3698 rdev_for_each(rdev, tmp, mddev) 3688 list_for_each_entry(rdev, &mddev->disks, same_set)
3699 if (rdev->raid_disk >= 0) { 3689 if (rdev->raid_disk >= 0) {
3700 char nm[20]; 3690 char nm[20];
3701 sprintf(nm, "rd%d", rdev->raid_disk); 3691 sprintf(nm, "rd%d", rdev->raid_disk);
@@ -3726,9 +3716,8 @@ static int do_md_run(mddev_t * mddev)
3726 * it will remove the drives and not do the right thing 3716 * it will remove the drives and not do the right thing
3727 */ 3717 */
3728 if (mddev->degraded && !mddev->sync_thread) { 3718 if (mddev->degraded && !mddev->sync_thread) {
3729 struct list_head *rtmp;
3730 int spares = 0; 3719 int spares = 0;
3731 rdev_for_each(rdev, rtmp, mddev) 3720 list_for_each_entry(rdev, &mddev->disks, same_set)
3732 if (rdev->raid_disk >= 0 && 3721 if (rdev->raid_disk >= 0 &&
3733 !test_bit(In_sync, &rdev->flags) && 3722 !test_bit(In_sync, &rdev->flags) &&
3734 !test_bit(Faulty, &rdev->flags)) 3723 !test_bit(Faulty, &rdev->flags))
@@ -3888,7 +3877,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3888 */ 3877 */
3889 if (mode == 0) { 3878 if (mode == 0) {
3890 mdk_rdev_t *rdev; 3879 mdk_rdev_t *rdev;
3891 struct list_head *tmp;
3892 3880
3893 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 3881 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
3894 3882
@@ -3900,7 +3888,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3900 } 3888 }
3901 mddev->bitmap_offset = 0; 3889 mddev->bitmap_offset = 0;
3902 3890
3903 rdev_for_each(rdev, tmp, mddev) 3891 list_for_each_entry(rdev, &mddev->disks, same_set)
3904 if (rdev->raid_disk >= 0) { 3892 if (rdev->raid_disk >= 0) {
3905 char nm[20]; 3893 char nm[20];
3906 sprintf(nm, "rd%d", rdev->raid_disk); 3894 sprintf(nm, "rd%d", rdev->raid_disk);
@@ -3961,7 +3949,6 @@ out:
3961static void autorun_array(mddev_t *mddev) 3949static void autorun_array(mddev_t *mddev)
3962{ 3950{
3963 mdk_rdev_t *rdev; 3951 mdk_rdev_t *rdev;
3964 struct list_head *tmp;
3965 int err; 3952 int err;
3966 3953
3967 if (list_empty(&mddev->disks)) 3954 if (list_empty(&mddev->disks))
@@ -3969,7 +3956,7 @@ static void autorun_array(mddev_t *mddev)
3969 3956
3970 printk(KERN_INFO "md: running: "); 3957 printk(KERN_INFO "md: running: ");
3971 3958
3972 rdev_for_each(rdev, tmp, mddev) { 3959 list_for_each_entry(rdev, &mddev->disks, same_set) {
3973 char b[BDEVNAME_SIZE]; 3960 char b[BDEVNAME_SIZE];
3974 printk("<%s>", bdevname(rdev->bdev,b)); 3961 printk("<%s>", bdevname(rdev->bdev,b));
3975 } 3962 }
@@ -3996,8 +3983,7 @@ static void autorun_array(mddev_t *mddev)
3996 */ 3983 */
3997static void autorun_devices(int part) 3984static void autorun_devices(int part)
3998{ 3985{
3999 struct list_head *tmp; 3986 mdk_rdev_t *rdev0, *rdev, *tmp;
4000 mdk_rdev_t *rdev0, *rdev;
4001 mddev_t *mddev; 3987 mddev_t *mddev;
4002 char b[BDEVNAME_SIZE]; 3988 char b[BDEVNAME_SIZE];
4003 3989
@@ -4012,7 +3998,7 @@ static void autorun_devices(int part)
4012 printk(KERN_INFO "md: considering %s ...\n", 3998 printk(KERN_INFO "md: considering %s ...\n",
4013 bdevname(rdev0->bdev,b)); 3999 bdevname(rdev0->bdev,b));
4014 INIT_LIST_HEAD(&candidates); 4000 INIT_LIST_HEAD(&candidates);
4015 rdev_for_each_list(rdev, tmp, pending_raid_disks) 4001 rdev_for_each_list(rdev, tmp, &pending_raid_disks)
4016 if (super_90_load(rdev, rdev0, 0) >= 0) { 4002 if (super_90_load(rdev, rdev0, 0) >= 0) {
4017 printk(KERN_INFO "md: adding %s ...\n", 4003 printk(KERN_INFO "md: adding %s ...\n",
4018 bdevname(rdev->bdev,b)); 4004 bdevname(rdev->bdev,b));
@@ -4058,7 +4044,7 @@ static void autorun_devices(int part)
4058 } else { 4044 } else {
4059 printk(KERN_INFO "md: created %s\n", mdname(mddev)); 4045 printk(KERN_INFO "md: created %s\n", mdname(mddev));
4060 mddev->persistent = 1; 4046 mddev->persistent = 1;
4061 rdev_for_each_list(rdev, tmp, candidates) { 4047 rdev_for_each_list(rdev, tmp, &candidates) {
4062 list_del_init(&rdev->same_set); 4048 list_del_init(&rdev->same_set);
4063 if (bind_rdev_to_array(rdev, mddev)) 4049 if (bind_rdev_to_array(rdev, mddev))
4064 export_rdev(rdev); 4050 export_rdev(rdev);
@@ -4069,7 +4055,7 @@ static void autorun_devices(int part)
4069 /* on success, candidates will be empty, on error 4055 /* on success, candidates will be empty, on error
4070 * it won't... 4056 * it won't...
4071 */ 4057 */
4072 rdev_for_each_list(rdev, tmp, candidates) { 4058 rdev_for_each_list(rdev, tmp, &candidates) {
4073 list_del_init(&rdev->same_set); 4059 list_del_init(&rdev->same_set);
4074 export_rdev(rdev); 4060 export_rdev(rdev);
4075 } 4061 }
@@ -4098,10 +4084,9 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
4098 mdu_array_info_t info; 4084 mdu_array_info_t info;
4099 int nr,working,active,failed,spare; 4085 int nr,working,active,failed,spare;
4100 mdk_rdev_t *rdev; 4086 mdk_rdev_t *rdev;
4101 struct list_head *tmp;
4102 4087
4103 nr=working=active=failed=spare=0; 4088 nr=working=active=failed=spare=0;
4104 rdev_for_each(rdev, tmp, mddev) { 4089 list_for_each_entry(rdev, &mddev->disks, same_set) {
4105 nr++; 4090 nr++;
4106 if (test_bit(Faulty, &rdev->flags)) 4091 if (test_bit(Faulty, &rdev->flags))
4107 failed++; 4092 failed++;
@@ -4619,9 +4604,8 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
4619 4604
4620static int update_size(mddev_t *mddev, sector_t num_sectors) 4605static int update_size(mddev_t *mddev, sector_t num_sectors)
4621{ 4606{
4622 mdk_rdev_t * rdev; 4607 mdk_rdev_t *rdev;
4623 int rv; 4608 int rv;
4624 struct list_head *tmp;
4625 int fit = (num_sectors == 0); 4609 int fit = (num_sectors == 0);
4626 4610
4627 if (mddev->pers->resize == NULL) 4611 if (mddev->pers->resize == NULL)
@@ -4643,7 +4627,7 @@ static int update_size(mddev_t *mddev, sector_t num_sectors)
4643 * grow, and re-add. 4627 * grow, and re-add.
4644 */ 4628 */
4645 return -EBUSY; 4629 return -EBUSY;
4646 rdev_for_each(rdev, tmp, mddev) { 4630 list_for_each_entry(rdev, &mddev->disks, same_set) {
4647 sector_t avail; 4631 sector_t avail;
4648 avail = rdev->size * 2; 4632 avail = rdev->size * 2;
4649 4633
@@ -5192,11 +5176,10 @@ static void status_unused(struct seq_file *seq)
5192{ 5176{
5193 int i = 0; 5177 int i = 0;
5194 mdk_rdev_t *rdev; 5178 mdk_rdev_t *rdev;
5195 struct list_head *tmp;
5196 5179
5197 seq_printf(seq, "unused devices: "); 5180 seq_printf(seq, "unused devices: ");
5198 5181
5199 rdev_for_each_list(rdev, tmp, pending_raid_disks) { 5182 list_for_each_entry(rdev, &pending_raid_disks, same_set) {
5200 char b[BDEVNAME_SIZE]; 5183 char b[BDEVNAME_SIZE];
5201 i++; 5184 i++;
5202 seq_printf(seq, "%s ", 5185 seq_printf(seq, "%s ",
@@ -5355,7 +5338,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
5355{ 5338{
5356 mddev_t *mddev = v; 5339 mddev_t *mddev = v;
5357 sector_t size; 5340 sector_t size;
5358 struct list_head *tmp2;
5359 mdk_rdev_t *rdev; 5341 mdk_rdev_t *rdev;
5360 struct mdstat_info *mi = seq->private; 5342 struct mdstat_info *mi = seq->private;
5361 struct bitmap *bitmap; 5343 struct bitmap *bitmap;
@@ -5392,7 +5374,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
5392 } 5374 }
5393 5375
5394 size = 0; 5376 size = 0;
5395 rdev_for_each(rdev, tmp2, mddev) { 5377 list_for_each_entry(rdev, &mddev->disks, same_set) {
5396 char b[BDEVNAME_SIZE]; 5378 char b[BDEVNAME_SIZE];
5397 seq_printf(seq, " %s[%d]", 5379 seq_printf(seq, " %s[%d]",
5398 bdevname(rdev->bdev,b), rdev->desc_nr); 5380 bdevname(rdev->bdev,b), rdev->desc_nr);
@@ -5699,7 +5681,6 @@ void md_do_sync(mddev_t *mddev)
5699 struct list_head *tmp; 5681 struct list_head *tmp;
5700 sector_t last_check; 5682 sector_t last_check;
5701 int skipped = 0; 5683 int skipped = 0;
5702 struct list_head *rtmp;
5703 mdk_rdev_t *rdev; 5684 mdk_rdev_t *rdev;
5704 char *desc; 5685 char *desc;
5705 5686
@@ -5804,7 +5785,7 @@ void md_do_sync(mddev_t *mddev)
5804 /* recovery follows the physical size of devices */ 5785 /* recovery follows the physical size of devices */
5805 max_sectors = mddev->size << 1; 5786 max_sectors = mddev->size << 1;
5806 j = MaxSector; 5787 j = MaxSector;
5807 rdev_for_each(rdev, rtmp, mddev) 5788 list_for_each_entry(rdev, &mddev->disks, same_set)
5808 if (rdev->raid_disk >= 0 && 5789 if (rdev->raid_disk >= 0 &&
5809 !test_bit(Faulty, &rdev->flags) && 5790 !test_bit(Faulty, &rdev->flags) &&
5810 !test_bit(In_sync, &rdev->flags) && 5791 !test_bit(In_sync, &rdev->flags) &&
@@ -5954,7 +5935,7 @@ void md_do_sync(mddev_t *mddev)
5954 } else { 5935 } else {
5955 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) 5936 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
5956 mddev->curr_resync = MaxSector; 5937 mddev->curr_resync = MaxSector;
5957 rdev_for_each(rdev, rtmp, mddev) 5938 list_for_each_entry(rdev, &mddev->disks, same_set)
5958 if (rdev->raid_disk >= 0 && 5939 if (rdev->raid_disk >= 0 &&
5959 !test_bit(Faulty, &rdev->flags) && 5940 !test_bit(Faulty, &rdev->flags) &&
5960 !test_bit(In_sync, &rdev->flags) && 5941 !test_bit(In_sync, &rdev->flags) &&
@@ -5990,10 +5971,9 @@ EXPORT_SYMBOL_GPL(md_do_sync);
5990static int remove_and_add_spares(mddev_t *mddev) 5971static int remove_and_add_spares(mddev_t *mddev)
5991{ 5972{
5992 mdk_rdev_t *rdev; 5973 mdk_rdev_t *rdev;
5993 struct list_head *rtmp;
5994 int spares = 0; 5974 int spares = 0;
5995 5975
5996 rdev_for_each(rdev, rtmp, mddev) 5976 list_for_each_entry(rdev, &mddev->disks, same_set)
5997 if (rdev->raid_disk >= 0 && 5977 if (rdev->raid_disk >= 0 &&
5998 !test_bit(Blocked, &rdev->flags) && 5978 !test_bit(Blocked, &rdev->flags) &&
5999 (test_bit(Faulty, &rdev->flags) || 5979 (test_bit(Faulty, &rdev->flags) ||
@@ -6009,7 +5989,7 @@ static int remove_and_add_spares(mddev_t *mddev)
6009 } 5989 }
6010 5990
6011 if (mddev->degraded && ! mddev->ro) { 5991 if (mddev->degraded && ! mddev->ro) {
6012 rdev_for_each(rdev, rtmp, mddev) { 5992 list_for_each_entry(rdev, &mddev->disks, same_set) {
6013 if (rdev->raid_disk >= 0 && 5993 if (rdev->raid_disk >= 0 &&
6014 !test_bit(In_sync, &rdev->flags) && 5994 !test_bit(In_sync, &rdev->flags) &&
6015 !test_bit(Blocked, &rdev->flags)) 5995 !test_bit(Blocked, &rdev->flags))
@@ -6061,7 +6041,6 @@ static int remove_and_add_spares(mddev_t *mddev)
6061void md_check_recovery(mddev_t *mddev) 6041void md_check_recovery(mddev_t *mddev)
6062{ 6042{
6063 mdk_rdev_t *rdev; 6043 mdk_rdev_t *rdev;
6064 struct list_head *rtmp;
6065 6044
6066 6045
6067 if (mddev->bitmap) 6046 if (mddev->bitmap)
@@ -6125,7 +6104,7 @@ void md_check_recovery(mddev_t *mddev)
6125 if (mddev->flags) 6104 if (mddev->flags)
6126 md_update_sb(mddev, 0); 6105 md_update_sb(mddev, 0);
6127 6106
6128 rdev_for_each(rdev, rtmp, mddev) 6107 list_for_each_entry(rdev, &mddev->disks, same_set)
6129 if (test_and_clear_bit(StateChanged, &rdev->flags)) 6108 if (test_and_clear_bit(StateChanged, &rdev->flags))
6130 sysfs_notify_dirent(rdev->sysfs_state); 6109 sysfs_notify_dirent(rdev->sysfs_state);
6131 6110
@@ -6154,7 +6133,7 @@ void md_check_recovery(mddev_t *mddev)
6154 * information must be scrapped 6133 * information must be scrapped
6155 */ 6134 */
6156 if (!mddev->degraded) 6135 if (!mddev->degraded)
6157 rdev_for_each(rdev, rtmp, mddev) 6136 list_for_each_entry(rdev, &mddev->disks, same_set)
6158 rdev->saved_raid_disk = -1; 6137 rdev->saved_raid_disk = -1;
6159 6138
6160 mddev->recovery = 0; 6139 mddev->recovery = 0;
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index d4ac47d11279..f6d08f241671 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -408,7 +408,6 @@ static int multipath_run (mddev_t *mddev)
408 int disk_idx; 408 int disk_idx;
409 struct multipath_info *disk; 409 struct multipath_info *disk;
410 mdk_rdev_t *rdev; 410 mdk_rdev_t *rdev;
411 struct list_head *tmp;
412 411
413 if (mddev->level != LEVEL_MULTIPATH) { 412 if (mddev->level != LEVEL_MULTIPATH) {
414 printk("multipath: %s: raid level not set to multipath IO (%d)\n", 413 printk("multipath: %s: raid level not set to multipath IO (%d)\n",
@@ -441,7 +440,7 @@ static int multipath_run (mddev_t *mddev)
441 } 440 }
442 441
443 conf->working_disks = 0; 442 conf->working_disks = 0;
444 rdev_for_each(rdev, tmp, mddev) { 443 list_for_each_entry(rdev, &mddev->disks, same_set) {
445 disk_idx = rdev->raid_disk; 444 disk_idx = rdev->raid_disk;
446 if (disk_idx < 0 || 445 if (disk_idx < 0 ||
447 disk_idx >= mddev->raid_disks) 446 disk_idx >= mddev->raid_disks)
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",
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9c788e2489b1..c165b1eed8bb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1919,7 +1919,6 @@ static int run(mddev_t *mddev)
1919 int i, j, disk_idx; 1919 int i, j, disk_idx;
1920 mirror_info_t *disk; 1920 mirror_info_t *disk;
1921 mdk_rdev_t *rdev; 1921 mdk_rdev_t *rdev;
1922 struct list_head *tmp;
1923 1922
1924 if (mddev->level != 1) { 1923 if (mddev->level != 1) {
1925 printk("raid1: %s: raid level not set to mirroring (%d)\n", 1924 printk("raid1: %s: raid level not set to mirroring (%d)\n",
@@ -1964,7 +1963,7 @@ static int run(mddev_t *mddev)
1964 spin_lock_init(&conf->device_lock); 1963 spin_lock_init(&conf->device_lock);
1965 mddev->queue->queue_lock = &conf->device_lock; 1964 mddev->queue->queue_lock = &conf->device_lock;
1966 1965
1967 rdev_for_each(rdev, tmp, mddev) { 1966 list_for_each_entry(rdev, &mddev->disks, same_set) {
1968 disk_idx = rdev->raid_disk; 1967 disk_idx = rdev->raid_disk;
1969 if (disk_idx >= mddev->raid_disks 1968 if (disk_idx >= mddev->raid_disks
1970 || disk_idx < 0) 1969 || disk_idx < 0)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 970a96ef9b18..6736d6dff981 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2025,7 +2025,6 @@ static int run(mddev_t *mddev)
2025 int i, disk_idx; 2025 int i, disk_idx;
2026 mirror_info_t *disk; 2026 mirror_info_t *disk;
2027 mdk_rdev_t *rdev; 2027 mdk_rdev_t *rdev;
2028 struct list_head *tmp;
2029 int nc, fc, fo; 2028 int nc, fc, fo;
2030 sector_t stride, size; 2029 sector_t stride, size;
2031 2030
@@ -2108,7 +2107,7 @@ static int run(mddev_t *mddev)
2108 spin_lock_init(&conf->device_lock); 2107 spin_lock_init(&conf->device_lock);
2109 mddev->queue->queue_lock = &conf->device_lock; 2108 mddev->queue->queue_lock = &conf->device_lock;
2110 2109
2111 rdev_for_each(rdev, tmp, mddev) { 2110 list_for_each_entry(rdev, &mddev->disks, same_set) {
2112 disk_idx = rdev->raid_disk; 2111 disk_idx = rdev->raid_disk;
2113 if (disk_idx >= mddev->raid_disks 2112 if (disk_idx >= mddev->raid_disks
2114 || disk_idx < 0) 2113 || disk_idx < 0)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index a36a7435edf5..a5ba080d303b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3998,7 +3998,6 @@ static int run(mddev_t *mddev)
3998 int raid_disk, memory; 3998 int raid_disk, memory;
3999 mdk_rdev_t *rdev; 3999 mdk_rdev_t *rdev;
4000 struct disk_info *disk; 4000 struct disk_info *disk;
4001 struct list_head *tmp;
4002 int working_disks = 0; 4001 int working_disks = 0;
4003 4002
4004 if (mddev->level != 5 && mddev->level != 4 && mddev->level != 6) { 4003 if (mddev->level != 5 && mddev->level != 4 && mddev->level != 6) {
@@ -4108,7 +4107,7 @@ static int run(mddev_t *mddev)
4108 4107
4109 pr_debug("raid5: run(%s) called.\n", mdname(mddev)); 4108 pr_debug("raid5: run(%s) called.\n", mdname(mddev));
4110 4109
4111 rdev_for_each(rdev, tmp, mddev) { 4110 list_for_each_entry(rdev, &mddev->disks, same_set) {
4112 raid_disk = rdev->raid_disk; 4111 raid_disk = rdev->raid_disk;
4113 if (raid_disk >= conf->raid_disks 4112 if (raid_disk >= conf->raid_disks
4114 || raid_disk < 0) 4113 || raid_disk < 0)
@@ -4533,7 +4532,6 @@ static int raid5_start_reshape(mddev_t *mddev)
4533{ 4532{
4534 raid5_conf_t *conf = mddev_to_conf(mddev); 4533 raid5_conf_t *conf = mddev_to_conf(mddev);
4535 mdk_rdev_t *rdev; 4534 mdk_rdev_t *rdev;
4536 struct list_head *rtmp;
4537 int spares = 0; 4535 int spares = 0;
4538 int added_devices = 0; 4536 int added_devices = 0;
4539 unsigned long flags; 4537 unsigned long flags;
@@ -4541,7 +4539,7 @@ static int raid5_start_reshape(mddev_t *mddev)
4541 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 4539 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
4542 return -EBUSY; 4540 return -EBUSY;
4543 4541
4544 rdev_for_each(rdev, rtmp, mddev) 4542 list_for_each_entry(rdev, &mddev->disks, same_set)
4545 if (rdev->raid_disk < 0 && 4543 if (rdev->raid_disk < 0 &&
4546 !test_bit(Faulty, &rdev->flags)) 4544 !test_bit(Faulty, &rdev->flags))
4547 spares++; 4545 spares++;
@@ -4563,7 +4561,7 @@ static int raid5_start_reshape(mddev_t *mddev)
4563 /* Add some new drives, as many as will fit. 4561 /* Add some new drives, as many as will fit.
4564 * We know there are enough to make the newly sized array work. 4562 * We know there are enough to make the newly sized array work.
4565 */ 4563 */
4566 rdev_for_each(rdev, rtmp, mddev) 4564 list_for_each_entry(rdev, &mddev->disks, same_set)
4567 if (rdev->raid_disk < 0 && 4565 if (rdev->raid_disk < 0 &&
4568 !test_bit(Faulty, &rdev->flags)) { 4566 !test_bit(Faulty, &rdev->flags)) {
4569 if (raid5_add_disk(mddev, rdev) == 0) { 4567 if (raid5_add_disk(mddev, rdev) == 0) {