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

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