Commit 5ed1df2e authored by NeilBrown's avatar NeilBrown

md: sync sync_completed has correct value as recovery finishes.

There can be a small window between the moment that recovery
actually writes the last block and the time when various sysfs
and /proc/mdstat attributes report that it has finished.
During this time, 'sync_completed' can have the wrong value.
This can confuse monitoring software.

So:
 - don't set curr_resync_completed beyond the end of the devices,
 - set it correctly when resync/recovery has completed.
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
parent c5e19d90
...@@ -7880,6 +7880,9 @@ void md_do_sync(struct md_thread *thread) ...@@ -7880,6 +7880,9 @@ void md_do_sync(struct md_thread *thread)
break; break;
j += sectors; j += sectors;
if (j > max_sectors)
/* when skipping, extra large numbers can be returned. */
j = max_sectors;
if (j > 2) if (j > 2)
mddev->curr_resync = j; mddev->curr_resync = j;
if (mddev_is_clustered(mddev)) if (mddev_is_clustered(mddev))
...@@ -7948,6 +7951,12 @@ void md_do_sync(struct md_thread *thread) ...@@ -7948,6 +7951,12 @@ void md_do_sync(struct md_thread *thread)
blk_finish_plug(&plug); blk_finish_plug(&plug);
wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active)); wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));
if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
mddev->curr_resync > 2) {
mddev->curr_resync_completed = mddev->curr_resync;
sysfs_notify(&mddev->kobj, NULL, "sync_completed");
}
/* tell personality that we are finished */ /* tell personality that we are finished */
mddev->pers->sync_request(mddev, max_sectors, &skipped); mddev->pers->sync_request(mddev, max_sectors, &skipped);
......
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