• NeilBrown's avatar
    md: set and test the ->persistent flag for md devices more consistently · 1ec4a939
    NeilBrown authored
    If you try to start an array for which the number of raid disks is listed as
    zero, md will currently try to read metadata off any devices that have been
    given.  This was done because the value of raid_disks is used to signal
    whether array details have been provided by userspace (raid_disks > 0) or must
    be read from the devices (raid_disks == 0).
    
    However for an array without persistent metadata (or with externally managed
    metadata) this is the wrong thing to do.  So we add a test in do_md_run to
    give an error if raid_disks is zero for non-persistent arrays.
    
    This requires that mddev->persistent is set corrently at this point, which it
    currently isn't for in-kernel autodetected arrays.
    
    So set ->persistent for autodetect arrays, and remove the settign in
    super_*_validate which is now redundant.
    
    Also clear ->persistent when stopping an array so it is consistently zero when
    starting an array.
    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>
    1ec4a939
md.c 149 KB