From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1g0Lvl-0006ib-Gu for mharc-grub-devel@gnu.org; Thu, 13 Sep 2018 03:20:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0Lvj-0006hN-Pq for grub-devel@gnu.org; Thu, 13 Sep 2018 03:20:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0Lvg-0001H5-L6 for grub-devel@gnu.org; Thu, 13 Sep 2018 03:20:47 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:41578) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0Lvg-0001GY-Bj for grub-devel@gnu.org; Thu, 13 Sep 2018 03:20:44 -0400 Received: from mazu (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Thu, 13 Sep 2018 01:20:37 -0600 Date: Thu, 13 Sep 2018 15:20:34 +0800 From: Michael Chang To: The development of GNU GRUB Cc: Martin Wilck Subject: [PATCH V1] hostdisk: Fix linux disk cache workaround on multipath disks Message-ID: <20180913072034.g7fbfnzify7zvouw@mazu> Mail-Followup-To: The development of GNU GRUB , Martin Wilck MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170421 (1.8.2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.250.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2018 07:20:48 -0000 In grub-core/osdep/linux/hostdisk.c::grub_util_fd_open_device() there's comment about linux disk cache issue as below: /* Linux has a bug that the disk cache for a whole disk is not consistent with the one for a partition of the disk. */ { .... } As the input argument of grub_util_fd_open_device() is using address in unit of sector size offset from the "disk", and in a bid to avoid Linux disk cache inconsistency problem described by comment above, grub translates the address again into the address offset from partition that has encompassed it, then use that partition device in place of disk device. The problem we encountered was that installing grub into multipath disk's partition didn't work reliably. It boiled down to the disk cache problem described above as strace result shown it was still using the whole disk device, not the partition device we would expect. This patch fixes the problem by adding the missing "/dev/dm-" name scheme handling in grub_hostdisk_linux_find_partition(). After applying the patch problem gets solved and we would like to have this fixing patch upstreamed as it looks good material to be. v1: Rework commit message. Signed-off-by: Michael Chang --- grub-core/osdep/linux/hostdisk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 06179fca7..ed530bdc4 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -263,6 +263,12 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector) p = real_dev + len; format = "-part%d"; } + else if (strncmp (real_dev, "/dev/dm-", + sizeof ("/dev/dm-") - 1) == 0) + { + p = real_dev + len - 1; + format = "%d"; + } else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9') { p = real_dev + len; -- 2.13.6