(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).
{
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))) {
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.");
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;