Commit 4e59ca7d authored by Dan Williams's avatar Dan Williams Committed by NeilBrown

md: rcu_read_lock() walk of mddev->disks in md_do_sync()

Other walks of this list are either under rcu_read_lock() or the list
mutation lock (mddev_lock()).  This protects against the improbable case of a
disk being removed from the array at the start of md_do_sync().
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 93be75ff
...@@ -6526,12 +6526,14 @@ void md_do_sync(mddev_t *mddev) ...@@ -6526,12 +6526,14 @@ void md_do_sync(mddev_t *mddev)
/* recovery follows the physical size of devices */ /* recovery follows the physical size of devices */
max_sectors = mddev->dev_sectors; max_sectors = mddev->dev_sectors;
j = MaxSector; j = MaxSector;
list_for_each_entry(rdev, &mddev->disks, same_set) rcu_read_lock();
list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
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) &&
rdev->recovery_offset < j) rdev->recovery_offset < j)
j = rdev->recovery_offset; j = rdev->recovery_offset;
rcu_read_unlock();
} }
printk(KERN_INFO "md: %s of RAID array %s\n", desc, mdname(mddev)); printk(KERN_INFO "md: %s of RAID array %s\n", desc, mdname(mddev));
...@@ -6701,12 +6703,14 @@ void md_do_sync(mddev_t *mddev) ...@@ -6701,12 +6703,14 @@ void md_do_sync(mddev_t *mddev)
} else { } else {
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
mddev->curr_resync = MaxSector; mddev->curr_resync = MaxSector;
list_for_each_entry(rdev, &mddev->disks, same_set) rcu_read_lock();
list_for_each_entry_rcu(rdev, &mddev->disks, same_set)
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) &&
rdev->recovery_offset < mddev->curr_resync) rdev->recovery_offset < mddev->curr_resync)
rdev->recovery_offset = mddev->curr_resync; rdev->recovery_offset = mddev->curr_resync;
rcu_read_unlock();
} }
} }
set_bit(MD_CHANGE_DEVS, &mddev->flags); set_bit(MD_CHANGE_DEVS, &mddev->flags);
......
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