[parted-devel] [PATCH] libparted/s390: Re-enabled virtio-attached DASD heuristics

Brian C. Lane bcl at redhat.com
Tue Oct 1 00:27:45 BST 2019


From: Viktor Mihajlovski <mihajlov at linux.ibm.com>

DASDs attached to KVM guest as virtio-blk devices are only handled
properly, if the unique DASD geometry is detected. Commit id
61dd3d4c5eb782eb43caa95342e63727db3f8281 has prevented proper geometry
detection. Fixed by making sure that HDIO_GETGEO takes precedence
on s390[x].

Signed-off-by: Viktor Mihajlovski <mihajlov at linux.ibm.com>
Signed-off-by: Brian C. Lane <bcl at redhat.com>
---
 libparted/arch/linux.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index bb4d5ea..09ec781 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -867,6 +867,7 @@ _device_probe_geometry (PedDevice* dev)
         LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
         struct stat             dev_stat;
         struct hd_geometry      geometry;
+        int                     geometry_is_valid = 0;
         int                     sector_size = 0;
 
         if (!_device_stat (dev, &dev_stat))
@@ -884,13 +885,19 @@ _device_probe_geometry (PedDevice* dev)
         dev->bios_geom.heads = 0;
         dev->bios_geom.cylinders = 0;
 
+        geometry_is_valid = !ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
+                            && geometry.sectors && geometry.heads;
+
+#if defined __s390__ || defined __s390x__
+        if (geometry_is_valid) {
+#else
         if (!ioctl (arch_specific->fd, BLKSSZGET, &sector_size)) {
                 /* get the sector count first */
                 dev->bios_geom.sectors = 1 + (sector_size / PED_SECTOR_SIZE_DEFAULT);
                 dev->bios_geom.heads = 255;
-        } else if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
-                        && geometry.sectors && geometry.heads) {
-                /* if BLKSSZGET failed, try the deprecated HDIO_GETGEO */
+        } else if (geometry_is_valid) {
+                /* if BLKSSZGET failed, use deprecated HDIO_GETGEO result */
+#endif
                 dev->bios_geom.sectors = geometry.sectors;
                 dev->bios_geom.heads = geometry.heads;
         } else {
-- 
2.21.0




More information about the parted-devel mailing list