Skip to contentSkip to conversation

Bug in 2.6.16-rc6 RAID size reporting

DISCUSSION Joshua Kugler 2 participants 3 messages Mar 15, 2006 – Mar 16, 2006 MD RAID

lore
Share & tools
lore
#0 lore raw

In my quest to get some stability in my system with large RAID devices, I installed mdadm 2.3.1 and compiled and installed 2.6.16-rc6.

Ran this command:

mdadm -C /dev/md1 --auto=yes -l raid1 -n 2 /dev/etherd/e0.0 /dev/etherd/e1.0

Those are AoE devices, by the way.

Started fine, syncing at 43000K/sec or so. Came in this morning, and /proc/mdstat had this to report:

Personalities : [raid1]
md1 : active raid1 etherd/e1.0[1] etherd/e0.0[0]

      5469958900 blocks super 1.0 [2/2] [UU]
      [==========================================================>]  resync 

=292.8% (3440402688/1174991604) finish=785.8min speed=43043K/sec

You'll notice that it says 5469958900 blocks, but 3440402688/1174991604 done. Oops.

I tried this with two 400GB drives:

mdadm -C /dev/md2 --auto=yes -l raid1 -n 2 /dev/sdc /dev/sdd

And they report correctly:

md2 : active raid1 sdd[1] sdc[0]

      390711296 blocks [2/2] [UU]
      [=>...................]  resync =  8.1% (31782144/390711296) 

finish=152.8min speed=39133K/sec

Line 4045, and following, in drivers/md/md.c seems to be the offending code:

if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))

	max_blocks = mddev->resync_max_sectors >> 1;
else
	max_blocks = mddev->size;

Should max_blocks be mddev->size even if it is resyncing?

The resyncing isn't done, so I can't tell you if the block count is correct after it's done. I'll let you know as soon as it's done (about 37 hours, since I had to do a hard reboot due to another unrelated issue...i.e. PEBKAC).

j----- k-----

Signature · 3 lines
Joshua Kugler                 PGP Key: http://pgp.mit.edu/
CDE System Administrator             ID 0xDB26D7CE
http://distance.uaf.edu/
#1 lore raw
Quoted 12 lines · On Wednesday March 15, [email protected] wrote:

In my quest to get some stability in my system with large RAID devices, I installed mdadm 2.3.1 and compiled and installed 2.6.16-rc6.

Ran this command:

mdadm -C /dev/md1 --auto=yes -l raid1 -n 2 /dev/etherd/e0.0 /dev/etherd/e1.0

Those are AoE devices, by the way.

Started fine, syncing at 43000K/sec or so. Came in this morning, and /proc/mdstat had this to report:

Quoted 7 lines

Personalities : [raid1]
md1 : active raid1 etherd/e1.0[1] etherd/e0.0[0]

      5469958900 blocks super 1.0 [2/2] [UU]
      [==========================================================>]  resync 

=292.8% (3440402688/1174991604) finish=785.8min speed=43043K/sec

You'll notice that it says 5469958900 blocks, but 3440402688/1174991604 done.

Hmmm. there is sever bitrot in that code. The following patch might help.

Quoted 7 lines

if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))

	max_blocks = mddev->resync_max_sectors >> 1;
else
	max_blocks = mddev->size;

Should max_blocks be mddev->size even if it is resyncing?

Yes, you have to resync the entire array - all ->size of it... maybe you are misunderstanding one of the (probably undocumented) variables..

NeilBrown

### Diffstat output

 ./drivers/md/md.c |   28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)
drivers/md/md.c renamed from drivers/md/md.c~current~ +23 -5
diff ./drivers/md/md.c~current~ ./drivers/md/md.c
@@ -4376,7 +4376,10 @@ static void status_unused(struct seq_fil
 
 static void status_resync(struct seq_file *seq, mddev_t * mddev)
 {
-	unsigned long max_blocks, resync, res, dt, db, rt;
+	sector_t max_blocks, resync, res;
+	unsigned long dt, db, rt;
+	int scale;
+	unsigned int per_milli;
 
 	resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active))/2;
 
@@ -4392,9 +4395,22 @@ static void status_resync(struct seq_fil
 		MD_BUG();
 		return;
 	}
-	res = (resync/1024)*1000/(max_blocks/1024 + 1);
+	/* Pick 'scale' such that (resync>>scale)*1000 will fit
+	 * in a sector_t, and (max_blocks>>scale) will fit in a
+	 * u32, as those are the requirements for sector_div.
+	 * Thus 'scale' must be at least 10
+	 */
+	scale = 10;
+	if (sizeof(sector_t) > sizeof(unsigned long)) {
+		while ( max_blocks/2 > (1ULL<<(scale+32)))
+			scale++;
+	}
+	res = (resync>>scale)*1000;
+	sector_div(res, (u32)((max_blocks>>scale)+1));
+
+	per_milli = res;
 	{
-		int i, x = res/50, y = 20-x;
+		int i, x = per_milli/50, y = 20-x;
 		seq_printf(seq, "[");
 		for (i = 0; i < x; i++)
 			seq_printf(seq, "=");
@@ -4403,12 +4419,14 @@ static void status_resync(struct seq_fil
 			seq_printf(seq, ".");
 		seq_printf(seq, "] ");
 	}
-	seq_printf(seq, " %s =%3lu.%lu%% (%lu/%lu)",
+	seq_printf(seq, " %s =%3u.%u%% (%llu/%llu)",
 		   (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)?
 		    "reshape" :
 		      (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ?
 		       "resync" : "recovery")),
-		      res/10, res % 10, resync, max_blocks);
+		      per_milli/10, per_milli % 10,
+		   (unsigned long long) resync,
+		   (unsigned long long) max_blocks);
 
 	/*
 	 * We do not want to overflow, so the order of operands and
#2 lore raw
Quoted 10 lines · Neil Brown
Quoted 9 lines · On Wednesday March 15, [email protected] wrote:

Started fine, syncing at 43000K/sec or so. Came in this morning, and /proc/mdstat had this to report:

Personalities : [raid1]
md1 : active raid1 etherd/e1.0[1] etherd/e0.0[0]

      5469958900 blocks super 1.0 [2/2] [UU]
      [==========================================================>] 

resync =292.8% (3440402688/1174991604) finish=785.8min speed=43043K/sec

Quoted 5 lines
Quoted 2 lines

You'll notice that it says 5469958900 blocks, but 3440402688/1174991604 done.

Hmmm. there is sever bitrot in that code. The following patch might help.

I'll wait until the patch is in the official tree. I am trying to patch rc6, but it seems you've made a lot of changes to your version of md.c:

patching file md.c
Hunk #1 succeeded at 4038 (offset -338 lines). Hunk #2 succeeded at 4057 (offset -338 lines). Hunk #3 FAILED at 4081.
1 out of 3 hunks FAILED -- saving rejects to file md.c.rej

Thanks for the fix, though. Hope to see it in the tree soon.

j----- k-----

Signature · 3 lines
Joshua Kugler                 PGP Key: http://pgp.mit.edu/
CDE System Administrator             ID 0xDB26D7CE
http://distance.uaf.edu/