Commit ff4e8d9a9f46e3a7f89d14ade52fe5d53a82c022

Authored by NeilBrown
Committed by Linus Torvalds
1 parent 0b8c9de05c

[PATCH] md: fix resync speed calculation for restarted resyncs

We introduced 'io_sectors' recently so we could count the sectors that causes
io during resync separate from sectors which didn't cause IO - there can be a
difference if a bitmap is being used to accelerate resync.

However when a speed is reported, we find the number of sectors processed
recently by subtracting an oldish io_sectors count from a current
'curr_resync' count.  This is wrong because curr_resync counts all sectors,
not just io sectors.

So, add a field to mddev to store the curren io_sectors separately from
curr_resync, and use that in the calculations.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 3 changed files with 10 additions and 6 deletions Side-by-side Diff

... ... @@ -2719,7 +2719,7 @@
2719 2719 sync_speed_show(mddev_t *mddev, char *page)
2720 2720 {
2721 2721 unsigned long resync, dt, db;
2722   - resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active));
  2722 + resync = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active));
2723 2723 dt = ((jiffies - mddev->resync_mark) / HZ);
2724 2724 if (!dt) dt++;
2725 2725 db = resync - (mddev->resync_mark_cnt);
2726 2726  
... ... @@ -4687,12 +4687,13 @@
4687 4687 */
4688 4688 dt = ((jiffies - mddev->resync_mark) / HZ);
4689 4689 if (!dt) dt++;
4690   - db = resync - (mddev->resync_mark_cnt/2);
4691   - rt = (dt * ((unsigned long)(max_blocks-resync) / (db/100+1)))/100;
  4690 + db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active))
  4691 + - mddev->resync_mark_cnt;
  4692 + rt = (dt * ((unsigned long)(max_blocks-resync) / (db/2/100+1)))/100;
4692 4693  
4693 4694 seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6);
4694 4695  
4695   - seq_printf(seq, " speed=%ldK/sec", db/dt);
  4696 + seq_printf(seq, " speed=%ldK/sec", db/2/dt);
4696 4697 }
4697 4698  
4698 4699 static void *md_seq_start(struct seq_file *seq, loff_t *pos)
... ... @@ -5203,6 +5204,7 @@
5203 5204  
5204 5205 j += sectors;
5205 5206 if (j>1) mddev->curr_resync = j;
  5207 + mddev->curr_mark_cnt = io_sectors;
5206 5208 if (last_check == 0)
5207 5209 /* this is the earliers that rebuilt will be
5208 5210 * visible in /proc/mdstat
... ... @@ -281,7 +281,8 @@
281 281 } else {
282 282 if (!test_bit(STRIPE_HANDLE, &sh->state))
283 283 atomic_inc(&conf->active_stripes);
284   - if (list_empty(&sh->lru))
  284 + if (list_empty(&sh->lru) &&
  285 + !test_bit(STRIPE_EXPANDING, &sh->state))
285 286 BUG();
286 287 list_del_init(&sh->lru);
287 288 }
include/linux/raid/md_k.h
... ... @@ -148,9 +148,10 @@
148 148  
149 149 struct mdk_thread_s *thread; /* management thread */
150 150 struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
151   - sector_t curr_resync; /* blocks scheduled */
  151 + sector_t curr_resync; /* last block scheduled */
152 152 unsigned long resync_mark; /* a recent timestamp */
153 153 sector_t resync_mark_cnt;/* blocks written at resync_mark */
  154 + sector_t curr_mark_cnt; /* blocks scheduled now */
154 155  
155 156 sector_t resync_max_sectors; /* may be set by personality */
156 157