• NeilBrown's avatar
    md/raid1: make sure resync waits for conflicting writes to complete. · 0fdbd42f
    NeilBrown authored
    commit 2f73d3c5 upstream.
    
    The resync/recovery process for raid1 was recently changed
    so that writes could happen in parallel with resync providing
    they were in different regions of the device.
    
    There is a problem though:  While a write request will always
    wait for conflicting resync to complete, a resync request
    will *not* always wait for conflicting writes to complete.
    
    Two changes are needed to fix this:
    
    1/ raise_barrier (which waits until it is safe to do resync)
       must wait until current_window_requests is zero
    2/ wait_battier (which waits at the start of a new write request)
       must update current_window_requests if the request could
       possible conflict with a concurrent resync.
    
    As concurrent writes and resync can lead to data loss,
    this patch is suitable for -stable.
    
    Fixes: 79ef3a8a
    Cc: majianpeng <majianpeng@gmail.com>
    Signed-off-by: default avatarNeilBrown <neilb@suse.de>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0fdbd42f
raid1.c 86.9 KB