Blame SOURCES/0090-libparted-s390-Re-enabled-virtio-attached-DASD-heuri.patch

1a4387
From d74cd53b7a0db94e08c9e034bdf9d59273ada723 Mon Sep 17 00:00:00 2001
1a4387
From: Viktor Mihajlovski <mihajlov@linux.ibm.com>
1a4387
Date: Fri, 27 Sep 2019 18:34:46 +0300
1a4387
Subject: [PATCH] libparted/s390: Re-enabled virtio-attached DASD heuristics
1a4387
1a4387
DASDs attached to KVM guest as virtio-blk devices are only handled
1a4387
properly, if the unique DASD geometry is detected. Commit id
1a4387
61dd3d4c5eb782eb43caa95342e63727db3f8281 has prevented proper geometry
1a4387
detection. Fixed by making sure that HDIO_GETGEO takes precedence
1a4387
on s390[x].
1a4387
1a4387
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
1a4387
Signed-off-by: Brian C. Lane <bcl@redhat.com>
1a4387
---
1a4387
 libparted/arch/linux.c | 13 ++++++++++---
1a4387
 1 file changed, 10 insertions(+), 3 deletions(-)
1a4387
1a4387
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
1a4387
index 7771a8b..a40e9f8 100644
1a4387
--- a/libparted/arch/linux.c
1a4387
+++ b/libparted/arch/linux.c
1a4387
@@ -867,6 +867,7 @@ _device_probe_geometry (PedDevice* dev)
1a4387
         LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
1a4387
         struct stat             dev_stat;
1a4387
         struct hd_geometry      geometry;
1a4387
+        int                     geometry_is_valid = 0;
1a4387
         int                     sector_size = 0;
1a4387
 
1a4387
         if (!_device_stat (dev, &dev_stat))
1a4387
@@ -884,13 +885,19 @@ _device_probe_geometry (PedDevice* dev)
1a4387
         dev->bios_geom.heads = 0;
1a4387
         dev->bios_geom.cylinders = 0;
1a4387
 
1a4387
+        geometry_is_valid = !ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
1a4387
+                            && geometry.sectors && geometry.heads;
1a4387
+
1a4387
+#if defined __s390__ || defined __s390x__
1a4387
+        if (geometry_is_valid) {
1a4387
+#else
1a4387
         if (!ioctl (arch_specific->fd, BLKSSZGET, &sector_size)) {
1a4387
                 /* get the sector count first */
1a4387
                 dev->bios_geom.sectors = 1 + (sector_size / PED_SECTOR_SIZE_DEFAULT);
1a4387
                 dev->bios_geom.heads = 255;
1a4387
-        } else if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
1a4387
-                        && geometry.sectors && geometry.heads) {
1a4387
-                /* if BLKSSZGET failed, try the deprecated HDIO_GETGEO */
1a4387
+        } else if (geometry_is_valid) {
1a4387
+                /* if BLKSSZGET failed, use deprecated HDIO_GETGEO result */
1a4387
+#endif
1a4387
                 dev->bios_geom.sectors = geometry.sectors;
1a4387
                 dev->bios_geom.heads = geometry.heads;
1a4387
         } else {
1a4387
-- 
1a4387
2.21.0
1a4387