md_monitor: Lock thread variable

The '->thread' variable can be accessed from various contexts,
and will be set to '0' if the thread is stopped.
Unfortunately the pthread library will crash if called with
0 argument, so we need to protect any accesses to this
via locks.

References: bnc#808647

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Check md_monitor structure against deletion

The md_monitor structure might be deleted asynchronously,
so we should check for the ->device pointer for validity.

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

Add reference counting to device_monitor structures.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_functions: fix typo in error_exit

error_exit has a typo which prevents it from printing any
messages.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_8: Wait for sync

We should be waiting for the array be become synchronized again
after the test case.

Signed-off-by: Hannes Reinecke <hare@suse.de>
monitor_testcase_8: Debugging output for mdadm --wait bug

mdadm --wait has a bug which makes it basically unuseable for
regression testing. Adding some more debugging messages to
track down this issue.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: Reset MD after 'SpareActive'

Whenever a device is being set to 'spare' we should check if
we can reset the array. Otherwise the array might stay in
degraded mode.

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

Testcase is now working a expected, so remove stale lines.

Signed-off-by: Hannes Reinecke <hare@suse.de>
md_monitor: lock accesses to dev->running

'running' might be modified from other threads, so we need to
lock it in dasd_monitor_thread.

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

Now that bug#817587 is fixed we can remove the workaround in
testcase 8.

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

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