Commit 070dc6dd authored by NeilBrown's avatar NeilBrown

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: default avatarNeilBrown <neilb@suse.de>
parent bd52b746
...@@ -1542,8 +1542,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector) ...@@ -1542,8 +1542,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
atomic_read(&bitmap->mddev->recovery_active) == 0); atomic_read(&bitmap->mddev->recovery_active) == 0);
bitmap->mddev->curr_resync_completed = bitmap->mddev->curr_resync; bitmap->mddev->curr_resync_completed = bitmap->mddev->curr_resync;
if (bitmap->mddev->persistent) set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1); sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1);
s = 0; s = 0;
while (s < sector && s < bitmap->mddev->resync_max_sectors) { while (s < sector && s < bitmap->mddev->resync_max_sectors) {
......
...@@ -2168,8 +2168,7 @@ static void md_update_sb(mddev_t * mddev, int force_change) ...@@ -2168,8 +2168,7 @@ static void md_update_sb(mddev_t * mddev, int force_change)
} }
if (!mddev->persistent) { if (!mddev->persistent) {
if (!mddev->external) clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
clear_bit(MD_CHANGE_DEVS, &mddev->flags); clear_bit(MD_CHANGE_DEVS, &mddev->flags);
wake_up(&mddev->sb_wait); wake_up(&mddev->sb_wait);
return; return;
...@@ -2179,7 +2178,6 @@ static void md_update_sb(mddev_t * mddev, int force_change) ...@@ -2179,7 +2178,6 @@ static void md_update_sb(mddev_t * mddev, int force_change)
mddev->utime = get_seconds(); mddev->utime = get_seconds();
set_bit(MD_CHANGE_PENDING, &mddev->flags);
if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
force_change = 1; force_change = 1;
if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags)) if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags))
...@@ -3372,7 +3370,7 @@ array_state_show(mddev_t *mddev, char *page) ...@@ -3372,7 +3370,7 @@ array_state_show(mddev_t *mddev, char *page)
case 0: case 0:
if (mddev->in_sync) if (mddev->in_sync)
st = clean; st = clean;
else if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) else if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
st = write_pending; st = write_pending;
else if (mddev->safemode) else if (mddev->safemode)
st = active_idle; st = active_idle;
...@@ -3453,9 +3451,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) ...@@ -3453,9 +3451,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
mddev->in_sync = 1; mddev->in_sync = 1;
if (mddev->safemode == 1) if (mddev->safemode == 1)
mddev->safemode = 0; mddev->safemode = 0;
if (mddev->persistent) set_bit(MD_CHANGE_CLEAN, &mddev->flags);
set_bit(MD_CHANGE_CLEAN,
&mddev->flags);
} }
err = 0; err = 0;
} else } else
...@@ -3467,8 +3463,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) ...@@ -3467,8 +3463,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
case active: case active:
if (mddev->pers) { if (mddev->pers) {
restart_array(mddev); restart_array(mddev);
if (mddev->external) clear_bit(MD_CHANGE_PENDING, &mddev->flags);
clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
wake_up(&mddev->sb_wait); wake_up(&mddev->sb_wait);
err = 0; err = 0;
} else { } else {
...@@ -6573,6 +6568,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi) ...@@ -6573,6 +6568,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
if (mddev->in_sync) { if (mddev->in_sync) {
mddev->in_sync = 0; mddev->in_sync = 0;
set_bit(MD_CHANGE_CLEAN, &mddev->flags); set_bit(MD_CHANGE_CLEAN, &mddev->flags);
set_bit(MD_CHANGE_PENDING, &mddev->flags);
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
did_change = 1; did_change = 1;
} }
...@@ -6581,7 +6577,6 @@ void md_write_start(mddev_t *mddev, struct bio *bi) ...@@ -6581,7 +6577,6 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
if (did_change) if (did_change)
sysfs_notify_dirent_safe(mddev->sysfs_state); sysfs_notify_dirent_safe(mddev->sysfs_state);
wait_event(mddev->sb_wait, wait_event(mddev->sb_wait,
!test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
!test_bit(MD_CHANGE_PENDING, &mddev->flags)); !test_bit(MD_CHANGE_PENDING, &mddev->flags));
} }
...@@ -6617,6 +6612,7 @@ int md_allow_write(mddev_t *mddev) ...@@ -6617,6 +6612,7 @@ int md_allow_write(mddev_t *mddev)
if (mddev->in_sync) { if (mddev->in_sync) {
mddev->in_sync = 0; mddev->in_sync = 0;
set_bit(MD_CHANGE_CLEAN, &mddev->flags); set_bit(MD_CHANGE_CLEAN, &mddev->flags);
set_bit(MD_CHANGE_PENDING, &mddev->flags);
if (mddev->safemode_delay && if (mddev->safemode_delay &&
mddev->safemode == 0) mddev->safemode == 0)
mddev->safemode = 1; mddev->safemode = 1;
...@@ -6626,7 +6622,7 @@ int md_allow_write(mddev_t *mddev) ...@@ -6626,7 +6622,7 @@ int md_allow_write(mddev_t *mddev)
} else } else
spin_unlock_irq(&mddev->write_lock); spin_unlock_irq(&mddev->write_lock);
if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
return -EAGAIN; return -EAGAIN;
else else
return 0; return 0;
...@@ -6824,8 +6820,7 @@ void md_do_sync(mddev_t *mddev) ...@@ -6824,8 +6820,7 @@ void md_do_sync(mddev_t *mddev)
atomic_read(&mddev->recovery_active) == 0); atomic_read(&mddev->recovery_active) == 0);
mddev->curr_resync_completed = mddev->curr_resync_completed =
mddev->curr_resync; mddev->curr_resync;
if (mddev->persistent) set_bit(MD_CHANGE_CLEAN, &mddev->flags);
set_bit(MD_CHANGE_CLEAN, &mddev->flags);
sysfs_notify(&mddev->kobj, NULL, "sync_completed"); sysfs_notify(&mddev->kobj, NULL, "sync_completed");
} }
...@@ -7104,8 +7099,7 @@ void md_check_recovery(mddev_t *mddev) ...@@ -7104,8 +7099,7 @@ void md_check_recovery(mddev_t *mddev)
mddev->recovery_cp == MaxSector) { mddev->recovery_cp == MaxSector) {
mddev->in_sync = 1; mddev->in_sync = 1;
did_change = 1; did_change = 1;
if (mddev->persistent) set_bit(MD_CHANGE_CLEAN, &mddev->flags);
set_bit(MD_CHANGE_CLEAN, &mddev->flags);
} }
if (mddev->safemode == 1) if (mddev->safemode == 1)
mddev->safemode = 0; mddev->safemode = 0;
......
...@@ -140,7 +140,7 @@ struct mddev_s ...@@ -140,7 +140,7 @@ struct mddev_s
unsigned long flags; unsigned long flags;
#define MD_CHANGE_DEVS 0 /* Some device status has changed */ #define MD_CHANGE_DEVS 0 /* Some device status has changed */
#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */ #define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */
#define MD_CHANGE_PENDING 2 /* superblock update in progress */ #define MD_CHANGE_PENDING 2 /* switch from 'clean' to 'active' in progress */
int suspended; int suspended;
atomic_t active_io; atomic_t active_io;
......
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