From: prajnoha@sourceware.org <prajnoha@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm ...
Date: 22 Sep 2011 17:09:50 -0000 [thread overview]
Message-ID: <20110922170950.22096.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2011-09-22 17:09:49
Modified files:
. : WHATS_NEW_DM
libdm : libdevmapper.h
libdm/ioctl : libdm-iface.c libdm-targets.h
Log message:
Add dm_task_retry_remove fn to use retry logic for device removal.
This call ensures that the dm device removal is retried several
times before failing.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.499&r2=1.500
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.149&r2=1.150
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-targets.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32
--- LVM2/WHATS_NEW_DM 2011/09/13 15:13:41 1.499
+++ LVM2/WHATS_NEW_DM 2011/09/22 17:09:48 1.500
@@ -1,6 +1,6 @@
Version 1.02.68 -
==================================
- Retry DM_DEVICE_REMOVE ioctl if device is busy.
+ Add dm_task_retry_remove fn to use retry logic for device removal.
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/libdevmapper.h 2011/09/02 01:32:09 1.149
+++ LVM2/libdm/libdevmapper.h 2011/09/22 17:09:48 1.150
@@ -191,6 +191,7 @@
int dm_task_query_inactive_table(struct dm_task *dmt);
int dm_task_suppress_identical_reload(struct dm_task *dmt);
int dm_task_secure_data(struct dm_task *dmt);
+int dm_task_retry_remove(struct dm_task *dmt);
/*
* Enable checks for common mistakes such as issuing ioctls in an unsafe order.
--- LVM2/libdm/ioctl/libdm-iface.c 2011/09/13 15:13:41 1.120
+++ LVM2/libdm/ioctl/libdm-iface.c 2011/09/22 17:09:48 1.121
@@ -828,6 +828,13 @@
return 1;
}
+int dm_task_retry_remove(struct dm_task *dmt)
+{
+ dmt->retry_remove = 1;
+
+ return 1;
+}
+
int dm_task_query_inactive_table(struct dm_task *dmt)
{
dmt->query_inactive_table = 1;
@@ -1539,16 +1546,15 @@
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)
+ unsigned buffer_repeat_count,
+ unsigned retry_repeat_count,
+ int *retryable)
{
struct dm_ioctl *dmi;
int ioctl_with_uevent;
- int retries = DM_REMOVE_IOCTL_RETRIES;
- dmi = _flatten(dmt, repeat_count);
+ dmi = _flatten(dmt, buffer_repeat_count);
if (!dmi) {
log_error("Couldn't create ioctl argument.");
return NULL;
@@ -1609,7 +1615,7 @@
}
log_debug("dm %s %s%s %s%s%s %s%.0d%s%.0d%s"
- "%s%c%c%s%s%s%s%s %.0" PRIu64 " %s [%u]",
+ "%s%c%c%s%s%s%s%s%s %.0" PRIu64 " %s [%u] (*%u)",
_cmd_data_v4[dmt->type].name,
dmt->new_uuid ? "UUID " : "",
dmi->name, dmi->uuid, dmt->newname ? " " : "",
@@ -1624,29 +1630,18 @@
dmt->no_flush ? 'N' : 'F',
dmt->read_only ? "R" : "",
dmt->skip_lockfs ? "S " : "",
+ dmt->retry_remove ? "T " : "",
dmt->secure_data ? "W " : "",
dmt->query_inactive_table ? "I " : "",
dmt->enable_checks ? "C" : "",
dmt->sector, _sanitise_message(dmt->message),
- dmi->data_size);
+ dmi->data_size, retry_repeat_count);
#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 "
@@ -1658,6 +1653,9 @@
"failed: %s",
_cmd_data_v4[dmt->type].name,
strerror(errno));
+
+ *retryable = errno == EBUSY;
+
_dm_zfree_dmi(dmi);
return NULL;
}
@@ -1680,6 +1678,9 @@
update_devs();
}
+#define DM_IOCTL_RETRIES 25
+#define DM_RETRY_USLEEP_DELAY 200000
+
int dm_task_run(struct dm_task *dmt)
{
struct dm_ioctl *dmi;
@@ -1687,6 +1688,8 @@
int check_udev;
int rely_on_udev;
int suspended_counter;
+ unsigned ioctl_retry = 1;
+ int retryable;
if ((unsigned) dmt->type >=
(sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
@@ -1734,7 +1737,14 @@
/* 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 (!(dmi = _do_dm_ioctl(dmt, command, _ioctl_buffer_double_factor,
+ ioctl_retry, &retryable))) {
+ if (retryable && dmt->type == DM_DEVICE_REMOVE &&
+ dmt->retry_remove && ++ioctl_retry <= DM_IOCTL_RETRIES) {
+ usleep(DM_RETRY_USLEEP_DELAY);
+ goto repeat_ioctl;
+ }
+
_udev_complete(dmt);
return 0;
}
--- LVM2/libdm/ioctl/libdm-targets.h 2011/08/09 17:56:48 1.31
+++ LVM2/libdm/ioctl/libdm-targets.h 2011/09/22 17:09:49 1.32
@@ -63,6 +63,7 @@
int cookie_set;
int new_uuid;
int secure_data;
+ int retry_remove;
int enable_checks;
char *uuid;
next reply other threads:[~2011-09-22 17:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 17:09 prajnoha [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-02 17:31 LVM2 ./WHATS_NEW_DM libdm/libdevmapper.h libdm zkabelac
2012-02-23 22:45 zkabelac
2012-02-15 12:23 prajnoha
2012-02-15 11:39 prajnoha
2012-02-15 11:27 prajnoha
2012-01-11 12:34 prajnoha
2011-12-21 12:47 zkabelac
2011-09-29 8:53 zkabelac
2011-09-22 17:36 prajnoha
2011-09-22 17:23 prajnoha
2011-09-22 17:17 prajnoha
2011-08-19 16:26 agk
2011-03-10 12:48 zkabelac
2011-02-18 14:38 zkabelac
2011-02-04 16:08 mbroz
2011-01-04 14:43 prajnoha
2010-10-25 13:13 zkabelac
2010-10-15 1:10 agk
2010-04-28 13:37 prajnoha
2009-11-13 12:43 prajnoha
2009-10-22 12:55 prajnoha
2009-06-03 11:40 agk
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=20110922170950.22096.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.