Blame SOURCES/0032-libparted-device-mapper-uses-512b-sectors-1188431.patch

fc4a62
From 07f2604aeeb20d187e7243007fc5ab1a0560a4b7 Mon Sep 17 00:00:00 2001
fc4a62
From: "Brian C. Lane" <bcl@redhat.com>
fc4a62
Date: Wed, 4 Feb 2015 16:46:07 -0800
fc4a62
Subject: [PATCH 32/32] libparted: device mapper uses 512b sectors (#1188431)
fc4a62
fc4a62
device mapper doesn't use the device's sector size when creating a
fc4a62
table. It always uses 512b units. This causes partitions to be created
fc4a62
8x smaller than expected on devices with 4906b sectors.
fc4a62
fc4a62
Resolves: rhbz#1188431
fc4a62
---
fc4a62
 libparted/arch/linux.c | 7 +++++--
fc4a62
 1 file changed, 5 insertions(+), 2 deletions(-)
fc4a62
fc4a62
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
fc4a62
index 788cdc3..1d11f58 100644
fc4a62
--- a/libparted/arch/linux.c
fc4a62
+++ b/libparted/arch/linux.c
fc4a62
@@ -2849,8 +2849,10 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
fc4a62
         dm_task_destroy (task);
fc4a62
         task = NULL;
fc4a62
 
fc4a62
+        /* device-mapper uses 512b units, not the device's sector size */
fc4a62
         if ( ! (params = zasprintf ("%d:%d %lld", arch_specific->major,
fc4a62
-                                    arch_specific->minor, part->geom.start)))
fc4a62
+                                    arch_specific->minor,
fc4a62
+                                    part->geom.start * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT))))
fc4a62
                 goto err;
fc4a62
 
fc4a62
         task = dm_task_create (DM_DEVICE_CREATE);
fc4a62
@@ -2860,7 +2862,8 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
fc4a62
         dm_task_set_name (task, vol_name);
fc4a62
         if (vol_uuid)
fc4a62
                 dm_task_set_uuid (task, vol_uuid);
fc4a62
-        dm_task_add_target (task, 0, part->geom.length,
fc4a62
+        /* device-mapper uses 512b units, not the device's sector size */
fc4a62
+        dm_task_add_target (task, 0, part->geom.length * (disk->dev->sector_size / PED_SECTOR_SIZE_DEFAULT),
fc4a62
                 "linear", params);
fc4a62
         if (!dm_task_set_cookie(task, &cookie, 0))
fc4a62
             goto err;
fc4a62
-- 
fc4a62
2.1.0
fc4a62