From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZuxIz-0006Pu-LR for mharc-grub-devel@gnu.org; Sat, 07 Nov 2015 01:48:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuxIx-0006Pj-9e for grub-devel@gnu.org; Sat, 07 Nov 2015 01:48:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuxIt-0001Wg-5l for grub-devel@gnu.org; Sat, 07 Nov 2015 01:48:51 -0500 Received: from mail-lb0-x229.google.com ([2a00:1450:4010:c04::229]:34701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuxIs-0001Wb-Ut; Sat, 07 Nov 2015 01:48:47 -0500 Received: by lbbwb3 with SMTP id wb3so71015712lbb.1; Fri, 06 Nov 2015 22:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=uSCxcWKWXl86NklCDZtjHBeOYIsNnKwEvMn17gB0ntI=; b=iZMxKvvwVg4Qr8441r7szDCZo40ZukSah2wpl43Qmwdxjqg2C+2upIQzPQLJrk2fN9 MhSSqXHUi4ULjd9kaH2rcwTwd4HZmdkOb6sQdTEU8oGa4Oi2zH69WdYOS8J8IZWzMGOy nD+5aWf0SNXYI/1QfdbKsytwuSTml7+JFawlxpV3v8/8tIlrnfkdZ4SqZapH8UYT3+tJ aVM2BZyShC3BT5hMdCDOwn6EoxOXfNaMNUiD9643Qz4LDZJ3IaLRTaElSuLuX3YB1aVc mCKmAi3L0Jh9vqkCCxtN+KCWkrcyuTzfksczSiuMryaW+0G1S837V83dYMb7hUjWeTom 9vqw== X-Received: by 10.112.180.230 with SMTP id dr6mr8808050lbc.72.1446878926162; Fri, 06 Nov 2015 22:48:46 -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 k6sm608184lbd.22.2015.11.06.22.48.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Nov 2015 22:48:45 -0800 (PST) Subject: Re: [BUG] grub-install fails on devices with high minor numbers To: Tim Walberg References: <20151106160813.GP4710@comcast.net> <563CF0B9.6090202@gmail.com> <20151106195948.GR4710@comcast.net> From: Andrei Borzenkov Message-ID: <563D9ECC.1060909@gmail.com> Date: Sat, 7 Nov 2015 09:48:44 +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: <20151106195948.GR4710@comcast.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::229 Cc: bug-grub@gnu.org, grub-devel@gnu.org 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: Sat, 07 Nov 2015 06:48:52 -0000 06.11.2015 22:59, Tim Walberg пишет: > 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. As far as I can tell, other places used makedev() already. Committed. Thanks!