md_monitor: Update I/O status to pending

We need to update the I/O status to pending to avoid reset_mirror()
to trigger while I/O is still pending.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: fixup device state in recovery

When a device is in recovery and detects an I/O failure we
should be setting the state to 'FAULTY', not 'RECOVERY'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Check MD device state in fail_component()

When we're failing a component we should be updating the device
state, otherwise we might end up failing a working mirror.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: set 'in_recovery' before resetting devices

When a 'RebuildStarted' message is received we should be setting
the 'in_recovery' flag before detecting devices. Otherwise we
might disconnect properly working devices.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: simplify reset_mirror()

When we're calling reset_mirror() we can just check the 'degraded'
flag from the md_devices to figure out the side to be reset.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: update the device state in fail_md_component()

fail_md_component() should fail the device, and not just update
the state. Otherwise we might not even fail the device at all.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_functions: Do not stop MDADM_PID on exit

Handled by EXIT trap.

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

Add checkpoint messages for QA integration.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: convert if-clause in md_rdev_update_state()

Convert if-clause to a switch for better readability.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase12: Checkpointing and simplify testcase

Modify testcase to use proper checkpoint messages and
simplify the state checks by first waiting for sync.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Do not fail devices on z/VM 'detach'

When a 'move' event is received the device itself will only
start reporting I/O errors a short while after. So if we
start to fail devices pre-emptively on this event the path
checker will detect the devices as running. This will cause
a recovery to start, which will immediately being interrupted
by the device throwing I/O errors.

So we should rather ignore this event and let md_monitor catch
the resulting I/O errors.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_functions: Stop iostat upon exit

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_*: Seek monitor_functions in the same dir

monitor_testcase_functions.sh is now assumed to reside in the same directory as
the script itself.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_3: Remove the test for $?

Let's get rid of the test for $? in preparation of setting on "-o errexit".

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase_functions: Mask exit status of some commands

In preparation of switching on shell option -e (alias -o errexit) we mask
command exit status where we don't care about success/fail.

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

Immediately terminate the script upon any failure.

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

Immediately terminate the script upon any failure.

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

Immediately terminate the script upon any failure.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
monitor_testcase: use wait_md()

Introduce wait_md() function instead of calling mdadm --wait
directly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_12: reset devices on exit

When the script is terminated abnormally we should be resetting /
reattaching all devices to get the system back in a sane state.
As we cannot sensibly save and restore the trap command I've
added a function 'reset_devices' which will take care of that.

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