• NeilBrown's avatar
    md: close a race with setting mddev->in_sync · 55cc39f3
    NeilBrown authored
    If ->in_sync is being set just as md_write_start() is being called,
    it is possible that set_in_sync() won't see the elevated
    ->writes_pending, and md_write_start() won't see the set ->in_sync.
    
    To close this race, re-test ->writes_pending after setting ->in_sync,
    and add memory barriers to ensure the increment of ->writes_pending
    will be seen by the time of this second test, or the new ->in_sync
    will be seen by md_write_start().
    
    Add a spinlock to array_state_show() to ensure this temporary
    instability is never visible from userspace.
    Signed-off-by: default avatarNeilBrown <neilb@suse.com>
    Signed-off-by: default avatarShaohua Li <shli@fb.com>
    55cc39f3
md.c 238 KB