Commit 6985c43f authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] Three one-liners in md.c

The main problem fixes is that in certain situations stopping md arrays may
take longer than you expect, or may require multiple attempts.  This would
only happen when resync/recovery is happening.

This patch fixes three vaguely related bugs.

1/ The recent change to use kthreads got the setting of the
   process name wrong.  This fixes it.
2/ The recent change to use kthreads lost the ability for
   md threads to be signalled with SIG_KILL.  This restores that.
3/ There is a long standing bug in that if:
    - An array needs recovery (onto a hot-spare) and
    - The recovery is being blocked because some other array being
       recovered shares a physical device and
    - The recovery thread is killed with SIG_KILL
   Then the recovery will appear to have completed with no IO being
   done, which can cause data corruption.
   This patch makes sure that incomplete recovery will be treated as
   incomplete.

Note that any kernel affected by bug 2 will not suffer the problem of bug
3, as the signal can never be delivered.  Thus the current 2.6.14-rc
kernels are not susceptible to data corruption.  Note also that if arrays
are shutdown (with "mdadm -S" or "raidstop") then the problem doesn't
occur.  It only happens if a SIGKILL is independently delivered as done by
'init' when shutting down.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4a9949d7
...@@ -3063,6 +3063,7 @@ static int md_thread(void * arg) ...@@ -3063,6 +3063,7 @@ static int md_thread(void * arg)
* many dirty RAID5 blocks. * many dirty RAID5 blocks.
*/ */
allow_signal(SIGKILL);
complete(thread->event); complete(thread->event);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
void (*run)(mddev_t *); void (*run)(mddev_t *);
...@@ -3111,7 +3112,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, ...@@ -3111,7 +3112,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
thread->mddev = mddev; thread->mddev = mddev;
thread->name = name; thread->name = name;
thread->timeout = MAX_SCHEDULE_TIMEOUT; thread->timeout = MAX_SCHEDULE_TIMEOUT;
thread->tsk = kthread_run(md_thread, thread, mdname(thread->mddev)); thread->tsk = kthread_run(md_thread, thread, name, mdname(thread->mddev));
if (IS_ERR(thread->tsk)) { if (IS_ERR(thread->tsk)) {
kfree(thread); kfree(thread);
return NULL; return NULL;
...@@ -3569,6 +3570,7 @@ static void md_do_sync(mddev_t *mddev) ...@@ -3569,6 +3570,7 @@ static void md_do_sync(mddev_t *mddev)
try_again: try_again:
if (signal_pending(current)) { if (signal_pending(current)) {
flush_signals(current); flush_signals(current);
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
goto skip; goto skip;
} }
ITERATE_MDDEV(mddev2,tmp) { ITERATE_MDDEV(mddev2,tmp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment