diff options
-rw-r--r-- | drivers/md/md.c | 58 | ||||
-rw-r--r-- | drivers/md/raid1.c | 1 | ||||
-rw-r--r-- | drivers/md/raid10.c | 1 | ||||
-rw-r--r-- | drivers/md/raid5.c | 1 | ||||
-rw-r--r-- | drivers/md/raid6main.c | 1 |
5 files changed, 24 insertions, 38 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 60835dfd058e..c842e34d850e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3203,37 +3203,6 @@ void md_write_end(mddev_t *mddev) | |||
3203 | } | 3203 | } |
3204 | } | 3204 | } |
3205 | 3205 | ||
3206 | static inline void md_enter_safemode(mddev_t *mddev) | ||
3207 | { | ||
3208 | if (!mddev->safemode) return; | ||
3209 | if (mddev->safemode == 2 && | ||
3210 | (atomic_read(&mddev->writes_pending) || mddev->in_sync || | ||
3211 | mddev->recovery_cp != MaxSector)) | ||
3212 | return; /* avoid the lock */ | ||
3213 | mddev_lock_uninterruptible(mddev); | ||
3214 | if (mddev->safemode && !atomic_read(&mddev->writes_pending) && | ||
3215 | !mddev->in_sync && mddev->recovery_cp == MaxSector) { | ||
3216 | mddev->in_sync = 1; | ||
3217 | md_update_sb(mddev); | ||
3218 | } | ||
3219 | mddev_unlock(mddev); | ||
3220 | |||
3221 | if (mddev->safemode == 1) | ||
3222 | mddev->safemode = 0; | ||
3223 | } | ||
3224 | |||
3225 | void md_handle_safemode(mddev_t *mddev) | ||
3226 | { | ||
3227 | if (signal_pending(current)) { | ||
3228 | printk(KERN_INFO "md: %s in immediate safe mode\n", | ||
3229 | mdname(mddev)); | ||
3230 | mddev->safemode = 2; | ||
3231 | flush_signals(current); | ||
3232 | } | ||
3233 | md_enter_safemode(mddev); | ||
3234 | } | ||
3235 | |||
3236 | |||
3237 | static DECLARE_WAIT_QUEUE_HEAD(resync_wait); | 3206 | static DECLARE_WAIT_QUEUE_HEAD(resync_wait); |
3238 | 3207 | ||
3239 | #define SYNC_MARKS 10 | 3208 | #define SYNC_MARKS 10 |
@@ -3449,7 +3418,6 @@ static void md_do_sync(mddev_t *mddev) | |||
3449 | mddev->recovery_cp = MaxSector; | 3418 | mddev->recovery_cp = MaxSector; |
3450 | } | 3419 | } |
3451 | 3420 | ||
3452 | md_enter_safemode(mddev); | ||
3453 | skip: | 3421 | skip: |
3454 | mddev->curr_resync = 0; | 3422 | mddev->curr_resync = 0; |
3455 | wake_up(&resync_wait); | 3423 | wake_up(&resync_wait); |
@@ -3490,14 +3458,37 @@ void md_check_recovery(mddev_t *mddev) | |||
3490 | 3458 | ||
3491 | if (mddev->ro) | 3459 | if (mddev->ro) |
3492 | return; | 3460 | return; |
3461 | |||
3462 | if (signal_pending(current)) { | ||
3463 | if (mddev->pers->sync_request) { | ||
3464 | printk(KERN_INFO "md: %s in immediate safe mode\n", | ||
3465 | mdname(mddev)); | ||
3466 | mddev->safemode = 2; | ||
3467 | } | ||
3468 | flush_signals(current); | ||
3469 | } | ||
3470 | |||
3493 | if ( ! ( | 3471 | if ( ! ( |
3494 | mddev->sb_dirty || | 3472 | mddev->sb_dirty || |
3495 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || | 3473 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || |
3496 | test_bit(MD_RECOVERY_DONE, &mddev->recovery) | 3474 | test_bit(MD_RECOVERY_DONE, &mddev->recovery) || |
3475 | (mddev->safemode == 1) || | ||
3476 | (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending) | ||
3477 | && !mddev->in_sync && mddev->recovery_cp == MaxSector) | ||
3497 | )) | 3478 | )) |
3498 | return; | 3479 | return; |
3480 | |||
3499 | if (mddev_trylock(mddev)==0) { | 3481 | if (mddev_trylock(mddev)==0) { |
3500 | int spares =0; | 3482 | int spares =0; |
3483 | |||
3484 | if (mddev->safemode && !atomic_read(&mddev->writes_pending) && | ||
3485 | !mddev->in_sync && mddev->recovery_cp == MaxSector) { | ||
3486 | mddev->in_sync = 1; | ||
3487 | mddev->sb_dirty = 1; | ||
3488 | } | ||
3489 | if (mddev->safemode == 1) | ||
3490 | mddev->safemode = 0; | ||
3491 | |||
3501 | if (mddev->sb_dirty) | 3492 | if (mddev->sb_dirty) |
3502 | md_update_sb(mddev); | 3493 | md_update_sb(mddev); |
3503 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) && | 3494 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) && |
@@ -3741,7 +3732,6 @@ EXPORT_SYMBOL(md_error); | |||
3741 | EXPORT_SYMBOL(md_done_sync); | 3732 | EXPORT_SYMBOL(md_done_sync); |
3742 | EXPORT_SYMBOL(md_write_start); | 3733 | EXPORT_SYMBOL(md_write_start); |
3743 | EXPORT_SYMBOL(md_write_end); | 3734 | EXPORT_SYMBOL(md_write_end); |
3744 | EXPORT_SYMBOL(md_handle_safemode); | ||
3745 | EXPORT_SYMBOL(md_register_thread); | 3735 | EXPORT_SYMBOL(md_register_thread); |
3746 | EXPORT_SYMBOL(md_unregister_thread); | 3736 | EXPORT_SYMBOL(md_unregister_thread); |
3747 | EXPORT_SYMBOL(md_wakeup_thread); | 3737 | EXPORT_SYMBOL(md_wakeup_thread); |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 4947f599b652..b34ad56362df 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -931,7 +931,6 @@ static void raid1d(mddev_t *mddev) | |||
931 | mdk_rdev_t *rdev; | 931 | mdk_rdev_t *rdev; |
932 | 932 | ||
933 | md_check_recovery(mddev); | 933 | md_check_recovery(mddev); |
934 | md_handle_safemode(mddev); | ||
935 | 934 | ||
936 | for (;;) { | 935 | for (;;) { |
937 | char b[BDEVNAME_SIZE]; | 936 | char b[BDEVNAME_SIZE]; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 3c37be6423d7..9ae21504db8a 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1216,7 +1216,6 @@ static void raid10d(mddev_t *mddev) | |||
1216 | mdk_rdev_t *rdev; | 1216 | mdk_rdev_t *rdev; |
1217 | 1217 | ||
1218 | md_check_recovery(mddev); | 1218 | md_check_recovery(mddev); |
1219 | md_handle_safemode(mddev); | ||
1220 | 1219 | ||
1221 | for (;;) { | 1220 | for (;;) { |
1222 | char b[BDEVNAME_SIZE]; | 1221 | char b[BDEVNAME_SIZE]; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 3cb11ac232fa..63b1c59d36ff 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -1546,7 +1546,6 @@ static void raid5d (mddev_t *mddev) | |||
1546 | PRINTK("+++ raid5d active\n"); | 1546 | PRINTK("+++ raid5d active\n"); |
1547 | 1547 | ||
1548 | md_check_recovery(mddev); | 1548 | md_check_recovery(mddev); |
1549 | md_handle_safemode(mddev); | ||
1550 | 1549 | ||
1551 | handled = 0; | 1550 | handled = 0; |
1552 | spin_lock_irq(&conf->device_lock); | 1551 | spin_lock_irq(&conf->device_lock); |
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 908edd78a792..9d0e0e42a3be 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c | |||
@@ -1705,7 +1705,6 @@ static void raid6d (mddev_t *mddev) | |||
1705 | PRINTK("+++ raid6d active\n"); | 1705 | PRINTK("+++ raid6d active\n"); |
1706 | 1706 | ||
1707 | md_check_recovery(mddev); | 1707 | md_check_recovery(mddev); |
1708 | md_handle_safemode(mddev); | ||
1709 | 1708 | ||
1710 | handled = 0; | 1709 | handled = 0; |
1711 | spin_lock_irq(&conf->device_lock); | 1710 | spin_lock_irq(&conf->device_lock); |