diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 11567c7999a2..43cf9cc9c1df 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2136,16 +2136,6 @@ static void sync_sbs(mddev_t * mddev, int nospares) | |||
2136 | * with the rest of the array) | 2136 | * with the rest of the array) |
2137 | */ | 2137 | */ |
2138 | mdk_rdev_t *rdev; | 2138 | mdk_rdev_t *rdev; |
2139 | |||
2140 | /* First make sure individual recovery_offsets are correct */ | ||
2141 | list_for_each_entry(rdev, &mddev->disks, same_set) { | ||
2142 | if (rdev->raid_disk >= 0 && | ||
2143 | mddev->delta_disks >= 0 && | ||
2144 | !test_bit(In_sync, &rdev->flags) && | ||
2145 | mddev->curr_resync_completed > rdev->recovery_offset) | ||
2146 | rdev->recovery_offset = mddev->curr_resync_completed; | ||
2147 | |||
2148 | } | ||
2149 | list_for_each_entry(rdev, &mddev->disks, same_set) { | 2139 | list_for_each_entry(rdev, &mddev->disks, same_set) { |
2150 | if (rdev->sb_events == mddev->events || | 2140 | if (rdev->sb_events == mddev->events || |
2151 | (nospares && | 2141 | (nospares && |
@@ -2167,13 +2157,27 @@ static void md_update_sb(mddev_t * mddev, int force_change) | |||
2167 | int sync_req; | 2157 | int sync_req; |
2168 | int nospares = 0; | 2158 | int nospares = 0; |
2169 | 2159 | ||
2170 | mddev->utime = get_seconds(); | ||
2171 | if (mddev->external) | ||
2172 | return; | ||
2173 | repeat: | 2160 | repeat: |
2161 | /* First make sure individual recovery_offsets are correct */ | ||
2162 | list_for_each_entry(rdev, &mddev->disks, same_set) { | ||
2163 | if (rdev->raid_disk >= 0 && | ||
2164 | mddev->delta_disks >= 0 && | ||
2165 | !test_bit(In_sync, &rdev->flags) && | ||
2166 | mddev->curr_resync_completed > rdev->recovery_offset) | ||
2167 | rdev->recovery_offset = mddev->curr_resync_completed; | ||
2168 | |||
2169 | } | ||
2170 | if (!mddev->persistent) { | ||
2171 | clear_bit(MD_CHANGE_CLEAN, &mddev->flags); | ||
2172 | clear_bit(MD_CHANGE_DEVS, &mddev->flags); | ||
2173 | wake_up(&mddev->sb_wait); | ||
2174 | return; | ||
2175 | } | ||
2176 | |||
2174 | spin_lock_irq(&mddev->write_lock); | 2177 | spin_lock_irq(&mddev->write_lock); |
2175 | 2178 | ||
2176 | set_bit(MD_CHANGE_PENDING, &mddev->flags); | 2179 | mddev->utime = get_seconds(); |
2180 | |||
2177 | if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) | 2181 | if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) |
2178 | force_change = 1; | 2182 | force_change = 1; |
2179 | if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags)) | 2183 | if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags)) |
@@ -2221,19 +2225,6 @@ repeat: | |||
2221 | MD_BUG(); | 2225 | MD_BUG(); |
2222 | mddev->events --; | 2226 | mddev->events --; |
2223 | } | 2227 | } |
2224 | |||
2225 | /* | ||
2226 | * do not write anything to disk if using | ||
2227 | * nonpersistent superblocks | ||
2228 | */ | ||
2229 | if (!mddev->persistent) { | ||
2230 | if (!mddev->external) | ||
2231 | clear_bit(MD_CHANGE_PENDING, &mddev->flags); | ||
2232 | |||
2233 | spin_unlock_irq(&mddev->write_lock); | ||
2234 | wake_up(&mddev->sb_wait); | ||
2235 | return; | ||
2236 | } | ||
2237 | sync_sbs(mddev, nospares); | 2228 | sync_sbs(mddev, nospares); |
2238 | spin_unlock_irq(&mddev->write_lock); | 2229 | spin_unlock_irq(&mddev->write_lock); |
2239 | 2230 | ||
@@ -3379,7 +3370,7 @@ array_state_show(mddev_t *mddev, char *page) | |||
3379 | case 0: | 3370 | case 0: |
3380 | if (mddev->in_sync) | 3371 | if (mddev->in_sync) |
3381 | st = clean; | 3372 | st = clean; |
3382 | else if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) | 3373 | else if (test_bit(MD_CHANGE_PENDING, &mddev->flags)) |
3383 | st = write_pending; | 3374 | st = write_pending; |
3384 | else if (mddev->safemode) | 3375 | else if (mddev->safemode) |
3385 | st = active_idle; | 3376 | st = active_idle; |
@@ -3460,9 +3451,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
3460 | mddev->in_sync = 1; | 3451 | mddev->in_sync = 1; |
3461 | if (mddev->safemode == 1) | 3452 | if (mddev->safemode == 1) |
3462 | mddev->safemode = 0; | 3453 | mddev->safemode = 0; |
3463 | if (mddev->persistent) | 3454 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); |
3464 | set_bit(MD_CHANGE_CLEAN, | ||
3465 | &mddev->flags); | ||
3466 | } | 3455 | } |
3467 | err = 0; | 3456 | err = 0; |
3468 | } else | 3457 | } else |
@@ -3474,8 +3463,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
3474 | case active: | 3463 | case active: |
3475 | if (mddev->pers) { | 3464 | if (mddev->pers) { |
3476 | restart_array(mddev); | 3465 | restart_array(mddev); |
3477 | if (mddev->external) | 3466 | clear_bit(MD_CHANGE_PENDING, &mddev->flags); |
3478 | clear_bit(MD_CHANGE_CLEAN, &mddev->flags); | ||
3479 | wake_up(&mddev->sb_wait); | 3467 | wake_up(&mddev->sb_wait); |
3480 | err = 0; | 3468 | err = 0; |
3481 | } else { | 3469 | } else { |
@@ -6580,6 +6568,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi) | |||
6580 | if (mddev->in_sync) { | 6568 | if (mddev->in_sync) { |
6581 | mddev->in_sync = 0; | 6569 | mddev->in_sync = 0; |
6582 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); | 6570 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); |
6571 | set_bit(MD_CHANGE_PENDING, &mddev->flags); | ||
6583 | md_wakeup_thread(mddev->thread); | 6572 | md_wakeup_thread(mddev->thread); |
6584 | did_change = 1; | 6573 | did_change = 1; |
6585 | } | 6574 | } |
@@ -6588,7 +6577,6 @@ void md_write_start(mddev_t *mddev, struct bio *bi) | |||
6588 | if (did_change) | 6577 | if (did_change) |
6589 | sysfs_notify_dirent_safe(mddev->sysfs_state); | 6578 | sysfs_notify_dirent_safe(mddev->sysfs_state); |
6590 | wait_event(mddev->sb_wait, | 6579 | wait_event(mddev->sb_wait, |
6591 | !test_bit(MD_CHANGE_CLEAN, &mddev->flags) && | ||
6592 | !test_bit(MD_CHANGE_PENDING, &mddev->flags)); | 6580 | !test_bit(MD_CHANGE_PENDING, &mddev->flags)); |
6593 | } | 6581 | } |
6594 | 6582 | ||
@@ -6624,6 +6612,7 @@ int md_allow_write(mddev_t *mddev) | |||
6624 | if (mddev->in_sync) { | 6612 | if (mddev->in_sync) { |
6625 | mddev->in_sync = 0; | 6613 | mddev->in_sync = 0; |
6626 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); | 6614 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); |
6615 | set_bit(MD_CHANGE_PENDING, &mddev->flags); | ||
6627 | if (mddev->safemode_delay && | 6616 | if (mddev->safemode_delay && |
6628 | mddev->safemode == 0) | 6617 | mddev->safemode == 0) |
6629 | mddev->safemode = 1; | 6618 | mddev->safemode = 1; |
@@ -6633,7 +6622,7 @@ int md_allow_write(mddev_t *mddev) | |||
6633 | } else | 6622 | } else |
6634 | spin_unlock_irq(&mddev->write_lock); | 6623 | spin_unlock_irq(&mddev->write_lock); |
6635 | 6624 | ||
6636 | if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) | 6625 | if (test_bit(MD_CHANGE_PENDING, &mddev->flags)) |
6637 | return -EAGAIN; | 6626 | return -EAGAIN; |
6638 | else | 6627 | else |
6639 | return 0; | 6628 | return 0; |
@@ -6831,8 +6820,7 @@ void md_do_sync(mddev_t *mddev) | |||
6831 | atomic_read(&mddev->recovery_active) == 0); | 6820 | atomic_read(&mddev->recovery_active) == 0); |
6832 | mddev->curr_resync_completed = | 6821 | mddev->curr_resync_completed = |
6833 | mddev->curr_resync; | 6822 | mddev->curr_resync; |
6834 | if (mddev->persistent) | 6823 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); |
6835 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); | ||
6836 | sysfs_notify(&mddev->kobj, NULL, "sync_completed"); | 6824 | sysfs_notify(&mddev->kobj, NULL, "sync_completed"); |
6837 | } | 6825 | } |
6838 | 6826 | ||
@@ -7111,8 +7099,7 @@ void md_check_recovery(mddev_t *mddev) | |||
7111 | mddev->recovery_cp == MaxSector) { | 7099 | mddev->recovery_cp == MaxSector) { |
7112 | mddev->in_sync = 1; | 7100 | mddev->in_sync = 1; |
7113 | did_change = 1; | 7101 | did_change = 1; |
7114 | if (mddev->persistent) | 7102 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); |
7115 | set_bit(MD_CHANGE_CLEAN, &mddev->flags); | ||
7116 | } | 7103 | } |
7117 | if (mddev->safemode == 1) | 7104 | if (mddev->safemode == 1) |
7118 | mddev->safemode = 0; | 7105 | mddev->safemode = 0; |