super1: fix some casts  of signed superblock fields.

These need to be cast to uint32_t before being cast to 'long', else
sign extension doesn't happen on 64bit hosts.

And bitmap_offset is le32, not le64 !!

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble: --update=metadata converts v0.90 to v1.0

This allows the smooth conversion of legacy 0.90 arrays
to 1.0 metadata.
Old metadata is likely to remain but will be ignored.
It can be removed with
  mdadm --zero-superblock --metadata=0.90 /dev/whatever

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble: allow --update=revert-reshape

This will cause a reshape to start going backwards.
Grow: allow for different sized devices when updating data_offset.

It is possible that the devices in an array have different sizes, and
different data_offsets.  So the 'before_space' and 'after_space' may
be different from drive to drive.
Any decisions about how much to change the data_offset must work on
all devices, so must be based on the minimum available space on
any devices.

So find this minimum first, then do the calculation.

Signed-off-by: NeilBrown <neilb@suse.de>
super1: set RESHAPE_NO_BACKUP based on new_offset.

We need to check for a backup iff the data_offset has changed.
Testing against level==10 was an effective but short-sighted approach.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow_continue: handle RESHAPE_NO_BACKUP correctly.

If the reshape does not require a backup, Grow_continue can
abort early.

Signed-off-by: NeilBrown <neilb@suse.de>
Incremental: allow --quiet to silence from errors from "-If"

-q is currently ineffective on "mdadm -If".   Messages that are not
usage errors should be suppressed.

Signed-off-by: NeilBrown <neilb@suse.de>
Make sure NOFILE resource limit is big enough.

Some people want to create truely enormous arrays.
As we sometimes need to hold one file descriptor for each
device, this can hit  the NOFILE limit.

So raise the limit if it ever looks like it might be a problem.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.h: add little bits of doco for 'struct superswitch'.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble/Incr: Don't include spares with too-high event count.

Some failure scenarios can leave a spare with a higher event count
than an in-sync device.  Assembling an array like this will confuse
the kernel.
So detect spares with event counts higher than the best non-spare
event count and exclude them from the array.

Reported-by: Alexander Lyakas <alex.bolshoy@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>