Skip to contentSkip to conversation

disk/mdraid1x: Fix >2TB RAID detection with BIOS

PATCH In review Robert LeBlanc 1 participant 4 messages Jan 25, 2017 – Mar 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 disk/mdraid1x: Fix >2TB RAID detection with BIOS

Changes in v3:
- Fix to return if not out of range instead of breaking out of the loop.

Changes in v2:
- Only continue checking for other metadata versions if we get an out of range error and reset grub_errno if we continue.

When a mdadm RAID array is on a drive larger than 2TB, the array is not able to be detected and as such even if the array has a partition that holds /boot under the 2TB limit, it is unable to boot the machine. This is caused by metadata 1.0 being tested first which allocates the superblock at the end of the device. When it tries to access the end of the device it throws an error and the code returns without trying to find the superblock at other locations (metadata 1.1 and 1.2). This patch changes the error to not be fatal and allow for the checking for the other metadata versions and allowing the machine to boot as long as /boot is under the 2TB BIOS limit. This won't cause issues with 1.0 metadata because GRUB is able to read the partitions from the front of the drive/partition without having to determine the data offset, since the data for metadata 1.0 starts at sector 0.

---
 grub-core/disk/mdraid1x_linux.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
grub-core/disk/mdraid1x_linux.c +11 -1
index 7cc80d3df..f0aeb6829 100644
@@ -148,7 +148,17 @@ grub_mdraid_detect (grub_disk_t disk,
 
       if (grub_disk_read (disk, sector, 0, sizeof (struct grub_raid_super_1x),
 			  &sb))
-	return NULL;
+	{
+	  if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+	    {
+	      grub_errno = GRUB_ERR_NONE;
+	      continue;
+	    }
+          else
+	    {
+	      return NULL;
+	    }
+	}
 
       if (sb.magic != grub_cpu_to_le32_compile_time (SB_MAGIC)
 	  || grub_le_to_cpu64 (sb.super_offset) != sector)
Signature · 1 line
2.11.0
#1 lore raw
Quoted 51 lines · Robert LeBlanc

Changes in v3:
- Fix to return if not out of range instead of breaking out of the loop.

Changes in v2:
- Only continue checking for other metadata versions if we get an out of range error and reset grub_errno if we continue.

When a mdadm RAID array is on a drive larger than 2TB, the array is not able to be detected and as such even if the array has a partition that holds /boot under the 2TB limit, it is unable to boot the machine. This is caused by metadata 1.0 being tested first which allocates the superblock at the end of the device. When it tries to access the end of the device it throws an error and the code returns without trying to find the superblock at other locations (metadata 1.1 and 1.2). This patch changes the error to not be fatal and allow for the checking for the other metadata versions and allowing the machine to boot as long as /boot is under the 2TB BIOS limit. This won't cause issues with 1.0 metadata because GRUB is able to read the partitions from the front of the drive/partition without having to determine the data offset, since the data for metadata 1.0 starts at sector 0.

---
 grub-core/disk/mdraid1x_linux.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
grub-core/disk/mdraid1x_linux.c +11 -2
index 7cc80d3df..f0aeb6829 100644
@@ -148,7 +148,17 @@ grub_mdraid_detect (grub_disk_t disk,
 
       if (grub_disk_read (disk, sector, 0, sizeof (struct grub_raid_super_1x),
                          &sb))
-       return NULL;
+       {
+         if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+           {
+             grub_errno = GRUB_ERR_NONE;
+             continue;
+           }
+          else
+           {
+             return NULL;
+           }
+       }
 
       if (sb.magic != grub_cpu_to_le32_compile_time (SB_MAGIC)
          || grub_le_to_cpu64 (sb.super_offset) != sector)
--
Quoted 2 lines

2.11.0

Vladimir,

Does this patch resolve your concerns?
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1

#2 lore raw
In reply to Robert LeBlanc
Quoted 40 lines · Robert LeBlanc

Changes in v3:
- Fix to return if not out of range instead of breaking out of the loop.

Changes in v2:
- Only continue checking for other metadata versions if we get an out of range error and reset grub_errno if we continue.

When a mdadm RAID array is on a drive larger than 2TB, the array is not able to be detected and as such even if the array has a partition that holds /boot under the 2TB limit, it is unable to boot the machine. This is caused by metadata 1.0 being tested first which allocates the superblock at the end of the device. When it tries to access the end of the device it throws an error and the code returns without trying to find the superblock at other locations (metadata 1.1 and 1.2). This patch changes the error to not be fatal and allow for the checking for the other metadata versions and allowing the machine to boot as long as /boot is under the 2TB BIOS limit. This won't cause issues with 1.0 metadata because GRUB is able to read the partitions from the front of the drive/partition without having to determine the data offset, since the data for metadata 1.0 starts at sector 0.

---
 grub-core/disk/mdraid1x_linux.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
grub-core/disk/mdraid1x_linux.c +4 -1
index 7cc80d3df..f0aeb6829 100644
@@ -148,7 +148,17 @@ grub_mdraid_detect (grub_disk_t disk,
 
       if (grub_disk_read (disk, sector, 0, sizeof (struct grub_raid_super_1x),
                          &sb))
-       return NULL;
+       {
+         if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+           {
+             grub_errno = GRUB_ERR_NONE;

grub-core/disk/mdraid1x_linux.c grub_mdraid_detect (grub_disk_t disk, · line 164

Quoted 10 lines
grub-core/disk/mdraid1x_linux.c +7 -0
+             continue;
+           }
+          else
+           {
+             return NULL;
+           }
+       }
 
       if (sb.magic != grub_cpu_to_le32_compile_time (SB_MAGIC)
          || grub_le_to_cpu64 (sb.super_offset) != sector)

Does this look okay? I'm not seeing this in patchworks to know what the status is.

Thanks,
Robert LeBlanc
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1

#3 lore raw

ping
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1

Quoted 61 lines · Robert LeBlanc
Quoted 40 lines · Robert LeBlanc

Changes in v3:
- Fix to return if not out of range instead of breaking out of the loop.

Changes in v2:
- Only continue checking for other metadata versions if we get an out of range error and reset grub_errno if we continue.

When a mdadm RAID array is on a drive larger than 2TB, the array is not able to be detected and as such even if the array has a partition that holds /boot under the 2TB limit, it is unable to boot the machine. This is caused by metadata 1.0 being tested first which allocates the superblock at the end of the device. When it tries to access the end of the device it throws an error and the code returns without trying to find the superblock at other locations (metadata 1.1 and 1.2). This patch changes the error to not be fatal and allow for the checking for the other metadata versions and allowing the machine to boot as long as /boot is under the 2TB BIOS limit. This won't cause issues with 1.0 metadata because GRUB is able to read the partitions from the front of the drive/partition without having to determine the data offset, since the data for metadata 1.0 starts at sector 0.

---
 grub-core/disk/mdraid1x_linux.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
grub-core/disk/mdraid1x_linux.c +4 -1
index 7cc80d3df..f0aeb6829 100644
@@ -148,7 +148,17 @@ grub_mdraid_detect (grub_disk_t disk,
 
       if (grub_disk_read (disk, sector, 0, sizeof (struct grub_raid_super_1x),
                          &sb))
-       return NULL;
+       {
+         if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
+           {
+             grub_errno = GRUB_ERR_NONE;

grub-core/disk/mdraid1x_linux.c grub_mdraid_detect (grub_disk_t disk, · line 164

Quoted 10 lines
grub-core/disk/mdraid1x_linux.c +7 -0
+             continue;
+           }
+          else
+           {
+             return NULL;
+           }
+       }
 
       if (sb.magic != grub_cpu_to_le32_compile_time (SB_MAGIC)
          || grub_le_to_cpu64 (sb.super_offset) != sector)

Does this look okay? I'm not seeing this in patchworks to know what the status is.

Thanks,
Robert LeBlanc
----------------
Robert LeBlanc
PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1