• NeilBrown's avatar
    md: lock access to rdev attributes properly · 27c529bb
    NeilBrown authored
    When we access attributes of an rdev (component device on an md array) through
    sysfs, we really need to lock the array against concurrent changes.  We
    currently do that when we change an attribute, but not when we read an
    attribute.  We need to lock when reading as well else rdev->mddev could become
    NULL while we are accessing it.
    
    So add appropriate locking (mddev_lock) to rdev_attr_show.
    
    rdev_size_store requires some extra care as well as it needs to unlock the
    mddev while scanning other mddevs for overlapping regions.  We currently
    assume that rdev->mddev will still be unchanged after the scan, but that
    cannot be certain.  So take a copy of rdev->mddev for use at the end of the
    function.
    Signed-off-by: default avatarNeil Brown <neilb@suse.de>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    27c529bb
md.c 152 KB