aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/md/md.c33
-rw-r--r--include/linux/raid/md_k.h2
2 files changed, 10 insertions, 25 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 25f2bbfe6a2b..097ae1b5484b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -3424,21 +3424,17 @@ static int md_thread(void * arg)
3424 */ 3424 */
3425 3425
3426 allow_signal(SIGKILL); 3426 allow_signal(SIGKILL);
3427 complete(thread->event);
3428 while (!kthread_should_stop()) { 3427 while (!kthread_should_stop()) {
3429 void (*run)(mddev_t *);
3430 3428
3431 wait_event_interruptible_timeout(thread->wqueue, 3429 wait_event_timeout(thread->wqueue,
3432 test_bit(THREAD_WAKEUP, &thread->flags) 3430 test_bit(THREAD_WAKEUP, &thread->flags)
3433 || kthread_should_stop(), 3431 || kthread_should_stop(),
3434 thread->timeout); 3432 thread->timeout);
3435 try_to_freeze(); 3433 try_to_freeze();
3436 3434
3437 clear_bit(THREAD_WAKEUP, &thread->flags); 3435 clear_bit(THREAD_WAKEUP, &thread->flags);
3438 3436
3439 run = thread->run; 3437 thread->run(thread->mddev);
3440 if (run)
3441 run(thread->mddev);
3442 } 3438 }
3443 3439
3444 return 0; 3440 return 0;
@@ -3457,7 +3453,6 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
3457 const char *name) 3453 const char *name)
3458{ 3454{
3459 mdk_thread_t *thread; 3455 mdk_thread_t *thread;
3460 struct completion event;
3461 3456
3462 thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL); 3457 thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL);
3463 if (!thread) 3458 if (!thread)
@@ -3466,18 +3461,14 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
3466 memset(thread, 0, sizeof(mdk_thread_t)); 3461 memset(thread, 0, sizeof(mdk_thread_t));
3467 init_waitqueue_head(&thread->wqueue); 3462 init_waitqueue_head(&thread->wqueue);
3468 3463
3469 init_completion(&event);
3470 thread->event = &event;
3471 thread->run = run; 3464 thread->run = run;
3472 thread->mddev = mddev; 3465 thread->mddev = mddev;
3473 thread->name = name;
3474 thread->timeout = MAX_SCHEDULE_TIMEOUT; 3466 thread->timeout = MAX_SCHEDULE_TIMEOUT;
3475 thread->tsk = kthread_run(md_thread, thread, name, mdname(thread->mddev)); 3467 thread->tsk = kthread_run(md_thread, thread, name, mdname(thread->mddev));
3476 if (IS_ERR(thread->tsk)) { 3468 if (IS_ERR(thread->tsk)) {
3477 kfree(thread); 3469 kfree(thread);
3478 return NULL; 3470 return NULL;
3479 } 3471 }
3480 wait_for_completion(&event);
3481 return thread; 3472 return thread;
3482} 3473}
3483 3474
@@ -3941,9 +3932,7 @@ static void md_do_sync(mddev_t *mddev)
3941 mddev->curr_resync = 2; 3932 mddev->curr_resync = 2;
3942 3933
3943 try_again: 3934 try_again:
3944 if (signal_pending(current) || 3935 if (kthread_should_stop()) {
3945 kthread_should_stop()) {
3946 flush_signals(current);
3947 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 3936 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
3948 goto skip; 3937 goto skip;
3949 } 3938 }
@@ -3963,9 +3952,8 @@ static void md_do_sync(mddev_t *mddev)
3963 * time 'round when curr_resync == 2 3952 * time 'round when curr_resync == 2
3964 */ 3953 */
3965 continue; 3954 continue;
3966 prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE); 3955 prepare_to_wait(&resync_wait, &wq, TASK_UNINTERRUPTIBLE);
3967 if (!signal_pending(current) && 3956 if (!kthread_should_stop() &&
3968 !kthread_should_stop() &&
3969 mddev2->curr_resync >= mddev->curr_resync) { 3957 mddev2->curr_resync >= mddev->curr_resync) {
3970 printk(KERN_INFO "md: delaying resync of %s" 3958 printk(KERN_INFO "md: delaying resync of %s"
3971 " until %s has finished resync (they" 3959 " until %s has finished resync (they"
@@ -4074,13 +4062,12 @@ static void md_do_sync(mddev_t *mddev)
4074 } 4062 }
4075 4063
4076 4064
4077 if (signal_pending(current) || kthread_should_stop()) { 4065 if (kthread_should_stop()) {
4078 /* 4066 /*
4079 * got a signal, exit. 4067 * got a signal, exit.
4080 */ 4068 */
4081 printk(KERN_INFO 4069 printk(KERN_INFO
4082 "md: md_do_sync() got signal ... exiting\n"); 4070 "md: md_do_sync() got signal ... exiting\n");
4083 flush_signals(current);
4084 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 4071 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
4085 goto out; 4072 goto out;
4086 } 4073 }
@@ -4102,7 +4089,7 @@ static void md_do_sync(mddev_t *mddev)
4102 if (currspeed > sysctl_speed_limit_min) { 4089 if (currspeed > sysctl_speed_limit_min) {
4103 if ((currspeed > sysctl_speed_limit_max) || 4090 if ((currspeed > sysctl_speed_limit_max) ||
4104 !is_mddev_idle(mddev)) { 4091 !is_mddev_idle(mddev)) {
4105 msleep_interruptible(250); 4092 msleep(250);
4106 goto repeat; 4093 goto repeat;
4107 } 4094 }
4108 } 4095 }
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index d5854c2b2721..46629a275ba9 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -334,10 +334,8 @@ typedef struct mdk_thread_s {
334 mddev_t *mddev; 334 mddev_t *mddev;
335 wait_queue_head_t wqueue; 335 wait_queue_head_t wqueue;
336 unsigned long flags; 336 unsigned long flags;
337 struct completion *event;
338 struct task_struct *tsk; 337 struct task_struct *tsk;
339 unsigned long timeout; 338 unsigned long timeout;
340 const char *name;
341} mdk_thread_t; 339} mdk_thread_t;
342 340
343#define THREAD_WAKEUP 0 341#define THREAD_WAKEUP 0