master - tools: add -b/--background for pvscan --cache -aay
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=008c33a21ba0e0...
Commit: 008c33a21ba0e0fb27319b63c7bad8fb8136f804
Parent: ea1e8166d57c40a5406b68864e19056df6d2f103
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 3 16:06:16 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 3 16:49:21 2013 +0200
tools: add -b/--background for pvscan --cache -aay
Udev daemon has recently introduced a limit on the number of udev
processes (there was no limit before). This causes a problem
when calling pvscan --cache -aay in lvmetad udev rules which
is supposed to activate the volumes. This activation is itself
synced with udev and so it waits for the activation to complete
before the pvscan finishes. The event processing can't continue
until this pvscan call is finished.
But if we're at the limit with the udev process count, we can't
instatiate any more udev processes, all such events are queued
and so we can't process the lvm activation event for which the
pvscan is waiting.
Then we're in a deadlock since the udev process with the
pvscan --cache -aay call waits for the lvm activation udev
processing to complete, but that will never happen as there's
this limit hit with the number of udev processes.
The process with pvscan --cache -aay actually times out eventually
(3min or 30sec, depends on the version of udev).
This patch makes it possible to run the pvscan --cache -aay
in the background so the udev processing can continue and hence
we can avoid the deadlock mentioned above.
---
WHATS_NEW | 2 +
man/pvscan.8.in | 4 ++
tools/commands.h | 5 ++-
tools/lvmcmdline.c | 8 ++++
tools/polldaemon.c | 76 +---------------------------------------
tools/toollib.c | 77 +++++++++++++++++++++++++++++++++++++++++
tools/toollib.h | 2 +
udev/69-dm-lvm-metad.rules.in | 2 +-
8 files changed, 98 insertions(+), 78 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f1a9933..c87bce1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.101 -
===================================
+ Use pvscan -b in udev rules to avoid a deadlock on udev process count limit.
+ Add pvscan -b/--background for the command to be processed in the background.
Don't assume stdin file descriptor is readable.
Avoid unlimited recursion when creating dtree containing inactive pvmove LV.
Require exactly 3 arguments for lvm2-activation-generator. Remove defaults.
diff --git a/man/pvscan.8.in b/man/pvscan.8.in
index 2246744..78ee3e2 100644
--- a/man/pvscan.8.in
+++ b/man/pvscan.8.in
@@ -19,6 +19,7 @@ pvscan \- scan all disks for physical volumes
.RB [ \-h | \-\-help ]
.B \-\-cache
.RB [ \-a | \-\-activate " " \fIay ]
+.RB [ \-b | \-\-background ]
.RB [ \-\-major
.I major
.B \-\-minor
@@ -51,6 +52,9 @@ activation/auto_activation_volume_list set in lvm.conf. If this list is not set,
all volumes are considered for autoactivation. The autoactivation is not yet
supported for logical volumes that are part of partial or clustered volume groups.
.TP
+.BR \-b ", " \-\-background
+Run the command in the background.
+.TP
.BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " ]..."
Scan one or more devices and instruct the lvmetad daemon to update its cached
state accordingly. Called internally by udev rules.
diff --git a/tools/commands.h b/tools/commands.h
index f9f81c5..ef7848d 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -724,6 +724,7 @@ xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY,
"pvscan " "\n"
+ "\t[-b|--background]\n"
"\t[--cache [-a|--activate ay] [ DevicePath | --major major --minor minor]...]\n"
"\t[-d|--debug] " "\n"
"\t{-e|--exported | -n|--novolumegroup} " "\n"
@@ -735,8 +736,8 @@ xx(pvscan,
"\t[-v|--verbose] " "\n"
"\t[--version]\n",
- activate_ARG, available_ARG, cache_ARG, exported_ARG,
- ignorelockingfailure_ARG, major_ARG, minor_ARG,
+ activate_ARG, available_ARG, background_ARG, cache_ARG,
+ exported_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG,
novolumegroup_ARG, partial_ARG, short_ARG, uuid_ARG)
xx(segtypes,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index a155d21..dc5d592 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1097,6 +1097,14 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
set_cmd_name(cmd->command->name);
+ if (arg_count(cmd, background_ARG)) {
+ if (!become_daemon(cmd, 1)) {
+ /* parent - quit immediately */
+ ret = ECMD_PROCESSED;
+ goto out;
+ }
+ }
+
if (arg_count(cmd, config_ARG))
if (!override_config_tree_from_string(cmd, arg_str_value(cmd, config_ARG, ""))) {
ret = EINVALID_CMD_LINE;
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index c139d2b..0b00e93 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -16,80 +16,6 @@
#include "tools.h"
#include "polldaemon.h"
#include "lvm2cmdline.h"
-#include <signal.h>
-#include <sys/wait.h>
-
-static void _sigchld_handler(int sig __attribute__((unused)))
-{
- while (wait4(-1, NULL, WNOHANG | WUNTRACED, NULL) > 0) ;
-}
-
-/*
- * returns:
- * -1 if the fork failed
- * 0 if the parent
- * 1 if the child
- */
-static int _become_daemon(struct cmd_context *cmd)
-{
- static const char devnull[] = "/dev/null";
- int null_fd;
- pid_t pid;
- struct sigaction act = {
- {_sigchld_handler},
- .sa_flags = SA_NOCLDSTOP,
- };
-
- log_verbose("Forking background process");
-
- sigaction(SIGCHLD, &act, NULL);
-
- sync_local_dev_names(cmd); /* Flush ops and reset dm cookie */
-
- if ((pid = fork()) == -1) {
- log_error("fork failed: %s", strerror(errno));
- return -1;
- }
-
- /* Parent */
- if (pid > 0)
- return 0;
-
- /* Child */
- if (setsid() == -1)
- log_error("Background process failed to setsid: %s",
- strerror(errno));
-
- /* For poll debugging it's best to disable for compilation */
-#if 1
- if ((null_fd = open(devnull, O_RDWR)) == -1) {
- log_sys_error("open", devnull);
- _exit(ECMD_FAILED);
- }
-
- if ((dup2(null_fd, STDIN_FILENO) < 0) || /* reopen stdin */
- (dup2(null_fd, STDOUT_FILENO) < 0) || /* reopen stdout */
- (dup2(null_fd, STDERR_FILENO) < 0)) { /* reopen stderr */
- log_sys_error("dup2", "redirect");
- (void) close(null_fd);
- _exit(ECMD_FAILED);
- }
-
- if (null_fd > STDERR_FILENO)
- (void) close(null_fd);
-
- init_verbose(VERBOSE_BASE_LEVEL);
-#endif
- strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
-
- reset_locking();
- if (!lvmcache_init())
- /* FIXME Clean up properly here */
- _exit(ECMD_FAILED);
- dev_close_all();
-
- return 1;
-}
progress_t poll_mirror_progress(struct cmd_context *cmd,
struct logical_volume *lv, const char *name,
@@ -340,7 +266,7 @@ int poll_daemon(struct cmd_context *cmd, const char *name, const char *uuid,
}
if (parms.background) {
- daemon_mode = _become_daemon(cmd);
+ daemon_mode = become_daemon(cmd, 0);
if (daemon_mode == 0)
return ECMD_PROCESSED; /* Parent */
else if (daemon_mode == 1)
diff --git a/tools/toollib.c b/tools/toollib.c
index befd3b8..50c43d9 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -15,12 +15,89 @@
#include "tools.h"
#include <sys/stat.h>
+#include <signal.h>
+#include <sys/wait.h>
const char *command_name(struct cmd_context *cmd)
{
return cmd->command->name;
}
+static void _sigchld_handler(int sig __attribute__((unused)))
+{
+ while (wait4(-1, NULL, WNOHANG | WUNTRACED, NULL) > 0) ;
+}
+
+/*
+ * returns:
+ * -1 if the fork failed
+ * 0 if the parent
+ * 1 if the child
+ */
+int become_daemon(struct cmd_context *cmd, int skip_lvm)
+{
+ static const char devnull[] = "/dev/null";
+ int null_fd;
+ pid_t pid;
+ struct sigaction act = {
+ {_sigchld_handler},
+ .sa_flags = SA_NOCLDSTOP,
+ };
+
+ log_verbose("Forking background process");
+
+ sigaction(SIGCHLD, &act, NULL);
+
+ if (!skip_lvm)
+ sync_local_dev_names(cmd); /* Flush ops and reset dm cookie */
+
+ if ((pid = fork()) == -1) {
+ log_error("fork failed: %s", strerror(errno));
+ return -1;
+ }
+
+ /* Parent */
+ if (pid > 0)
+ return 0;
+
+ /* Child */
+ if (setsid() == -1)
+ log_error("Background process failed to setsid: %s",
+ strerror(errno));
+
+ /* For poll debugging it's best to disable for compilation */
+#if 1
+ if ((null_fd = open(devnull, O_RDWR)) == -1) {
+ log_sys_error("open", devnull);
+ _exit(ECMD_FAILED);
+ }
+
+ if ((dup2(null_fd, STDIN_FILENO) < 0) || /* reopen stdin */
+ (dup2(null_fd, STDOUT_FILENO) < 0) || /* reopen stdout */
+ (dup2(null_fd, STDERR_FILENO) < 0)) { /* reopen stderr */
+ log_sys_error("dup2", "redirect");
+ (void) close(null_fd);
+ _exit(ECMD_FAILED);
+ }
+
+ if (null_fd > STDERR_FILENO)
+ (void) close(null_fd);
+
+ init_verbose(VERBOSE_BASE_LEVEL);
+#endif
+ strncpy(*cmd->argv, "(lvm2)", strlen(*cmd->argv));
+
+ if (!skip_lvm) {
+ reset_locking();
+ if (!lvmcache_init())
+ /* FIXME Clean up properly here */
+ _exit(ECMD_FAILED);
+ }
+ dev_close_all();
+
+ return 1;
+}
+
/*
* Strip dev_dir if present
*/
diff --git a/tools/toollib.h b/tools/toollib.h
index cfcb934..cd9ca49 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -18,6 +18,8 @@
#include "metadata-exported.h"
+int become_daemon(struct cmd_context *cmd, int skip_lvm);
+
int autobackup_set(void);
int autobackup_init(const char *backup_dir, int keep_days, int keep_number,
int autobackup);
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index 2d6720e..6162e26 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -34,6 +34,6 @@ KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", ENV{DM_ACTIVATION}!="1", GOTO="lvm_end"
LABEL="lvm_scan"
-RUN+="(LVM_EXEC)/lvm pvscan --cache --activate ay --major $major --minor $minor"
+RUN+="(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major $major --minor $minor"
LABEL="lvm_end"
9 years, 6 months
master - test: Skip tests involving mirror recovery on known bad kernels.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea1e8166d57c40...
Commit: ea1e8166d57c40a5406b68864e19056df6d2f103
Parent: 6a5838a69ccd0b6eb2f6c69ec9a12de37c7ba73c
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Sep 3 15:49:14 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Sep 3 16:24:32 2013 +0200
test: Skip tests involving mirror recovery on known bad kernels.
---
test/lib/aux.sh | 4 ++++
test/shell/lvconvert-repair-dmeventd.sh | 1 +
test/shell/lvconvert-repair-transient-dmeventd.sh | 1 +
test/shell/lvconvert-repair-transient.sh | 1 +
4 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index c9bb1fb..bca709a 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -604,6 +604,10 @@ api() {
"$abs_top_builddir/test/api/wrapper" "$@" && rm -f debug.log
}
+skip_if_mirror_recovery_broken() {
+ test `uname -r` = 3.3.4-5.fc17.i686 && skip
+}
+
udev_wait() {
pgrep udev >/dev/null || return 0
which udevadm >/dev/null || return 0
diff --git a/test/shell/lvconvert-repair-dmeventd.sh b/test/shell/lvconvert-repair-dmeventd.sh
index b3ccca5..55eee37 100644
--- a/test/shell/lvconvert-repair-dmeventd.sh
+++ b/test/shell/lvconvert-repair-dmeventd.sh
@@ -12,6 +12,7 @@
. lib/test
which mkfs.ext2 || skip
+aux skip_if_mirror_recovery_broken
aux prepare_vg 5
aux prepare_dmeventd
diff --git a/test/shell/lvconvert-repair-transient-dmeventd.sh b/test/shell/lvconvert-repair-transient-dmeventd.sh
index 51c95e1..699195a 100644
--- a/test/shell/lvconvert-repair-transient-dmeventd.sh
+++ b/test/shell/lvconvert-repair-transient-dmeventd.sh
@@ -11,6 +11,7 @@
. lib/test
+aux skip_if_mirror_recovery_broken
aux prepare_vg 5
aux prepare_dmeventd
diff --git a/test/shell/lvconvert-repair-transient.sh b/test/shell/lvconvert-repair-transient.sh
index 93eb803..28b06c6 100644
--- a/test/shell/lvconvert-repair-transient.sh
+++ b/test/shell/lvconvert-repair-transient.sh
@@ -11,6 +11,7 @@
. lib/test
+aux skip_if_mirror_recovery_broken
aux prepare_vg 5
lvcreate -aey --type mirror -m 3 --ignoremonitoring -L 1 -n 4way $vg
9 years, 6 months
master - pvscan: show -aay with --cache for help
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6a5838a69ccd0b...
Commit: 6a5838a69ccd0b6eb2f6c69ec9a12de37c7ba73c
Parent: 44c1a02c1805ec4487af1bc3057fcd8e40f8a375
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Sep 3 09:51:30 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Sep 3 09:51:30 2013 +0200
pvscan: show -aay with --cache for help
---
tools/commands.h | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 841a6b6..f9f81c5 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -724,8 +724,7 @@ xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY,
"pvscan " "\n"
- "\t[-a|--activate ay]\n"
- "\t[--cache [ DevicePath | --major major --minor minor]...]\n"
+ "\t[--cache [-a|--activate ay] [ DevicePath | --major major --minor minor]...]\n"
"\t[-d|--debug] " "\n"
"\t{-e|--exported | -n|--novolumegroup} " "\n"
"\t[-h|-?|--help]" "\n"
9 years, 6 months
master - revert: commit 82d83a01ce2cac77fec2e9b763061fbfb5f01ce8
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=44c1a02c1805ec...
Commit: 44c1a02c1805ec4487af1bc3057fcd8e40f8a375
Parent: 039585bb0d0cccb4c30c1f3fafe007e24ad101b6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Sep 2 13:46:49 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Sep 2 13:53:27 2013 +0200
revert: commit 82d83a01ce2cac77fec2e9b763061fbfb5f01ce8
The commit 82d83a01ce2cac77fec2e9b763061fbfb5f01ce8
"autoactivation: refresh existing VG before autoactivation"
causes problems (dangling udev_sync cookies, slow processing
of the pvscan --cache --major --minor call from udev rules)
when the autoactivation handler is run in parallel on
several PVs that belong to the same VG. Revert this patch
until the exact source of the problem is found and then
properly fixed and handled.
---
WHATS_NEW | 1 -
tools/pvscan.c | 20 +++++++-------------
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c56be6d..f1a9933 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -14,7 +14,6 @@ Version 2.02.101 -
Prevent cluster mirror logs from being corrupted by redundant checkpoints.
Fix ignored lvmetad update on loop device configuration (2.02.99).
Use LVM_PATH instead of hardcoded value in lvm2 activation systemd generator.
- Refresh existing VG before autoactivation (event retrigger/device reappeared).
Fix vgck to notice on-disk corruption even if lvmetad is used.
Move mpath device filter before partitioned filter (which opens devices).
Split partitioned filter out of lvm_type filter.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3f16b05..96bbf6b 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -98,7 +98,6 @@ static int _auto_activation_handler(struct cmd_context *cmd,
struct volume_group *vg;
int consistent = 0;
struct id vgid_raw;
- int r = 0;
/* TODO: add support for partial and clustered VGs */
if (partial)
@@ -107,29 +106,24 @@ static int _auto_activation_handler(struct cmd_context *cmd,
if (!id_read_format(&vgid_raw, vgid))
return_0;
- /* NB. This is safe because we know lvmetad is running and we won't hit disk. */
+ /* NB. This is safe because we know lvmetad is running and we won't hit
+ * disk. */
if (!(vg = vg_read_internal(cmd, NULL, (const char *) &vgid_raw, 0, &consistent)))
return 1;
if (vg_is_clustered(vg)) {
- r = 1; goto out;
- }
-
- if (!vg_refresh_visible(vg->cmd, vg)) {
- log_error("%s: refresh before autoactivation failed.", vg->name);
- goto out;
+ release_vg(vg);
+ return 1;
}
if (!vgchange_activate(vg->cmd, vg, activate)) {
log_error("%s: autoactivation failed.", vg->name);
- goto out;
+ release_vg(vg);
+ return 0;
}
- r = 1;
-
-out:
release_vg(vg);
- return r;
+ return 1;
}
static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
9 years, 6 months
master - tests: test pvmove behavior after restart
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=039585bb0d0ccc...
Commit: 039585bb0d0cccb4c30c1f3fafe007e24ad101b6
Parent: 7cc36a93f6b4a9648f430e32973ea882e3c0e7c7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 30 14:53:57 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Aug 31 21:40:51 2013 +0200
tests: test pvmove behavior after restart
Simulate crash of the system and restarted pvmove after next VG
activation.
Test is catching regression introduced in 2.02.99 for partial tree
creation changes.
---
test/shell/pvmove-restart.sh | 52 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
new file mode 100644
index 0000000..c8da45e
--- /dev/null
+++ b/test/shell/pvmove-restart.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Check pvmove behavior when it's progress and machine is rebooted
+
+. lib/test
+
+aux prepare_pvs 3 60
+
+vgcreate -s 128k $vg "$dev1" "$dev2" "$dev3"
+
+# Create multisegment LV
+lvcreate -an -Zn -l5 -n $lv1 $vg "$dev1"
+lvextend -l+10 $vg/$lv1 "$dev2"
+lvextend -l+5 $vg/$lv1 "$dev1"
+lvextend -l+10 $vg/$lv1 "$dev2"
+
+# Slowdown writes
+aux delay_dev "$dev3" 0 100
+
+lvs -o+devices $vg
+
+pvmove -i0 -n $vg/$lv1 "$dev1" "$dev3" &
+PVMOVE=$!
+# Let's wait a bit till pvmove starts and kill it
+sleep 1
+kill -9 $PVMOVE
+
+# Simulate reboot - forcibly remove related devices
+dmsetup remove $vg-$lv1
+dmsetup remove $vg-pvmove0
+
+# Only PVs should be left in table...
+dmsetup table
+
+# Restart pvmove
+vgchange -ay $vg
+
+pvmove --abort
+
+# Restore delayed device back
+aux delay_dev "$dev3"
+
+lvs -a -o+devices $vg
9 years, 6 months
master - tests: add delay_dev
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7cc36a93f6b4a9...
Commit: 7cc36a93f6b4a9648f430e32973ea882e3c0e7c7
Parent: 350cf7968c77d090b49fc41761221da930d60538
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 30 14:50:58 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Aug 31 21:40:51 2013 +0200
tests: add delay_dev
Function to create slower responsive device.
Useful for testing things which needs to happen something during on
going operation - with 'delayed' device - much smaller sizes of devices
are needed and its much more deterministic (though still not optimal)
---
test/lib/aux.sh | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 36de6e5..c9bb1fb 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -342,6 +342,35 @@ prepare_devs() {
echo "ok"
}
+# Replace linear PV device with its 'delayed' version
+# Could be used to more deterministicaly hit some problems.
+# Parameters: {device path} [read delay ms] [write delay ms]
+# Original device is restored when both delay params are 0 (or missing).
+# i.e. delay_dev "$dev1" 0 200
+delay_dev() {
+ target_at_least dm-delay 1 2 0 || skip
+ local name=$(echo "$1" | sed -e 's,.*/,,')
+ local read_ms=${2:-0}
+ local write_ms=${3:-0}
+ local pos
+ local size
+ local type
+ local pvdev
+ local offset
+
+ read pos size type pvdev offset < "$name.table"
+
+ init_udev_transaction
+ if test $read_ms -ne 0 -o $write_ms -ne 0 ; then
+ echo "0 $size delay $pvdev $offset $read_ms $pvdev $offset $write_ms" | \
+ dmsetup load "$name"
+ else
+ dmsetup load "$name" "$name.table"
+ fi
+ dmsetup resume "$name"
+ finish_udev_transaction
+}
+
disable_dev() {
local dev
9 years, 6 months
master - libdm: new name can't be empty
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=350cf7968c77d0...
Commit: 350cf7968c77d090b49fc41761221da930d60538
Parent: eee3aeeb612c65c0851bf8080e0ef381587837ab
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 30 14:46:34 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Aug 31 21:40:28 2013 +0200
libdm: new name can't be empty
Do not allow passing '' names to kernel.
This test was missing also in kernel, so it has allowed
to create device with '' name. This then confused dmsetup tool,
since such name is unexpected and unsupported. To remove
such name from table, user has to use -j -m to specify which device
should be removed.
This patch fixes the posibility to run this operation:
dmsetup rename existingdev ''
after this operation commands like 'dmsetup table' are failing.
This patch prohibits to use such name.
---
WHATS_NEW_DM | 1 +
libdm/libdm-common.c | 5 +++++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3995187..f5d7dc2 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.80 -
==================================
+ Do not allow passing empty new name for dmsetup rename.
Display any output returned by 'dmsetup message'.
Add dm_task_get_message_response to libdevmapper.
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 9043352..c0669cb 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -698,6 +698,11 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname)
return 0;
}
+ if (!*newname) {
+ log_error("Non empty new name is required.");
+ return 0;
+ }
+
if (!check_multiple_mangled_string_allowed(newname, "new name", mangling_mode))
return_0;
9 years, 6 months