aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-21 20:17:11 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 22:07:42 -0400
commitfca4d848f0e6fafdc2b25f8a0cf1e76935f13ac2 (patch)
treecabed019bfe5d00ddbe06e349f20cff78ab6f6bf /drivers/md/md.c
parentc361777fb9347a4d16b82272f7d3b234e94bef2d (diff)
[PATCH] md: merge md_enter_safemode into md_check_recovery
md_enter_safemode checks if it is time to mark the md superblock as 'clean'. i.e. if all writes have completed and a suitable delay has passed. This is currently called from md_handle_safemode which in-turn is called (almost) every time md_check_recovery is called, and from the end of md_do_sync which causes the mddev->thread to run, which will always call md_check_recovery as well. So it doesn't need to be a separate function and fits quite well into md_check_recovery. The "almost" is because multipathd calls md_check_recovery but not md_handle_safemode. This is OK because the code from md_enter_safemode is a no-op if mddev->safemode == 0, which it always is for a multipathd (providing we don't allow it to be set to 2 on a signal...) Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c58
1 files changed, 24 insertions, 34 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
3206static 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
3225void 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
3237static DECLARE_WAIT_QUEUE_HEAD(resync_wait); 3206static 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);
3741EXPORT_SYMBOL(md_done_sync); 3732EXPORT_SYMBOL(md_done_sync);
3742EXPORT_SYMBOL(md_write_start); 3733EXPORT_SYMBOL(md_write_start);
3743EXPORT_SYMBOL(md_write_end); 3734EXPORT_SYMBOL(md_write_end);
3744EXPORT_SYMBOL(md_handle_safemode);
3745EXPORT_SYMBOL(md_register_thread); 3735EXPORT_SYMBOL(md_register_thread);
3746EXPORT_SYMBOL(md_unregister_thread); 3736EXPORT_SYMBOL(md_unregister_thread);
3747EXPORT_SYMBOL(md_wakeup_thread); 3737EXPORT_SYMBOL(md_wakeup_thread);