Don't set 'hold' option for mdstat_read if not needed.

We only need 'hold' if we want to mdstat_wait for a change.
These two callers don't care about a change, so they shouldn't
use the 'hold' flag.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: use mdstat_wait to wait for delayed reshape.

Having a fix time for a wait is clumsy and can make us
wait much too long.
So use mdstat_wait and keep the mdstat_fd open.
This requires an 'mdstat_close' so it doesn't stay open
forever.

Signed-off-by: NeilBrown <neilb@suse.de>
Stop: fix up synchronising end of reshape to good boundary.

If we stop too soon after reshape starts (probably only during
testing), we can get confused by the status of the reshape.
If that might be happening - sleep a bit longer.

Also allow for reshape going unusually slowly (again, probably only
during testing).

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

This was waiting on "reshape_position" which doesn't
get update events.
Before sysfs_wait was introduced, the code to wait didn't
wait at all, so it spun.
With sysfs_wait, it would wait forever.

Change to wait in sync_completed which does get events.

Signed-off-by: NeilBrown <neilb@suse.de>
Grow: pass INVALID_SECTORS to reshape_array, not 0.

'0' means 'make it 0', which isn't what we want here.
We want 'leave it unchanged'.

Signed-off-by: NeilBrown  <neilb@suse.de>
test: allow resync/reshape etc to go faster.

Whenever we "check wait" - make the resync process go at full speed.

Also allow script to adjust it manually.

Signed-off-by: NeilBrown <neilb@suse.de>
Merge commit '956a13fb850321bed8568dfa8692c0c323538d7c'
DDF: increase seq number in ddf_set_updates_pending

Increase seq number only when there's actually a metadata change.
This is better then increasing it at every write.

This also fixes another endianness bug.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: make "null_aligned" a static buffer

Use a static buffer for this "zero page". This makes it easier
to factor out the header writing code.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: factor out writing super block to single disk

Factor out single disk from __write_init_super_ddf to a new function
_write_super_to_disk. Use this function in store_super_ddf.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: err_bad_md_layout: fix return value

This function must use -1 to indicate failure. Fix it.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: kill_subarray_ddf: fix case without mdmon running

When mdmon wasn't runnning, meta data wasn't committed to disk.
Fixed.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: getinfo_super_ddf_bvd: fix offset calculation for SVDs

Fix a bug that caused the wrong conf record to be used to derive
data offset and size on secondary RAID (RAID10).

Signed-off-by: NeilBrown <neilb@suse.de>
tests/10ddf-create: create RAID5 first

Let the first created array be RAID5 rather than RAID0. This makes
the test harder than before, because everything after the first
Create has do be done indirectly through mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
test: increase number of devices to 13

extended DDF/RAID10 tests need 6 disks for DDF.

Signed-off-by: NeilBrown <neilb@suse.de>
tests/10ddf-geometry: new unit test

Test various RAID geometries, creation and deletion of subarrays

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: add endian-safe typedefs

This adds typedefs for big-endian numbers. This will hopefully
reduce the number of endianness bugs I make.

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: convert big endian to be32 type

Part 2 of endianness-safe conversion

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: convert big-endian __u64 to be64 type

Signed-off-by: NeilBrown <neilb@suse.de>
DDF: convert big-endian __u16 to be16 type

Last step of endian-safe recoding. This requires also bit
operations.

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