From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZupoC-0006Xc-Q8 for mharc-grub-devel@gnu.org; Fri, 06 Nov 2015 17:48:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZunAx-0007wP-Uy for grub-devel@gnu.org; Fri, 06 Nov 2015 14:59:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZunAt-0000NE-UF for grub-devel@gnu.org; Fri, 06 Nov 2015 14:59:55 -0500 Received: from resqmta-po-08v.sys.comcast.net ([96.114.154.167]:41889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZunAt-0000Mn-Ni for grub-devel@gnu.org; Fri, 06 Nov 2015 14:59:51 -0500 Received: from resomta-po-16v.sys.comcast.net ([96.114.154.240]) by resqmta-po-08v.sys.comcast.net with comcast id eKzC1r0025BUCh401KzqPg; Fri, 06 Nov 2015 19:59:50 +0000 Received: from beta.localdomain ([73.22.157.204]) by resomta-po-16v.sys.comcast.net with comcast id eKzp1r00D4QsobM01KzquF; Fri, 06 Nov 2015 19:59:50 +0000 Received: from calvin.localdomain ([10.0.0.8]) by beta.localdomain with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZunAr-0004b8-5N; Fri, 06 Nov 2015 13:59:49 -0600 Received: from tew by calvin.localdomain with local (Exim 4.80) (envelope-from ) id 1ZunAq-0004na-Fb; Fri, 06 Nov 2015 13:59:48 -0600 Date: Fri, 6 Nov 2015 13:59:48 -0600 From: Tim Walberg To: Andrei Borzenkov Subject: Re: [BUG] grub-install fails on devices with high minor numbers Message-ID: <20151106195948.GR4710@comcast.net> References: <20151106160813.GP4710@comcast.net> <563CF0B9.6090202@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <563CF0B9.6090202@gmail.com> Errors-To: Tim Walberg User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1446839990; bh=rp1Ag6xjt75ASm4zJR51UazuWtyei7UjKxDM0i/8IOQ=; h=Received:Received:Received:Received:Date:From:To:Subject: Message-ID:Reply-To:MIME-Version:Content-Type; b=ndaqNXw3VZZV1z4PSoLXKgS3b1rnYpkB9OnnfyPU3SpXnR5T8hGzlXCW+knpWRJZE m44L6+Qiq5E6oqJ1OgSiqe7MrdXPqe6RD8HNdV1loMDUqogj2qs+k66sViYmEbPN3j CFdJ9ysj6AKPvZR+/7kQNbOWm5aQhxkHqajaupPmEwwGPFmiGDakFp0Lf4Ey57Gv7S KqY/R0K5h9sJ0Prhl63bovpcDxo7obVMiSqEErc2D4hazqe7b+bqn/QB5RjtN5gBhT Yl8/M2lpav+wA/edkvnHJbYasq79L4nyRcRiRxCikarO893NbKyNzV/wyDVqnseeD8 xDV+IRkv3/SHA== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 96.114.154.167 X-Mailman-Approved-At: Fri, 06 Nov 2015 17:48:36 -0500 Cc: bug-grub@gnu.org, grub-devel@gnu.org, Tim Walberg X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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: Fri, 06 Nov 2015 19:59:57 -0000 On 11/06/2015 21:26 +0300, Andrei Borzenkov wrote: >> 06.11.2015 19:08, Tim Walberg ??????????: >> >On some relatively large systems that are used for virtualization, >> >often containing upwards of 100 virtual machines, we've started running >> >into issues with GRUB not being able to install on a new virtual machine >> >(using the typical process of mounting all the VM file systems on the host >> >and running grub-install under chroot). We've tracked the issue down to this >> >code, which is clearly erroneous - device minor numbers have been more than >> >8 bits for quite some time now - in grub-core/osdep/devmapper/getroot.c: >> > >> > char * >> > grub_util_devmapper_part_to_disk (struct stat *st, >> > int *is_part, const char *path) >> > { >> > int major, minor; >> > >> > if (grub_util_get_dm_node_linear_info (st->st_rdev, >> > &major, &minor, 0)) >> > { >> > *is_part = 1; >> > return grub_find_device ("/dev", >> > (major << 8) | minor); <<<<< --------- ERROR! >> > } >> > *is_part = 0; >> > return xstrdup (path); >> > } >> > >> >When we have enough device-mapper devices (including all their partitions) >> >on a host that the next newly-added set of devices ends up with minor numbers >> >outside the 8-bit range, this code fails, with the result that grub-install >> >can't find the devices that it needs to complete the install. >> > >> >There might be other places in the code where similar assumptions are made. >> >Someone more familiar with the code would probably be better for tracking >> >those down. But, this one at least needs to be fixed. >> > >> >> >> Does attached patch help? >> From: Andrei Borzenkov >> Subject: [PATCH] devmapper/getroot: use makedev instead of direct shift >> >> Fixes device detection with large number of devices. >> >> Reported by Tim Wallberg >> >> --- >> grub-core/osdep/devmapper/getroot.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c >> index 0a77a04..64419f6 100644 >> --- a/grub-core/osdep/devmapper/getroot.c >> +++ b/grub-core/osdep/devmapper/getroot.c >> @@ -208,8 +208,7 @@ grub_util_devmapper_part_to_disk (struct stat *st, >> &major, &minor, 0)) >> { >> *is_part = 1; >> - return grub_find_device ("/dev", >> - (major << 8) | minor); >> + return grub_find_device ("/dev", makedev (major, minor)); >> } >> *is_part = 0; >> return xstrdup (path); >> -- >> tg: (cd6d79c..) u/makedev (depends on: master) End of included message Yes, that appears to have resolved the issue. I was already testing essentially that patch on my own, but wasn't sure if there might be similar assumptions made elsewhere in the code. This single fix handles at least the use case we were having issues with. Thanks! tw -- twalberg@gmail.com