• J
    DM RAID: Fix raid_resume not reviving failed devices in all cases · a4dc163a
    Jonathan Brassow 提交于
    DM RAID:  Fix raid_resume not reviving failed devices in all cases
    
    When a device fails in a RAID array, it is marked as Faulty.  Later,
    md_check_recovery is called which (through the call chain) calls
    'hot_remove_disk' in order to have the personalities remove the device
    from use in the array.
    
    Sometimes, it is possible for the array to be suspended before the
    personalities get their chance to perform 'hot_remove_disk'.  This is
    normally not an issue.  If the array is deactivated, then the failed
    device will be noticed when the array is reinstantiated.  If the
    array is resumed and the disk is still missing, md_check_recovery will
    be called upon resume and 'hot_remove_disk' will be called at that
    time.  However, (for dm-raid) if the device has been restored,
    a resume on the array would cause it to attempt to revive the device
    by calling 'hot_add_disk'.  If 'hot_remove_disk' had not been called,
    a situation is then created where the device is thought to concurrently
    be the replacement and the device to be replaced.  Thus, the device
    is first sync'ed with the rest of the array (because it is the replacement
    device) and then marked Faulty and removed from the array (because
    it is also the device being replaced).
    
    The solution is to check and see if the device had properly been removed
    before the array was suspended.  This is done by seeing whether the
    device's 'raid_disk' field is -1 - a condition that implies that
    'md_check_recovery -> remove_and_add_spares (where raid_disk is set to -1)
    -> hot_remove_disk' has been called.  If 'raid_disk' is not -1, then
    'hot_remove_disk' must be called to complete the removal of the previously
    faulty device before it can be revived via 'hot_add_disk'.
    Signed-off-by: NJonathan Brassow <jbrassow@redhat.com>
    Signed-off-by: NNeilBrown <neilb@suse.de>
    a4dc163a
dm-raid.c 45.0 KB