]> sourceware.org Git - lvm2.git/commitdiff
Synchronize "remove" dm task while reverting unsuccessful "create" dm task
authorPeter Rajnoha <prajnoha@redhat.com>
Mon, 3 May 2010 21:06:53 +0000 (21:06 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Mon, 3 May 2010 21:06:53 +0000 (21:06 +0000)
(with table provided).

This remove ioctl generates udev events like any other hence it needs to be
synchronized properly as well. Also, add dm task type in debug log when
setting a cookie (for better debugging).

libdm/ioctl/libdm-iface.c
libdm/libdm-common.c

index a34801213b138b9f46cf959ce2240448bb18762c..c0ac36afe7705d7004816cf63b8a94a1f5916688 100644 (file)
@@ -1546,6 +1546,7 @@ static int _create_and_load_v4(struct dm_task *dmt)
 {
        struct dm_task *task;
        int r;
+       uint32_t cookie;
 
        /* Use new task struct to create the device */
        if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
@@ -1625,7 +1626,18 @@ static int _create_and_load_v4(struct dm_task *dmt)
        dmt->type = DM_DEVICE_REMOVE;
        dm_free(dmt->uuid);
        dmt->uuid = NULL;
-       dmt->cookie_set = 0;
+
+       /*
+        * Also udev-synchronize "remove" dm task that is a part of this revert!
+        * But only if the original dm task was supposed to be synchronized.
+        */
+       if (dmt->cookie_set) {
+               cookie = (dmt->event_nr & ~DM_UDEV_FLAGS_MASK) |
+                        (DM_COOKIE_MAGIC << DM_UDEV_FLAGS_SHIFT);
+               dm_task_set_cookie(dmt, &cookie,
+                                  (dmt->event_nr & DM_UDEV_FLAGS_MASK) >>
+                                   DM_UDEV_FLAGS_SHIFT);
+       }
 
        if (!dm_task_run(dmt))
                log_error("Failed to revert device creation.");
index 2f5faa377effb9cf8c821cc5e4950f13f76a4db5..9ae2855b4eb67b717b6810763afcc632abaa62e4 100644 (file)
@@ -1192,7 +1192,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie, uint16_t flags)
        dmt->cookie_set = 1;
 
        log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task "
-                 "with flags 0x%" PRIx16, *cookie, semid, flags);
+                 "type %d with flags 0x%" PRIx16, *cookie, semid, dmt->type, flags);
 
        return 1;
 
This page took 0.042451 seconds and 5 git commands to generate.