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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha at sourceware.org	2011-09-13 15:13:41

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

Log message:
	Retry DM_DEVICE_REMOVE ioctl if device is busy.
	
	This is a workaround for long-lasting problem with using the WATCH udev
	rule. When trying to remove a DM device, this one can still be opened
	while processing the event in parallel (generated based on the WATCH
	udev rule).
	
	Let's use this until we have a proper solution.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.498&r2=1.499
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120

--- LVM2/WHATS_NEW_DM	2011/09/07 08:37:48	1.498
+++ LVM2/WHATS_NEW_DM	2011/09/13 15:13:41	1.499
@@ -1,5 +1,6 @@
 Version 1.02.68 -
 ==================================
+  Retry DM_DEVICE_REMOVE ioctl if device is busy.
   Remove unused passed parameters for _mirror_emit_segment_line().
   Add dm_config and string character escaping functions to libdevmapper.
   Mark unreleased memory pools as internal error.
--- LVM2/libdm/ioctl/libdm-iface.c	2011/08/19 17:02:48	1.119
+++ LVM2/libdm/ioctl/libdm-iface.c	2011/09/13 15:13:41	1.120
@@ -1539,11 +1539,14 @@
 	return sanitised_message;
 }
 
+#define DM_REMOVE_IOCTL_RETRIES 25
+
 static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
 				     unsigned repeat_count)
 {
 	struct dm_ioctl *dmi;
 	int ioctl_with_uevent;
+	int retries = DM_REMOVE_IOCTL_RETRIES;
 
 	dmi = _flatten(dmt, repeat_count);
 	if (!dmi) {
@@ -1627,11 +1630,23 @@
 		  dmt->sector, _sanitise_message(dmt->message),
 		  dmi->data_size);
 #ifdef DM_IOCTLS
+repeat_dm_ioctl:
 	if (ioctl(_control_fd, command, dmi) < 0) {
 		if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
 				       (dmt->type == DM_DEVICE_MKNODES) ||
 				       (dmt->type == DM_DEVICE_STATUS)))
 			dmi->flags &= ~DM_EXISTS_FLAG;	/* FIXME */
+		/*
+		 * FIXME: This is a workaround for asynchronous events generated
+		 *        as a result of using the WATCH udev rule with which we
+		 *        have no way of synchronizing. Processing such events in
+		 *        parallel causes devices to be open.
+		 */
+		else if (errno == EBUSY && (dmt->type == DM_DEVICE_REMOVE) && retries--) {
+			log_debug("device-mapper: device is busy, retrying removal");
+			usleep(200000);
+			goto repeat_dm_ioctl;
+		}
 		else {
 			if (_log_suppress)
 				log_verbose("device-mapper: %s ioctl "



             reply	other threads:[~2011-09-13 15:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-13 15:13 prajnoha [this message]
2011-09-16 12:07 ` LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c Alasdair G Kergon
2011-09-17 19:34   ` Mikulas Patocka
  -- strict thread matches above, loose matches on Subject: below --
2012-03-01 10:07 zkabelac
2012-02-15 12:17 prajnoha
2012-02-08 12:59 zkabelac
2012-02-08 11:25 zkabelac
2011-11-08 17:32 snitzer
2011-10-20 10:38 zkabelac
2011-08-11 20:49 zkabelac
2011-07-24 23:59 agk
2011-07-02  1:17 agk
2011-06-09 15:07 mbroz
2011-03-25 23:50 agk
2011-03-08 22:43 zkabelac
2011-03-01 23:27 agk
2011-02-21 16:26 snitzer
2010-08-18 13:11 prajnoha
2010-05-13 13:31 mbroz

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=20110913151342.26443.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.