• Neil Brown's avatar
    [PATCH] md 17 of 22 - Strengthen the locking of mddev. · bc0eea33
    Neil Brown authored
    Strengthen the locking of mddev.
    
    mddev is only ever locked in md.c, so we move {,un}lock_mddev
    out of the header and into md.c, and rename to mddev_{,un}lock
    for consistancy with mddev_{get,put,find}.
    
    When building arrays (typically at boot time) we now lock, and unlock
    as it is the "right" thing to do.  The lock should never fail.
    
    When generating /proc/mdstat, we lock each array before inspecting it.
    
    In md_ioctl, we lock the mddev early and unlock at the end, rather than
    locking in two different places.
    
    In md_open we make sure we can get a lock before completing the open.  This
    ensures that we sync with do_md_stop properly.
    
    In md_do_recovery, we lock each mddev before checking it's status.
    
    md_do_recovery must unlock while recovery happens, and a do_md_stop at this
    point will deadlock when md_do_recovery tries to regain the lock.  This will be
    fixed in a later patch.
    bc0eea33
md_k.h 8.64 KB