• Heinz Mauelshagen's avatar
    dm raid: fix inconclusive reshape layout on fast raid4/5/6 table reload sequences · f99a8e43
    Heinz Mauelshagen authored
    If fast table reloads occur during an ongoing reshape of raid4/5/6
    devices the target may race reading a superblock vs the the MD resync
    thread; causing an inconclusive reshape state to be read in its
    constructor.
    
    lvm2 test lvconvert-raid-reshape-stripes-load-reload.sh can cause
    BUG_ON() to trigger in md_run(), e.g.:
    "kernel BUG at drivers/md/raid5.c:7567!".
    
    Scenario triggering the bug:
    
    1. the MD sync thread calls end_reshape() from raid5_sync_request()
       when done reshaping. However end_reshape() _only_ updates the
       reshape position to MaxSector keeping the changed layout
       configuration though (i.e. any delta disks, chunk sector or RAID
       algorithm changes). That inconclusive configuration is stored in
       the superblock.
    
    2. dm-raid constructs a mapping, loading named inconsistent superblock
       as of step 1 before step 3 is able to finish resetting the reshape
       state completely, and calls md_run() which leads to mentioned bug
       in raid5.c.
    
    3. the MD RAID personality's finish_reshape() is called; which resets
       the reshape information on chunk sectors, delta disks, etc. This
       explains why the bug is rarely seen on multi-core machines, as MD's
       finish_reshape() superblock update races with the dm-raid
       constructor's superblock load in step 2.
    
    Fix identifies inconclusive superblock content in the dm-raid
    constructor and resets it before calling md_run(), factoring out
    identifying checks into rs_is_layout_change() to share in existing
    rs_reshape_requested() and new rs_reset_inclonclusive_reshape(). Also
    enhance a comment and remove an empty line.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    f99a8e43
dm-raid.c 118 KB