Merge branch 'md-fixes' of https://github.com/liu-song-6/linux into for-linus
Pull MD fix from Song. * 'md-fixes' of https://github.com/liu-song-6/linux: md: fix for divide error in status_resync
This commit is contained in:
commit
440078db7a
|
@ -7607,9 +7607,9 @@ static void status_unused(struct seq_file *seq)
|
||||||
static int status_resync(struct seq_file *seq, struct mddev *mddev)
|
static int status_resync(struct seq_file *seq, struct mddev *mddev)
|
||||||
{
|
{
|
||||||
sector_t max_sectors, resync, res;
|
sector_t max_sectors, resync, res;
|
||||||
unsigned long dt, db;
|
unsigned long dt, db = 0;
|
||||||
sector_t rt;
|
sector_t rt, curr_mark_cnt, resync_mark_cnt;
|
||||||
int scale;
|
int scale, recovery_active;
|
||||||
unsigned int per_milli;
|
unsigned int per_milli;
|
||||||
|
|
||||||
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ||
|
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ||
|
||||||
|
@ -7698,7 +7698,10 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
|
||||||
* db: blocks written from mark until now
|
* db: blocks written from mark until now
|
||||||
* rt: remaining time
|
* rt: remaining time
|
||||||
*
|
*
|
||||||
* rt is a sector_t, so could be 32bit or 64bit.
|
* rt is a sector_t, which is always 64bit now. We are keeping
|
||||||
|
* the original algorithm, but it is not really necessary.
|
||||||
|
*
|
||||||
|
* Original algorithm:
|
||||||
* So we divide before multiply in case it is 32bit and close
|
* So we divide before multiply in case it is 32bit and close
|
||||||
* to the limit.
|
* to the limit.
|
||||||
* We scale the divisor (db) by 32 to avoid losing precision
|
* We scale the divisor (db) by 32 to avoid losing precision
|
||||||
|
@ -7709,11 +7712,16 @@ static int status_resync(struct seq_file *seq, struct mddev *mddev)
|
||||||
*/
|
*/
|
||||||
dt = ((jiffies - mddev->resync_mark) / HZ);
|
dt = ((jiffies - mddev->resync_mark) / HZ);
|
||||||
if (!dt) dt++;
|
if (!dt) dt++;
|
||||||
db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active))
|
|
||||||
- mddev->resync_mark_cnt;
|
curr_mark_cnt = mddev->curr_mark_cnt;
|
||||||
|
recovery_active = atomic_read(&mddev->recovery_active);
|
||||||
|
resync_mark_cnt = mddev->resync_mark_cnt;
|
||||||
|
|
||||||
|
if (curr_mark_cnt >= (recovery_active + resync_mark_cnt))
|
||||||
|
db = curr_mark_cnt - (recovery_active + resync_mark_cnt);
|
||||||
|
|
||||||
rt = max_sectors - resync; /* number of remaining sectors */
|
rt = max_sectors - resync; /* number of remaining sectors */
|
||||||
sector_div(rt, db/32+1);
|
rt = div64_u64(rt, db/32+1);
|
||||||
rt *= dt;
|
rt *= dt;
|
||||||
rt >>= 5;
|
rt >>= 5;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue