aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-08-30 03:33:34 -0400
committerNeilBrown <neilb@suse.de>2010-08-30 04:06:21 -0400
commit070dc6dd7103b6b3f7e4d46e754354a5c15f366e (patch)
tree173e72d08b2070d496c203a6d5156b9a2ad2808c /drivers/md/md.c
parentbd52b746262c8d77e73903d6608014fb2fcdcd9d (diff)
md: resolve confusion of MD_CHANGE_CLEAN
MD_CHANGE_CLEAN is used for two different purposes and this leads to confusion. One of the purposes is largely mirrored by MD_CHANGE_PENDING which is not used for anything else, so have MD_CHANGE_PENDING take over that purpose fully. The two purposes are: 1/ tell md_update_sb that an update is needed and that it is just a clean/dirty transition. 2/ tell user-space that an transition from clean to dirty is pending (something wants to write), and tell te kernel (by clearin the flag) that the transition is OK. The first purpose remains wit MD_CHANGE_CLEAN, the second is moved fully to MD_CHANGE_PENDING. This means that various places which conditionally set or cleared MD_CHANGE_CLEAN no longer need to be conditional. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index a1f6b59b8b37..43cf9cc9c1df 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2168,8 +2168,7 @@ repeat:
2168 2168
2169 } 2169 }
2170 if (!mddev->persistent) { 2170 if (!mddev->persistent) {
2171 if (!mddev->external) 2171 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
2172 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
2173 clear_bit(MD_CHANGE_DEVS, &mddev->flags); 2172 clear_bit(MD_CHANGE_DEVS, &mddev->flags);
2174 wake_up(&mddev->sb_wait); 2173 wake_up(&mddev->sb_wait);
2175 return; 2174 return;
@@ -2179,7 +2178,6 @@ repeat:
2179 2178
2180 mddev->utime = get_seconds(); 2179 mddev->utime = get_seconds();
2181 2180
2182 set_bit(MD_CHANGE_PENDING, &mddev->flags);
2183 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) 2181 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
2184 force_change = 1; 2182 force_change = 1;
2185 if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags)) 2183 if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags))
@@ -3372,7 +3370,7 @@ array_state_show(mddev_t *mddev, char *page)
3372 case 0: 3370 case 0:
3373 if (mddev->in_sync) 3371 if (mddev->in_sync)
3374 st = clean; 3372 st = clean;
3375 else if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) 3373 else if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
3376 st = write_pending; 3374 st = write_pending;
3377 else if (mddev->safemode) 3375 else if (mddev->safemode)
3378 st = active_idle; 3376 st = active_idle;
@@ -3453,9 +3451,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3453 mddev->in_sync = 1; 3451 mddev->in_sync = 1;
3454 if (mddev->safemode == 1) 3452 if (mddev->safemode == 1)
3455 mddev->safemode = 0; 3453 mddev->safemode = 0;
3456 if (mddev->persistent) 3454 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
3457 set_bit(MD_CHANGE_CLEAN,
3458 &mddev->flags);
3459 } 3455 }
3460 err = 0; 3456 err = 0;
3461 } else 3457 } else
@@ -3467,8 +3463,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3467 case active: 3463 case active:
3468 if (mddev->pers) { 3464 if (mddev->pers) {
3469 restart_array(mddev); 3465 restart_array(mddev);
3470 if (mddev->external) 3466 clear_bit(MD_CHANGE_PENDING, &mddev->flags);
3471 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
3472 wake_up(&mddev->sb_wait); 3467 wake_up(&mddev->sb_wait);
3473 err = 0; 3468 err = 0;
3474 } else { 3469 } else {
@@ -6573,6 +6568,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
6573 if (mddev->in_sync) { 6568 if (mddev->in_sync) {
6574 mddev->in_sync = 0; 6569 mddev->in_sync = 0;
6575 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 6570 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6571 set_bit(MD_CHANGE_PENDING, &mddev->flags);
6576 md_wakeup_thread(mddev->thread); 6572 md_wakeup_thread(mddev->thread);
6577 did_change = 1; 6573 did_change = 1;
6578 } 6574 }
@@ -6581,7 +6577,6 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
6581 if (did_change) 6577 if (did_change)
6582 sysfs_notify_dirent_safe(mddev->sysfs_state); 6578 sysfs_notify_dirent_safe(mddev->sysfs_state);
6583 wait_event(mddev->sb_wait, 6579 wait_event(mddev->sb_wait,
6584 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
6585 !test_bit(MD_CHANGE_PENDING, &mddev->flags)); 6580 !test_bit(MD_CHANGE_PENDING, &mddev->flags));
6586} 6581}
6587 6582
@@ -6617,6 +6612,7 @@ int md_allow_write(mddev_t *mddev)
6617 if (mddev->in_sync) { 6612 if (mddev->in_sync) {
6618 mddev->in_sync = 0; 6613 mddev->in_sync = 0;
6619 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 6614 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6615 set_bit(MD_CHANGE_PENDING, &mddev->flags);
6620 if (mddev->safemode_delay && 6616 if (mddev->safemode_delay &&
6621 mddev->safemode == 0) 6617 mddev->safemode == 0)
6622 mddev->safemode = 1; 6618 mddev->safemode = 1;
@@ -6626,7 +6622,7 @@ int md_allow_write(mddev_t *mddev)
6626 } else 6622 } else
6627 spin_unlock_irq(&mddev->write_lock); 6623 spin_unlock_irq(&mddev->write_lock);
6628 6624
6629 if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) 6625 if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
6630 return -EAGAIN; 6626 return -EAGAIN;
6631 else 6627 else
6632 return 0; 6628 return 0;
@@ -6824,8 +6820,7 @@ void md_do_sync(mddev_t *mddev)
6824 atomic_read(&mddev->recovery_active) == 0); 6820 atomic_read(&mddev->recovery_active) == 0);
6825 mddev->curr_resync_completed = 6821 mddev->curr_resync_completed =
6826 mddev->curr_resync; 6822 mddev->curr_resync;
6827 if (mddev->persistent) 6823 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6828 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6829 sysfs_notify(&mddev->kobj, NULL, "sync_completed"); 6824 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6830 } 6825 }
6831 6826
@@ -7104,8 +7099,7 @@ void md_check_recovery(mddev_t *mddev)
7104 mddev->recovery_cp == MaxSector) { 7099 mddev->recovery_cp == MaxSector) {
7105 mddev->in_sync = 1; 7100 mddev->in_sync = 1;
7106 did_change = 1; 7101 did_change = 1;
7107 if (mddev->persistent) 7102 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
7108 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
7109 } 7103 }
7110 if (mddev->safemode == 1) 7104 if (mddev->safemode == 1)
7111 mddev->safemode = 0; 7105 mddev->safemode = 0;