Commit dafb20fa authored by NeilBrown's avatar NeilBrown

md: tidy up rdev_for_each usage.

md.h has an 'rdev_for_each()' macro for iterating the rdevs in an
mddev.  However it uses the 'safe' version of list_for_each_entry,
and so requires the extra variable, but doesn't include 'safe' in the
name, which is useful documentation.

Consequently some places use this safe version without needing it, and
many use an explicity list_for_each entry.

So:
 - rename rdev_for_each to rdev_for_each_safe
 - create a new rdev_for_each which uses the plain
   list_for_each_entry,
 - use the 'safe' version only where needed, and convert all other
   list_for_each_entry calls to use rdev_for_each.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent d6b42dcb
...@@ -171,7 +171,7 @@ static struct page *read_sb_page(struct mddev *mddev, loff_t offset, ...@@ -171,7 +171,7 @@ static struct page *read_sb_page(struct mddev *mddev, loff_t offset,
did_alloc = 1; did_alloc = 1;
} }
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (! test_bit(In_sync, &rdev->flags) if (! test_bit(In_sync, &rdev->flags)
|| test_bit(Faulty, &rdev->flags)) || test_bit(Faulty, &rdev->flags))
continue; continue;
......
...@@ -615,14 +615,14 @@ static int read_disk_sb(struct md_rdev *rdev, int size) ...@@ -615,14 +615,14 @@ static int read_disk_sb(struct md_rdev *rdev, int size)
static void super_sync(struct mddev *mddev, struct md_rdev *rdev) static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
{ {
struct md_rdev *r, *t; struct md_rdev *r;
uint64_t failed_devices; uint64_t failed_devices;
struct dm_raid_superblock *sb; struct dm_raid_superblock *sb;
sb = page_address(rdev->sb_page); sb = page_address(rdev->sb_page);
failed_devices = le64_to_cpu(sb->failed_devices); failed_devices = le64_to_cpu(sb->failed_devices);
rdev_for_each(r, t, mddev) rdev_for_each(r, mddev)
if ((r->raid_disk >= 0) && test_bit(Faulty, &r->flags)) if ((r->raid_disk >= 0) && test_bit(Faulty, &r->flags))
failed_devices |= (1ULL << r->raid_disk); failed_devices |= (1ULL << r->raid_disk);
...@@ -707,7 +707,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev) ...@@ -707,7 +707,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
struct dm_raid_superblock *sb; struct dm_raid_superblock *sb;
uint32_t new_devs = 0; uint32_t new_devs = 0;
uint32_t rebuilds = 0; uint32_t rebuilds = 0;
struct md_rdev *r, *t; struct md_rdev *r;
struct dm_raid_superblock *sb2; struct dm_raid_superblock *sb2;
sb = page_address(rdev->sb_page); sb = page_address(rdev->sb_page);
...@@ -750,7 +750,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev) ...@@ -750,7 +750,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
* case the In_sync bit will /not/ be set and * case the In_sync bit will /not/ be set and
* recovery_cp must be MaxSector. * recovery_cp must be MaxSector.
*/ */
rdev_for_each(r, t, mddev) { rdev_for_each(r, mddev) {
if (!test_bit(In_sync, &r->flags)) { if (!test_bit(In_sync, &r->flags)) {
DMINFO("Device %d specified for rebuild: " DMINFO("Device %d specified for rebuild: "
"Clearing superblock", r->raid_disk); "Clearing superblock", r->raid_disk);
...@@ -782,7 +782,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev) ...@@ -782,7 +782,7 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
* Now we set the Faulty bit for those devices that are * Now we set the Faulty bit for those devices that are
* recorded in the superblock as failed. * recorded in the superblock as failed.
*/ */
rdev_for_each(r, t, mddev) { rdev_for_each(r, mddev) {
if (!r->sb_page) if (!r->sb_page)
continue; continue;
sb2 = page_address(r->sb_page); sb2 = page_address(r->sb_page);
...@@ -855,11 +855,11 @@ static int super_validate(struct mddev *mddev, struct md_rdev *rdev) ...@@ -855,11 +855,11 @@ static int super_validate(struct mddev *mddev, struct md_rdev *rdev)
static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs) static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
{ {
int ret; int ret;
struct md_rdev *rdev, *freshest, *tmp; struct md_rdev *rdev, *freshest;
struct mddev *mddev = &rs->md; struct mddev *mddev = &rs->md;
freshest = NULL; freshest = NULL;
rdev_for_each(rdev, tmp, mddev) { rdev_for_each(rdev, mddev) {
if (!rdev->meta_bdev) if (!rdev->meta_bdev)
continue; continue;
...@@ -888,7 +888,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs) ...@@ -888,7 +888,7 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
if (super_validate(mddev, freshest)) if (super_validate(mddev, freshest))
return -EINVAL; return -EINVAL;
rdev_for_each(rdev, tmp, mddev) rdev_for_each(rdev, mddev)
if ((rdev != freshest) && super_validate(mddev, rdev)) if ((rdev != freshest) && super_validate(mddev, rdev))
return -EINVAL; return -EINVAL;
......
...@@ -315,7 +315,7 @@ static int run(struct mddev *mddev) ...@@ -315,7 +315,7 @@ static int run(struct mddev *mddev)
} }
conf->nfaults = 0; conf->nfaults = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
conf->rdev = rdev; conf->rdev = rdev;
md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
......
...@@ -138,7 +138,7 @@ static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks) ...@@ -138,7 +138,7 @@ static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks)
cnt = 0; cnt = 0;
conf->array_sectors = 0; conf->array_sectors = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
int j = rdev->raid_disk; int j = rdev->raid_disk;
struct dev_info *disk = conf->disks + j; struct dev_info *disk = conf->disks + j;
sector_t sectors; sector_t sectors;
......
...@@ -439,7 +439,7 @@ static void submit_flushes(struct work_struct *ws) ...@@ -439,7 +439,7 @@ static void submit_flushes(struct work_struct *ws)
INIT_WORK(&mddev->flush_work, md_submit_flush_data); INIT_WORK(&mddev->flush_work, md_submit_flush_data);
atomic_set(&mddev->flush_pending, 1); atomic_set(&mddev->flush_pending, 1);
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(rdev, &mddev->disks, same_set) rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Faulty, &rdev->flags)) { !test_bit(Faulty, &rdev->flags)) {
/* Take two references, one is dropped /* Take two references, one is dropped
...@@ -749,7 +749,7 @@ static struct md_rdev * find_rdev_nr(struct mddev *mddev, int nr) ...@@ -749,7 +749,7 @@ static struct md_rdev * find_rdev_nr(struct mddev *mddev, int nr)
{ {
struct md_rdev *rdev; struct md_rdev *rdev;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->desc_nr == nr) if (rdev->desc_nr == nr)
return rdev; return rdev;
...@@ -760,7 +760,7 @@ static struct md_rdev * find_rdev(struct mddev * mddev, dev_t dev) ...@@ -760,7 +760,7 @@ static struct md_rdev * find_rdev(struct mddev * mddev, dev_t dev)
{ {
struct md_rdev *rdev; struct md_rdev *rdev;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->bdev->bd_dev == dev) if (rdev->bdev->bd_dev == dev)
return rdev; return rdev;
...@@ -1342,7 +1342,7 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1342,7 +1342,7 @@ static void super_90_sync(struct mddev *mddev, struct md_rdev *rdev)
sb->state |= (1<<MD_SB_BITMAP_PRESENT); sb->state |= (1<<MD_SB_BITMAP_PRESENT);
sb->disks[0].state = (1<<MD_DISK_REMOVED); sb->disks[0].state = (1<<MD_DISK_REMOVED);
list_for_each_entry(rdev2, &mddev->disks, same_set) { rdev_for_each(rdev2, mddev) {
mdp_disk_t *d; mdp_disk_t *d;
int desc_nr; int desc_nr;
int is_active = test_bit(In_sync, &rdev2->flags); int is_active = test_bit(In_sync, &rdev2->flags);
...@@ -1816,7 +1816,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1816,7 +1816,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
} }
max_dev = 0; max_dev = 0;
list_for_each_entry(rdev2, &mddev->disks, same_set) rdev_for_each(rdev2, mddev)
if (rdev2->desc_nr+1 > max_dev) if (rdev2->desc_nr+1 > max_dev)
max_dev = rdev2->desc_nr+1; max_dev = rdev2->desc_nr+1;
...@@ -1833,7 +1833,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev) ...@@ -1833,7 +1833,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
for (i=0; i<max_dev;i++) for (i=0; i<max_dev;i++)
sb->dev_roles[i] = cpu_to_le16(0xfffe); sb->dev_roles[i] = cpu_to_le16(0xfffe);
list_for_each_entry(rdev2, &mddev->disks, same_set) { rdev_for_each(rdev2, mddev) {
i = rdev2->desc_nr; i = rdev2->desc_nr;
if (test_bit(Faulty, &rdev2->flags)) if (test_bit(Faulty, &rdev2->flags))
sb->dev_roles[i] = cpu_to_le16(0xfffe); sb->dev_roles[i] = cpu_to_le16(0xfffe);
...@@ -1948,7 +1948,7 @@ int md_integrity_register(struct mddev *mddev) ...@@ -1948,7 +1948,7 @@ int md_integrity_register(struct mddev *mddev)
return 0; /* nothing to do */ return 0; /* nothing to do */
if (!mddev->gendisk || blk_get_integrity(mddev->gendisk)) if (!mddev->gendisk || blk_get_integrity(mddev->gendisk))
return 0; /* shouldn't register, or already is */ return 0; /* shouldn't register, or already is */
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
/* skip spares and non-functional disks */ /* skip spares and non-functional disks */
if (test_bit(Faulty, &rdev->flags)) if (test_bit(Faulty, &rdev->flags))
continue; continue;
...@@ -2175,7 +2175,7 @@ static void export_array(struct mddev *mddev) ...@@ -2175,7 +2175,7 @@ static void export_array(struct mddev *mddev)
{ {
struct md_rdev *rdev, *tmp; struct md_rdev *rdev, *tmp;
rdev_for_each(rdev, tmp, mddev) { rdev_for_each_safe(rdev, tmp, mddev) {
if (!rdev->mddev) { if (!rdev->mddev) {
MD_BUG(); MD_BUG();
continue; continue;
...@@ -2307,11 +2307,11 @@ static void md_print_devices(void) ...@@ -2307,11 +2307,11 @@ static void md_print_devices(void)
bitmap_print_sb(mddev->bitmap); bitmap_print_sb(mddev->bitmap);
else else
printk("%s: ", mdname(mddev)); printk("%s: ", mdname(mddev));
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
printk("<%s>", bdevname(rdev->bdev,b)); printk("<%s>", bdevname(rdev->bdev,b));
printk("\n"); printk("\n");
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
print_rdev(rdev, mddev->major_version); print_rdev(rdev, mddev->major_version);
} }
printk("md: **********************************\n"); printk("md: **********************************\n");
...@@ -2328,7 +2328,7 @@ static void sync_sbs(struct mddev * mddev, int nospares) ...@@ -2328,7 +2328,7 @@ static void sync_sbs(struct mddev * mddev, int nospares)
* with the rest of the array) * with the rest of the array)
*/ */
struct md_rdev *rdev; struct md_rdev *rdev;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->sb_events == mddev->events || if (rdev->sb_events == mddev->events ||
(nospares && (nospares &&
rdev->raid_disk < 0 && rdev->raid_disk < 0 &&
...@@ -2351,7 +2351,7 @@ static void md_update_sb(struct mddev * mddev, int force_change) ...@@ -2351,7 +2351,7 @@ static void md_update_sb(struct mddev * mddev, int force_change)
repeat: repeat:
/* First make sure individual recovery_offsets are correct */ /* First make sure individual recovery_offsets are correct */
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
mddev->delta_disks >= 0 && mddev->delta_disks >= 0 &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
...@@ -2364,7 +2364,7 @@ static void md_update_sb(struct mddev * mddev, int force_change) ...@@ -2364,7 +2364,7 @@ static void md_update_sb(struct mddev * mddev, int force_change)
clear_bit(MD_CHANGE_DEVS, &mddev->flags); clear_bit(MD_CHANGE_DEVS, &mddev->flags);
if (!mddev->external) { if (!mddev->external) {
clear_bit(MD_CHANGE_PENDING, &mddev->flags); clear_bit(MD_CHANGE_PENDING, &mddev->flags);
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->badblocks.changed) { if (rdev->badblocks.changed) {
md_ack_all_badblocks(&rdev->badblocks); md_ack_all_badblocks(&rdev->badblocks);
md_error(mddev, rdev); md_error(mddev, rdev);
...@@ -2430,7 +2430,7 @@ static void md_update_sb(struct mddev * mddev, int force_change) ...@@ -2430,7 +2430,7 @@ static void md_update_sb(struct mddev * mddev, int force_change)
mddev->events --; mddev->events --;
} }
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->badblocks.changed) if (rdev->badblocks.changed)
any_badblocks_changed++; any_badblocks_changed++;
if (test_bit(Faulty, &rdev->flags)) if (test_bit(Faulty, &rdev->flags))
...@@ -2444,7 +2444,7 @@ static void md_update_sb(struct mddev * mddev, int force_change) ...@@ -2444,7 +2444,7 @@ static void md_update_sb(struct mddev * mddev, int force_change)
mdname(mddev), mddev->in_sync); mdname(mddev), mddev->in_sync);
bitmap_update_sb(mddev->bitmap); bitmap_update_sb(mddev->bitmap);
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
if (rdev->sb_loaded != 1) if (rdev->sb_loaded != 1)
...@@ -2493,7 +2493,7 @@ static void md_update_sb(struct mddev * mddev, int force_change) ...@@ -2493,7 +2493,7 @@ static void md_update_sb(struct mddev * mddev, int force_change)
if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
sysfs_notify(&mddev->kobj, NULL, "sync_completed"); sysfs_notify(&mddev->kobj, NULL, "sync_completed");
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (test_and_clear_bit(FaultRecorded, &rdev->flags)) if (test_and_clear_bit(FaultRecorded, &rdev->flags))
clear_bit(Blocked, &rdev->flags); clear_bit(Blocked, &rdev->flags);
...@@ -2896,7 +2896,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len) ...@@ -2896,7 +2896,7 @@ rdev_size_store(struct md_rdev *rdev, const char *buf, size_t len)
struct md_rdev *rdev2; struct md_rdev *rdev2;
mddev_lock(mddev); mddev_lock(mddev);
list_for_each_entry(rdev2, &mddev->disks, same_set) rdev_for_each(rdev2, mddev)
if (rdev->bdev == rdev2->bdev && if (rdev->bdev == rdev2->bdev &&
rdev != rdev2 && rdev != rdev2 &&
overlaps(rdev->data_offset, rdev->sectors, overlaps(rdev->data_offset, rdev->sectors,
...@@ -3193,7 +3193,7 @@ static void analyze_sbs(struct mddev * mddev) ...@@ -3193,7 +3193,7 @@ static void analyze_sbs(struct mddev * mddev)
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
freshest = NULL; freshest = NULL;
rdev_for_each(rdev, tmp, mddev) rdev_for_each_safe(rdev, tmp, mddev)
switch (super_types[mddev->major_version]. switch (super_types[mddev->major_version].
load_super(rdev, freshest, mddev->minor_version)) { load_super(rdev, freshest, mddev->minor_version)) {
case 1: case 1:
...@@ -3214,7 +3214,7 @@ static void analyze_sbs(struct mddev * mddev) ...@@ -3214,7 +3214,7 @@ static void analyze_sbs(struct mddev * mddev)
validate_super(mddev, freshest); validate_super(mddev, freshest);
i = 0; i = 0;
rdev_for_each(rdev, tmp, mddev) { rdev_for_each_safe(rdev, tmp, mddev) {
if (mddev->max_disks && if (mddev->max_disks &&
(rdev->desc_nr >= mddev->max_disks || (rdev->desc_nr >= mddev->max_disks ||
i > mddev->max_disks)) { i > mddev->max_disks)) {
...@@ -3403,7 +3403,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3403,7 +3403,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
return -EINVAL; return -EINVAL;
} }
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
rdev->new_raid_disk = rdev->raid_disk; rdev->new_raid_disk = rdev->raid_disk;
/* ->takeover must set new_* and/or delta_disks /* ->takeover must set new_* and/or delta_disks
...@@ -3456,7 +3456,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3456,7 +3456,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
mddev->safemode = 0; mddev->safemode = 0;
} }
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->raid_disk < 0) if (rdev->raid_disk < 0)
continue; continue;
if (rdev->new_raid_disk >= mddev->raid_disks) if (rdev->new_raid_disk >= mddev->raid_disks)
...@@ -3465,7 +3465,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3465,7 +3465,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
continue; continue;
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
} }
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->raid_disk < 0) if (rdev->raid_disk < 0)
continue; continue;
if (rdev->new_raid_disk == rdev->raid_disk) if (rdev->new_raid_disk == rdev->raid_disk)
...@@ -4796,7 +4796,7 @@ int md_run(struct mddev *mddev) ...@@ -4796,7 +4796,7 @@ int md_run(struct mddev *mddev)
* the only valid external interface is through the md * the only valid external interface is through the md
* device. * device.
*/ */
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (test_bit(Faulty, &rdev->flags)) if (test_bit(Faulty, &rdev->flags))
continue; continue;
sync_blockdev(rdev->bdev); sync_blockdev(rdev->bdev);
...@@ -4867,8 +4867,8 @@ int md_run(struct mddev *mddev) ...@@ -4867,8 +4867,8 @@ int md_run(struct mddev *mddev)
struct md_rdev *rdev2; struct md_rdev *rdev2;
int warned = 0; int warned = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
list_for_each_entry(rdev2, &mddev->disks, same_set) { rdev_for_each(rdev2, mddev) {
if (rdev < rdev2 && if (rdev < rdev2 &&
rdev->bdev->bd_contains == rdev->bdev->bd_contains ==
rdev2->bdev->bd_contains) { rdev2->bdev->bd_contains) {
...@@ -4945,7 +4945,7 @@ int md_run(struct mddev *mddev) ...@@ -4945,7 +4945,7 @@ int md_run(struct mddev *mddev)
mddev->in_sync = 1; mddev->in_sync = 1;
smp_wmb(); smp_wmb();
mddev->ready = 1; mddev->ready = 1;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
if (sysfs_link_rdev(mddev, rdev)) if (sysfs_link_rdev(mddev, rdev))
/* failure here is OK */; /* failure here is OK */;
...@@ -5175,7 +5175,7 @@ static int do_md_stop(struct mddev * mddev, int mode, int is_open) ...@@ -5175,7 +5175,7 @@ static int do_md_stop(struct mddev * mddev, int mode, int is_open)
/* tell userspace to handle 'inactive' */ /* tell userspace to handle 'inactive' */
sysfs_notify_dirent_safe(mddev->sysfs_state); sysfs_notify_dirent_safe(mddev->sysfs_state);
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
sysfs_unlink_rdev(mddev, rdev); sysfs_unlink_rdev(mddev, rdev);
...@@ -5226,7 +5226,7 @@ static void autorun_array(struct mddev *mddev) ...@@ -5226,7 +5226,7 @@ static void autorun_array(struct mddev *mddev)
printk(KERN_INFO "md: running: "); printk(KERN_INFO "md: running: ");
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
printk("<%s>", bdevname(rdev->bdev,b)); printk("<%s>", bdevname(rdev->bdev,b));
} }
...@@ -5356,7 +5356,7 @@ static int get_array_info(struct mddev * mddev, void __user * arg) ...@@ -5356,7 +5356,7 @@ static int get_array_info(struct mddev * mddev, void __user * arg)
struct md_rdev *rdev; struct md_rdev *rdev;
nr=working=insync=failed=spare=0; nr=working=insync=failed=spare=0;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
nr++; nr++;
if (test_bit(Faulty, &rdev->flags)) if (test_bit(Faulty, &rdev->flags))
failed++; failed++;
...@@ -5923,7 +5923,7 @@ static int update_size(struct mddev *mddev, sector_t num_sectors) ...@@ -5923,7 +5923,7 @@ static int update_size(struct mddev *mddev, sector_t num_sectors)
* grow, and re-add. * grow, and re-add.
*/ */
return -EBUSY; return -EBUSY;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
sector_t avail = rdev->sectors; sector_t avail = rdev->sectors;
if (fit && (num_sectors == 0 || num_sectors > avail)) if (fit && (num_sectors == 0 || num_sectors > avail))
...@@ -6758,7 +6758,7 @@ static int md_seq_show(struct seq_file *seq, void *v) ...@@ -6758,7 +6758,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
} }
sectors = 0; sectors = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
char b[BDEVNAME_SIZE]; char b[BDEVNAME_SIZE];
seq_printf(seq, " %s[%d]", seq_printf(seq, " %s[%d]",
bdevname(rdev->bdev,b), rdev->desc_nr); bdevname(rdev->bdev,b), rdev->desc_nr);
...@@ -7170,7 +7170,7 @@ void md_do_sync(struct mddev *mddev) ...@@ -7170,7 +7170,7 @@ void md_do_sync(struct mddev *mddev)
max_sectors = mddev->dev_sectors; max_sectors = mddev->dev_sectors;
j = MaxSector; j = MaxSector;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(rdev, &mddev->disks, same_set) rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Faulty, &rdev->flags) && !test_bit(Faulty, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
...@@ -7342,7 +7342,7 @@ void md_do_sync(struct mddev *mddev) ...@@ -7342,7 +7342,7 @@ void md_do_sync(struct mddev *mddev)
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
mddev->curr_resync = MaxSector; mddev->curr_resync = MaxSector;
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(rdev, &mddev->disks, same_set) rdev_for_each_rcu(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
mddev->delta_disks >= 0 && mddev->delta_disks >= 0 &&
!test_bit(Faulty, &rdev->flags) && !test_bit(Faulty, &rdev->flags) &&
...@@ -7388,7 +7388,7 @@ static int remove_and_add_spares(struct mddev *mddev) ...@@ -7388,7 +7388,7 @@ static int remove_and_add_spares(struct mddev *mddev)
mddev->curr_resync_completed = 0; mddev->curr_resync_completed = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Blocked, &rdev->flags) && !test_bit(Blocked, &rdev->flags) &&
(test_bit(Faulty, &rdev->flags) || (test_bit(Faulty, &rdev->flags) ||
...@@ -7406,7 +7406,7 @@ static int remove_and_add_spares(struct mddev *mddev) ...@@ -7406,7 +7406,7 @@ static int remove_and_add_spares(struct mddev *mddev)
"degraded"); "degraded");
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(In_sync, &rdev->flags) && !test_bit(In_sync, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags)) !test_bit(Faulty, &rdev->flags))
...@@ -7451,7 +7451,7 @@ static void reap_sync_thread(struct mddev *mddev) ...@@ -7451,7 +7451,7 @@ static void reap_sync_thread(struct mddev *mddev)
* do the superblock for an incrementally recovered device * do the superblock for an incrementally recovered device
* written out. * written out.
*/ */
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (!mddev->degraded || if (!mddev->degraded ||
test_bit(In_sync, &rdev->flags)) test_bit(In_sync, &rdev->flags))
rdev->saved_raid_disk = -1; rdev->saved_raid_disk = -1;
...@@ -7529,7 +7529,7 @@ void md_check_recovery(struct mddev *mddev) ...@@ -7529,7 +7529,7 @@ void md_check_recovery(struct mddev *mddev)
* failed devices. * failed devices.
*/ */
struct md_rdev *rdev; struct md_rdev *rdev;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0 && if (rdev->raid_disk >= 0 &&
!test_bit(Blocked, &rdev->flags) && !test_bit(Blocked, &rdev->flags) &&
test_bit(Faulty, &rdev->flags) && test_bit(Faulty, &rdev->flags) &&
......
...@@ -519,7 +519,10 @@ static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev) ...@@ -519,7 +519,10 @@ static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev)
/* /*
* iterates through the 'same array disks' ringlist * iterates through the 'same array disks' ringlist
*/ */
#define rdev_for_each(rdev, tmp, mddev) \ #define rdev_for_each(rdev, mddev) \
list_for_each_entry(rdev, &((mddev)->disks), same_set)
#define rdev_for_each_safe(rdev, tmp, mddev) \
list_for_each_entry_safe(rdev, tmp, &((mddev)->disks), same_set) list_for_each_entry_safe(rdev, tmp, &((mddev)->disks), same_set)
#define rdev_for_each_rcu(rdev, mddev) \ #define rdev_for_each_rcu(rdev, mddev) \
......
...@@ -428,7 +428,7 @@ static int multipath_run (struct mddev *mddev) ...@@ -428,7 +428,7 @@ static int multipath_run (struct mddev *mddev)
} }
working_disks = 0; working_disks = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
disk_idx = rdev->raid_disk; disk_idx = rdev->raid_disk;
if (disk_idx < 0 || if (disk_idx < 0 ||
disk_idx >= mddev->raid_disks) disk_idx >= mddev->raid_disks)
......
...@@ -91,7 +91,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) ...@@ -91,7 +91,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
if (!conf) if (!conf)
return -ENOMEM; return -ENOMEM;
list_for_each_entry(rdev1, &mddev->disks, same_set) { rdev_for_each(rdev1, mddev) {
pr_debug("md/raid0:%s: looking at %s\n", pr_debug("md/raid0:%s: looking at %s\n",
mdname(mddev), mdname(mddev),
bdevname(rdev1->bdev, b)); bdevname(rdev1->bdev, b));
...@@ -102,7 +102,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) ...@@ -102,7 +102,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
sector_div(sectors, mddev->chunk_sectors); sector_div(sectors, mddev->chunk_sectors);
rdev1->sectors = sectors * mddev->chunk_sectors; rdev1->sectors = sectors * mddev->chunk_sectors;
list_for_each_entry(rdev2, &mddev->disks, same_set) { rdev_for_each(rdev2, mddev) {
pr_debug("md/raid0:%s: comparing %s(%llu)" pr_debug("md/raid0:%s: comparing %s(%llu)"
" with %s(%llu)\n", " with %s(%llu)\n",
mdname(mddev), mdname(mddev),
...@@ -157,7 +157,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) ...@@ -157,7 +157,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
smallest = NULL; smallest = NULL;
dev = conf->devlist; dev = conf->devlist;
err = -EINVAL; err = -EINVAL;
list_for_each_entry(rdev1, &mddev->disks, same_set) { rdev_for_each(rdev1, mddev) {
int j = rdev1->raid_disk; int j = rdev1->raid_disk;
if (mddev->level == 10) { if (mddev->level == 10) {
...@@ -329,7 +329,7 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks ...@@ -329,7 +329,7 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks
WARN_ONCE(sectors || raid_disks, WARN_ONCE(sectors || raid_disks,
"%s does not support generic reshape\n", __func__); "%s does not support generic reshape\n", __func__);
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
array_sectors += rdev->sectors; array_sectors += rdev->sectors;
return array_sectors; return array_sectors;
...@@ -543,7 +543,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev) ...@@ -543,7 +543,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
/* check slot number for a disk */ /* check slot number for a disk */
if (rdev->raid_disk == mddev->raid_disks-1) { if (rdev->raid_disk == mddev->raid_disks-1) {
printk(KERN_ERR "md/raid0:%s: raid5 must have missing parity disk!\n", printk(KERN_ERR "md/raid0:%s: raid5 must have missing parity disk!\n",
......
...@@ -2504,7 +2504,7 @@ static struct r1conf *setup_conf(struct mddev *mddev) ...@@ -2504,7 +2504,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
err = -EINVAL; err = -EINVAL;
spin_lock_init(&conf->device_lock); spin_lock_init(&conf->device_lock);
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
int disk_idx = rdev->raid_disk; int disk_idx = rdev->raid_disk;
if (disk_idx >= mddev->raid_disks if (disk_idx >= mddev->raid_disks
|| disk_idx < 0) || disk_idx < 0)
...@@ -2622,7 +2622,7 @@ static int run(struct mddev *mddev) ...@@ -2622,7 +2622,7 @@ static int run(struct mddev *mddev)
if (IS_ERR(conf)) if (IS_ERR(conf))
return PTR_ERR(conf); return PTR_ERR(conf);
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
if (!mddev->gendisk) if (!mddev->gendisk)
continue; continue;
disk_stack_limits(mddev->gendisk, rdev->bdev, disk_stack_limits(mddev->gendisk, rdev->bdev,
......
...@@ -3253,7 +3253,7 @@ static int run(struct mddev *mddev) ...@@ -3253,7 +3253,7 @@ static int run(struct mddev *mddev)
blk_queue_io_opt(mddev->queue, chunk_size * blk_queue_io_opt(mddev->queue, chunk_size *
(conf->raid_disks / conf->near_copies)); (conf->raid_disks / conf->near_copies));
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
disk_idx = rdev->raid_disk; disk_idx = rdev->raid_disk;
if (disk_idx >= conf->raid_disks if (disk_idx >= conf->raid_disks
...@@ -3419,7 +3419,7 @@ static void *raid10_takeover_raid0(struct mddev *mddev) ...@@ -3419,7 +3419,7 @@ static void *raid10_takeover_raid0(struct mddev *mddev)
conf = setup_conf(mddev); conf = setup_conf(mddev);
if (!IS_ERR(conf)) { if (!IS_ERR(conf)) {
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk >= 0) if (rdev->raid_disk >= 0)
rdev->new_raid_disk = rdev->raid_disk * 2; rdev->new_raid_disk = rdev->raid_disk * 2;
conf->barrier = 1; conf->barrier = 1;
......
...@@ -4842,7 +4842,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) ...@@ -4842,7 +4842,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
pr_debug("raid456: run(%s) called.\n", mdname(mddev)); pr_debug("raid456: run(%s) called.\n", mdname(mddev));
list_for_each_entry(rdev, &mddev->disks, same_set) { rdev_for_each(rdev, mddev) {
raid_disk = rdev->raid_disk; raid_disk = rdev->raid_disk;
if (raid_disk >= max_disks if (raid_disk >= max_disks
|| raid_disk < 0) || raid_disk < 0)
...@@ -5177,7 +5177,7 @@ static int run(struct mddev *mddev) ...@@ -5177,7 +5177,7 @@ static int run(struct mddev *mddev)
blk_queue_io_opt(mddev->queue, chunk_size * blk_queue_io_opt(mddev->queue, chunk_size *
(conf->raid_disks - conf->max_degraded)); (conf->raid_disks - conf->max_degraded));
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
disk_stack_limits(mddev->gendisk, rdev->bdev, disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9); rdev->data_offset << 9);
} }
...@@ -5500,7 +5500,7 @@ static int raid5_start_reshape(struct mddev *mddev) ...@@ -5500,7 +5500,7 @@ static int raid5_start_reshape(struct mddev *mddev)
if (!check_stripe_cache(mddev)) if (!check_stripe_cache(mddev))
return -ENOSPC; return -ENOSPC;
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (!test_bit(In_sync, &rdev->flags) if (!test_bit(In_sync, &rdev->flags)
&& !test_bit(Faulty, &rdev->flags)) && !test_bit(Faulty, &rdev->flags))
spares++; spares++;
...@@ -5546,7 +5546,7 @@ static int raid5_start_reshape(struct mddev *mddev) ...@@ -5546,7 +5546,7 @@ static int raid5_start_reshape(struct mddev *mddev)
* such devices during the reshape and confusion could result. * such devices during the reshape and confusion could result.
*/ */
if (mddev->delta_disks >= 0) { if (mddev->delta_disks >= 0) {
list_for_each_entry(rdev, &mddev->disks, same_set) rdev_for_each(rdev, mddev)
if (rdev->raid_disk < 0 && if (rdev->raid_disk < 0 &&
!test_bit(Faulty, &rdev->flags)) { !test_bit(Faulty, &rdev->flags)) {
if (raid5_add_disk(mddev, rdev) == 0) { if (raid5_add_disk(mddev, rdev) == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment