Assemble: don't ever consider a 'spare' to be the 'most recent'.

If all devices have the same event count and the first one is a spare,
then that spare will be the 'most_recent'.
However then other devices will think the 'most_recent' has failed
(for v0.90 metadata) and will be rejected from the array.

So never consider a 'spare' to be 'most recent'.

Reported-by: Andreas Baer <synthetic.gods@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
mdmon: make sure we set safe_mode on SIGTERM.

Without this, array may not go clean and mdmon will then
not exit.

A safe_mode of '0' (which is the only one that is handled differently
by this patch) means "never switch to 'active_idle'".  We don't want
that when mdmon is stopping.

Signed-off-by: NeilBrown <neilb@suse.de>
Config: factor reading of file out into separate function.

This will make it easier to read multiple files in a conf.d/

Signed-off-by: NeilBrown <neilb@suse.de>
Conf: allow conf file to be a directory.

If config file is a directory, process each file within with a name
ending in ".conf" that doesn't start with ".".
Files are processed in lexical order.

Signed-off-by: NeilBrown <neilb@suse.de>
config: read /etc/mdadm.conf.d as well as /etc/mdadm.conf

If a configfile is explicitly given, just that file or directory
is read. Otherwise we now read both a file
  /etc/mdadm.conf
and a directory
  /etc/mdadm.conf.d

This allows a transition to directory based config, which in turn
allows easy control from scripts.

Signed-off-by: NeilBrown  <neilb@suse.de>
Config: multiple occurences of lines is not an error.

As we now support config directories it is helpful if
lines are allowed to occur multiple times with one
over-riding the other.
So stop giving warnings when later lines are ignored.

Signed-off-by: NeilBrown <neilb@suse.de>
config: refactor load_conffile() to have a single exit.

This will make next patch cleaner.
No functional change.

Signed-off-by: NeilBrown <neilb@suse.de>
config: support MDADM_CONF_AUTO= env var.

If a distribution allows the choice between using mdadm and
dmraid for DDF and IMSM to be made by some config file
(/etc/defaults/ /sys/sysconfig/ etc) which is queried by
/etc/init.d scripts, then the fact that mdadm implements this
choce through the config file is not very helpful.

So allow the "AUTO" line to be specified in part using MDADM_CONF_AUTO
in environment.

Signed-off-by: NeilBrown <neilb@suse.de>
Release mdadm-3.3

(and  various cosmetic fixes)

Signed-off-by: NeilBrown <neilb@suse.de>