1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-22 01:49:28 +03:00

Compare commits

..

25 Commits

Author SHA1 Message Date
5e48b04561 pvscan: only add device args to dev cache
Optimize the common pvscan --cache command by only adding
the necessary devs to dev-cache.
2021-10-18 16:24:24 -05:00
3e893b9b09 hints: new pvs_online type
Use a new form of hints to reduce device scanning in
vgchange -aay run by the udev rule for event based
autoactivation.

Standard hints allow a command with a named VG arg to scan
only the PVs in the named VG, rather than scanning all
available PVs.  Standard hints are useful with a stable set
of system devices.  When new devices are arriving, as occurs
during system startup, the hints are repeatedly invalidated,
which makes standard hints unhelpful while devices are
regularly appearing.  This is the situation in which
vgchange -aay is used, so standard hints are not generally
helpful for autoactivation.

In the context of system startup, pvscan --cache is keeping
track of available PVs using the pvs_online files, similar
to what the hints file does for a running system.  Given this,
a new hint mode, hints = "pvs_online", is added which derives
an equivalent to standard hints, based on pvs_online files
that are being created by udev-run pvscans.  This hint mode
is useful while devices are appearing, e.g. during system
startup, and vgchange -aay can benefit from it.

pvscan --cache -aay autoactivation already has a similar
optimization (the "quick" activation case) that is based
on the pvs_online file, but it is not implemented as a
form of hints.

This new form of hints is mainly useful in the context of
event based autoactivation, during which standard hints are
not useful.  Once the system is in a steady state after startup
(devices are not regularly appearing), the standard hints are
most useful.  The pvs_online hint method could be used on a
running system, but would be no better than standard hints,
and may be inferior because pvs_online files are not rigidly
updated after system startup.
2021-10-15 16:27:04 -05:00
c06d5fe28e add fixed event activation services
Add two new fixed activation services for startup:
lvm-activate-vgs-main and lvm-activate-vgs-last.

The -main service runs early, without service dependencies.
The -last service runs later, after other services have
started (other services that may set up devices for PVs,
like mulitpathd.)

The lvm-activate-vgs services both run "vgchange -aay"
to activate all VGs that are preset and complete at the
time of system startup.  When there are many VGs, these
two vgchange commands will replace many per-VG vgchange
commands.

The last service enables event activation by creating
the file /run/lvm/event-activation-on.  After that,
new devices that appear will be processed by event based
autoactivation commands.  Prior to the existence of the
event-activation-on file, event-based commands do nothing.

lvm.conf event_activation_options can be used to
configure service-based activation only, or event-based
activation only, or the approach described above which
begins with service based activation and then switches
to event-based.

service_only: only the -main and -last services will
activate VGs.  VGs on devices that appear later will
not be autoactivated.

event_only: the -main and -last services will not
activate any VGs, and all VGs will be activated
from per-VG event-based activation commands.

service_to_event: the -main and -last services will
activate VGs that are complete at the time the
services run, and VGs that appear later will be
activated from per-VG event-based activation
commands.
2021-10-15 16:25:01 -05:00
4f1957ee50 vgchange: add vgonline option
Using --vgonline with vgchange -aay makes vgchange use
/run/lvm/vgs_online/ files in the same way as pvscan.
If the online file for the vg does not exist and the
command is able to exclusively create it, then it will
activate the VG.  If the online file exists or the create
fails, then the VG will not be activated.
2021-10-15 12:59:03 -05:00
bf87b8354d configure: update 2021-10-15 10:11:34 +02:00
9d87549f80 configure.ac: enhance systemd testing
Enhance logic for checking supported systemd version,
while doing only a single check for systemd package.
For version checking use  PKG_CHECK_EXISTS() macro.

Also use one pkg check for blkid.

Avoid checking version for thin/cache_check when tools are not present
on system.
2021-10-15 10:09:21 +02:00
2e2d673780 makefile: enhance run-unit-test target
Use TMPDIR for executing test and also ensure
all libraries linked to the test are from builddir.
2021-10-15 09:55:54 +02:00
037165300e unit-test: better check for O_DIRECT
Instead of guessing tmpfs usage, just directly try if we could
reopen file with O_DIRECT on the used filesystem.
2021-10-15 09:55:54 +02:00
52a52d5567 configure: bash var typo 2021-10-15 00:32:36 +02:00
04725763a1 gcc: always initialize vg_complete 2021-10-15 00:09:07 +02:00
14cf579263 gcc: archive reoder struct vars
Easier for automatic struct initialization = { 0 } without warns
from older gcc.
2021-10-15 00:09:07 +02:00
438408de7d configure: missed braces
Missed [] around AS_IF internals,
Also missed to call pkg_config_init prior PKG_CHECK_MODULES().
2021-10-15 00:08:29 +02:00
8784211958 debug: reduce some debugging noise
Resolve event_activation configure option just once.

Do not print debug_devs about 'bad' filtering, when
actually filter already printed reason for skipping

Do not trace more then once about backup being disabled.

No debug when unlinked file does not exists in pvscan.
2021-10-14 23:34:11 +02:00
ae92888a7b make: generate 2021-10-14 23:34:11 +02:00
0bd5388b16 log: also build without systemd_journal_support 2021-10-14 23:34:11 +02:00
b73e1cd4b3 configure: updates 2021-10-14 23:34:11 +02:00
6635ff77e3 configure.ac: improvement
Handle automatically new setttings

--disable-systemd-journal
--disable-appmachineid

Both setting will check presence of apropriate header files.
In case they are present, build will try to automatically build with
them (adding systemd dependency)

User can anytime disabled them and drop systemd dependency.

Also add --with-default-use-devices-file  configure option to
select automatically default value for this option.
For this moment keep default upstream as 0
2021-10-14 23:34:11 +02:00
32cb1c4cdd makefiles: use proper install prefix for python dbus
For non-standard prefix dir use correct installation path
(so the python files are not installed into user's system).
2021-10-14 23:34:11 +02:00
af0ce203e9 debug: better error message
Add more details about size difference.
2021-10-14 23:34:11 +02:00
7e346ee2a5 archiving: update refactoring
Commit 5ea426e656 handled case with
file path without '/' incorrectly - there is valid use-case so
switch 'log_error()' to valid code branch.
2021-10-14 23:33:26 +02:00
c38473548e fix segfault handling duplicate PVs
cmd arg was missing when switching to use an alternative
duplicate dev.
2021-10-14 14:02:59 -05:00
e88163ceac fix lvmcache_add log_debug pvid
from previous cleanup
2021-10-13 17:30:21 -05:00
6fb497ef42 toollib: remove all devices list from process_each_pv
Reporting non-PVs / "all devices" is only done by
pvs -a or pvdisplay -a, so avoid the work managing
a list of all devices in process_each_pv.
In the case when it's needed, use the results of
label_scan which already determines which devs
are not PVs.
2021-10-13 17:29:32 -05:00
272d1ccac8 devices file: unmatching system id should just be warning
there are likely more cases than not where the systemid
does not match and the command should still run.
2021-10-13 13:42:04 -05:00
062ea3c418 fix syslog setting
Just setting lvm.conf level=N should not send messages to
syslog (now the journal by default.)

Sending messages to syslog should require setting lvm.conf
log { syslog=1 level=N }.
2021-10-11 17:11:01 -05:00
29 changed files with 756 additions and 597 deletions

View File

@ -126,7 +126,7 @@ devices {
# be used, regardless of this setting, when the --devicesfile
# option is set to a specific file name.
# This configuration option has an automatic default value.
# use_devicesfile = 1
# use_devicesfile = 0
# Configuration option devices/devicesfile.
# The name of the system devices file, listing devices that LVM should use.
@ -236,12 +236,6 @@ devices {
# This configuration option has an automatic default value.
# multipath_wwids_file = "/etc/multipath/wwids"
# Configuration option devices/multipath_wwids_file.
# The path to the multipath wwids file used for multipath component detection.
# Set this to an empty string to disable the use of the multipath wwids file.
# This configuration option has an automatic default value.
# multipath_wwids_file = "/etc/multipath/wwids"
# Configuration option devices/md_component_detection.
# Enable detection and exclusion of MD component devices.
# An MD component device is a block device that MD uses as part
@ -842,7 +836,7 @@ log {
# Configuration option log/syslog.
# Send log messages through syslog.
# This configuration option has an automatic default value.
# syslog = 1
# syslog = 0
# Configuration option log/file.
# Write error and debug log messages to a file specified here.

423
configure vendored
View File

@ -668,7 +668,6 @@ SALCK_CFLAGS
SACKPT_LIBS
SACKPT_CFLAGS
REPLICATORS
READLINE_LIBS
RT_LIBS
QUORUM_LIBS
QUORUM_CFLAGS
@ -755,6 +754,8 @@ BUILD_LVMDBUSD
BUILD_DMEVENTD
BUILD_CMIRRORD
BLKID_PC
READLINE_LIBS
READLINE_CFLAGS
MODPROBE_CMD
MSGFMT
EDITLINE_LIBS
@ -776,12 +777,6 @@ SYSTEMD_LIBS
SYSTEMD_CFLAGS
BLKID_LIBS
BLKID_CFLAGS
APP_MACHINEID_LIBS
APP_MACHINEID_CFLAGS
NOTIFY_DBUS_LIBS
NOTIFY_DBUS_CFLAGS
BLKID_LIBS
BLKID_CFLAGS
LOCKD_IDM_LIBS
LOCKD_IDM_CFLAGS
LOCKD_DLM_CONTROL_LIBS
@ -912,6 +907,7 @@ with_device_uid
with_device_gid
with_device_mode
with_device_nodes_on
with_default_use_devices_file
with_default_name_mangling
with_snapshots
with_mirrors
@ -961,6 +957,7 @@ enable_use_lvmpolld
with_lvmpolld_pidfile
enable_dmfilemapd
enable_notify_dbus
enable_systemd_journal
enable_app_machineid
enable_blkid_wiping
enable_udev_systemd_background_jobs
@ -1032,21 +1029,17 @@ LOCKD_DLM_CONTROL_CFLAGS
LOCKD_DLM_CONTROL_LIBS
LOCKD_IDM_CFLAGS
LOCKD_IDM_LIBS
NOTIFY_DBUS_CFLAGS
NOTIFY_DBUS_LIBS
APP_MACHINEID_CFLAGS
APP_MACHINEID_LIBS
BLKID_CFLAGS
BLKID_LIBS
NOTIFY_DBUS_CFLAGS
NOTIFY_DBUS_LIBS
SYSTEMD_CFLAGS
SYSTEMD_LIBS
UDEV_CFLAGS
UDEV_LIBS
PYTHON
EDITLINE_CFLAGS
EDITLINE_LIBS'
EDITLINE_LIBS
READLINE_CFLAGS
READLINE_LIBS'
# Initialize some variables set by options.
@ -1700,7 +1693,9 @@ Optional Features:
--disable-use-lvmpolld disable usage of LVM Poll Daemon
--enable-dmfilemapd enable the dmstats filemap daemon
--enable-notify-dbus enable LVM notification using dbus
--enable-app-machineid enable LVM system ID using app-specific machine-id
--disable-systemd-journal
disable LVM systemd journaling
--disable-app-machineid disable LVM system ID using app-specific machine-id
--disable-blkid_wiping disable libblkid detection of signatures when wiping
and use native code instead
--disable-udev-systemd-background-jobs
@ -1737,6 +1732,8 @@ Optional Packages:
--with-device-mode=MODE set the mode used for new device nodes [MODE=0600]
--with-device-nodes-on=ON
create nodes on resume or create [ON=resume]
--with-default-use-devices-file
default for lvm.conf devices/use_devicesfile = [0]
--with-default-name-mangling=MANGLING
default name mangling: auto/none/hex [auto]
--with-snapshots=TYPE snapshot support: internal/none [internal]
@ -1859,17 +1856,6 @@ Some influential environment variables:
BLKID_CFLAGS
C compiler flags for BLKID, overriding pkg-config
BLKID_LIBS linker flags for BLKID, overriding pkg-config
NOTIFY_DBUS_CFLAGS
C compiler flags for NOTIFY_DBUS, overriding pkg-config
NOTIFY_DBUS_LIBS
linker flags for NOTIFY_DBUS, overriding pkg-config
APP_MACHINEID_CFLAGS
C compiler flags for APP_MACHINEID, overriding pkg-config
APP_MACHINEID_LIBS
linker flags for APP_MACHINEID, overriding pkg-config
BLKID_CFLAGS
C compiler flags for BLKID, overriding pkg-config
BLKID_LIBS linker flags for BLKID, overriding pkg-config
SYSTEMD_CFLAGS
C compiler flags for SYSTEMD, overriding pkg-config
SYSTEMD_LIBS
@ -1881,6 +1867,10 @@ Some influential environment variables:
C compiler flags for EDITLINE, overriding pkg-config
EDITLINE_LIBS
linker flags for EDITLINE, overriding pkg-config
READLINE_CFLAGS
C compiler flags for readline
READLINE_LIBS
linker flags for readline
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@ -6718,18 +6708,17 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __builtin_ffs" >&5
printf %s "checking for __builtin_ffs... " >&6; }
if test ${ax_cv_have___builtin_ffs+y}
then :
printf %s "(cached) " >&6
else $as_nop
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ffs" >&5
$as_echo_n "checking for __builtin_ffs... " >&6; }
if ${ax_cv_have___builtin_ffs+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
main ()
{
__builtin_ffs(0)
@ -6738,26 +6727,31 @@ main (void)
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
if ac_fn_c_try_link "$LINENO"; then :
ax_cv_have___builtin_ffs=yes
else $as_nop
else
ax_cv_have___builtin_ffs=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have___builtin_ffs" >&5
printf "%s\n" "$ax_cv_have___builtin_ffs" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have___builtin_ffs" >&5
$as_echo "$ax_cv_have___builtin_ffs" >&6; }
if test yes = $ax_cv_have___builtin_ffs
then :
if test yes = $ax_cv_have___builtin_ffs; then :
printf "%s\n" "#define HAVE___BUILTIN_FFS 1" >>confdefs.h
cat >>confdefs.h <<_ACEOF
#define HAVE___BUILTIN_FFS 1
_ACEOF
fi
$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
@ -6783,25 +6777,17 @@ else
fi
done
ac_fn_c_check_func "$LINENO" "ffs" "ac_cv_func_ffs"
if test "x$ac_cv_func_ffs" = xyes
then :
printf "%s\n" "#define HAVE_FFS 1" >>confdefs.h
for ac_func in ffs prlimit versionsort
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
ac_fn_c_check_func "$LINENO" "prlimit" "ac_cv_func_prlimit"
if test "x$ac_cv_func_prlimit" = xyes
then :
printf "%s\n" "#define HAVE_PRLIMIT 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "versionsort" "ac_cv_func_versionsort"
if test "x$ac_cv_func_versionsort" = xyes
then :
printf "%s\n" "#define HAVE_VERSIONSORT 1" >>confdefs.h
fi
done
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
@ -8366,7 +8352,6 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking file owner" >&5
$as_echo_n "checking file owner... " >&6; }
@ -8476,6 +8461,29 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking default for use_devicesfile" >&5
$as_echo_n "checking default for use_devicesfile... " >&6; }
# Check whether --with-default-use-devices-file was given.
if test "${with_default_use_devices_file+set}" = set; then :
withval=$with_default_use_devices_file; DEFAULT_USE_DEVICES_FILE=$enableval
else
DEFAULT_USE_DEVICES_FILE=0
fi
case "$DEFAULT_USE_DEVICES_FILE" in
0|1);;
*) as_fn_error $? "--with-default-use-devices-file parameter invalid" "$LINENO" 5;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_USE_DEVICES_FILE" >&5
$as_echo "$DEFAULT_USE_DEVICES_FILE" >&6; }
cat >>confdefs.h <<_ACEOF
#define DEFAULT_USE_DEVICES_FILE $DEFAULT_USE_DEVICES_FILE
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking default name mangling" >&5
$as_echo_n "checking default name mangling... " >&6; }
@ -8772,7 +8780,7 @@ $as_echo "$as_me: WARNING: thin_check not found in path $PATH" >&2;}
THIN_CONFIGURE_WARN=y
fi
fi
if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
if test "$THIN_CHECK_NEEDS_CHECK" = yes && test "$THIN_CONFIGURE_WARN" != y ; then
THIN_CHECK_VSN=`"$THIN_CHECK_CMD" -V 2>/dev/null`
THIN_CHECK_VSN_MAJOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $1}'`
THIN_CHECK_VSN_MINOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $2}'`
@ -9320,7 +9328,7 @@ $as_echo "$as_me: WARNING: cache_check not found in path $PATH" >&2;}
CACHE_CONFIGURE_WARN=y
fi
fi
if test "$CACHE_CHECK_NEEDS_CHECK" = yes; then
if test "$CACHE_CHECK_NEEDS_CHECK" = yes && test "$CACHE_CONFIGURE_WARN" != y ; then
$CACHE_CHECK_CMD -V 2>/dev/null >conftest.tmp
read -r CACHE_CHECK_VSN < conftest.tmp
IFS=.- read -r CACHE_CHECK_VSN_MAJOR CACHE_CHECK_VSN_MINOR CACHE_CHECK_VSN_PATCH LEFTOVER < conftest.tmp
@ -9856,13 +9864,13 @@ _ACEOF
# Do we want to link lvm2 with a big library for vdoformating ?
#
#AC_ARG_WITH(vdo-include,
# AC_HELP_STRING([--with-vdo-include=PATH],
# AS_HELP_STRING([--with-vdo-include=PATH],
# [vdo support: Path to utils headers: [/usr/include/vdo/utils]]),
# VDO_INCLUDE=$withval, VDO_INCLUDE="/usr/include/vdo/utils")
#AC_MSG_RESULT($VDO_INCLUDE)
#
#AC_ARG_WITH(vdo-lib,
# AC_HELP_STRING([--with-vdo-lib=PATH],
# AS_HELP_STRING([--with-vdo-lib=PATH],
# [vdo support: Path to utils lib: [/usr/lib]]),
# VDO_LIB=$withval, VDO_LIB="/usr/lib")
#AC_MSG_RESULT($VDO_LIB)
@ -11559,12 +11567,34 @@ fi
fi
SYSTEMD_MIN_VERSION=0
pkg_config_init
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 205\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 205") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
SYSTEMD_MIN_VERSION=205
fi
################################################################################
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 221\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 221") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
SYSTEMD_MIN_VERSION=221
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build notifydbus" >&5
$as_echo_n "checking whether to build notifydbus... " >&6; }
# Check whether --enable-notify-dbus was given.
if test "${enable_notify_dbus+set}" = set; then :
enableval=$enable_notify_dbus; NOTIFYDBUS_SUPPORT=$enableval
enableval=$enable_notify_dbus; if test "$enableval" = yes && test "$SYSTEMD_MIN_VERSION" -lt 221; then :
as_fn_error $? "Enabling notify-dbus requires systemd >= 221" "$LINENO" 5
fi
NOTIFYDBUS_SUPPORT=$enableval
else
NOTIFYDBUS_SUPPORT=no
fi
@ -11572,125 +11602,105 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $NOTIFYDBUS_SUPPORT" >&5
$as_echo "$NOTIFYDBUS_SUPPORT" >&6; }
if test "$NOTIFYDBUS_SUPPORT" = yes; then
if test "$NOTIFYDBUS_SUPPORT" = yes; then :
$as_echo "#define NOTIFYDBUS_SUPPORT 1" >>confdefs.h
SYSTEMD_LIBS="-lsystemd"
fi
################################################################################
if test "$NOTIFYDBUS_SUPPORT" = yes; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NOTIFY_DBUS" >&5
$as_echo_n "checking for NOTIFY_DBUS... " >&6; }
if test -n "$NOTIFY_DBUS_CFLAGS"; then
pkg_cv_NOTIFY_DBUS_CFLAGS="$NOTIFY_DBUS_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 221\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 221") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_NOTIFY_DBUS_CFLAGS=`$PKG_CONFIG --cflags "systemd >= 221" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
if test "$SYSTEMD_MIN_VERSION" -ge 221; then :
SYSTEMD_JOURNAL_SUPPORT=maybe
else
pkg_failed=yes
SYSTEMD_JOURNAL_SUPPORT=no
fi
else
pkg_failed=untried
ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-journal.h" "ac_cv_header_systemd_sd_journal_h" "$ac_includes_default"
if test "x$ac_cv_header_systemd_sd_journal_h" = xyes; then :
if test "$SYSTEMD_JOURNAL_SUPPORT" != no; then :
SYSTEMD_JOURNAL_SUPPORT=yes
fi
if test -n "$NOTIFY_DBUS_LIBS"; then
pkg_cv_NOTIFY_DBUS_LIBS="$NOTIFY_DBUS_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 221\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 221") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_NOTIFY_DBUS_LIBS=`$PKG_CONFIG --libs "systemd >= 221" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
SYSTEMD_JOURNAL_SUPPORT=no
fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to log to systemd journal" >&5
$as_echo_n "checking whether to log to systemd journal... " >&6; }
# Check whether --enable-systemd-journal was given.
if test "${enable_systemd_journal+set}" = set; then :
enableval=$enable_systemd_journal; if test "$enableval" = yes && test "$SYSTEMD_JOURNAL_SUPPORT" = no; then :
as_fn_error $? "Enabling systemd journal requires systemd/sd-journal.h and systemd >= 221." "$LINENO" 5
fi
if test $_pkg_short_errors_supported = yes; then
NOTIFY_DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "systemd >= 221" 2>&1`
else
NOTIFY_DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "systemd >= 221" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$NOTIFY_DBUS_PKG_ERRORS" >&5
$bailout
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$bailout
else
NOTIFY_DBUS_CFLAGS=$pkg_cv_NOTIFY_DBUS_CFLAGS
NOTIFY_DBUS_LIBS=$pkg_cv_NOTIFY_DBUS_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
HAVE_NOTIFY_DBUS=yes
SYSTEMD_JOURNAL_SUPPORT=$enableval
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYSTEMD_JOURNAL_SUPPORT" >&5
$as_echo "$SYSTEMD_JOURNAL_SUPPORT" >&6; }
if test "$SYSTEMD_JOURNAL_SUPPORT" = yes; then :
$as_echo "#define SYSTEMD_JOURNAL_SUPPORT 1" >>confdefs.h
fi
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build appmachineid" >&5
$as_echo_n "checking whether to build appmachineid... " >&6; }
# Check whether --enable-app-machineid was given.
if test "${enable_app_machineid+set}" = set; then :
enableval=$enable_app_machineid; APP_MACHINEID_SUPPORT=$enableval
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 234\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 234") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
SYSTEMD_MIN_VERSION=234 APP_MACHINEID_SUPPORT=maybe
else
APP_MACHINEID_SUPPORT=no
fi
ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-id128.h" "ac_cv_header_systemd_sd_id128_h" "$ac_includes_default"
if test "x$ac_cv_header_systemd_sd_id128_h" = xyes; then :
if test "$APP_MACHINEID_SUPPORT" != no; then :
APP_MACHINEID_SUPPORT=yes
fi
else
APP_MACHINEID_SUPPORT=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support systemd appmachineid" >&5
$as_echo_n "checking whether to support systemd appmachineid... " >&6; }
# Check whether --enable-app-machineid was given.
if test "${enable_app_machineid+set}" = set; then :
enableval=$enable_app_machineid; if test "$enableval" = yes && test "$APP_MACHINEID_SUPPORT" = no; then :
as_fn_error $? "Enabling app machineid requires systemd/sd-id128.h and systemd >= 234." "$LINENO" 5
fi
APP_MACHINEID_SUPPORT=$enableval
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $APP_MACHINEID_SUPPORT" >&5
$as_echo "$APP_MACHINEID_SUPPORT" >&6; }
if test "$APP_MACHINEID_SUPPORT" = yes; then
if test "$APP_MACHINEID_SUPPORT" = yes; then :
$as_echo "#define APP_MACHINEID_SUPPORT 1" >>confdefs.h
SYSTEMD_LIBS="-lsystemd"
fi
################################################################################
if test "$APP_MACHINEID_SUPPORT" = yes; then
if test "$NOTIFYDBUS_SUPPORT" = yes || test "$SYSTEMD_JOURNAL_SUPPORT" = yes || test "$APP_MACHINEID_SUPPORT" = yes ; then :
pkg_config_init
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for APP_MACHINEID" >&5
$as_echo_n "checking for APP_MACHINEID... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SYSTEMD" >&5
$as_echo_n "checking for SYSTEMD... " >&6; }
if test -n "$APP_MACHINEID_CFLAGS"; then
pkg_cv_APP_MACHINEID_CFLAGS="$APP_MACHINEID_CFLAGS"
if test -n "$SYSTEMD_CFLAGS"; then
pkg_cv_SYSTEMD_CFLAGS="$SYSTEMD_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 234\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 234") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_APP_MACHINEID_CFLAGS=`$PKG_CONFIG --cflags "systemd >= 234" 2>/dev/null`
pkg_cv_SYSTEMD_CFLAGS=`$PKG_CONFIG --cflags "systemd" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@ -11698,16 +11708,16 @@ fi
else
pkg_failed=untried
fi
if test -n "$APP_MACHINEID_LIBS"; then
pkg_cv_APP_MACHINEID_LIBS="$APP_MACHINEID_LIBS"
if test -n "$SYSTEMD_LIBS"; then
pkg_cv_SYSTEMD_LIBS="$SYSTEMD_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 234\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 234") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_APP_MACHINEID_LIBS=`$PKG_CONFIG --libs "systemd >= 234" 2>/dev/null`
pkg_cv_SYSTEMD_LIBS=`$PKG_CONFIG --libs "systemd" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@ -11728,12 +11738,12 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
APP_MACHINEID_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "systemd >= 234" 2>&1`
SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "systemd" 2>&1`
else
APP_MACHINEID_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "systemd >= 234" 2>&1`
SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "systemd" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$APP_MACHINEID_PKG_ERRORS" >&5
echo "$SYSTEMD_PKG_ERRORS" >&5
$bailout
elif test $pkg_failed = untried; then
@ -11741,11 +11751,11 @@ elif test $pkg_failed = untried; then
$as_echo "no" >&6; }
$bailout
else
APP_MACHINEID_CFLAGS=$pkg_cv_APP_MACHINEID_CFLAGS
APP_MACHINEID_LIBS=$pkg_cv_APP_MACHINEID_LIBS
SYSTEMD_CFLAGS=$pkg_cv_SYSTEMD_CFLAGS
SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
HAVE_APP_MACHINEID=yes
SYSTEMD_LIBS="-lsystemd"
fi
fi
@ -11868,85 +11878,14 @@ fi
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" != no; then
pkg_config_init
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SYSTEMD" >&5
$as_echo_n "checking for SYSTEMD... " >&6; }
if test -n "$SYSTEMD_CFLAGS"; then
pkg_cv_SYSTEMD_CFLAGS="$SYSTEMD_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 205\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 205") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_SYSTEMD_CFLAGS=`$PKG_CONFIG --cflags "systemd >= 205" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
if test "$SYSTEMD_MIN_VERSION" -ge 205; then :
UDEV_SYSTEMD_BACKGROUND_JOBS=yes
else
pkg_failed=yes
fi
else
pkg_failed=untried
fi
if test -n "$SYSTEMD_LIBS"; then
pkg_cv_SYSTEMD_LIBS="$SYSTEMD_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 205\""; } >&5
($PKG_CONFIG --exists --print-errors "systemd >= 205") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_SYSTEMD_LIBS=`$PKG_CONFIG --libs "systemd >= 205" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then :
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
pkg_failed=yes
as_fn_error $? "bailing out... systemd >= 205 is required" "$LINENO" 5
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "systemd >= 205" 2>&1`
else
SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "systemd >= 205" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$SYSTEMD_PKG_ERRORS" >&5
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
as_fn_error $? "bailing out... systemd >= 205 is required" "$LINENO" 5
fi
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
as_fn_error $? "bailing out... systemd >= 205 is required" "$LINENO" 5
fi
else
SYSTEMD_CFLAGS=$pkg_cv_SYSTEMD_CFLAGS
SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
UDEV_SYSTEMD_BACKGROUND_JOBS=yes
fi
fi
@ -14386,6 +14325,19 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
################################################################################
@ -14530,11 +14482,6 @@ _ACEOF

View File

@ -219,7 +219,6 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
################################################################################
dnl -- Setup the ownership of the files
AC_MSG_CHECKING(file owner)
@ -286,6 +285,20 @@ esac
AC_MSG_RESULT(on $ADD_NODE)
AC_DEFINE_UNQUOTED([DEFAULT_DM_ADD_NODE], $add_on, [Define default node creation behavior with dmsetup create])
dnl -- Default settings for lvm.conf { devices/use_devicesfile }
AC_MSG_CHECKING(default for use_devicesfile)
AC_ARG_WITH(default-use-devices-file,
AS_HELP_STRING([--with-default-use-devices-file], [default for lvm.conf devices/use_devicesfile = [0]]),
DEFAULT_USE_DEVICES_FILE=$enableval, DEFAULT_USE_DEVICES_FILE=0)
case "$DEFAULT_USE_DEVICES_FILE" in
0|1);;
*) AC_MSG_ERROR([--with-default-use-devices-file parameter invalid]);;
esac
AC_MSG_RESULT($DEFAULT_USE_DEVICES_FILE)
AC_DEFINE_UNQUOTED(DEFAULT_USE_DEVICES_FILE, [$DEFAULT_USE_DEVICES_FILE],
[Default for lvm.conf use_devicefile.])
AC_MSG_CHECKING(default name mangling)
AC_ARG_WITH(default-name-mangling,
AS_HELP_STRING([--with-default-name-mangling=MANGLING],
@ -417,7 +430,7 @@ case "$THIN" in
THIN_CONFIGURE_WARN=y
fi
fi
if test "$THIN_CHECK_NEEDS_CHECK" = yes; then
if test "$THIN_CHECK_NEEDS_CHECK" = yes && test "$THIN_CONFIGURE_WARN" != y ; then
THIN_CHECK_VSN=`"$THIN_CHECK_CMD" -V 2>/dev/null`
THIN_CHECK_VSN_MAJOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $1}'`
THIN_CHECK_VSN_MINOR=`echo "$THIN_CHECK_VSN" | $AWK -F '.' '{print $2}'`
@ -530,7 +543,7 @@ case "$CACHE" in
CACHE_CONFIGURE_WARN=y
fi
fi
if test "$CACHE_CHECK_NEEDS_CHECK" = yes; then
if test "$CACHE_CHECK_NEEDS_CHECK" = yes && test "$CACHE_CONFIGURE_WARN" != y ; then
$CACHE_CHECK_CMD -V 2>/dev/null >conftest.tmp
read -r CACHE_CHECK_VSN < conftest.tmp
IFS=.- read -r CACHE_CHECK_VSN_MAJOR CACHE_CHECK_VSN_MINOR CACHE_CHECK_VSN_PATCH LEFTOVER < conftest.tmp
@ -1052,45 +1065,65 @@ if test "$BUILD_DMFILEMAPD" = yes; then
AC_CHECK_HEADER([linux/fiemap.h], , [AC_MSG_ERROR(--enable-dmfilemapd requires fiemap.h)])
fi
SYSTEMD_MIN_VERSION=0
pkg_config_init
PKG_CHECK_EXISTS(systemd >= 205, [SYSTEMD_MIN_VERSION=205], [])
################################################################################
dnl -- Build notifydbus
PKG_CHECK_EXISTS(systemd >= 221, [SYSTEMD_MIN_VERSION=221], [])
AC_MSG_CHECKING(whether to build notifydbus)
AC_ARG_ENABLE(notify-dbus,
AS_HELP_STRING([--enable-notify-dbus],
[enable LVM notification using dbus]),
AS_IF([test "$enableval" = yes && test "$SYSTEMD_MIN_VERSION" -lt 221],
AC_MSG_ERROR([Enabling notify-dbus requires systemd >= 221]))
NOTIFYDBUS_SUPPORT=$enableval, NOTIFYDBUS_SUPPORT=no)
AC_MSG_RESULT($NOTIFYDBUS_SUPPORT)
if test "$NOTIFYDBUS_SUPPORT" = yes; then
AC_DEFINE([NOTIFYDBUS_SUPPORT], 1, [Define to 1 to include code that uses dbus notification.])
SYSTEMD_LIBS="-lsystemd"
fi
AS_IF([test "$NOTIFYDBUS_SUPPORT" = yes],
AC_DEFINE([NOTIFYDBUS_SUPPORT], 1, [Define to 1 to include code that uses dbus notification.]))
################################################################################
dnl -- Look for dbus libraries
if test "$NOTIFYDBUS_SUPPORT" = yes; then
PKG_CHECK_MODULES(NOTIFY_DBUS, systemd >= 221, [HAVE_NOTIFY_DBUS=yes], $bailout)
fi
dnl -- Build with systemd journaling when the header file is present
AS_IF([test "$SYSTEMD_MIN_VERSION" -ge 221], [SYSTEMD_JOURNAL_SUPPORT=maybe], [SYSTEMD_JOURNAL_SUPPORT=no])
AC_CHECK_HEADER([systemd/sd-journal.h],
[AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" != no], [SYSTEMD_JOURNAL_SUPPORT=yes])],
[SYSTEMD_JOURNAL_SUPPORT=no])
AC_MSG_CHECKING(whether to log to systemd journal)
AC_ARG_ENABLE(systemd-journal,
AS_HELP_STRING([--disable-systemd-journal],
[disable LVM systemd journaling]),
AS_IF([test "$enableval" = yes && test "$SYSTEMD_JOURNAL_SUPPORT" = no],
AC_MSG_ERROR([Enabling systemd journal requires systemd/sd-journal.h and systemd >= 221.]))
SYSTEMD_JOURNAL_SUPPORT=$enableval, [])
AC_MSG_RESULT($SYSTEMD_JOURNAL_SUPPORT)
AS_IF([test "$SYSTEMD_JOURNAL_SUPPORT" = yes],
AC_DEFINE([SYSTEMD_JOURNAL_SUPPORT], 1, [Define to 1 to include code that uses systemd journal.]))
################################################################################
dnl -- Build appmachineid
AC_MSG_CHECKING(whether to build appmachineid)
dnl -- Build appmachineid when header file sd-id128.h is present
PKG_CHECK_EXISTS(systemd >= 234, [SYSTEMD_MIN_VERSION=234 APP_MACHINEID_SUPPORT=maybe], [APP_MACHINEID_SUPPORT=no])
AC_CHECK_HEADER([systemd/sd-id128.h],
[AS_IF([test "$APP_MACHINEID_SUPPORT" != no], [APP_MACHINEID_SUPPORT=yes])],
[APP_MACHINEID_SUPPORT=no])
AC_MSG_CHECKING(whether to support systemd appmachineid)
AC_ARG_ENABLE(app-machineid,
AC_HELP_STRING([--enable-app-machineid],
[enable LVM system ID using app-specific machine-id]),
APP_MACHINEID_SUPPORT=$enableval, APP_MACHINEID_SUPPORT=no)
AC_HELP_STRING([--disable-app-machineid],
[disable LVM system ID using app-specific machine-id]),
AS_IF([test "$enableval" = yes && test "$APP_MACHINEID_SUPPORT" = no],
AC_MSG_ERROR([Enabling app machineid requires systemd/sd-id128.h and systemd >= 234.]))
APP_MACHINEID_SUPPORT=$enableval, [])
AC_MSG_RESULT($APP_MACHINEID_SUPPORT)
if test "$APP_MACHINEID_SUPPORT" = yes; then
AC_DEFINE([APP_MACHINEID_SUPPORT], 1, [Define to 1 to include code that uses libsystemd machine-id apis.])
SYSTEMD_LIBS="-lsystemd"
fi
AS_IF([test "$APP_MACHINEID_SUPPORT" = yes],
AC_DEFINE([APP_MACHINEID_SUPPORT], 1, [Define to 1 to include code that uses libsystemd machine-id apis.]))
################################################################################
dnl -- Look for libsystemd libraries
if test "$APP_MACHINEID_SUPPORT" = yes; then
PKG_CHECK_MODULES(APP_MACHINEID, systemd >= 234, [HAVE_APP_MACHINEID=yes], $bailout)
fi
dnl -- Look for libsystemd libraries if needed
AS_IF([test "$NOTIFYDBUS_SUPPORT" = yes || test "$SYSTEMD_JOURNAL_SUPPORT" = yes || test "$APP_MACHINEID_SUPPORT" = yes ] ,[
pkg_config_init
PKG_CHECK_MODULES(SYSTEMD, [systemd], [SYSTEMD_LIBS="-lsystemd"], $bailout) ])
################################################################################
@ -1129,14 +1162,11 @@ AC_ARG_ENABLE(udev-systemd-background-jobs,
UDEV_SYSTEMD_BACKGROUND_JOBS=maybe)
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" != no; then
pkg_config_init
PKG_CHECK_MODULES(SYSTEMD, systemd >= 205,
[UDEV_SYSTEMD_BACKGROUND_JOBS=yes],
[if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
AC_MSG_ERROR([bailing out... systemd >= 205 is required])
fi])
AS_IF([test "$SYSTEMD_MIN_VERSION" -ge 205],
UDEV_SYSTEMD_BACKGROUND_JOBS=yes,
AS_IF([test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe],
[UDEV_SYSTEMD_BACKGROUND_JOBS=no],
[AC_MSG_ERROR([bailing out... systemd >= 205 is required])]))
fi
AC_MSG_CHECKING(whether to use udev-systemd protocol for jobs in background)
@ -1768,6 +1798,19 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[[()]]' '{print $2}'`
AC_DEFINE_UNQUOTED(LVM_CONFIGURE_LINE, "$CONFIGURE_LINE", [configure command line used])
AC_ARG_VAR([BLKID_CFLAGS], [C compiler flags for blkid])
AC_ARG_VAR([BLKID_LIBS], [linker flags for blkid])
AC_ARG_VAR([CPG_CFLAGS], [C compiler flags for cpg])
AC_ARG_VAR([CPG_LIBS], [linker flags for cpg])
AC_ARG_VAR([EDITLINE_CFLAGS], [C compiler flags for editline])
AC_ARG_VAR([EDITLINE_LIBS], [linker flags for editline])
AC_ARG_VAR([READLINE_CFLAGS], [C compiler flags for readline])
AC_ARG_VAR([READLINE_LIBS], [linker flags for readline])
AC_ARG_VAR([SYSTEMD_CFLAGS], [C compiler flags for systemd])
AC_ARG_VAR([SYSTEMD_LIBS], [linker flags for systemd])
AC_ARG_VAR([UDEV_CFLAGS], [C compiler flags for udev])
AC_ARG_VAR([UDEV_LIBS], [linker flags for udev])
################################################################################
AC_SUBST(AWK)
AC_SUBST(BLKID_PC)
@ -1791,8 +1834,6 @@ AC_SUBST(CONFDB_CFLAGS)
AC_SUBST(CONFDB_LIBS)
AC_SUBST(CONFDIR)
AC_SUBST(COPTIMISE_FLAG)
AC_SUBST(CPG_CFLAGS)
AC_SUBST(CPG_LIBS)
AC_SUBST(CSCOPE_CMD)
AC_SUBST(DEBUG)
AC_SUBST(DEFAULT_ARCHIVE_SUBDIR)
@ -1864,8 +1905,6 @@ AC_SUBST(PYTHON3DIR)
AC_SUBST(QUORUM_CFLAGS)
AC_SUBST(QUORUM_LIBS)
AC_SUBST(RT_LIBS)
AC_SUBST(READLINE_LIBS)
AC_SUBST(EDITLINE_LIBS)
AC_SUBST(REPLICATORS)
AC_SUBST(SACKPT_CFLAGS)
AC_SUBST(SACKPT_LIBS)
@ -1875,7 +1914,6 @@ AC_SUBST(SBINDIR)
AC_SUBST(SELINUX_LIBS)
AC_SUBST(SELINUX_PC)
AC_SUBST(SYSCONFDIR)
AC_SUBST(SYSTEMD_LIBS)
AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR)
AC_SUBST(STATIC_LINK)

View File

@ -90,6 +90,9 @@
/* Use blkid wiping by default. */
#undef DEFAULT_USE_BLKID_WIPING
/* Default for lvm.conf use_devicefile. */
#undef DEFAULT_USE_DEVICES_FILE
/* Use lvmlockd by default. */
#undef DEFAULT_USE_LVMLOCKD
@ -668,6 +671,9 @@
/* Define to 1 if strerror_r returns char *. */
#undef STRERROR_R_CHAR_P
/* Define to 1 to include code that uses systemd journal. */
#undef SYSTEMD_JOURNAL_SUPPORT
/* Path to testsuite data */
#undef TESTSUITE_DATA

12
lib/cache/lvmcache.c vendored
View File

@ -1349,7 +1349,7 @@ int lvmcache_label_scan(struct cmd_context *cmd)
dm_list_iterate_items(devl, &add_cache_devs) {
log_debug_cache("Adding chosen duplicate %s", dev_name(devl->dev));
label_scan_dev(devl->dev);
label_scan_dev(cmd, devl->dev);
}
dm_list_splice(&_unused_duplicates, &del_cache_devs);
@ -2168,15 +2168,17 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
{
const char *pvid = pvid_arg;
const char *vgid = vgid_arg;
char pvid_dashed[64] __attribute__((aligned(8)));
struct lvmcache_vgsummary vgsummary = { 0 };
struct lvmcache_info *info;
struct lvmcache_info *info_lookup;
struct device_list *devl;
int created = 0;
if (!id_write_format((const struct id *)&pvid, pvid_dashed, sizeof(pvid_dashed)))
stack;
/*
* Note: ensure that callers of lvmcache_add() pass null terminated
* pvid and vgid strings, and do not pass char* that is type cast
* from struct id.
*/
log_debug_cache("Found PVID %s on %s", pvid, dev_name(dev));
@ -2206,7 +2208,7 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
if (!created) {
if (info->dev != dev) {
log_debug_cache("Saving initial duplicate device %s previously seen on %s with PVID %s.",
dev_name(dev), dev_name(info->dev), pvid_dashed);
dev_name(dev), dev_name(info->dev), pvid);
memset(&dev->pvid, 0, sizeof(dev->pvid));
memcpy(dev->pvid, pvid, ID_LEN);

View File

@ -377,12 +377,11 @@ static void _init_logging(struct cmd_context *cmd)
/* Syslog */
cmd->default_settings.syslog = find_config_tree_bool(cmd, log_syslog_CFG, NULL);
if (cmd->default_settings.syslog != 1)
if (cmd->default_settings.syslog)
init_syslog(1, DEFAULT_LOG_FACILITY);
else
fin_syslog();
if (cmd->default_settings.syslog > 1)
init_syslog(cmd->default_settings.syslog);
/* Debug level for log file output */
cmd->default_settings.debug = find_config_tree_int(cmd, log_level_CFG, NULL);
init_debug(cmd->default_settings.debug);
@ -766,6 +765,7 @@ static int _process_config(struct cmd_context *cmd)
init_pv_min_size((uint64_t)pv_min_kb * (1024 >> SECTOR_SHIFT));
cmd->check_pv_dev_sizes = find_config_tree_bool(cmd, metadata_check_pv_device_sizes_CFG, NULL);
cmd->event_activation = find_config_tree_bool(cmd, global_event_activation_CFG, NULL);
if (!process_profilable_config(cmd))
return_0;
@ -1653,8 +1653,6 @@ struct cmd_context *create_toolcontext(unsigned is_clvmd,
bindtextdomain(INTL_PACKAGE, LOCALEDIR);
#endif
init_syslog(DEFAULT_LOG_FACILITY);
if (!(cmd = zalloc(sizeof(*cmd)))) {
log_error("Failed to allocate command context");
return NULL;

View File

@ -200,6 +200,8 @@ struct cmd_context {
unsigned check_devs_used:1; /* check devs used by LVs */
unsigned print_device_id_not_found:1; /* print devices file entries not found */
unsigned ignore_device_name_mismatch:1; /* skip updating devices file names */
unsigned backup_disabled:1; /* skip repeated debug message */
unsigned event_activation:1; /* whether event_activation is set */
/*
* Devices and filtering.

View File

@ -221,7 +221,7 @@
#endif
#define DEFAULT_COMMAND_LOG_REPORT 0
#define DEFAULT_SYSLOG 1
#define DEFAULT_SYSLOG 0
#define DEFAULT_VERBOSE 0
#define DEFAULT_SILENT 0
#define DEFAULT_LOGLEVEL 0
@ -322,7 +322,6 @@
#define DEFAULT_MD_COMPONENT_CHECKS "auto"
#define DEFAULT_USE_DEVICES_FILE 1
#define DEFAULT_DEVICES_FILE "system.devices"
#define DEFAULT_SEARCH_FOR_DEVNAMES "auto"

View File

@ -1831,7 +1831,7 @@ int setup_devices_file(struct cmd_context *cmd)
* Add all system devices to dev-cache, and attempt to
* match all devices_file entries to dev-cache entries.
*/
static int _setup_devices(struct cmd_context *cmd, int no_file_match)
int setup_devices(struct cmd_context *cmd)
{
int file_exists;
int lock_mode = 0;
@ -1958,13 +1958,6 @@ static int _setup_devices(struct cmd_context *cmd, int no_file_match)
*/
dev_cache_scan(cmd);
/*
* The caller uses "no_file_match" if it wants to match specific devs
* itself, instead of matching everything in device_ids_match.
*/
if (no_file_match && cmd->enable_devices_file)
return 1;
/*
* Match entries from cmd->use_devices with device structs in dev-cache.
*/
@ -1973,16 +1966,6 @@ static int _setup_devices(struct cmd_context *cmd, int no_file_match)
return 1;
}
int setup_devices(struct cmd_context *cmd)
{
return _setup_devices(cmd, 0);
}
int setup_devices_no_file_match(struct cmd_context *cmd)
{
return _setup_devices(cmd, 1);
}
/*
* The alternative to setup_devices() when the command is interested
* in using only one PV.
@ -2051,3 +2034,188 @@ int setup_device(struct cmd_context *cmd, const char *devname)
return 1;
}
/*
* pvscan --cache is specialized/optimized to look only at command args,
* so this just sets up the devices file, then individual devices are
* added to dev-cache and matched with device_ids later in pvscan.
*/
int setup_devices_for_pvscan_cache(struct cmd_context *cmd)
{
if (cmd->enable_devices_list) {
if (!_setup_devices_list(cmd))
return_0;
return 1;
}
if (!setup_devices_file(cmd))
return_0;
if (!cmd->enable_devices_file)
return 1;
if (!devices_file_exists(cmd)) {
log_debug("Devices file not found, ignoring.");
cmd->enable_devices_file = 0;
return 1;
}
if (!lock_devices_file(cmd, LOCK_SH)) {
log_error("Failed to lock the devices file to read.");
return 0;
}
if (!device_ids_read(cmd)) {
log_error("Failed to read the devices file.");
unlock_devices_file(cmd);
return 0;
}
unlock_devices_file(cmd);
return 1;
}
/* Get a device name from a devno. */
static char *_get_devname_from_devno(struct cmd_context *cmd, dev_t devno)
{
char path[PATH_MAX];
char devname[PATH_MAX];
char namebuf[NAME_LEN];
char line[1024];
int major = MAJOR(devno);
int minor = MINOR(devno);
int line_major;
int line_minor;
uint64_t line_blocks;
DIR *dir;
struct dirent *dirent;
FILE *fp;
/*
* $ ls /sys/dev/block/8:0/device/block/
* sda
*/
if (major_is_scsi_device(cmd->dev_types, major)) {
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/device/block",
dm_sysfs_dir(), major, minor) < 0) {
return NULL;
}
if (!(dir = opendir(path)))
return NULL;
while ((dirent = readdir(dir))) {
if (dirent->d_name[0] == '.')
continue;
if (dm_snprintf(devname, sizeof(devname), "/dev/%s", dirent->d_name) < 0) {
devname[0] = '\0';
stack;
}
break;
}
closedir(dir);
if (devname[0]) {
log_debug("Found %s for %d:%d from sys", devname, major, minor);
return _strdup(devname);
}
return NULL;
}
/*
* $ cat /sys/dev/block/253:3/dm/name
* mpatha
*/
if (major == cmd->dev_types->device_mapper_major) {
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/dm/name",
dm_sysfs_dir(), major, minor) < 0) {
return NULL;
}
if (!get_sysfs_value(path, namebuf, sizeof(namebuf), 0))
return NULL;
if (dm_snprintf(devname, sizeof(devname), "/dev/mapper/%s", namebuf) < 0) {
devname[0] = '\0';
stack;
}
if (devname[0]) {
log_debug("Found %s for %d:%d from sys", devname, major, minor);
return _strdup(devname);
}
return NULL;
}
/*
* /proc/partitions lists
* major minor #blocks name
*/
if (!(fp = fopen("/proc/partitions", "r")))
return NULL;
while (fgets(line, sizeof(line), fp)) {
if (sscanf(line, "%u %u %llu %s", &line_major, &line_minor, (unsigned long long *)&line_blocks, namebuf) != 4)
continue;
if (line_major != major)
continue;
if (line_minor != minor)
continue;
if (dm_snprintf(devname, sizeof(devname), "/dev/%s", namebuf) < 0) {
devname[0] = '\0';
stack;
}
break;
}
fclose(fp);
if (devname[0]) {
log_debug("Found %s for %d:%d from proc", devname, major, minor);
return _strdup(devname);
}
/*
* If necessary, this could continue searching by stat'ing /dev entries.
*/
return NULL;
}
int setup_devname_in_dev_cache(struct cmd_context *cmd, const char *devname)
{
struct stat buf;
struct device *dev;
if (stat(devname, &buf) < 0) {
log_error("Cannot access device %s.", devname);
return 0;
}
if (!S_ISBLK(buf.st_mode)) {
log_error("Invaild device type %s.", devname);
return 0;
}
if (!_insert_dev(devname, buf.st_rdev))
return_0;
if (!(dev = (struct device *) dm_hash_lookup(_cache.names, devname)))
return_0;
return 1;
}
int setup_devno_in_dev_cache(struct cmd_context *cmd, dev_t devno)
{
const char *devname;
if (!(devname = _get_devname_from_devno(cmd, devno)))
return_0;
return setup_devname_in_dev_cache(cmd, devname);
}

View File

@ -77,7 +77,11 @@ int get_dm_uuid_from_sysfs(char *buf, size_t buf_size, int major, int minor);
int setup_devices_file(struct cmd_context *cmd);
int setup_devices(struct cmd_context *cmd);
int setup_devices_no_file_match(struct cmd_context *cmd);
int setup_device(struct cmd_context *cmd, const char *devname);
/* Normal device setup functions are split up for pvscan optimization. */
int setup_devices_for_pvscan_cache(struct cmd_context *cmd);
int setup_devname_in_dev_cache(struct cmd_context *cmd, const char *devname);
int setup_devno_in_dev_cache(struct cmd_context *cmd, dev_t devno);
#endif

View File

@ -39,6 +39,7 @@
#define DEV_IS_MD_COMPONENT 0x00020000 /* device is an md component */
#define DEV_IS_NVME 0x00040000 /* set if dev is nvme */
#define DEV_MATCHED_USE_ID 0x00080000 /* matched an entry from cmd->use_devices */
#define DEV_SCAN_FOUND_NOLABEL 0x00100000 /* label_scan read, passed filters, but no lvm label */
/*
* Support for external device info.

View File

@ -543,11 +543,8 @@ int device_ids_read(struct cmd_context *cmd)
log_debug("read devices file systemid %s", _devices_file_systemid);
if ((!cmd->system_id && _devices_file_systemid[0]) ||
(cmd->system_id && strcmp(cmd->system_id, _devices_file_systemid))) {
log_warn("WARNING: ignoring devices file with wrong system id %s vs local %s.",
log_warn("WARNING: devices file has unmatching system id %s vs local %s.",
_devices_file_systemid[0] ? _devices_file_systemid : "none", cmd->system_id ?: "none");
free_dus(&cmd->use_devices);
ret = 0;
goto out;
}
continue;
}
@ -613,7 +610,6 @@ int device_ids_read(struct cmd_context *cmd)
dm_list_add(&cmd->use_devices, &du->list);
}
out:
if (fclose(fp))
stack;
@ -1537,6 +1533,22 @@ int device_ids_match_dev(struct cmd_context *cmd, struct device *dev)
* passes the filter.
*/
void device_ids_match_device_list(struct cmd_context *cmd)
{
struct dev_use *du;
dm_list_iterate_items(du, &cmd->use_devices) {
if (du->dev)
continue;
if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
log_warn("Device not found for %s.", du->devname);
} else {
/* Should we set dev->id? Which idtype? Use --deviceidtype? */
du->dev->flags |= DEV_MATCHED_USE_ID;
}
}
}
void device_ids_match(struct cmd_context *cmd)
{
struct dev_iter *iter;
@ -1544,16 +1556,7 @@ void device_ids_match(struct cmd_context *cmd)
struct device *dev;
if (cmd->enable_devices_list) {
dm_list_iterate_items(du, &cmd->use_devices) {
if (du->dev)
continue;
if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
log_warn("Device not found for %s.", du->devname);
} else {
/* Should we set dev->id? Which idtype? Use --deviceidtype? */
du->dev->flags |= DEV_MATCHED_USE_ID;
}
}
device_ids_match_device_list(cmd);
return;
}

View File

@ -32,6 +32,7 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid,
void device_id_pvremove(struct cmd_context *cmd, struct device *dev);
void device_ids_match(struct cmd_context *cmd);
int device_ids_match_dev(struct cmd_context *cmd, struct device *dev);
void device_ids_match_device_list(struct cmd_context *cmd);
void device_ids_validate(struct cmd_context *cmd, struct dm_list *scanned_devs, int *device_ids_invalid, int noupdate);
int device_ids_version_unchanged(struct cmd_context *cmd);
void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_list, int *search_count, int noupdate);

View File

@ -137,7 +137,8 @@ static int _lookup_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
l = PF_GOOD_DEVICE;
}
log_debug_devs("filter caching %s %s", pass ? "good" : "bad", dev_name(dev));
if (!dev->filtered_flags) /* skipping reason already logged by filter */
log_debug_devs("filter caching %s %s", pass ? "good" : "bad", dev_name(dev));
dm_list_iterate_items(sl, &dev->aliases)
if (!dm_hash_insert(pf->devices, sl->str, l)) {

View File

@ -47,9 +47,8 @@
* with the least recent at the head.
*/
struct archive_file {
struct dm_list list;
const char *name;
struct dm_list list;
uint32_t index;
};
@ -373,21 +372,21 @@ int archive_list_file(struct cmd_context *cmd, const char *file)
}
if (!(af.name = strrchr(file, '/'))) {
log_error("No '/' in file path %s found.", file);
return 0;
af.name = file;
path[0] = 0;
} else {
len = (size_t)(af.name - file);
if (len >= sizeof(path)) {
log_error(INTERNAL_ERROR "Passed file path name %s is too long.", file);
return 0;
}
memcpy(path, file, len);
path[len] = 0;
af.name++; /* jump over '/' */
}
len = (size_t)(af.name - file);
if (len >= sizeof(path)) {
log_error(INTERNAL_ERROR "Passed file path name %s is too long.", file);
return 0;
}
memcpy(path, file, len);
path[len] = 0;
af.name++; /* jump over '/' */
_display_archive(cmd, path, &af);
return 1;

View File

@ -626,7 +626,10 @@ void check_current_backup(struct volume_group *vg)
int old_suppress;
if (!vg->cmd->backup_params->enabled || !vg->cmd->backup_params->dir) {
log_debug("Skipping check for current backup, since backup is disabled.");
if (!vg->cmd->backup_disabled) {
log_debug("Skipping check for current backup, since backup is disabled.");
vg->cmd->backup_disabled = 1;
}
return;
}

View File

@ -1922,7 +1922,9 @@ static int _text_pv_initialise(const struct format_type *fmt,
pv->pe_count = pva->extent_count;
if ((pv->pe_start + pv->pe_count * (uint64_t)pv->pe_size - 1) > pv->size) {
log_error("Physical extents end beyond end of device %s.",
log_error("Physical extents (%s) end beyond end of device (%s) %s.",
display_size(pv->fmt->cmd, pv->pe_start + pv->pe_count * (uint64_t)pv->pe_size - 1),
display_size(pv->fmt->cmd, pv->size),
pv_dev_name(pv));
return 0;
}

View File

@ -403,6 +403,7 @@ static int _process_block(struct cmd_context *cmd, struct dev_filter *f,
memset(dev->pvid, 0, sizeof(dev->pvid));
}
dev->flags |= DEV_SCAN_FOUND_NOLABEL;
*is_lvm_device = 0;
goto out;
}
@ -1490,7 +1491,7 @@ void label_scan_destroy(struct cmd_context *cmd)
* device, this is not a commonly used function.
*/
int label_scan_dev(struct device *dev)
int label_scan_dev(struct cmd_context *cmd, struct device *dev)
{
struct dm_list one_dev;
struct device_list *devl;
@ -1505,7 +1506,7 @@ int label_scan_dev(struct device *dev)
label_scan_invalidate(dev);
_scan_list(NULL, NULL, &one_dev, 0, &failed);
_scan_list(cmd, NULL, &one_dev, 0, &failed);
free(devl);

View File

@ -107,7 +107,7 @@ int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_lis
int label_scan_devs_cached(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_devs_excl(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_dev(struct device *dev);
int label_scan_dev(struct cmd_context *cmd, struct device *dev);
void label_scan_invalidate(struct device *dev);
void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv);
void label_scan_drop(struct cmd_context *cmd);

View File

@ -25,7 +25,10 @@
#include <syslog.h>
#include <ctype.h>
#include <time.h>
#ifdef SYSTEMD_JOURNAL_SUPPORT
#include <systemd/sd-journal.h>
#endif
static FILE *_log_file;
static char _log_file_path[PATH_MAX];
@ -312,8 +315,13 @@ void init_log_while_suspended(int log_while_suspended)
_log_while_suspended = log_while_suspended;
}
void init_syslog(int facility)
void init_syslog(int enable, int facility)
{
if (!enable) {
_syslog = 0;
return;
}
if (getenv("LVM_SUPPRESS_SYSLOG"))
return;
@ -617,6 +625,7 @@ static void _vprint_log(int level, const char *file, int line, int dm_errno_or_c
log_it:
#ifdef SYSTEMD_JOURNAL_SUPPORT
if (_log_journal) {
int to_journal = 0;
@ -642,6 +651,7 @@ static void _vprint_log(int level, const char *file, int line, int dm_errno_or_c
va_end(ap);
}
}
#endif
if (!logged_via_report && ((verbose_level() >= level) && !_log_suppress)) {
if (verbose_level() > _LOG_DEBUG) {
@ -853,6 +863,7 @@ void log_set_report_object_name_and_id(const char *name, const char *id)
void log_command(const char *cmd_line, const char *cmd_name, const char *cmd_id)
{
#ifdef SYSTEMD_JOURNAL_SUPPORT
if (_log_journal & LOG_JOURNAL_COMMAND) {
/*
@ -870,6 +881,7 @@ void log_command(const char *cmd_line, const char *cmd_name, const char *cmd_id)
"PRIORITY=%i", LOG_INFO,
NULL);
}
#endif
}
uint32_t log_journal_str_to_val(const char *str)

View File

@ -59,7 +59,7 @@ void init_abort_on_internal_errors(int fatal);
void fin_log(void);
void reset_log_duplicated(void);
void init_syslog(int facility);
void init_syslog(int enable, int facility);
void fin_syslog(void);
void init_log_journal(uint32_t fields);

View File

@ -73,22 +73,29 @@ CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
LIB_SUFFIX = @LIB_SUFFIX@
USE_TRACKING = @USE_TRACKING@
DL_LIBS = @DL_LIBS@
RT_LIBS = @RT_LIBS@
M_LIBS = @M_LIBS@
AIO_LIBS = @AIO_LIBS@
AIO_CFLAGS = @AIO_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
READLINE_LIBS = @READLINE_LIBS@
EDITLINE_LIBS = @EDITLINE_LIBS@
SELINUX_LIBS = @SELINUX_LIBS@
UDEV_CFLAGS = @UDEV_CFLAGS@
UDEV_LIBS = @UDEV_LIBS@
AIO_LIBS = @AIO_LIBS@
BLKID_CFLAGS = @BLKID_CFLAGS@
BLKID_LIBS = @BLKID_LIBS@
CPG_CFLAGS = @CPG_CFLAGS@
CPG_LIBS = @CPG_LIBS@
EDITLINE_CFLAGS = @EDITLINE_CFLAGS@
EDITLINE_LIBS = @EDITLINE_LIBS@
PTHREAD_LIBS = @PTHREAD_LIBS@
READLINE_CFLAGS = @READLINE_CFLAGS@
READLINE_LIBS = @READLINE_LIBS@
SELINUX_LIBS = @SELINUX_LIBS@
SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@
SYSTEMD_LIBS = @SYSTEMD_LIBS@
UDEV_CFLAGS = @UDEV_CFLAGS@
UDEV_LIBS = @UDEV_LIBS@
VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
USE_TRACKING = @USE_TRACKING@
VALGRIND_LIBS = @VALGRIND_LIBS@
# Setup directory variables
prefix = @prefix@
@ -121,7 +128,7 @@ systemd_generator_dir = $(DESTDIR)$(SYSTEMD_GENERATOR_DIR)
systemd_dir = $(DESTDIR)@systemdutildir@
tmpfiles_dir = $(DESTDIR)@tmpfilesdir@
ocf_scriptdir = $(DESTDIR)@OCFDIR@
pythonprefix = $(DESTDIR)$(prefix)
PYTHON_PREFIX = $(DESTDIR)$(prefix)
# N.B. No $(DESTDIR) prefix here.
python2dir = @PYTHON2DIR@

View File

@ -51,6 +51,8 @@ pvscan \(em List all physical volumes
\fB-j\fP|\fB--major\fP \fINumber\fP
.br
\fB--minor\fP \fINumber\fP
.br
\fB--nohints\fP
.br
\fB--nolocking\fP
.br

View File

@ -54,7 +54,12 @@ $(UNIT_TARGET): $(UNIT_OBJECTS) $(LVMINTERNAL_LIBS)
unit-test: $(UNIT_TARGET)
run-unit-test: $(UNIT_TARGET)
@echo "Running unit tests"
LD_LIBRARY_PATH=$(top_builddir)/libdm $(UNIT_TARGET) run
test -n "$$LVM_TEST_DIR" || LVM_TEST_DIR=$${TMPDIR:-/tmp} ;\
TESTDIR=$$(mktemp -d -t -p "$$LVM_TEST_DIR" "LVMTEST.XXXXXXXXXX") ;\
cd "$$TESTDIR" ;\
LD_LIBRARY_PATH=$(abs_top_builddir)/libdm:$(abs_top_builddir)/daemons/dmeventd $(abs_top_builddir)/$(UNIT_TARGET) run ;\
cd $$OLDPWD ;\
$(RM) -r "$${TESTDIR:?}"
ifeq ("$(DEPENDS)","yes")
-include $(UNIT_SOURCE:%.c=%.d)

View File

@ -49,31 +49,39 @@ static uint64_t byte(block_address b, uint64_t offset)
static void *_fix_init(struct io_engine *engine)
{
uint8_t buffer[T_BLOCK_SIZE];
struct fixture *f = malloc(sizeof(*f));
unsigned b, i;
struct statvfs fsdata = { 0 };
uint8_t buffer[T_BLOCK_SIZE];
struct fixture *f = malloc(sizeof(*f));
unsigned b, i;
static int _runs_is_tmpfs = -1;
memset(buffer, 0, sizeof(buffer));
T_ASSERT(f);
if (_runs_is_tmpfs == -1) {
// With testing in tmpfs directory O_DIRECT cannot be used
// tmpfs has f_fsid == 0 (unsure if this is best guess)
_runs_is_tmpfs = (statvfs(".", &fsdata) == 0 && !fsdata.f_fsid) ? 1 : 0;
if (_runs_is_tmpfs)
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
/* coverity[secure_temp] don't care */
f->fd = mkstemp(f->fname);
T_ASSERT(f->fd >= 0);
(void) close(f->fd);
// test if we can reopen with O_DIRECT
if ((f->fd = open(f->fname, O_RDWR | O_DIRECT)) >= 0) {
_runs_is_tmpfs = 0;
(void) close(f->fd);
} else {
_runs_is_tmpfs = 1; // likely running on tmpfs
printf(" Running test in tmpfs, *NOT* using O_DIRECT\n");
}
(void) unlink(f->fname);
}
T_ASSERT(f);
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
snprintf(f->fname, sizeof(f->fname), "unit-test-XXXXXX");
/* coverity[secure_temp] don't care */
f->fd = mkstemp(f->fname);
T_ASSERT(f->fd >= 0);
for (b = 0; b < NR_BLOCKS; b++) {
for (i = 0; i < sizeof(buffer); i++)
buffer[i] = _pattern_at(INIT_PATTERN, byte(b, i));
for (i = 0; i < sizeof(buffer); i++)
buffer[i] = _pattern_at(INIT_PATTERN, byte(b, i));
T_ASSERT(write(f->fd, buffer, T_BLOCK_SIZE) > 0);
}
@ -89,7 +97,7 @@ static void *_fix_init(struct io_engine *engine)
f->di = bcache_set_fd(f->fd);
return f;
return f;
}
static void *_async_init(void)

View File

@ -353,7 +353,7 @@ static void _lookup_file_remove(char *vgname)
log_debug("Unlink pvs_lookup: %s", path);
if (unlink(path))
if (unlink(path) && (errno != ENOENT))
log_sys_debug("unlink", path);
}
@ -374,7 +374,7 @@ void online_vg_file_remove(const char *vgname)
log_debug("Unlink vg online: %s", path);
if (unlink(path))
if (unlink(path) && (errno != ENOENT))
log_sys_debug("unlink", path);
}
@ -414,7 +414,7 @@ static void _online_pvid_file_remove_devno(int major, int minor)
if ((file_major == major) && (file_minor == minor)) {
log_debug("Unlink pv online %s", path);
if (unlink(path))
if (unlink(path) && (errno != ENOENT))
log_sys_debug("unlink", path);
if (file_vgname[0]) {
@ -442,7 +442,7 @@ static void _online_files_remove(const char *dirpath)
memset(path, 0, sizeof(path));
snprintf(path, sizeof(path), "%s/%s", dirpath, de->d_name);
if (unlink(path))
if (unlink(path) && (errno != ENOENT))
log_sys_debug("unlink", path);
}
if (closedir(dir))
@ -834,7 +834,7 @@ static int _pvscan_aa_single(struct cmd_context *cmd, const char *vg_name,
log_debug("pvscan autoactivating VG %s.", vg_name);
if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
if (!vgchange_activate(cmd, vg, CHANGE_AAY, 1)) {
log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@ -943,11 +943,21 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, const char *vgname,
devno = MKDEV(file_major, file_minor);
if (!setup_devno_in_dev_cache(cmd, devno)) {
log_error_pvscan(cmd, "No device set up for %d:%d PVID %s", file_major, file_minor, pvid);
goto bad;
}
if (!(dev = dev_cache_get_by_devt(cmd, devno, NULL, NULL))) {
log_error_pvscan(cmd, "No device found for %d:%d PVID %s", file_major, file_minor, pvid);
goto bad;
}
/*
* Do not need to match device_id here, see comment after
* get_devs_from_saved_vg about relying on pvid online file.
*/
name1 = dev_name(dev);
name2 = pvl->pv->device_hint;
@ -1112,7 +1122,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
log_debug("pvscan autoactivating VG %s.", vgname);
if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
if (!vgchange_activate(cmd, vg, CHANGE_AAY, 1)) {
log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@ -1278,11 +1288,15 @@ static int _get_args_devs(struct cmd_context *cmd, struct dm_list *pvscan_args,
/* in common usage, no dev will be found for a devno */
dm_list_iterate_items(arg, pvscan_args) {
if (arg->devname)
if (arg->devname) {
if (!setup_devname_in_dev_cache(cmd, arg->devname))
log_error_pvscan(cmd, "No device set up for name arg %s", arg->devname);
arg->dev = dev_cache_get(cmd, arg->devname, NULL);
else if (arg->devno)
} else if (arg->devno) {
if (!setup_devno_in_dev_cache(cmd, arg->devno))
log_error_pvscan(cmd, "No device set up for devno arg %d", (int)arg->devno);
arg->dev = dev_cache_get_by_devt(cmd, arg->devno, NULL, NULL);
else
} else
return_0;
}
@ -1381,7 +1395,7 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
int pvs_online;
int pvs_offline;
int pvs_unknown;
int vg_complete;
int vg_complete = 0;
int do_full_check;
int ret = 1;
@ -1758,11 +1772,13 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
cmd->pvscan_cache_single = 1;
/*
* "no_file_match" means that when the devices file is used,
* setup_devices will skip matching devs to devices file entries.
* Specific devs must be matched later with device_ids_match_dev().
* Special pvscan-specific setup steps to avoid looking
* at any devices except for device args.
* Read devices file and determine if devices file will be used.
* Does not do dev_cache_scan (adds nothing to dev-cache), and
* does not do any device id matching.
*/
if (!setup_devices_no_file_match(cmd)) {
if (!setup_devices_for_pvscan_cache(cmd)) {
log_error_pvscan(cmd, "Failed to set up devices.");
return 0;
}
@ -1821,17 +1837,21 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
log_debug("pvscan_cache_args: filter devs nodata");
/*
* Match dev args with the devices file because
* setup_devices_no_file_match() was used above which skipped checking
* the devices file. If a match fails here do not exclude it, that
* will be done below by passes_filter() which runs filter-deviceid.
* The relax_deviceid_filter case needs to be able to work around
* Match dev args with the devices file because special/optimized
* device setup was used above which does not check the devices file.
* If a match fails here do not exclude it, that will be done below by
* passes_filter() which runs filter-deviceid. The
* relax_deviceid_filter case needs to be able to work around
* unmatching devs.
*/
if (cmd->enable_devices_file) {
dm_list_iterate_items_safe(devl, devl2, &pvscan_devs)
dm_list_iterate_items(devl, &pvscan_devs)
device_ids_match_dev(cmd, devl->dev);
}
if (cmd->enable_devices_list)
device_ids_match_device_list(cmd);
if (cmd->enable_devices_file && device_ids_use_devname(cmd)) {
relax_deviceid_filter = 1;

View File

@ -828,7 +828,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
* user may want to take charge of activation changes to the VG
* and not have the system autoactivation interfere.
*/
if (!is_change_activating(activate) && find_config_tree_bool(cmd, global_event_activation_CFG, NULL))
if (!is_change_activating(activate) && cmd->event_activation)
online_vg_file_remove(lv->vg->name);
set_lv_notify(lv->vg->cmd);
@ -1481,7 +1481,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
/*
* add info to lvmcache from the duplicate dev.
*/
label_scan_dev(devl->dev);
label_scan_dev(cmd, devl->dev);
/*
* the info/label should now be found because
@ -3882,63 +3882,6 @@ static int _get_arg_devices(struct cmd_context *cmd,
return ret_max;
}
static int _get_all_devices(struct cmd_context *cmd,
int process_all_devices,
struct dm_list *all_devices)
{
struct dev_iter *iter;
struct device *dev;
struct device_id_list *dil;
struct hint *hint;
int r = ECMD_FAILED;
/*
* If command is using hints and is only looking for PVs
* (not all devices), then we can use only devs from hints.
*/
if (!process_all_devices && !dm_list_empty(&cmd->hints)) {
log_debug("Getting list of all devices from hints");
dm_list_iterate_items(hint, &cmd->hints) {
if (!(dev = dev_cache_get(cmd, hint->name, NULL)))
continue;
if (!(dil = dm_pool_zalloc(cmd->mem, sizeof(*dil)))) {
log_error("device_id_list alloc failed.");
return ECMD_FAILED;
}
memcpy(dil->pvid, hint->pvid, ID_LEN);
dil->dev = dev;
dm_list_add(all_devices, &dil->list);
}
return ECMD_PROCESSED;
}
log_debug("Getting list of all devices from system");
if (!(iter = dev_iter_create(cmd->filter, 1))) {
log_error("dev_iter creation failed.");
return ECMD_FAILED;
}
while ((dev = dev_iter_get(cmd, iter))) {
if (!(dil = dm_pool_zalloc(cmd->mem, sizeof(*dil)))) {
log_error("device_id_list alloc failed.");
goto out;
}
memcpy(dil->pvid, dev->pvid, ID_LEN);
dil->dev = dev;
dm_list_add(all_devices, &dil->list);
}
r = ECMD_PROCESSED;
out:
dev_iter_destroy(iter);
return r;
}
static int _device_list_remove(struct dm_list *devices, struct device *dev)
{
struct device_id_list *dil;
@ -3965,47 +3908,66 @@ static struct device_id_list *_device_list_find_dev(struct dm_list *devices, str
return NULL;
}
static int _process_device_list(struct cmd_context *cmd, struct dm_list *all_devices,
/* Process devices that are not PVs. */
static int _process_other_devices(struct cmd_context *cmd,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
struct dev_iter *iter;
struct physical_volume pv_dummy;
struct physical_volume *pv;
struct device_id_list *dil;
int ret_max = ECMD_PROCESSED;
int ret = 0;
struct device *dev;
int failed = 0;
int ret;
log_debug("Processing devices that are not PVs");
/*
* Pretend that each device is a PV with dummy values.
* FIXME Formalise this extension or find an alternative.
* We want devices here that passed filters during
* label_scan but were found to not be PVs.
*
* No filtering used in iter, DEV_SCAN_FOUND_NOLABEL
* was set by label_scan which did filtering.
*/
dm_list_iterate_items(dil, all_devices) {
if (sigint_caught())
return_ECMD_FAILED;
if (!(iter = dev_iter_create(NULL, 0)))
return_0;
while ((dev = dev_iter_get(cmd, iter))) {
if (sigint_caught()) {
failed = 1;
break;
}
if (!(dev->flags & DEV_SCAN_FOUND_NOLABEL))
continue;
/*
* Pretend that each device is a PV with dummy values.
* FIXME Formalise this extension or find an alternative.
*/
memset(&pv_dummy, 0, sizeof(pv_dummy));
dm_list_init(&pv_dummy.tags);
dm_list_init(&pv_dummy.segments);
pv_dummy.dev = dil->dev;
pv_dummy.dev = dev;
pv = &pv_dummy;
log_very_verbose("Processing device %s.", dev_name(dil->dev));
log_very_verbose("Processing device %s.", dev_name(dev));
ret = process_single_pv(cmd, NULL, pv, handle);
if (ret > ret_max)
ret_max = ret;
if (ret != ECMD_PROCESSED)
failed = 1;
}
dev_iter_destroy(iter);
return ECMD_PROCESSED;
return failed ? 0 : 1;
}
static int _process_duplicate_pvs(struct cmd_context *cmd,
struct dm_list *all_devices,
struct dm_list *arg_devices,
int process_all_devices,
int process_other_devices,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
@ -4015,8 +3977,8 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
struct lvmcache_info *info;
const char *vgname;
const char *vgid;
int ret_max = ECMD_PROCESSED;
int ret = 0;
int failed = 0;
int ret;
struct physical_volume dummy_pv = {
.pe_size = 1,
@ -4045,20 +4007,15 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
dm_list_init(&unused_duplicate_devs);
if (!lvmcache_get_unused_duplicates(cmd, &unused_duplicate_devs))
return_ECMD_FAILED;
return_0;
dm_list_iterate_items(devl, &unused_duplicate_devs) {
/* Duplicates are displayed if -a is used or the dev is named as an arg. */
_device_list_remove(all_devices, devl->dev);
if (!process_all_devices && dm_list_empty(arg_devices))
continue;
if ((dil = _device_list_find_dev(arg_devices, devl->dev)))
_device_list_remove(arg_devices, devl->dev);
if (!process_all_devices && !dil)
if (!process_other_devices && !dil)
continue;
if (!(cmd->cname->flags & ENABLE_DUPLICATE_DEVS))
@ -4087,7 +4044,7 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
*/
if (!(info = lvmcache_info_from_pvid(devl->dev->pvid, NULL, 0))) {
log_error(INTERNAL_ERROR "No info for pvid");
return ECMD_FAILED;
return 0;
}
vgname = lvmcache_vgname_from_info(info);
@ -4103,47 +4060,39 @@ static int _process_duplicate_pvs(struct cmd_context *cmd,
memset(&dummy_vg.id, 0, sizeof(dummy_vg.id));
ret = process_single_pv(cmd, &dummy_vg, &dummy_pv, handle);
if (ret > ret_max)
ret_max = ret;
if (ret != ECMD_PROCESSED)
failed = 1;
if (sigint_caught())
return_ECMD_FAILED;
return_0;
}
return ECMD_PROCESSED;
return failed ? 0 : 1;
}
static int _process_pvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg,
struct dm_list *all_devices,
struct dm_list *arg_devices,
struct dm_list *arg_tags,
int process_all_pvs,
int process_all_devices,
int skip,
uint32_t error_flags,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
log_report_t saved_log_report_state = log_get_report_state();
char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
char pv_uuid[64] __attribute__((aligned(8)));
char vg_uuid[64] __attribute__((aligned(8)));
int handle_supplied = handle != NULL;
struct physical_volume *pv;
struct pv_list *pvl;
struct device_id_list *dil;
struct device_list *devl;
struct dm_list outdated_devs;
const char *pv_name;
int process_pv;
int do_report_ret_code = 1;
int ret_max = ECMD_PROCESSED;
int ret = 0;
dm_list_init(&outdated_devs);
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_PV);
vg_uuid[0] = '\0';
@ -4221,18 +4170,6 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
else
log_very_verbose("Processing PV %s in VG %s.", pv_name, vg->name);
_device_list_remove(all_devices, pv->dev);
/*
* pv->dev should be found in all_devices unless it's a
* case of a "missing device". Previously there have
* been cases where we needed to skip processing the PV
* if pv->dev was not found in all_devices to avoid
* processing a PV twice, i.e. when the PV had no MDAs
* it would be seen once in its real VG and again
* wrongly in the orphan VG. This no longer happens.
*/
if (!skip) {
ret = process_single_pv(cmd, vg, pv, handle);
if (ret != ECMD_PROCESSED)
@ -4252,13 +4189,6 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
log_set_report_object_name_and_id(NULL, NULL);
}
if (!is_orphan_vg(vg->name)) {
memcpy(vgid, &vg->id, ID_LEN);
lvmcache_get_outdated_devs(cmd, vg->name, vgid, &outdated_devs);
}
dm_list_iterate_items(devl, &outdated_devs)
_device_list_remove(all_devices, devl->dev);
do_report_ret_code = 0;
out:
if (do_report_ret_code)
@ -4278,18 +4208,15 @@ out:
* arg_devices and arg_tags are empty, then process all PVs.
* No PV should be processed more than once.
*
* Each PV is removed from arg_devices and all_devices when it is
* processed. Any names remaining in arg_devices were not found, and
* should produce an error. Any devices remaining in all_devices were
* not found and should be processed by process_device_list().
* Each PV is removed from arg_devices when it is processed.
* Any names remaining in arg_devices were not found, and
* should produce an error.
*/
static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t read_flags,
struct dm_list *all_vgnameids,
struct dm_list *all_devices,
struct dm_list *arg_devices,
struct dm_list *arg_tags,
int process_all_pvs,
int process_all_devices,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
@ -4358,8 +4285,8 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t read_flags,
* error_vg->pvs entries from devices list.
*/
ret = _process_pvs_in_vg(cmd, vg ? vg : error_vg, all_devices, arg_devices, arg_tags,
process_all_pvs, process_all_devices, skip, error_flags,
ret = _process_pvs_in_vg(cmd, vg ? vg : error_vg, arg_devices, arg_tags,
process_all_pvs, skip, error_flags,
handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
@ -4405,10 +4332,9 @@ int process_each_pv(struct cmd_context *cmd,
struct dm_list arg_pvnames; /* str_list */
struct dm_list arg_devices; /* device_id_list */
struct dm_list all_vgnameids; /* vgnameid_list */
struct dm_list all_devices; /* device_id_list */
struct device_id_list *dil;
int process_all_pvs;
int process_all_devices;
int process_other_devices;
int ret_max = ECMD_PROCESSED;
int ret;
@ -4435,7 +4361,6 @@ int process_each_pv(struct cmd_context *cmd,
dm_list_init(&arg_pvnames);
dm_list_init(&arg_devices);
dm_list_init(&all_vgnameids);
dm_list_init(&all_devices);
/*
* Create two lists from argv:
@ -4457,7 +4382,7 @@ int process_each_pv(struct cmd_context *cmd,
process_all_pvs = dm_list_empty(&arg_pvnames) && dm_list_empty(&arg_tags);
process_all_devices = process_all_pvs && (cmd->cname->flags & ENABLE_ALL_DEVS) && all_is_set;
process_other_devices = process_all_pvs && (cmd->cname->flags & ENABLE_ALL_DEVS) && all_is_set;
/* Needed for a current listing of the global VG namespace. */
if (!only_this_vgname && !lock_global(cmd, "sh")) {
@ -4473,16 +4398,6 @@ int process_each_pv(struct cmd_context *cmd,
goto_out;
}
/*
* If the caller wants to process all devices (not just PVs), then all PVs
* from all VGs are processed first, removing them from all_devices. Then
* any devs remaining in all_devices are processed.
*/
if ((ret = _get_all_devices(cmd, process_all_devices, &all_devices)) != ECMD_PROCESSED) {
ret_max = ret;
goto_out;
}
if ((ret = _get_arg_devices(cmd, &arg_pvnames, &arg_devices)) != ECMD_PROCESSED) {
/* get_arg_devices reports EINIT_FAILED for any PV names not found. */
ret_max = ret;
@ -4491,9 +4406,8 @@ int process_each_pv(struct cmd_context *cmd,
ret_max = ECMD_FAILED; /* but ATM we've returned FAILED for all cases */
}
ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids, &all_devices,
&arg_devices, &arg_tags,
process_all_pvs, process_all_devices,
ret = _process_pvs_in_vgs(cmd, read_flags, &all_vgnameids,
&arg_devices, &arg_tags, process_all_pvs,
handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
@ -4501,58 +4415,29 @@ int process_each_pv(struct cmd_context *cmd,
ret_max = ret;
/*
* Process the list of unused duplicate devs so they can be shown by
* report/display commands. These are the devices that were not chosen
* to be used in lvmcache because another device with the same PVID was
* preferred. The unused duplicate devs are not seen by
* _process_pvs_in_vgs, which only sees the preferred device for the
* PVID.
*
* The main purpose in reporting/displaying the unused duplicate PVs
* here is so that they do not appear to be unused/free devices or
* orphans.
*
* We do not allow modifying the unused duplicate PVs. To modify a
* non-preferred duplicate PV, e.g. pvchange -u, a filter needs to be
* used with the command to exclude the other devices with the same
* PVID. This results in the command seeing only the one device with
* the PVID and allows it to be changed. (If the duplicates actually
* represent the same underlying storage, these precautions are
* unnecessary, but lvm can't tell when the duplicates are different
* paths to the same storage or different underlying storage.)
*
* Even the preferred duplicate PV in lvmcache is limitted from being
* modified (by allow_changes_with_duplicate_pvs setting), because lvm
* cannot be sure that the preferred duplicate device is the correct one,
* e.g. if a VG has two PVs, and both PVs are cloned, lvm might prefer
* one of the original PVs and one of the cloned PVs, pairing them
* together as the VG. Any changes on the VG or PVs in that state would
* end up changing one of the original PVs and one of the cloned PVs.
*
* vgimportclone of the two cloned PVs changes their PV UUIDs and gives
* them a new VG name.
* Process the list of unused duplicate devs to display duplicate PVs
* in two cases: 1. pvs -a (which has traditionally included duplicate
* PVs in addition to the expected non-PV devices), 2. pvs <devname>
* (duplicate dev is named on the command line.)
*/
ret = _process_duplicate_pvs(cmd, &all_devices, &arg_devices, process_all_devices,
handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
if (ret > ret_max)
ret_max = ret;
if (process_other_devices || !dm_list_empty(&arg_devices)) {
if (!_process_duplicate_pvs(cmd, &arg_devices, process_other_devices, handle, process_single_pv))
ret_max = ECMD_FAILED;
}
dm_list_iterate_items(dil, &arg_devices) {
log_error("Failed to find physical volume \"%s\".", dev_name(dil->dev));
ret_max = ECMD_FAILED;
}
if (!process_all_devices)
goto out;
/*
* pvs -a and pvdisplay -a want to show devices that are not PVs.
*/
if (process_other_devices) {
if (!_process_other_devices(cmd, handle, process_single_pv))
ret_max = ECMD_FAILED;
}
ret = _process_device_list(cmd, &all_devices, handle, process_single_pv);
if (ret != ECMD_PROCESSED)
stack;
if (ret > ret_max)
ret_max = ret;
out:
log_restore_report_state(saved_log_report_state);
return ret_max;
@ -5871,19 +5756,48 @@ int get_event_activation_config_settings(struct cmd_context *cmd,
return 1;
}
int get_event_activation_command_options(struct cmd_context *cmd, const char *ea, int *ea_service, int *ea_event, int *ea_on)
static int _ea_option_value(const char *val, int *ea_service, int *ea_event, int *ea_on)
{
if (strstr(ea, "service"))
if (!strcmp(val, "service"))
*ea_service = 1;
if (strstr(ea, "event"))
else if (!strcmp(val, "event"))
*ea_event = 1;
if (strstr(ea, "on"))
else if (!strcmp(val, "on"))
*ea_on = 1;
if (*ea_service && *ea_event) {
log_error("Invalid --eventactivation options, service and event are incompatible.");
else {
log_error("Unknown --eventactivation value.");
return 0;
}
return 1;
}
int get_event_activation_command_options(struct cmd_context *cmd, const char *ea, int *ea_service, int *ea_event, int *ea_on)
{
char ea_vals[128] = {0};
char *val1, *val2;
strncpy(ea_vals, ea, 127);
/* Currently only two values can be used together. */
val1 = ea_vals;
if ((val2 = strchr(ea_vals, ','))) {
*val2 = '\0';
val2++;
}
if (val1 && !_ea_option_value(val1, ea_service, ea_event, ea_on))
return 0;
if (val2 && !_ea_option_value(val2, ea_service, ea_event, ea_on))
return 0;
if (*ea_service && *ea_event) {
log_error("Invalid --eventactivation options, service and event are incompatible.");
return 0;
}
return 1;
}

View File

@ -226,9 +226,8 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv, unsigned
int mirror_remove_missing(struct cmd_context *cmd,
struct logical_volume *lv, int force);
int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
activation_change_t activate);
activation_change_t activate, int vg_complete_to_activate);
int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg);

View File

@ -19,6 +19,7 @@
struct vgchange_params {
int lock_start_count;
unsigned int lock_start_sanlock : 1;
unsigned int vg_complete_to_activate : 1;
};
/*
@ -230,10 +231,11 @@ static int _online_pvid_file_create_all(struct cmd_context *cmd)
}
int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
activation_change_t activate)
activation_change_t activate, int vg_complete_to_activate)
{
int lv_open, active, monitored = 0, r = 1;
const struct lv_list *lvl;
struct pv_list *pvl;
int do_activate = is_change_activating(activate);
/*
@ -259,6 +261,15 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
if (do_activate && vg_complete_to_activate) {
dm_list_iterate_items(pvl, &vg->pvs) {
if (!pvl->pv->dev) {
log_print("VG %s is incomplete.", vg->name);
return 1;
}
}
}
/*
* Safe, since we never write out new metadata here. Required for
* partial activation to work.
@ -687,6 +698,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
struct processing_handle *handle)
{
struct vgchange_params *vp = (struct vgchange_params *)handle->custom_handle;
int ret = ECMD_PROCESSED;
unsigned i;
activation_change_t activate;
@ -744,7 +756,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (arg_is_set(cmd, activate_ARG)) {
activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, 0);
if (!vgchange_activate(cmd, vg, activate))
if (!vgchange_activate(cmd, vg, activate, vp->vg_complete_to_activate))
return_ECMD_FAILED;
} else if (arg_is_set(cmd, refresh_ARG)) {
/* refreshes the visible LVs (which starts polling) */
@ -765,7 +777,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
return ret;
}
static int _check_event_activation(struct cmd_context *cmd, int *skip_command, int *enable_events)
static int _check_event_activation(struct cmd_context *cmd, struct vgchange_params *vp, int *skip_command, int *enable_events)
{
const char *ea;
int service_only = 0, event_only = 0, service_to_event = 0;
@ -858,11 +870,20 @@ static int _check_event_activation(struct cmd_context *cmd, int *skip_command, i
*enable_events = 1;
}
/*
* lvm.conf service_to_event, and vgchange -aay --eventactivation service,
* then only activate LVs if the VG is complete.
* A later event will complete the VG and activate it.
*/
if (event_activation && service_to_event && ea_service)
vp->vg_complete_to_activate = 1;
return 1;
}
int vgchange(struct cmd_context *cmd, int argc, char **argv)
{
struct vgchange_params vp = { 0 };
struct processing_handle *handle;
uint32_t flags = 0;
int ret;
@ -978,7 +999,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, eventactivation_ARG)) {
int skip_command = 0, enable_events = 0;
if (!_check_event_activation(cmd, &skip_command, &enable_events))
if (!_check_event_activation(cmd, &vp, &skip_command, &enable_events))
return ECMD_FAILED;
if (skip_command)
return ECMD_PROCESSED;
@ -1004,6 +1025,8 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
handle->custom_handle = &vp;
ret = process_each_vg(cmd, argc, argv, NULL, NULL, flags, 0, handle, &_vgchange_single);
destroy_processing_handle(cmd, handle);