• NeilBrown's avatar
    md: fix race when unfreezing sync_action · 56ccc112
    NeilBrown authored
    A recent change removed the need for locking around writing
    to "sync_action" (and various other places), but introduced a
    subtle race.
    When e.g. setting 'reshape' on a 'frozen' array, the 'frozen'
    flag is cleared before 'reshape' is set, so the md thread can
    get in and start trying recovery - which isn't wanted.
    
    So instead of clearing MD_RECOVERY_FROZEN for any command
    except 'frozen', only clear it when each specific command
    is parsed.  This allows the handling of 'reshape' to clear
    the bit while a lock is held.
    
    Also remove some places where we set MD_RECOVERY_NEEDED,
    as it is always set on non-error exit of the function.
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Fixes: 6791875e ("md: make reconfig_mutex optional for writes to md sysfs files.")
    56ccc112
md.c 233 KB