md_monitor: Remove unused argument to fail_md_component()

fail_md_component() never referenced the first argument,
so remove it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: rename mddev->lock into ->status_lock

In preparation for fine-grained locking.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: fine-grained locking

Using a single lock to protect the md structure causes delays
when processing CLI commands. So by the time the CLI command
is processed recovery might already have been started, causing
md_monitor to errorneously fail the array.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_2: Improve waiting

Instead of just call 'sleep 10' we should be calling
wait_for_sync() as recovery might have been started.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_functions: Ensure proper termination of dt

The SIGTER we send to the subshell running dt somehow does not get propagated
to dt.  As running dt is the last action made by the subshell there is no point
in keeping it around.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_4: Enable -o errexit for increased safety

Immediately terminate the script upon any failure.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_5: Enable -o errexit for increased safety

Immediately terminate the script upon any failure.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_functions: Not finding 'dt' is not fatal

'which' returns an error exit status if it does not find the executable.  That
should not stop our scripts.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_functions: Remove unused variable

DT_PID is not needed after we switched back to job control in 87bb3fb
(monitor_testcase_functions: use % jobspec when terminating dd).

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_functions: Kill dd upon process termination

We need to signal dd when the parent process exits.  Bash does not process
signals when it's waiting for a command to complete therefore we must start dd
in background and set an EXIT trap to pass the signal to the backrounded dd.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
md_monitor: ignore non-existent 'holders' directory

When discovering devices the 'holders' directory might not
be present (yet). So fix the code to properly ignore this
and continue.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Attach devices from discover_md_components()

During recovery or restarting offlined devices MD might already
have attached the devices, even though the corresponding udev
event hasn't been processed yet. So we should attach the devices
during discover_md_components().

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_3: Wait for md_monitor to pick up changes

When reactivating the failed array udev will send out events
for every device, which will cause 'mdadm --incremental' to be
called for every device. This in turn will start a recovery for
every device, so wait_for_sync will return with an error after
the first recovery, even though there are more device events
pending. Or another recovery might already have been started.
So we need to wait for md_monitor to pick up changes, which
will indicate if all devices have been processed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_5: Check for z/VM guest

Testcase 5 is using chpid on/off, which need a dedicated machine
to work correctly. So disable this test for every other instance.

Signed-off-by: Hannes Reinecke <hare@suse.de>
dasd.php: Add script for managing DASDs

dasd.php is a script for managing DASDs via a web interface.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_6: Cleanups

When waiting for reservations to be registered we should be
limiting the wait, so as not to wait forever.
And the call to 'wget' should be put into a function for
better readability.
And we should always set the device to 'online' via wget
to be sure the reserve call will succeed.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Merge branch 'master' of github.com:/hreinecke/md_monitor
monitor_testcase_1: Clean shutdown

On shutdown we should be disabling all traps, and shut down
the array by hand. Otherwise we might run into problems as
the monitor is still running.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: separate out 'allocate_dasd' function

We need to allocate the device_monitor structure in several
places, so separate it out to a function.

Signed-off-by: Hannes Reinecke <hare@suse.de>