sysfs_read: return devices in same order as in filesystem.

When we read devices from sysfs (../md/dev-*), store them in the same
order that they appear.  That makes more sense when exposed to a
human (as the next patch will).

Signed-off-by: NeilBrown <neilb@suse.de>
Detail: add device information to --detail --export

We may well want more per-device information here, but this
is a start.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble: when forcing a single-degraded RAID6 array, trigger a 'repair'.

When an active/degraded RAID6 array is force-started we clear the
'active' flag, but it is still possible that some parity is
no in sync.  This is because there are two parity block.
It would be nice to be able to tell the kernel "P is OK, Q maybe not".
But that is not possible.

So when we force-assemble such an array, trigger a 'repair' to fix up
any errant Q blocks.

This is not ideal as a restart during the repair will not be continued
after the restart, but it is the best we can do without kernel help.

Signed-off-by: NeilBrown <neilb@suse.de>
Manage: split Manage_runstop into Manage_run and Manage_stop

The two branches have virtually nothing in common, so it is simpler if
they are separate.

Signed-off-by: NeilBrown <neilb@suse.de>
Manage: allow "--stop" on kernel names.

e.g.
   mdadm --stop md4

This works even if udev has become confused or killed.

Signed-off-by: NeilBrown <neilb@suse.de>
Remove lots of unnecessary white space.

Now that I am using white-space mode in Emacs I can see all of this,
and I don't like it :-)

Signed-off-by: NeilBrown <neilb@suse.de>
tests: rearrange sometest groupings.

All 'update' tests in 04
More imsm tests in 09

Signed-off-by: NeilBrown <neilb@suse.de>
Add test for --update=metadata and fix bug it found.

We were not setting device size correctly for raid0.

Signed-off-by: NeilBrown <neilb@suse.de>
Add test for interaction of --assemble with --incr

and fix the bug that it found.  The refactor of start_array()
missed a test.

Signed-off-by: NeilBrown <neilb@suse.de>
tests: add test for non-numeric device names

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: a data_offset should not be tested against 0.

It should always be tested against INVALID_SECTORS!!!

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: Make sure new data-offset is well-aligned

If we choose a new data-offset, make sure it is rounded to a largest
power of to possible, up to 1Meg

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: Try hard to set new_offset.

Setting new_offset can fail if the v1.x "data_size" is too small.
So if that happens, try increasing it first by writing "0".
That can fail on spare devices due to a kernel bug, so if it doesn't
try writing the correct number of sectors.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: fix two problems with new_data_offset

1/ ignore failed devices - obviously
2/ We need to tell the kernel which direction the reshape should
   progress even if we didn't choose the particular data_offset
   to use.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: analyse_change needs to set new_size even if nothing much is happening.

This means it will be set for a "--data-offset" only reshape so that
case doesn't complain that the array is getting smaller.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: clear new_layout when we change the level.

After changing the level, the meaning of layout numbers changes,
so we will keeping a new_layout value around can cause later confusion.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: remove excess drives when converting to RAID0.

When converting to RAID0, all spares and non-data drives
need to be removed first.
It is possible that the first HOT_REMOVE_DISK will fail because the
personality hasn't let go of it yet, so retry a few times.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: centralise level-change code.

There are now 3 places which change level.
And they all do it slightly differently with different
messages etc.

Make a single function for this and use it.

Signed-off-by: NeilBrown <neilb@suse.de>
test/00names: use appropriate mdadm.conf

Using non-numeric names needs an mdadm.conf setting,
so make sure we have one.

Signed-off-by: NeilBrown <neilb@suse.de>
tests: add test for converting levels to raid0 and back.

Now that I have this mostly working, I should make sure
it doesn't break...

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