master - udev+systemd: refine lvm2-pvscan@.service to better track device existence
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3fee6610286f83...
Commit: 3fee6610286f83737d193c9047e24e8d7c85d1ce
Parent: 0a48137d39c51163ee29608c8c7ccbeecb4a7815
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 22 14:03:53 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 22 14:22:40 2013 +0200
udev+systemd: refine lvm2-pvscan@.service to better track device existence
When using ENV{SYSTEMD_WANTS}=lvm2-pvscan@... to instantiate a service
for lvmetad scan when the new PV appears in the system, the service
is started and executed. However, to track device removal, we need
to bind it (the "BindsTo" systemd directive) to a certain .device
systemd unit.
In default systemd setup, the device is tracked by it's name and
sysfs path (there's normally a sysfs path .device systemd unit for
a device and then the device name .device unit as an alias for it).
Neither of these two is useful for lvmetad update as we need to bind
it to device's <major>:<minor> pair.
The /dev/block/<major>:<minor> is the essential symlink under /dev
that exists for each block device (created by default udev rules
provided by udev directly). So let's use this as an alias for
the device's .device unit as well by means of "ENV{SYSTEMD_ALIAS}"
declaration within udev rules which systemd understands (this will
create a new alias "dev-block-<major>:<minor>.device".
Then we can easily bind the "dev-block-<major>:<minor>" device
systemd unit with instantiated lvm2-pvscan@<major>:<minor>.service.
So once the device is removed from the systemd, the
lvm-pvscan@<major>:<minor>.service executes it's ExecStop action
(which in turn notifies lvmetad about the device being gone).
This completes the udev-systemd-lvmetad interaction then.
---
WHATS_NEW | 1 +
scripts/lvm2_pvscan_systemd_red_hat@.service.in | 11 +++++++----
udev/Makefile.in | 4 +++-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index df81923..2d7792b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Add dev-block-<major>:<minor>.device systemd alias for complete PV tracking.
Use major:minor as short form of --major and --minor arg for pvscan --cache.
Remove 2>/dev/null from three lvm commands executed by vgimportclone.
Add configure --enable-udev-systemd-background-jobs.
diff --git a/scripts/lvm2_pvscan_systemd_red_hat@.service.in b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
index 9d91b5e..07ea5ca 100644
--- a/scripts/lvm2_pvscan_systemd_red_hat@.service.in
+++ b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
@@ -1,11 +1,14 @@
[Unit]
-Description=LVM2 PV scan on %I
+Description=LVM2 PV scan on device %i
Documentation=man:pvscan(8)
DefaultDependencies=no
-After=lvm2-lvmetad.socket %i.device
+BindsTo=dev-block-%i.device
+After=lvm2-lvmetad.socket
Before=shutdown.target
Conflicts=shutdown.target
[Service]
-Type=simple
-ExecStart=@sbindir@/pvscan --cache --activate ay %I
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@sbindir@/pvscan --cache --activate ay /dev/block/%i
+ExecStop=/usr/sbin/pvscan --cache %i
diff --git a/udev/Makefile.in b/udev/Makefile.in
index fdf43df..8f0dc8a 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -47,7 +47,9 @@ BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
endif
ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes")
-PVSCAN_RULE=ENV{SYSTEMD_WANTS}=\"lvm2-pvscan(a)\$$devnode.service\"
+PVSCAN_RULE="ENV{SYSTEMD_ALIAS}=\"/dev/block/$$major:$$minor\" \
+ ENV{ID_MODEL}=\"LVM PV $$env{ID_FS_UUID_ENC} on /dev/$$name\" \
+ ENV{SYSTEMD_WANTS}=\"lvm2-pvscan(a)\$$devnode.service\""
else
PVSCAN_RULE=RUN\+\=\"$(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major \$$major --minor \$$minor\", ENV{LVM_SCANNED}=\"1\"
endif
10 years, 6 months
master - pvscan: use major:minor as short form of --major and --minor arg for pvscan --cache
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0a48137d39c511...
Commit: 0a48137d39c51163ee29608c8c7ccbeecb4a7815
Parent: 65456a4a29d8f25ab75af2145b8a6b2a9ff391e5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 22 13:52:18 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 22 13:52:18 2013 +0200
pvscan: use major:minor as short form of --major and --minor arg for pvscan --cache
Before, pvscan recognized either:
pvscan --cache --major <major> --minor <minor>
or
pvscan --cache <DevicePath>
When the device is gone and we need to notify lvmetad about device
removal, only --major/--minor works as we can't translate DevicePath
into major/minor pair anymore. The device does not exist in the system
and we don't keep DevicePath index in lvmetad cache to make the
translation internally into original major/minor pair. It would be
useless to keep this index just for this one exact case.
There's nothing bad about using "--major <major> --minor <minor>",
but it makes our life a bit harder when trying to make an
interconnection with systemd units, mainly with instantiated services
where only one and only one arg can be passed (which is encoded in the
service name).
This patch tries to make this easier by adding support for recognizing
the "<major>:<minor>" as a shortcut for the longer form
"--major <major> --minor <minor>". The rule here is simple: if the argument
starts with "/", it's a DevicePath, otherwise it's a <major>:<minor> pair.
---
WHATS_NEW | 1 +
man/pvscan.8.in | 4 ++-
tools/pvscan.c | 61 +++++++++++++++++++++++++++++++++++++++++-------------
3 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 61aeb72..df81923 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Use major:minor as short form of --major and --minor arg for pvscan --cache.
Remove 2>/dev/null from three lvm commands executed by vgimportclone.
Add configure --enable-udev-systemd-background-jobs.
Add lvm2-pvscan@.service to run pvscan as a service for lvmetad/autoactivation.
diff --git a/man/pvscan.8.in b/man/pvscan.8.in
index 211c82b..37ecaaf 100644
--- a/man/pvscan.8.in
+++ b/man/pvscan.8.in
@@ -25,7 +25,9 @@ pvscan \- scan all disks for physical volumes
.B \-\-minor
.I minor
|
-.IR DevicePath ]...
+.IR DevicePath
+|
+.IR major:minor ]...
.SH DESCRIPTION
pvscan scans all supported LVM block devices in the system for
physical volumes.
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3f16b05..b6a07bd 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -132,6 +132,27 @@ out:
return r;
}
+static int _clear_dev_from_lvmetad_cache(dev_t devno, int32_t major, int32_t minor,
+ activation_handler handler)
+{
+ char *buf;
+
+ if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
+ stack;
+ if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
+ if (buf)
+ dm_free(buf);
+ return 0;
+ }
+
+ log_print_unless_silent("Device %s not found. "
+ "Cleared from lvmetad cache.", buf ? : "");
+ if (buf)
+ dm_free(buf);
+
+ return 1;
+}
+
static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
{
int ret = ECMD_PROCESSED;
@@ -142,7 +163,6 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
int devno_args = 0;
struct arg_value_group_list *current_group;
dev_t devno;
- char *buf;
activation_handler handler = NULL;
/*
@@ -193,11 +213,30 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
/* Process any command line PVs first. */
while (argc--) {
pv_name = *argv++;
- dev = dev_cache_get(pv_name, cmd->lvmetad_filter);
- if (!dev) {
- log_error("Physical Volume %s not found.", pv_name);
- ret = ECMD_FAILED;
- continue;
+ if (pv_name[0] == '/') {
+ /* device path */
+ if (!(dev = dev_cache_get(pv_name, cmd->lvmetad_filter))) {
+ log_error("Physical Volume %s not found.", pv_name);
+ ret = ECMD_FAILED;
+ continue;
+ }
+ }
+ else {
+ /* device major:minor */
+ if (sscanf(pv_name, "%d:%d", &major, &minor) != 2) {
+ log_error("Failed to parse major:minor from %s", pv_name);
+ ret = ECMD_FAILED;
+ continue;
+ }
+ devno = MKDEV((dev_t)major, minor);
+ if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
+ if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) {
+ stack;
+ ret = ECMD_FAILED;
+ break;
+ }
+ continue;
+ }
}
if (sigint_caught()) {
ret = ECMD_FAILED;
@@ -225,19 +264,11 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
devno = MKDEV((dev_t)major, minor);
if (!(dev = dev_cache_get_by_devt(devno, cmd->lvmetad_filter))) {
- if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
+ if (!(_clear_dev_from_lvmetad_cache(devno, major, minor, handler))) {
stack;
- if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
ret = ECMD_FAILED;
- if (buf)
- dm_free(buf);
break;
}
-
- log_print_unless_silent("Device %s not found. "
- "Cleared from lvmetad cache.", buf ? : "");
- if (buf)
- dm_free(buf);
continue;
}
if (sigint_caught()) {
10 years, 6 months
master - vgimportclone: remove 2>/dev/null from three lvm commands
by Mike Snitzer
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=65456a4a29d8f2...
Commit: 65456a4a29d8f25ab75af2145b8a6b2a9ff391e5
Parent: 7763607f3617188906dae9e9ae218e9099f5e6e9
Author: Mike Snitzer <snitzer(a)redhat.com>
AuthorDate: Mon Oct 21 18:04:14 2013 -0400
Committer: Mike Snitzer <snitzer(a)redhat.com>
CommitterDate: Mon Oct 21 18:04:14 2013 -0400
vgimportclone: remove 2>/dev/null from three lvm commands
There is no point eating stderr for these commands. In fact the
redirect causes confusion and hurts dubugging.
Also reword an error message if the pvs command fails so as not be
certain that a device is not a PV. Coupled with removing the stderr
redirect this will improve the user experience in the face of errors.
---
WHATS_NEW | 1 +
scripts/vgimportclone.sh | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 96e6775..61aeb72 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Remove 2>/dev/null from three lvm commands executed by vgimportclone.
Add configure --enable-udev-systemd-background-jobs.
Add lvm2-pvscan@.service to run pvscan as a service for lvmetad/autoactivation.
Fix lvconvert swap of poolmetadata volume for active thin pool.
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index d6ad75d..7087557 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -204,8 +204,8 @@ for ARG
do
if [ -b "$ARG" ]
then
- PVS_OUT=`"${LVM}" pvs ${LVM_OPTS} --noheadings -o vg_name "$ARG" 2>/dev/null`
- checkvalue $? "$ARG is not a PV."
+ PVS_OUT=`"${LVM}" pvs ${LVM_OPTS} --noheadings -o vg_name "$ARG"`
+ checkvalue $? "$ARG could not be verified to be a PV without errors."
PV_VGNAME=$(echo $PVS_OUT | $GREP -v '[[:space:]]+$')
[ -z "$PV_VGNAME" ] && die 3 "$ARG is not in a VG."
@@ -227,7 +227,7 @@ fi
### Get the existing state so we can use it later
#####################################################################
-OLDVGS=`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings 2>/dev/null`
+OLDVGS=`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings`
checkvalue $? "Current VG names could not be collected without errors"
#####################################################################
@@ -280,7 +280,7 @@ export LVM_SYSTEM_DIR=${TMP_LVM_SYSTEM_DIR}
### Rename the VG(s) and change the VG and PV UUIDs.
#####################################################################
-PVINFO=`"${LVM}" pvs ${LVM_OPTS} -o pv_name,vg_name,vg_attr --noheadings --separator : 2>/dev/null`
+PVINFO=`"${LVM}" pvs ${LVM_OPTS} -o pv_name,vg_name,vg_attr --noheadings --separator :`
checkvalue $? "PV info could not be collected without errors"
# output VG info so each line looks like: name:exported?:disk1,disk2,...
10 years, 6 months
master - TEST: Test was trying to kill 2 devices in RAID5 instead of RAID6
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7763607f361718...
Commit: 7763607f3617188906dae9e9ae218e9099f5e6e9
Parent: 546db1c4be55d47d41082a345e15a35055223154
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Oct 18 09:33:37 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Oct 18 09:33:37 2013 -0500
TEST: Test was trying to kill 2 devices in RAID5 instead of RAID6
Segment type being used for test should have been 'raid6'.
---
test/shell/lvconvert-repair-raid.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/lvconvert-repair-raid.sh b/test/shell/lvconvert-repair-raid.sh
index 84e247d..71c84c1 100644
--- a/test/shell/lvconvert-repair-raid.sh
+++ b/test/shell/lvconvert-repair-raid.sh
@@ -29,7 +29,7 @@ vgextend $vg "$dev3"
lvremove -ff $vg
# RAID6 double replace
-lvcreate --type raid5 -i 3 -l 2 -n $lv1 $vg \
+lvcreate --type raid6 -i 3 -l 2 -n $lv1 $vg \
"$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
aux wait_for_sync $vg $lv1
aux disable_dev "$dev4" "$dev5"
10 years, 6 months
master - udev+systemd: make pvscan --cache -aay run as systemd background job from udev
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=546db1c4be55d4...
Commit: 546db1c4be55d47d41082a345e15a35055223154
Parent: 9f406ce252c40a29c06dba4bebe92b570207df93
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 18 11:07:21 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Oct 18 11:38:49 2013 +0200
udev+systemd: make pvscan --cache -aay run as systemd background job from udev
The new lvm2-pvscan@.service is responsible for on-demand execution
of "pvscan --cache --activate ay" which causes lvmetad to be
updated and LVM activation done if the VG is complete.
Also, use udev-systemd mechanism to instantiate the job as the
lvm2-pvscan(a)$devnode.service on each newly appeared PV in the system.
This prevents the background job to be killed (that would happen
if it was directly forked from udev rule - this behaviour is seen
in recent versions of udev with the help of systemd that can track
detached processes - the detached process would still be in the same
cgroup).
To enable this official udev-systemd protocol for instantiating
background jobs, use new --enable-udev-systemd-background-jobs
configure switch (it's disabled by default). This option is highly
recommended wherever systemd is used!
---
WHATS_NEW | 2 +
configure | 26 +++++++++++++++++++---
configure.in | 11 +++++++++
scripts/Makefile.in | 2 +
scripts/lvm2_pvscan_systemd_red_hat@.service.in | 11 +++++++++
udev/69-dm-lvm-metad.rules.in | 2 +-
udev/Makefile.in | 8 ++++++-
7 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 79a960c..96e6775 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.104
===================================
+ Add configure --enable-udev-systemd-background-jobs.
+ Add lvm2-pvscan@.service to run pvscan as a service for lvmetad/autoactivation.
Fix lvconvert swap of poolmetadata volume for active thin pool.
Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
diff --git a/configure b/configure
index 20a706a..002a7d2 100755
--- a/configure
+++ b/configure
@@ -613,6 +613,7 @@ DMEVENTD_PIDFILE
WRITE_INSTALL
UDEV_HAS_BUILTIN_BLKID
UDEV_RULE_EXEC_DETECTION
+UDEV_SYSTEMD_BACKGROUND_JOBS
UDEV_SYNC
UDEV_RULES
UDEV_PC
@@ -849,6 +850,7 @@ enable_valgrind_pool
enable_devmapper
enable_lvmetad
with_lvmetad_pidfile
+enable_udev_systemd_background_jobs
enable_udev_sync
enable_udev_rules
enable_udev_rule_exec_detection
@@ -1552,6 +1554,9 @@ Optional Features:
--enable-valgrind-pool enable valgrind awareness of pools
--disable-devmapper disable LVM2 device-mapper interaction
--enable-lvmetad enable the LVM Metadata Daemon
+ --enable-udev-systemd-background-jobs
+ enable udev-systemd protocol to instantiate a
+ service for background job
--enable-udev_sync enable synchronisation with udev processing
--enable-udev_rules install rule files needed for udev synchronisation
--enable-udev-rule-exec-detection
@@ -9090,6 +9095,19 @@ _ACEOF
fi
################################################################################
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use udev-systemd protocol for jobs in background" >&5
+$as_echo_n "checking whether to use udev-systemd protocol for jobs in background... " >&6; }
+# Check whether --enable-udev-systemd-background-jobs was given.
+if test "${enable_udev_systemd_background_jobs+set}" = set; then :
+ enableval=$enable_udev_systemd_background_jobs; UDEV_SYSTEMD_BACKGROUND_JOBS=$enableval
+else
+ UDEV_SYSTEMD_BACKGROUND_JOBS=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UDEV_SYSTEMD_BACKGROUND_JOBS" >&5
+$as_echo "$UDEV_SYSTEMD_BACKGROUND_JOBS" >&6; }
+
+################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable synchronisation with udev processing" >&5
$as_echo_n "checking whether to enable synchronisation with udev processing... " >&6; }
# Check whether --enable-udev_sync was given.
@@ -9668,8 +9686,7 @@ if [ \( "x$LVM1" = xshared -o "x$POOL" = xshared -o "x$CLUSTER" = xshared \
fi
################################################################################
-if [ "$DMEVENTD" = yes -o "$CLVMD" != none ] ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_lock in -lpthread" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_mutex_lock in -lpthread" >&5
$as_echo_n "checking for pthread_mutex_lock in -lpthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_mutex_lock+set}" = set; then :
$as_echo_n "(cached) " >&6
@@ -9711,7 +9728,6 @@ else
hard_bailout
fi
-fi
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable selinux support" >&5
@@ -10933,8 +10949,9 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
+
################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile conf/Makefile conf/example.conf conf/default.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_
init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile conf/Makefile conf/example.conf conf/default.profile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile python/Makefile python/setup.py scripts/blkdeactivate.sh scripts/blk_availability_
init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -11671,6 +11688,7 @@ do
"scripts/lvm2_lvmetad_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_init_red_hat" ;;
"scripts/lvm2_lvmetad_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.socket" ;;
"scripts/lvm2_lvmetad_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.service" ;;
+ "scripts/lvm2_pvscan_systemd_red_hat@.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_pvscan_systemd_red_hat@.service" ;;
"scripts/lvm2_monitoring_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_init_red_hat" ;;
"scripts/dm_event_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.socket" ;;
"scripts/dm_event_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.service" ;;
diff --git a/configure.in b/configure.in
index 3bd2439..07b0afc 100644
--- a/configure.in
+++ b/configure.in
@@ -940,6 +940,15 @@ if test x$BUILD_LVMETAD = xyes; then
fi
################################################################################
+dnl -- Enable udev-systemd protocol to instantiate a service for background jobs
+AC_MSG_CHECKING(whether to use udev-systemd protocol for jobs in background)
+AC_ARG_ENABLE(udev-systemd-background-jobs,
+ AC_HELP_STRING([--enable-udev-systemd-background-jobs],
+ [enable udev-systemd protocol to instantiate a service for background job]),
+ UDEV_SYSTEMD_BACKGROUND_JOBS=$enableval, UDEV_SYSTEMD_BACKGROUND_JOBS=no)
+AC_MSG_RESULT($UDEV_SYSTEMD_BACKGROUND_JOBS)
+
+################################################################################
dnl -- Enable udev synchronisation
AC_MSG_CHECKING(whether to enable synchronisation with udev processing)
AC_ARG_ENABLE(udev_sync,
@@ -1626,6 +1635,7 @@ AC_SUBST(UDEV_LIBS)
AC_SUBST(UDEV_PC)
AC_SUBST(UDEV_RULES)
AC_SUBST(UDEV_SYNC)
+AC_SUBST(UDEV_SYSTEMD_BACKGROUND_JOBS)
AC_SUBST(UDEV_RULE_EXEC_DETECTION)
AC_SUBST(UDEV_HAS_BUILTIN_BLKID)
AC_SUBST(CUNIT_LIBS)
@@ -1700,6 +1710,7 @@ scripts/cmirrord_init_red_hat
scripts/lvm2_lvmetad_init_red_hat
scripts/lvm2_lvmetad_systemd_red_hat.socket
scripts/lvm2_lvmetad_systemd_red_hat.service
+scripts/lvm2_pvscan_systemd_red_hat@.service
scripts/lvm2_monitoring_init_red_hat
scripts/dm_event_systemd_red_hat.socket
scripts/dm_event_systemd_red_hat.service
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index a658903..fac7e40 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -107,6 +107,7 @@ endif
ifeq ("@BUILD_LVMETAD@", "yes")
$(INSTALL_DATA) lvm2_lvmetad_systemd_red_hat.socket $(systemd_unit_dir)/lvm2-lvmetad.socket
$(INSTALL_DATA) lvm2_lvmetad_systemd_red_hat.service $(systemd_unit_dir)/lvm2-lvmetad.service
+ $(INSTALL_DATA) lvm2_pvscan_systemd_red_hat@.service $(systemd_unit_dir)/lvm2-pvscan@.service
endif
install_tmpfiles_configuration:
@@ -118,6 +119,7 @@ DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat \
dm_event_systemd_red_hat.socket dm_event_systemd_red_hat.service \
lvm2_monitoring_systemd_red_hat.service \
lvm2_lvmetad_systemd_red_hat.socket lvm2_lvmetad_systemd_red_hat.service \
+ lvm2_lvmetad_systemd_red_hat@.service \
lvm2_tmpfiles_red_hat.conf blk_availability_init_red_hat \
blk_availability_systemd_red_hat.service \
blkdeactivate.sh
diff --git a/scripts/lvm2_pvscan_systemd_red_hat@.service.in b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
new file mode 100644
index 0000000..9d91b5e
--- /dev/null
+++ b/scripts/lvm2_pvscan_systemd_red_hat@.service.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=LVM2 PV scan on %I
+Documentation=man:pvscan(8)
+DefaultDependencies=no
+After=lvm2-lvmetad.socket %i.device
+Before=shutdown.target
+Conflicts=shutdown.target
+
+[Service]
+Type=simple
+ExecStart=@sbindir@/pvscan --cache --activate ay %I
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index 3303f4d..3e303b1 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -79,6 +79,6 @@ LABEL="lvm_scan"
# MD | | X | X* | |
# loop | | X | X* | |
# other | X | | X | | X
-RUN+="(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1"
+(PVSCAN_RULE)
LABEL="lvm_end"
diff --git a/udev/Makefile.in b/udev/Makefile.in
index 5c15bdb..fdf43df 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -46,8 +46,14 @@ else
BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
endif
+ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes")
+PVSCAN_RULE=ENV{SYSTEMD_WANTS}=\"lvm2-pvscan(a)\$$devnode.service\"
+else
+PVSCAN_RULE=RUN\+\=\"$(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major \$$major --minor \$$minor\", ENV{LVM_SCANNED}=\"1\"
+endif
+
%.rules: %.rules.in
- $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@
+ $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(PVSCAN_RULE)+$(PVSCAN_RULE)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@
%_install: %.rules
$(INSTALL_DATA) -D $< $(udevdir)/$(<F)
10 years, 6 months
master - tests: drop settle for old systems
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f406ce252c40a...
Commit: 9f406ce252c40a29c06dba4bebe92b570207df93
Parent: 7f4452a41e55a60678cadda99ae1a383a367a9e5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 17 22:54:12 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 17 22:54:12 2013 +0200
tests: drop settle for old systems
Reverts previously added udevsettle call.
Seems to be unrelated, while udev on old system may take over 10
minutes, to finish it's very slow and CPU intensive work, it doesn't
interact directly with created device, only access /dev/mapper/control
node via dmsetup, so the device is ocasionaly blocked by something else.
---
test/lib/utils.sh | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index c3bd533..0f58b25 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -214,5 +214,3 @@ case "$PATH" in
esac
test -z "$PREFIX" || prepare_test_vars
-
-test ! -e /sbin/udevsettle || if pidof udevd >/dev/null; then /sbin/udevsettle ; fi
10 years, 6 months
master - tests: older losetup allows only single device name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f4452a41e55a6...
Commit: 7f4452a41e55a60678cadda99ae1a383a367a9e5
Parent: d9e44112c53cad296858f5f796add99441a4b2ae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 17 17:52:42 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 17 17:52:42 2013 +0200
tests: older losetup allows only single device name
Stay compatible with only 1 arg for losetup -d
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index d27d263..f51fc0d 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -162,7 +162,7 @@ teardown_devs() {
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
test ${#stray_loops[@]} -eq 0 || {
echo "Removing stray loop devices containing $COMMON_PREFIX: ${stray_loops[@]}"
- losetup -d "${stray_loops[@]}"
+ for i in "${stray_loops[@]}" ; do losetup -d $i ; done
}
}
}
10 years, 6 months
master - tests: fix last commit
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d9e44112c53cad...
Commit: d9e44112c53cad296858f5f796add99441a4b2ae
Parent: 66f4698a93c6cc7d0fb027c5e4209b1de6a880ef
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 17 16:59:30 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 17 16:59:30 2013 +0200
tests: fix last commit
It must not fail here during execution, so always check in a way
that '||' is used for call of settle.
---
test/lib/utils.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 8311c4c..c3bd533 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -215,4 +215,4 @@ esac
test -z "$PREFIX" || prepare_test_vars
-test -e /sbin/udevsettle && pidof udevd >/dev/null && /sbin/udevsettle
+test ! -e /sbin/udevsettle || if pidof udevd >/dev/null; then /sbin/udevsettle ; fi
10 years, 6 months
master - tests: workaround udevd compromising tests
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=66f4698a93c6cc...
Commit: 66f4698a93c6cc7d0fb027c5e4209b1de6a880ef
Parent: 93a07a1b841628bb4c8caaa7f0470fc77f656ff2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 17 16:19:06 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 17 16:19:06 2013 +0200
tests: workaround udevd compromising tests
Patch helps a bit when lvm2 is build with disabled udev_sync support,
but udevd runs in the system - so it randomly influences unrelated tests
even - so before every test wait at least till udevd is settled.
---
test/lib/utils.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index 0f58b25..8311c4c 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -214,3 +214,5 @@ case "$PATH" in
esac
test -z "$PREFIX" || prepare_test_vars
+
+test -e /sbin/udevsettle && pidof udevd >/dev/null && /sbin/udevsettle
10 years, 6 months
master - tests: fix exporting content of make vars
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=93a07a1b841628...
Commit: 93a07a1b841628bb4c8caaa7f0470fc77f656ff2
Parent: f9725503f86593512e9472152ce2642f4b2f414f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Oct 17 10:41:08 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Oct 17 11:57:35 2013 +0200
tests: fix exporting content of make vars
Further tune script, so it works correctly with
usable and unusable thin tools.
---
test/Makefile.in | 7 ++++---
test/shell/lvconvert-repair-thin.sh | 31 +++++++++++++++----------------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 961eb9e..943a4ce 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -25,9 +25,10 @@ abs_top_builddir = "@abs_top_builddir@"
abs_top_srcdir = "@abs_top_srcdir@"
LVM_TEST_RESULTS ?= results
-LVM_TEST_THIN_DUMP_CMD ?= "@THIN_DUMP_CMD@"
-LVM_TEST_THIN_CHECK_CMD ?= "@THIN_CHECK_CMD@"
-LVM_TEST_THIN_REPAIR_CMD ?= "@THIN_REPAIR_CMD@"
+export LVM_TEST_THIN_CHECK_CMD?=@THIN_CHECK_CMD@
+export LVM_TEST_THIN_DUMP_CMD?=@THIN_DUMP_CMD@
+export LVM_TEST_THIN_REPAIR_CMD?=@THIN_REPAIR_CMD@
+
SUBDIRS = api unit
SOURCES = lib/not.c lib/harness.c
diff --git a/test/shell/lvconvert-repair-thin.sh b/test/shell/lvconvert-repair-thin.sh
index 225dcc8..aa301d6 100644
--- a/test/shell/lvconvert-repair-thin.sh
+++ b/test/shell/lvconvert-repair-thin.sh
@@ -14,18 +14,14 @@
. lib/test
-# Set tools from configuration (set by Makefile)
-# Allow user override to take tools from unusual places
-LVM_TEST_THIN_CHECK_CMD=${LVM_TEST_THIN_CHECK_CMD:-thin_check}
-LVM_TEST_THIN_DUMP_CMD=${LVM_TEST_THIN_DUMP_CMD:-thin_dump}
-LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD:-thin_repair}
-
which mkfs.ext2 || skip
-# Maybe check also version of the tools here??
-which $LVM_TEST_THIN_CHECK_CMD || skip
-which $LVM_TEST_THIN_DUMP_CMD || skip
-which $LVM_TEST_THIN_REPAIR_CMD || skip
+# By default use tools from configuration (exported through Makefile)
+# Allow user to override location of binaries to take tools from different laces
+# Maybe check also version of the tools here?
+test -n "$LVM_TEST_THIN_CHECK_CMD" || LVM_TEST_THIN_CHECK_CMD=$(which thin_check) || skip
+test -n "$LVM_TEST_THIN_DUMP_CMD" || LVM_TEST_THIN_DUMP_CMD=$(which thin_dump) || skip
+test -n "$LVM_TEST_THIN_REPAIR_CMD" || LVM_TEST_THIN_REPAIR_CMD=$(which thin_repair) || skip
#
# Main
@@ -76,6 +72,8 @@ should not $LVM_TEST_THIN_DUMP_CMD $DM_DEV_DIR/$vg/repair | tee dump
should $LVM_TEST_THIN_REPAIR_CMD -i $DM_DEV_DIR/$vg/repair -o $DM_DEV_DIR/$vg/fixed
+should $LVM_TEST_THIN_DUMP_CMD --repair $DM_DEV_DIR/$vg/repair | tee repaired_xml
+
should $LVM_TEST_THIN_CHECK_CMD $DM_DEV_DIR/$vg/fixed
# Swap repaired metadata back
@@ -90,13 +88,14 @@ dmsetup table
dmsetup info -c
dmsetup ls --tree
-# Currently in troubles - we can't remove thin volume from broken pool
-lvchange -an $vg/repair
-lvchange -an $vg/fixed
-lvchange -an $vg/pool_tmeta0
-dmsetup remove $vg-pool_tdata
-dmsetup remove $vg-pool_tmeta
+lvchange -an $vg
+
+# FIXME: Currently in deep troubles - we can't remove thin volume from broken pool
+should lvremove -ff $vg
+# let's not block PVs with openned _tdata/_tmeta devices
+dmsetup remove $vg-pool_tdata || true
+dmsetup remove $vg-pool_tmeta || true
dmsetup table
10 years, 6 months