Blame SOURCES/parted-2.1-libparted-use-dm_udev_wait-698121.patch

fc4a62
From e3f74af78b774b235123b9d5fa40fead3b003bb2 Mon Sep 17 00:00:00 2001
fc4a62
From: "Brian C. Lane" <bcl@redhat.com>
fc4a62
Date: Fri, 20 Jan 2012 15:31:43 -0800
fc4a62
Subject: [PATCH] libparted: use dm_udev_wait (#698121)
fc4a62
fc4a62
This applies Peter Rajnoha's patch to use dm_udev_wait to
fc4a62
synchronize with udev.
fc4a62
fc4a62
This requires libdevmapper v1.02.39 and higher.
fc4a62
fc4a62
Patch is from:
fc4a62
https://lists.gnu.org/archive/html/bug-parted/2010-09/msg00007.html
fc4a62
fc4a62
Resolves: rhbz#698121
fc4a62
---
fc4a62
 libparted/arch/linux.c |   16 +++++++++++++++-
fc4a62
 1 files changed, 15 insertions(+), 1 deletions(-)
fc4a62
fc4a62
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
fc4a62
index e2c4139..1fcbcad 100644
fc4a62
--- a/libparted/arch/linux.c
fc4a62
+++ b/libparted/arch/linux.c
fc4a62
@@ -1319,6 +1319,10 @@ linux_new (const char* path)
fc4a62
         dev->dirty = 0;
fc4a62
         dev->boot_dirty = 0;
fc4a62
 
fc4a62
+#ifdef ENABLE_DEVICE_MAPPER
fc4a62
+        dm_udev_set_sync_support(1);
fc4a62
+#endif
fc4a62
+
fc4a62
         if (!_device_probe_type (dev))
fc4a62
                 goto error_free_arch_specific;
fc4a62
 
fc4a62
@@ -2676,16 +2680,21 @@ static int
fc4a62
 _dm_remove_map_name(char *name)
fc4a62
 {
fc4a62
         struct dm_task  *task = NULL;
fc4a62
-        int             rc;
fc4a62
+        int             rc = 0;
fc4a62
+        uint32_t        cookie = 0;
fc4a62
 
fc4a62
         task = dm_task_create(DM_DEVICE_REMOVE);
fc4a62
         if (!task)
fc4a62
                 return 1;
fc4a62
 
fc4a62
         dm_task_set_name (task, name);
fc4a62
+        if (!dm_task_set_cookie(task, &cookie, 0))
fc4a62
+            goto err;
fc4a62
 
fc4a62
         rc = dm_task_run(task);
fc4a62
+        dm_udev_wait(cookie);
fc4a62
         dm_task_update_nodes();
fc4a62
+err:
fc4a62
         dm_task_destroy(task);
fc4a62
         if (!rc)
fc4a62
                 return 1;
fc4a62
@@ -2796,6 +2805,7 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
fc4a62
         const char*     dev_name = NULL;
fc4a62
         char*           params = NULL;
fc4a62
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (disk->dev);
fc4a62
+        uint32_t        cookie = 0;
fc4a62
 
fc4a62
         /* Get map name from devicemapper */
fc4a62
         struct dm_task *task = dm_task_create (DM_DEVICE_INFO);
fc4a62
@@ -2832,14 +2842,18 @@ _dm_add_partition (PedDisk* disk, PedPartition* part)
fc4a62
         dm_task_set_name (task, vol_name);
fc4a62
         dm_task_add_target (task, 0, part->geom.length,
fc4a62
                 "linear", params);
fc4a62
+        if (!dm_task_set_cookie(task, &cookie, 0))
fc4a62
+            goto err;
fc4a62
         if (dm_task_run (task)) {
fc4a62
                 //printf("0 %ld linear %s\n", part->geom.length, params);
fc4a62
+                dm_udev_wait(cookie);
fc4a62
                 dm_task_update_nodes();
fc4a62
                 dm_task_destroy(task);
fc4a62
                 free(params);
fc4a62
                 free(vol_name);
fc4a62
                 return 1;
fc4a62
         } else {
fc4a62
+                dm_udev_wait(cookie);
fc4a62
                 _dm_remove_map_name(vol_name);
fc4a62
         }
fc4a62
 err:
fc4a62
-- 
fc4a62
1.7.7.6
fc4a62