All of lore.kernel.org
 help / color / mirror / Atom feed
From: prajnoha@sourceware.org <prajnoha@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/libdm/ioctl libdm-iface.c
Date: 6 Aug 2009 15:02:02 -0000	[thread overview]
Message-ID: <20090806150202.2968.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha at sourceware.org	2009-08-06 15:02:01

Modified files:
	libdm/ioctl    : libdm-iface.c 

Log message:
	Fix failure situations in dm_task_run for udev sync.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61

--- LVM2/libdm/ioctl/libdm-iface.c	2009/08/03 18:01:48	1.60
+++ LVM2/libdm/ioctl/libdm-iface.c	2009/08/06 15:02:01	1.61
@@ -1486,6 +1486,18 @@
 	return _process_all_v4(dmt);
 }
 
+/*
+ * If an operation that uses a cookie fails, decrement the
+ * semaphore instead of udev.
+ */
+static int _udev_complete(struct dm_task *dmt)
+{
+	if (dmt->cookie_set)
+		return dm_udev_complete(dmt->event_nr);
+
+	return 1;
+}
+
 static int _create_and_load_v4(struct dm_task *dmt)
 {
 	struct dm_task *task;
@@ -1494,17 +1506,20 @@
 	/* Use new task struct to create the device */
 	if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
 		log_error("Failed to create device-mapper task struct");
+		_udev_complete(dmt);
 		return 0;
 	}
 
 	/* Copy across relevant fields */
 	if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
 		dm_task_destroy(task);
+		_udev_complete(dmt);
 		return 0;
 	}
 
 	if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid)) {
 		dm_task_destroy(task);
+		_udev_complete(dmt);
 		return 0;
 	}
 
@@ -1516,18 +1531,22 @@
 
 	r = dm_task_run(task);
 	dm_task_destroy(task);
-	if (!r)
-		return r;
+	if (!r) {
+		_udev_complete(dmt);
+		return 0;
+	}
 
 	/* Next load the table */
 	if (!(task = dm_task_create(DM_DEVICE_RELOAD))) {
 		log_error("Failed to create device-mapper task struct");
+		_udev_complete(dmt);
 		return 0;
 	}
 
 	/* Copy across relevant fields */
 	if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
 		dm_task_destroy(task);
+		_udev_complete(dmt);
 		return 0;
 	}
 
@@ -1540,8 +1559,10 @@
 	task->head = NULL;
 	task->tail = NULL;
 	dm_task_destroy(task);
-	if (!r)
+	if (!r) {
+		_udev_complete(dmt);
 		goto revert;
+	}
 
 	/* Use the original structure last so the info will be correct */
 	dmt->type = DM_DEVICE_RESUME;
@@ -1557,6 +1578,7 @@
  	dmt->type = DM_DEVICE_REMOVE;
 	dm_free(dmt->uuid);
 	dmt->uuid = NULL;
+	dmt->cookie_set = 0;
 
 	if (!dm_task_run(dmt))
 		log_error("Failed to revert device creation.");
@@ -1739,19 +1761,15 @@
 	if ((dmt->type == DM_DEVICE_RELOAD) && dmt->suppress_identical_reload)
 		return _reload_with_suppression_v4(dmt);
 
-	if (!_open_control())
+	if (!_open_control()) {
+		_udev_complete(dmt);
 		return 0;
+	}
 
 	/* FIXME Detect and warn if cookie set but should not be. */
 repeat_ioctl:
 	if (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor))) {
-		/*
-		 * If an operation that uses a cookie fails, decrement the 
-		 * semaphore instead of udev.
-		 * FIXME Review error paths: found one where uevent fired too.
-		 */
-		if (dmt->cookie_set)
-			dm_udev_complete(dmt->event_nr);
+		_udev_complete(dmt);
 		return 0;
 	}
 



             reply	other threads:[~2009-08-06 15:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 15:02 prajnoha [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-05-03 22:08 LVM2/libdm/ioctl libdm-iface.c prajnoha
2010-07-28 10:30 prajnoha
2010-08-16 11:13 prajnoha
2010-11-30 22:32 zkabelac
2011-01-31 11:54 prajnoha
2011-02-04 21:26 agk
2011-03-02  8:41 zkabelac
2011-03-05 21:17 mbroz
2011-03-06  1:18 ` Alasdair G Kergon
2011-03-06  1:36   ` Milan Broz
2011-03-06  1:51     ` Alasdair G Kergon
2011-03-20  2:00 agk
2011-03-20 13:09 ` Zdenek Kabelac
2011-03-20 21:41   ` Alasdair G Kergon
2011-03-20 23:51     ` Zdenek Kabelac
2011-03-21  1:47       ` Alasdair G Kergon
2011-06-13  3:53 agk
2011-06-29  8:54 agk
2011-06-29 11:36 agk
2011-06-29 16:08 agk
2011-08-19 16:49 agk
2011-09-22 18:00 prajnoha
2011-09-23 17:16 agk
2011-10-17 14:36 zkabelac
2011-11-08 19:02 snitzer
2012-03-01 10:46 zkabelac
2012-03-05 14:45 prajnoha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090806150202.2968.qmail@sourceware.org \
    --to=prajnoha@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.