Skip to content

Commit 54f8934

Browse files
majianpengneilbrown
authored andcommitted
md: Update checkpoint of resync/recovery based on time.
md will current only only checkpoint recovery or resync ever 1/16th of the device size. As devices get larger this can become a long time an so a lot of work that might need to be duplicated after a shutdown. So add a time-based checkpoint. Every 5 minutes limits the amount of duplicated effort to at most 5 minutes, and has almost zero impact on performance. [changelog entry re-written by NeilBrown] Signed-off-by: Jianpeng Ma <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 35d78c6 commit 54f8934

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/md/md.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7277,6 +7277,7 @@ EXPORT_SYMBOL_GPL(md_allow_write);
72777277

72787278
#define SYNC_MARKS 10
72797279
#define SYNC_MARK_STEP (3*HZ)
7280+
#define UPDATE_FREQUENCY (5*60*HZ)
72807281
void md_do_sync(struct md_thread *thread)
72817282
{
72827283
struct mddev *mddev = thread->mddev;
@@ -7285,6 +7286,7 @@ void md_do_sync(struct md_thread *thread)
72857286
window;
72867287
sector_t max_sectors,j, io_sectors;
72877288
unsigned long mark[SYNC_MARKS];
7289+
unsigned long update_time;
72887290
sector_t mark_cnt[SYNC_MARKS];
72897291
int last_mark,m;
72907292
struct list_head *tmp;
@@ -7444,6 +7446,7 @@ void md_do_sync(struct md_thread *thread)
74447446
mddev->curr_resync_completed = j;
74457447
sysfs_notify(&mddev->kobj, NULL, "sync_completed");
74467448
md_new_event(mddev);
7449+
update_time = jiffies;
74477450

74487451
blk_start_plug(&plug);
74497452
while (j < max_sectors) {
@@ -7455,6 +7458,7 @@ void md_do_sync(struct md_thread *thread)
74557458
((mddev->curr_resync > mddev->curr_resync_completed &&
74567459
(mddev->curr_resync - mddev->curr_resync_completed)
74577460
> (max_sectors >> 4)) ||
7461+
time_after_eq(jiffies, update_time + UPDATE_FREQUENCY) ||
74587462
(j - mddev->curr_resync_completed)*2
74597463
>= mddev->resync_max - mddev->curr_resync_completed
74607464
)) {
@@ -7465,6 +7469,7 @@ void md_do_sync(struct md_thread *thread)
74657469
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) &&
74667470
j > mddev->recovery_cp)
74677471
mddev->recovery_cp = j;
7472+
update_time = jiffies;
74687473
set_bit(MD_CHANGE_CLEAN, &mddev->flags);
74697474
sysfs_notify(&mddev->kobj, NULL, "sync_completed");
74707475
}

0 commit comments

Comments
 (0)