diff options
author | Jonathan Brassow <jbrassow@redhat.com> | 2013-05-08 18:57:13 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-06-13 18:10:25 -0400 |
commit | f381e71b042af910fbe5f8222792cc5092750993 (patch) | |
tree | f63cc984c0fbae60cd4f4dbca3c7e77972981fec /drivers/md/dm-raid.c | |
parent | 9092c02d943515b3c9ffd5d0003527f8cc1dd77b (diff) |
DM RAID: Break-up untidy function
DM RAID: Break-up untidy function
Clean-up excessive indentation by moving some code in raid_resume()
into its own function.
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r-- | drivers/md/dm-raid.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index facaf9142d5a..59d15ec0ba81 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
@@ -1572,15 +1572,51 @@ static void raid_postsuspend(struct dm_target *ti) | |||
1572 | mddev_suspend(&rs->md); | 1572 | mddev_suspend(&rs->md); |
1573 | } | 1573 | } |
1574 | 1574 | ||
1575 | static void raid_resume(struct dm_target *ti) | 1575 | static void attempt_restore_of_faulty_devices(struct raid_set *rs) |
1576 | { | 1576 | { |
1577 | int i; | 1577 | int i; |
1578 | uint64_t failed_devices, cleared_failed_devices = 0; | 1578 | uint64_t failed_devices, cleared_failed_devices = 0; |
1579 | unsigned long flags; | 1579 | unsigned long flags; |
1580 | struct dm_raid_superblock *sb; | 1580 | struct dm_raid_superblock *sb; |
1581 | struct raid_set *rs = ti->private; | ||
1582 | struct md_rdev *r; | 1581 | struct md_rdev *r; |
1583 | 1582 | ||
1583 | for (i = 0; i < rs->md.raid_disks; i++) { | ||
1584 | r = &rs->dev[i].rdev; | ||
1585 | if (test_bit(Faulty, &r->flags) && r->sb_page && | ||
1586 | sync_page_io(r, 0, r->sb_size, r->sb_page, READ, 1)) { | ||
1587 | DMINFO("Faulty %s device #%d has readable super block." | ||
1588 | " Attempting to revive it.", | ||
1589 | rs->raid_type->name, i); | ||
1590 | r->raid_disk = i; | ||
1591 | r->saved_raid_disk = i; | ||
1592 | flags = r->flags; | ||
1593 | clear_bit(Faulty, &r->flags); | ||
1594 | clear_bit(WriteErrorSeen, &r->flags); | ||
1595 | clear_bit(In_sync, &r->flags); | ||
1596 | if (r->mddev->pers->hot_add_disk(r->mddev, r)) { | ||
1597 | r->raid_disk = -1; | ||
1598 | r->saved_raid_disk = -1; | ||
1599 | r->flags = flags; | ||
1600 | } else { | ||
1601 | r->recovery_offset = 0; | ||
1602 | cleared_failed_devices |= 1 << i; | ||
1603 | } | ||
1604 | } | ||
1605 | } | ||
1606 | if (cleared_failed_devices) { | ||
1607 | rdev_for_each(r, &rs->md) { | ||
1608 | sb = page_address(r->sb_page); | ||
1609 | failed_devices = le64_to_cpu(sb->failed_devices); | ||
1610 | failed_devices &= ~cleared_failed_devices; | ||
1611 | sb->failed_devices = cpu_to_le64(failed_devices); | ||
1612 | } | ||
1613 | } | ||
1614 | } | ||
1615 | |||
1616 | static void raid_resume(struct dm_target *ti) | ||
1617 | { | ||
1618 | struct raid_set *rs = ti->private; | ||
1619 | |||
1584 | set_bit(MD_CHANGE_DEVS, &rs->md.flags); | 1620 | set_bit(MD_CHANGE_DEVS, &rs->md.flags); |
1585 | if (!rs->bitmap_loaded) { | 1621 | if (!rs->bitmap_loaded) { |
1586 | bitmap_load(&rs->md); | 1622 | bitmap_load(&rs->md); |
@@ -1591,37 +1627,7 @@ static void raid_resume(struct dm_target *ti) | |||
1591 | * Take this opportunity to check whether any failed | 1627 | * Take this opportunity to check whether any failed |
1592 | * devices are reachable again. | 1628 | * devices are reachable again. |
1593 | */ | 1629 | */ |
1594 | for (i = 0; i < rs->md.raid_disks; i++) { | 1630 | attempt_restore_of_faulty_devices(rs); |
1595 | r = &rs->dev[i].rdev; | ||
1596 | if (test_bit(Faulty, &r->flags) && r->sb_page && | ||
1597 | sync_page_io(r, 0, r->sb_size, | ||
1598 | r->sb_page, READ, 1)) { | ||
1599 | DMINFO("Faulty device #%d has readable super" | ||
1600 | "block. Attempting to revive it.", i); | ||
1601 | r->raid_disk = i; | ||
1602 | r->saved_raid_disk = i; | ||
1603 | flags = r->flags; | ||
1604 | clear_bit(Faulty, &r->flags); | ||
1605 | clear_bit(WriteErrorSeen, &r->flags); | ||
1606 | clear_bit(In_sync, &r->flags); | ||
1607 | if (r->mddev->pers->hot_add_disk(r->mddev, r)) { | ||
1608 | r->raid_disk = -1; | ||
1609 | r->saved_raid_disk = -1; | ||
1610 | r->flags = flags; | ||
1611 | } else { | ||
1612 | r->recovery_offset = 0; | ||
1613 | cleared_failed_devices |= 1 << i; | ||
1614 | } | ||
1615 | } | ||
1616 | } | ||
1617 | if (cleared_failed_devices) { | ||
1618 | rdev_for_each(r, &rs->md) { | ||
1619 | sb = page_address(r->sb_page); | ||
1620 | failed_devices = le64_to_cpu(sb->failed_devices); | ||
1621 | failed_devices &= ~cleared_failed_devices; | ||
1622 | sb->failed_devices = cpu_to_le64(failed_devices); | ||
1623 | } | ||
1624 | } | ||
1625 | } | 1631 | } |
1626 | 1632 | ||
1627 | clear_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); | 1633 | clear_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); |