Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Q4EHM-0002dc-SJ for mharc-grub-devel@gnu.org; Mon, 28 Mar 2011 11:22:52 -0400 Received: from [140.186.70.92] (port=58846 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4EHJ-0002ae-Sa for grub-devel@gnu.org; Mon, 28 Mar 2011 11:22:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4EHH-0008Bm-Vm for grub-devel@gnu.org; Mon, 28 Mar 2011 11:22:49 -0400 Received: from smarthost03.mail.zen.net.uk ([212.23.3.142]:60517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4EHH-0008BF-Oi for grub-devel@gnu.org; Mon, 28 Mar 2011 11:22:47 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost03.mail.zen.net.uk with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Q4EHF-0005h5-Jb for grub-devel@gnu.org; Mon, 28 Mar 2011 15:22:45 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 4.72) (envelope-from ) id 1Q4EHD-000635-31 for grub-devel@gnu.org; Mon, 28 Mar 2011 16:22:43 +0100 Date: Mon, 28 Mar 2011 16:22:42 +0100 From: Colin Watson To: grub-devel@gnu.org Message-ID: <20110328152242.GJ9163@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Originating-Smarthost03-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.23.3.142 Subject: [PATCH] Get mdraid 1.x array size from data_size if size is zero X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 15:22:51 -0000 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 * 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' --- grub-core/disk/mdraid1x_linux.c 2011-03-28 14:17:22 +0000 +++ grub-core/disk/mdraid1x_linux.c 2011-03-28 15:18:10 +0000 @@ -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) >= -- Colin Watson [cjwatson@ubuntu.com]