aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
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/md/md.c
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/md/md.c')
-rw-r--r--drivers/md/md.c107
1 files changed, 43 insertions, 64 deletions
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;