mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
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@$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!
This commit is contained in:
parent
9f406ce252
commit
546db1c4be
@ -1,5 +1,7 @@
|
|||||||
Version 2.02.104
|
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.
|
Fix lvconvert swap of poolmetadata volume for active thin pool.
|
||||||
Check for open count with a timeout before removal/deactivation of an LV.
|
Check for open count with a timeout before removal/deactivation of an LV.
|
||||||
Report RAID images split with tracking as out-of-sync ("I").
|
Report RAID images split with tracking as out-of-sync ("I").
|
||||||
|
24
configure
vendored
24
configure
vendored
@ -613,6 +613,7 @@ DMEVENTD_PIDFILE
|
|||||||
WRITE_INSTALL
|
WRITE_INSTALL
|
||||||
UDEV_HAS_BUILTIN_BLKID
|
UDEV_HAS_BUILTIN_BLKID
|
||||||
UDEV_RULE_EXEC_DETECTION
|
UDEV_RULE_EXEC_DETECTION
|
||||||
|
UDEV_SYSTEMD_BACKGROUND_JOBS
|
||||||
UDEV_SYNC
|
UDEV_SYNC
|
||||||
UDEV_RULES
|
UDEV_RULES
|
||||||
UDEV_PC
|
UDEV_PC
|
||||||
@ -849,6 +850,7 @@ enable_valgrind_pool
|
|||||||
enable_devmapper
|
enable_devmapper
|
||||||
enable_lvmetad
|
enable_lvmetad
|
||||||
with_lvmetad_pidfile
|
with_lvmetad_pidfile
|
||||||
|
enable_udev_systemd_background_jobs
|
||||||
enable_udev_sync
|
enable_udev_sync
|
||||||
enable_udev_rules
|
enable_udev_rules
|
||||||
enable_udev_rule_exec_detection
|
enable_udev_rule_exec_detection
|
||||||
@ -1552,6 +1554,9 @@ Optional Features:
|
|||||||
--enable-valgrind-pool enable valgrind awareness of pools
|
--enable-valgrind-pool enable valgrind awareness of pools
|
||||||
--disable-devmapper disable LVM2 device-mapper interaction
|
--disable-devmapper disable LVM2 device-mapper interaction
|
||||||
--enable-lvmetad enable the LVM Metadata Daemon
|
--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_sync enable synchronisation with udev processing
|
||||||
--enable-udev_rules install rule files needed for udev synchronisation
|
--enable-udev_rules install rule files needed for udev synchronisation
|
||||||
--enable-udev-rule-exec-detection
|
--enable-udev-rule-exec-detection
|
||||||
@ -9089,6 +9094,19 @@ _ACEOF
|
|||||||
|
|
||||||
fi
|
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 "$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; }
|
$as_echo_n "checking whether to enable synchronisation with udev processing... " >&6; }
|
||||||
@ -9668,7 +9686,6 @@ if [ \( "x$LVM1" = xshared -o "x$POOL" = xshared -o "x$CLUSTER" = xshared \
|
|||||||
fi
|
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; }
|
$as_echo_n "checking for pthread_mutex_lock in -lpthread... " >&6; }
|
||||||
if test "${ac_cv_lib_pthread_pthread_mutex_lock+set}" = set; then :
|
if test "${ac_cv_lib_pthread_pthread_mutex_lock+set}" = set; then :
|
||||||
@ -9711,7 +9728,6 @@ else
|
|||||||
hard_bailout
|
hard_bailout
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable selinux support" >&5
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable selinux support" >&5
|
||||||
@ -10931,10 +10947,11 @@ 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
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# 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_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.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_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/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.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" ;;
|
"scripts/dm_event_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.service" ;;
|
||||||
|
11
configure.in
11
configure.in
@ -939,6 +939,15 @@ if test x$BUILD_LVMETAD = xyes; then
|
|||||||
[Path to lvmetad pidfile.])
|
[Path to lvmetad pidfile.])
|
||||||
fi
|
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
|
dnl -- Enable udev synchronisation
|
||||||
AC_MSG_CHECKING(whether to enable synchronisation with udev processing)
|
AC_MSG_CHECKING(whether to enable synchronisation with udev processing)
|
||||||
@ -1626,6 +1635,7 @@ AC_SUBST(UDEV_LIBS)
|
|||||||
AC_SUBST(UDEV_PC)
|
AC_SUBST(UDEV_PC)
|
||||||
AC_SUBST(UDEV_RULES)
|
AC_SUBST(UDEV_RULES)
|
||||||
AC_SUBST(UDEV_SYNC)
|
AC_SUBST(UDEV_SYNC)
|
||||||
|
AC_SUBST(UDEV_SYSTEMD_BACKGROUND_JOBS)
|
||||||
AC_SUBST(UDEV_RULE_EXEC_DETECTION)
|
AC_SUBST(UDEV_RULE_EXEC_DETECTION)
|
||||||
AC_SUBST(UDEV_HAS_BUILTIN_BLKID)
|
AC_SUBST(UDEV_HAS_BUILTIN_BLKID)
|
||||||
AC_SUBST(CUNIT_LIBS)
|
AC_SUBST(CUNIT_LIBS)
|
||||||
@ -1700,6 +1710,7 @@ scripts/cmirrord_init_red_hat
|
|||||||
scripts/lvm2_lvmetad_init_red_hat
|
scripts/lvm2_lvmetad_init_red_hat
|
||||||
scripts/lvm2_lvmetad_systemd_red_hat.socket
|
scripts/lvm2_lvmetad_systemd_red_hat.socket
|
||||||
scripts/lvm2_lvmetad_systemd_red_hat.service
|
scripts/lvm2_lvmetad_systemd_red_hat.service
|
||||||
|
scripts/lvm2_pvscan_systemd_red_hat@.service
|
||||||
scripts/lvm2_monitoring_init_red_hat
|
scripts/lvm2_monitoring_init_red_hat
|
||||||
scripts/dm_event_systemd_red_hat.socket
|
scripts/dm_event_systemd_red_hat.socket
|
||||||
scripts/dm_event_systemd_red_hat.service
|
scripts/dm_event_systemd_red_hat.service
|
||||||
|
@ -107,6 +107,7 @@ endif
|
|||||||
ifeq ("@BUILD_LVMETAD@", "yes")
|
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.socket $(systemd_unit_dir)/lvm2-lvmetad.socket
|
||||||
$(INSTALL_DATA) lvm2_lvmetad_systemd_red_hat.service $(systemd_unit_dir)/lvm2-lvmetad.service
|
$(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
|
endif
|
||||||
|
|
||||||
install_tmpfiles_configuration:
|
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 \
|
dm_event_systemd_red_hat.socket dm_event_systemd_red_hat.service \
|
||||||
lvm2_monitoring_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.socket lvm2_lvmetad_systemd_red_hat.service \
|
||||||
|
lvm2_lvmetad_systemd_red_hat@.service \
|
||||||
lvm2_tmpfiles_red_hat.conf blk_availability_init_red_hat \
|
lvm2_tmpfiles_red_hat.conf blk_availability_init_red_hat \
|
||||||
blk_availability_systemd_red_hat.service \
|
blk_availability_systemd_red_hat.service \
|
||||||
blkdeactivate.sh
|
blkdeactivate.sh
|
||||||
|
11
scripts/lvm2_pvscan_systemd_red_hat@.service.in
Normal file
11
scripts/lvm2_pvscan_systemd_red_hat@.service.in
Normal file
@ -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
|
@ -79,6 +79,6 @@ LABEL="lvm_scan"
|
|||||||
# MD | | X | X* | |
|
# MD | | X | X* | |
|
||||||
# loop | | X | X* | |
|
# loop | | X | X* | |
|
||||||
# other | X | | 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"
|
LABEL="lvm_end"
|
||||||
|
@ -46,8 +46,14 @@ else
|
|||||||
BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
|
BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes")
|
||||||
|
PVSCAN_RULE=ENV{SYSTEMD_WANTS}=\"lvm2-pvscan@\$$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
|
%.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: %.rules
|
||||||
$(INSTALL_DATA) -D $< $(udevdir)/$(<F)
|
$(INSTALL_DATA) -D $< $(udevdir)/$(<F)
|
||||||
|
Loading…
Reference in New Issue
Block a user