From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZuliE-0007oy-V8 for mharc-grub-devel@gnu.org; Fri, 06 Nov 2015 13:26:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuliB-0007nH-V3 for grub-devel@gnu.org; Fri, 06 Nov 2015 13:26:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zuli8-00061r-Mc for grub-devel@gnu.org; Fri, 06 Nov 2015 13:26:07 -0500 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]:33218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuli8-00061R-EU; Fri, 06 Nov 2015 13:26:04 -0500 Received: by lbbkw15 with SMTP id kw15so57680787lbb.0; Fri, 06 Nov 2015 10:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=vIuD/ZeZkRGpNBoc3wzJ/w8opKW4feNCMyP1Qry5W4c=; b=xpAXWQxysUn+xPK3nU/YjRbM3guMrwiN3HLyD4fLJeAS1k/8hELy4uFEB9XdxhXZgW U/uzyi7tvIepye7IetY+AdivP5sC100MOUCC9o3ZwZi2y+fh0f50+2bo6qYgT1AN4O/A eOFYVE53hs8kIO8Qwr87DeuWifnVth4wFSbt82adH5mZOEajpumezJK4wEo7pPJ7nnZY r2LTmBqHvJV//QRiff2wY8944CJwv6yG6iEom7pzDvY7j1tNajh/GoWLzvlcvIatYH1d WFAKi9OpKD8hMvtTbf15KQbalBP+rJseiMj8DV/sZ64z910If9cIvY/haycJtJB22p+O AlEA== X-Received: by 10.112.189.193 with SMTP id gk1mr7506615lbc.98.1446834363793; Fri, 06 Nov 2015 10:26:03 -0800 (PST) Received: from [192.168.1.41] (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id tm7sm164367lbb.38.2015.11.06.10.26.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2015 10:26:02 -0800 (PST) Subject: Re: [BUG] grub-install fails on devices with high minor numbers To: Tim Walberg , bug-grub@gnu.org, grub-devel@gnu.org References: <20151106160813.GP4710@comcast.net> From: Andrei Borzenkov Message-ID: <563CF0B9.6090202@gmail.com> Date: Fri, 6 Nov 2015 21:26:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151106160813.GP4710@comcast.net> Content-Type: multipart/mixed; boundary="------------070701070304040009070709" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22c 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 18:26:09 -0000 This is a multi-part message in MIME format. --------------070701070304040009070709 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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? --------------070701070304040009070709 Content-Type: text/x-patch; name="devmapper-getroot.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="devmapper-getroot.patch" 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) --------------070701070304040009070709--