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

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