Skip to contentSkip to conversation

Get mdraid 1.x array size from data_size if size is zero

PATCH New Colin Watson 1 participant 1 message Mar 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Get mdraid 1.x array size from data_size if size is zero

On RAID-0 devices, the 'size' member in the RAID superblock is 0, meaning (as far as I can tell) "use all available space in physical volume". GRUB's mdraid 0.9 support handles this, but its mdraid 1.x support does not. The 'data_size' member is more useful.

I've continued using 'size' if it's non-zero, partly for minimal risk to 1.99 (so this shouldn't break anything that currently works) and partly because 'data_size' is a bit larger than 'size' on RAID-1 and I thought we probably ought to use the smaller size in case the larger size included some kind of reserved blocks. I didn't have time to unpick the full details of the differences from mdadm.

This was originally reported as:

https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/743136

2011-03-28 Colin Watson <[email protected]>

	* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): If
	real_sb->size is zero (e.g. RAID-0), get the disk size from
	real_sb->data_size instead.
	Fixes Ubuntu bug #743136.

=== modified file 'grub-core/disk/mdraid1x_linux.c'

disk/mdraid1x_linux.c +4 -1
@@ -192,7 +192,10 @@ grub_mdraid_detect (grub_disk_t disk, st
 	array->level = grub_le_to_cpu32 (real_sb->level);
 	array->layout = grub_le_to_cpu32 (real_sb->layout);
 	array->total_devs = grub_le_to_cpu32 (real_sb->raid_disks);
-	array->disk_size = grub_le_to_cpu64 (real_sb->size);
+	if (real_sb->size)
+	  array->disk_size = grub_le_to_cpu64 (real_sb->size);
+	else
+	  array->disk_size = grub_le_to_cpu64 (real_sb->data_size);
 	array->chunk_size = grub_le_to_cpu32 (real_sb->chunksize);
 
 	if (grub_le_to_cpu32 (real_sb->dev_number) >=
Signature · 1 line
Colin Watson                                       [[email protected]]