diff options
author | NeilBrown <neilb@suse.de> | 2006-03-27 04:18:04 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:45:01 -0500 |
commit | 4588b42e9d0d0904a745c96cead66506c75bae21 (patch) | |
tree | 203162f7e829da88e0bb81bc0c3f49d6f832f855 /drivers/md | |
parent | 1be7892fffb45f6017494a88ff68fe84c6de26b4 (diff) |
[PATCH] md: Update status_resync to handle LARGE devices
status_resync - used by /proc/mdstat to report the status of a resync, assumes
that device sizes will always fit into an 'unsigned long' This is no longer
the case...
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 686314f070a5..a3ecaf8ed30a 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -4044,7 +4044,10 @@ static void status_unused(struct seq_file *seq) | |||
4044 | 4044 | ||
4045 | static void status_resync(struct seq_file *seq, mddev_t * mddev) | 4045 | static void status_resync(struct seq_file *seq, mddev_t * mddev) |
4046 | { | 4046 | { |
4047 | unsigned long max_blocks, resync, res, dt, db, rt; | 4047 | sector_t max_blocks, resync, res; |
4048 | unsigned long dt, db, rt; | ||
4049 | int scale; | ||
4050 | unsigned int per_milli; | ||
4048 | 4051 | ||
4049 | resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active))/2; | 4052 | resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active))/2; |
4050 | 4053 | ||
@@ -4060,9 +4063,22 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev) | |||
4060 | MD_BUG(); | 4063 | MD_BUG(); |
4061 | return; | 4064 | return; |
4062 | } | 4065 | } |
4063 | res = (resync/1024)*1000/(max_blocks/1024 + 1); | 4066 | /* Pick 'scale' such that (resync>>scale)*1000 will fit |
4067 | * in a sector_t, and (max_blocks>>scale) will fit in a | ||
4068 | * u32, as those are the requirements for sector_div. | ||
4069 | * Thus 'scale' must be at least 10 | ||
4070 | */ | ||
4071 | scale = 10; | ||
4072 | if (sizeof(sector_t) > sizeof(unsigned long)) { | ||
4073 | while ( max_blocks/2 > (1ULL<<(scale+32))) | ||
4074 | scale++; | ||
4075 | } | ||
4076 | res = (resync>>scale)*1000; | ||
4077 | sector_div(res, (u32)((max_blocks>>scale)+1)); | ||
4078 | |||
4079 | per_milli = res; | ||
4064 | { | 4080 | { |
4065 | int i, x = res/50, y = 20-x; | 4081 | int i, x = per_milli/50, y = 20-x; |
4066 | seq_printf(seq, "["); | 4082 | seq_printf(seq, "["); |
4067 | for (i = 0; i < x; i++) | 4083 | for (i = 0; i < x; i++) |
4068 | seq_printf(seq, "="); | 4084 | seq_printf(seq, "="); |
@@ -4071,10 +4087,12 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev) | |||
4071 | seq_printf(seq, "."); | 4087 | seq_printf(seq, "."); |
4072 | seq_printf(seq, "] "); | 4088 | seq_printf(seq, "] "); |
4073 | } | 4089 | } |
4074 | seq_printf(seq, " %s =%3lu.%lu%% (%lu/%lu)", | 4090 | seq_printf(seq, " %s =%3u.%u%% (%llu/%llu)", |
4075 | (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? | 4091 | (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? |
4076 | "resync" : "recovery"), | 4092 | "resync" : "recovery"), |
4077 | res/10, res % 10, resync, max_blocks); | 4093 | per_milli/10, per_milli % 10, |
4094 | (unsigned long long) resync, | ||
4095 | (unsigned long long) max_blocks); | ||
4078 | 4096 | ||
4079 | /* | 4097 | /* |
4080 | * We do not want to overflow, so the order of operands and | 4098 | * We do not want to overflow, so the order of operands and |
@@ -4088,7 +4106,7 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev) | |||
4088 | dt = ((jiffies - mddev->resync_mark) / HZ); | 4106 | dt = ((jiffies - mddev->resync_mark) / HZ); |
4089 | if (!dt) dt++; | 4107 | if (!dt) dt++; |
4090 | db = resync - (mddev->resync_mark_cnt/2); | 4108 | db = resync - (mddev->resync_mark_cnt/2); |
4091 | rt = (dt * ((max_blocks-resync) / (db/100+1)))/100; | 4109 | rt = (dt * ((unsigned long)(max_blocks-resync) / (db/100+1)))/100; |
4092 | 4110 | ||
4093 | seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6); | 4111 | seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6); |
4094 | 4112 | ||