1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-17 21:44:24 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Petr Rockai
4aaffe0650 lvmetad: Avoid duplicate entries in the list of alternate devices. 2015-04-28 17:25:06 +02:00
325 changed files with 1779 additions and 7489 deletions

View File

@@ -1,6 +1,6 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -15,8 +15,6 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
SUBDIRS = conf daemons include lib libdaemon libdm man scripts tools
@@ -93,41 +91,12 @@ cscope.out:
all: cscope.out
endif
DISTCLEAN_TARGETS += cscope.out
CLEAN_DIRS += autom4te.cache
check check_system check_cluster check_local check_lvmetad unit: all
$(MAKE) -C test $(@)
conf.generate: tools
# how to use parenthesis in makefiles
leftparen:=(
LVM_VER := $(firstword $(subst $(leftparen), ,$(LVM_VERSION)))
VER := LVM2.$(LVM_VER)
# release file name
FILE_VER := $(VER).tgz
CLEAN_TARGETS += $(FILE_VER)
CLEAN_DIRS += $(rpmbuilddir)
dist:
@echo "Generating $(FILE_VER)";\
(cd $(top_srcdir); git ls-tree -r HEAD --name-only | xargs tar --transform "s,^,$(VER)/," -c) | gzip >$(FILE_VER)
rpm: dist
$(RM) -r $(rpmbuilddir)/SOURCES
$(MKDIR_P) $(rpmbuilddir)/SOURCES
$(LN_S) -f $(abs_top_builddir)/$(FILE_VER) $(rpmbuilddir)/SOURCES
$(LN_S) -f $(abs_top_srcdir)/spec/build.inc $(rpmbuilddir)/SOURCES
$(LN_S) -f $(abs_top_srcdir)/spec/macros.inc $(rpmbuilddir)/SOURCES
$(LN_S) -f $(abs_top_srcdir)/spec/packages.inc $(rpmbuilddir)/SOURCES
DM_VER=$$(cut -d- -f1 $(top_srcdir)/VERSION_DM);\
GIT_VER=$$(cd $(top_srcdir); git describe | cut -d- --output-delimiter=. -f2,3 || echo 0);\
sed -e "s,\(device_mapper_version\) [0-9.]*$$,\1 $$DM_VER," \
-e "s,^\(Version:[^0-9%]*\)[0-9.]*$$,\1 $(LVM_VER)," \
-e "s,^\(Release:[^0-9%]*\)[0-9.]\+,\1 $$GIT_VER," \
$(top_srcdir)/spec/source.inc >$(rpmbuilddir)/SOURCES/source.inc
rpmbuild -v --define "_topdir $(rpmbuilddir)" -ba $(top_srcdir)/spec/lvm2.spec
generate: conf.generate
$(MAKE) -C conf generate

View File

@@ -1 +1 @@
2.02.120(2)-git (2015-05-15)
2.02.119(2)-git (2015-03-24)

View File

@@ -1 +1 @@
1.02.97-git (2015-05-15)
1.02.96-git (2015-03-24)

View File

@@ -1,46 +1,5 @@
Version 2.02.120 - 15th May 2015
================================
Make various adjustments to Makefile compilation flags.
Add lvmpolld debug message class.
Add lvmpolld client mode for querying running server instance for status info.
Fix some libdaemon socket creation and reuse error paths.
Daemons (libdaemon) support exit on idle also in non-systemd environment.
Provide make dist and make rpm targets
Configure lvm.conf for use_lvmetad and use_lvmpolld.
Add lvpoll for cmdline communication with lvmpolld.
Add lvmpolld acting as a free-standing version of polldaemon.
Avoid repeated identical lvmetad VG lookups in commands processing all VGs.
Handle switches to alternative duplicate PVs efficiently with lvmetad.
Properly validate PV size for pvcreate --restorefile.
Fix check if pvcreate wiped device (2.02.117).
Fix storing of vgid when caching metadata (2.02.118).
Fix recursive lvm-config man page. (2.02.119)
Refactor polldaemon interfaces to poll every operation by VG/LV couple
Skip wait after testing in _wait_for_single_lv when polling finished
Return 'None' in python for empty string properties instead of crashing.
Distinguish signed numerical property type in reports for lvm2app library.
Reread raid completion status immediately when progress appears to be zero.
lvm2app closes locking on lvm_quit().
Configure detects /run or /var/run.
Add missing newline in clvmd --help output.
Version 2.02.119 - 2nd May 2015
===============================
New LVM_LOG_FILE_EPOCH, LVM_EXPECTED_EXIT_STATUS env vars. Man page to follow.
Remove detailed content from lvm.conf man page: use lvmconfig instead.
Generate complete config files with lvmconfig or 'make generate'.
Also display info on deprecated config with lvmconfig --withcomments.
Display version since which config is deprecated in lvmconfig --withversions.
Add --showdeprecated to lvmconfig to also display deprecated settings.
Hide deprecated settings in lvmconfig output for all types but current,diff.
Introduce support for exit on idle feature in libdaemon
Add --showunsupported to lvmconfig to also display unsupported settings.
Display unsupported settings for lvmconfig --type current,diff only by default
Honour lvmconfig --ignoreunsupported and --ignoreadvanced for all --type.
Make python bindings usable with python3 (and compatible with 2.6 & 2.7).
Add lvmconfig -l|--list as shortcut for lvmconfig --type list --withsummary.
Add lvmconfig --type list to display plain list of configuration settings.
Introduce lvmconfig as the preferred form of 'lvm dumpconfig'.
Version 2.02.119 -
==================================
Add lv_ancestors and lv_descendants reporting fields.
Add --ignorelocal option to dumpconfig to ignore the local section.
Close connection to lvmetad after fork.
@@ -48,26 +7,19 @@ Version 2.02.119 - 2nd May 2015
Split pvmove update metadata fn in an initial one and a subsequent one.
Refactor shared pvmove and lvconvert code into new _poll files.
Add --unconfigured option to dumpconfig to print strings unconfigured.
Add --withsummary option to dumpconfig to print first line - summary comment.
Use number of device holders to help choose between duplicate PVs.
Try to make lvmetad and non-lvmetad duplicate PV handling as similar as poss.
Issue warnings about duplicate PVs discovered by lvmetad.
Track alternative devices with matching PVIDs in lvmetad.
Add --withfullcomments option to dumpconfig to print full comment.
Check for lvm binary in blkdeactivate and skip LVM processing if not present.
Add --enable-halvm and --disable-halvm options to lvmconf script.
Add --services, --mirrorservice and --startstopservices option to lvmconf.
Use proper default value of global/use_lvmetad when processing lvmconf script.
Respect allocation/cling_tag_list during intial contiguous allocation.
Add A_PARTITION_BY_TAGS set when allocated areas should not share tags.
Make changes persist with python addTag/removeTag.
Set correct vgid when updating cache when writing PV metadata.
More efficient clvmd singlenode locking emulation.
Reject lvcreate -m with raid4/5/6 to avoid unexpected layout.
Don't skip invalidation of cached orphans if vg write lck is held (2.02.118).
Log relevant PV tags when using cling allocation.
Add str_list_add_list() to combine two lists.
Fix LV processing with selection to always do the selection on initial state.
Add internal LV_REMOVED LV status flag.
Version 2.02.118 - 23rd March 2015
==================================

View File

@@ -1,10 +1,5 @@
Version 1.02.97 - 15th May 2015
===============================
New dm_task_get_info(DM_1_02_97) supports internal_suspend state.
New symbols are versioned and comes with versioned symbol name (DM_1_02_97).
Version 1.02.96 - 2nd May 2015
==============================
Version 1.02.96 -
=================================
Fix selection to not match if using reserved value in criteria with >,<,>=,<.
Fix selection to not match reserved values for size fields if using >,<,>=,<.
Include uuid or device number in log message after ioctl failure.

View File

@@ -27,8 +27,8 @@ include $(top_builddir)/make.tmpl
.PHONY: install_conf install_localconf install_profiles
generate:
(cat $(top_srcdir)/conf/example.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withcomments --ignorelocal) > example.conf.in
(cat $(top_srcdir)/conf/lvmlocal.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withcomments local) > lvmlocal.conf.in
(cat $(top_srcdir)/conf/example.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments --ignorelocal) > example.conf.in
(cat $(top_srcdir)/conf/lvmlocal.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments local) > lvmlocal.conf.in
install_conf: $(CONFSRC)
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \

View File

@@ -4,17 +4,6 @@
#
# Refer to 'man lvm.conf' for further information including the file layout.
#
# Refer to 'man lvm.conf' for information about how settings configured in
# this file are combined with built-in values and command line options to
# arrive at the final values used by LVM.
#
# Refer to 'man lvmconfig' for information about displaying the built-in
# and configured values used by LVM.
#
# If a default value is set in this file (not commented out), then a
# new version of LVM using this file will continue using that value,
# even if the new version of LVM changes the built-in default value.
#
# To put this file in a different directory and override @DEFAULT_SYS_DIR@ set
# the environment variable LVM_SYSTEM_DIR before running the tools.
#

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,7 @@ local {
# Set the system_id to the string 'host1'.
# system_id = "host1"
# This configuration option does not have a default value defined.
# system_id=""
# system_id=""
# Configuration option local/extra_system_ids.
# A list of extra VG system IDs the local host can access.
@@ -49,5 +49,5 @@ local {
# Use this only after consulting 'man lvmsystemid'
# to be certain of correct usage and possible dangers.
# This configuration option does not have a default value defined.
# extra_system_ids=[]
# extra_system_ids=[]
}

143
configure vendored
View File

@@ -636,7 +636,6 @@ kerneldir
interface
CMIRRORD_PIDFILE
CLVMD_PIDFILE
LVMPOLLD_PIDFILE
LVMETAD_PIDFILE
DMEVENTD_PIDFILE
WRITE_INSTALL
@@ -700,8 +699,6 @@ DMEVENTD_PATH
DMEVENTD
DL_LIBS
DEVMAPPER
DEFAULT_USE_LVMPOLLD
DEFAULT_USE_LVMETAD
DEFAULT_SYS_DIR
DEFAULT_SPARSE_SEGTYPE
DEFAULT_RUN_DIR
@@ -727,7 +724,6 @@ CLDWHOLEARCHIVE
CLDNOWHOLEARCHIVE
CLDFLAGS
CACHE
BUILD_LVMPOLLD
BUILD_LVMETAD
BUILD_DMEVENTD
BUILD_CMIRRORD
@@ -917,11 +913,7 @@ enable_testing
enable_valgrind_pool
enable_devmapper
enable_lvmetad
enable_use_lvmetad
with_lvmetad_pidfile
enable_lvmpolld
enable_use_lvmpolld
with_lvmpolld_pidfile
enable_blkid_wiping
enable_udev_systemd_background_jobs
enable_udev_sync
@@ -1635,9 +1627,6 @@ Optional Features:
--enable-valgrind-pool enable valgrind awareness of pools
--disable-devmapper disable LVM2 device-mapper interaction
--enable-lvmetad enable the LVM Metadata Daemon
--disable-use-lvmetad disable usage of LVM Metadata Daemon
--enable-lvmpolld enable the LVM Polling Daemon
--disable-use-lvmpolld disable usage of LVM Poll Daemon
--disable-blkid_wiping disable libblkid detection of signatures when wiping
and use native code instead
--disable-udev-systemd-background-jobs
@@ -1709,11 +1698,11 @@ Optional Packages:
--with-ocfdir=DIR install OCF files in
[PREFIX/lib/ocf/resource.d/lvm2]
--with-default-pid-dir=PID_DIR
Default directory to keep PID files in. [autodetect]
Default directory to keep PID files in. [/var/run]
--with-default-dm-run-dir=DM_RUN_DIR
Default DM run directory. [autodetect]
Default DM run directory. [/var/run]
--with-default-run-dir=RUN_DIR
Default LVM run directory. [autodetect_run_dir/lvm]
Default LVM run directory. [/var/run/lvm]
--with-clvmd=TYPE build cluster LVM Daemon
The following cluster manager combinations are valid:
* cman (RHEL5 or equivalent)
@@ -1729,8 +1718,6 @@ Optional Packages:
--with-optimisation=OPT C optimisation flag [OPT=-O2]
--with-lvmetad-pidfile=PATH
lvmetad pidfile [PID_DIR/lvmetad.pid]
--with-lvmpolld-pidfile=PATH
lvmpolld pidfile [PID_DIR/lvmpolld.pid]
--with-localedir=DIR translation files in DIR [PREFIX/share/locale]
--with-confdir=DIR configuration files in DIR [/etc]
--with-staticdir=DIR static binaries in DIR [EPREFIX/sbin]
@@ -3033,11 +3020,10 @@ test -n "$target_alias" &&
NONENONEs,x,x, &&
program_prefix=${target_alias}-
if test -z "$CFLAGS"; then :
COPTIMISE_FLAG="-O2"
fi
case "$host_os" in
linux*)
CFLAGS="$CFLAGS"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
ELDFLAGS="-Wl,--export-dynamic"
# FIXME Generate list and use --dynamic-list=.dlopen.sym
@@ -3047,7 +3033,6 @@ case "$host_os" in
LIB_SUFFIX=so
DEVMAPPER=yes
LVMETAD=no
LVMPOLLD=no
ODIRECT=yes
DM_IOCTLS=yes
SELINUX=yes
@@ -3057,6 +3042,7 @@ case "$host_os" in
;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS"
ELDFLAGS=
CLDWHOLEARCHIVE="-all_load"
@@ -3184,8 +3170,6 @@ fi
test -n "$AWK" && break
done
save_CFLAGS=$CFLAGS
save_CXXFLAGS=$CXXFLAGS
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -4232,8 +4216,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
CFLAGS=$save_CFLAGS
CXXFLAGS=$save_CXXFLAGS
ac_ext=c
@@ -8969,19 +8951,13 @@ fi
}
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default run directory" >&5
$as_echo_n "checking for default run directory... " >&6; }
RUN_DIR="/run"
test -d "/run" || RUN_DIR="/var/run"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUN_DIR" >&5
$as_echo "$RUN_DIR" >&6; }
# Check whether --with-default-pid-dir was given.
if test "${with_default_pid_dir+set}" = set; then :
withval=$with_default_pid_dir; DEFAULT_PID_DIR="$withval"
else
DEFAULT_PID_DIR=$RUN_DIR
DEFAULT_PID_DIR="/var/run"
fi
@@ -8996,7 +8972,7 @@ _ACEOF
if test "${with_default_dm_run_dir+set}" = set; then :
withval=$with_default_dm_run_dir; DEFAULT_DM_RUN_DIR="$withval"
else
DEFAULT_DM_RUN_DIR=$RUN_DIR
DEFAULT_DM_RUN_DIR="/var/run"
fi
@@ -9011,7 +8987,7 @@ _ACEOF
if test "${with_default_run_dir+set}" = set; then :
withval=$with_default_run_dir; DEFAULT_RUN_DIR="$withval"
else
DEFAULT_RUN_DIR="$RUN_DIR/lvm"
DEFAULT_RUN_DIR="/var/run/lvm"
fi
@@ -10854,20 +10830,6 @@ $as_echo "$LVMETAD" >&6; }
BUILD_LVMETAD=$LVMETAD
if test "$BUILD_LVMETAD" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking defaults for use_lvmetad" >&5
$as_echo_n "checking defaults for use_lvmetad... " >&6; }
# Check whether --enable-use_lvmetad was given.
if test "${enable_use_lvmetad+set}" = set; then :
enableval=$enable_use_lvmetad; case ${enableval} in
yes) DEFAULT_USE_LVMETAD=1 ;;
*) DEFAULT_USE_LVMETAD=0 ;;
esac
else
DEFAULT_USE_LVMETAD=1
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_USE_LVMETAD" >&5
$as_echo "$DEFAULT_USE_LVMETAD" >&6; }
$as_echo "#define LVMETAD_SUPPORT 1" >>confdefs.h
@@ -10885,69 +10847,8 @@ cat >>confdefs.h <<_ACEOF
#define LVMETAD_PIDFILE "$LVMETAD_PIDFILE"
_ACEOF
else
DEFAULT_USE_LVMETAD=0
fi
cat >>confdefs.h <<_ACEOF
#define DEFAULT_USE_LVMETAD $DEFAULT_USE_LVMETAD
_ACEOF
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build lvmpolld" >&5
$as_echo_n "checking whether to build lvmpolld... " >&6; }
# Check whether --enable-lvmpolld was given.
if test "${enable_lvmpolld+set}" = set; then :
enableval=$enable_lvmpolld; LVMPOLLD=$enableval
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LVMPOLLD" >&5
$as_echo "$LVMPOLLD" >&6; }
BUILD_LVMPOLLD=$LVMPOLLD
if test "$BUILD_LVMPOLLD" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking defaults for use_lvmpolld" >&5
$as_echo_n "checking defaults for use_lvmpolld... " >&6; }
# Check whether --enable-use_lvmpolld was given.
if test "${enable_use_lvmpolld+set}" = set; then :
enableval=$enable_use_lvmpolld; case ${enableval} in
yes) DEFAULT_USE_LVMPOLLD=1 ;;
*) DEFAULT_USE_LVMPOLLD=0 ;;
esac
else
DEFAULT_USE_LVMPOLLD=1
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEFAULT_USE_LVMPOLLD" >&5
$as_echo "$DEFAULT_USE_LVMPOLLD" >&6; }
$as_echo "#define LVMPOLLD_SUPPORT 1" >>confdefs.h
# Check whether --with-lvmpolld-pidfile was given.
if test "${with_lvmpolld_pidfile+set}" = set; then :
withval=$with_lvmpolld_pidfile; LVMPOLLD_PIDFILE=$withval
else
LVMPOLLD_PIDFILE="$DEFAULT_PID_DIR/lvmpolld.pid"
fi
cat >>confdefs.h <<_ACEOF
#define LVMPOLLD_PIDFILE "$LVMPOLLD_PIDFILE"
_ACEOF
else
DEFAULT_USE_LVMPOLLD=0
fi
cat >>confdefs.h <<_ACEOF
#define DEFAULT_USE_LVMPOLLD $DEFAULT_USE_LVMPOLLD
_ACEOF
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libblkid detection of signatures when wiping" >&5
$as_echo_n "checking whether to enable libblkid detection of signatures when wiping... " >&6; }
@@ -13235,17 +13136,13 @@ 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 daemons/lvmpolld/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.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 lib/cache_segtype/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/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_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/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.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 lib/cache_segtype/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/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cluster_activation_red_hat.sh scripts/lvm2_cluster_activation_systemd_red_hat.service scripts/lvm2_clvmd_systemd_red_hat.service scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -13954,7 +13851,6 @@ do
"daemons/dmeventd/plugins/snapshot/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/plugins/snapshot/Makefile" ;;
"daemons/dmeventd/plugins/thin/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/plugins/thin/Makefile" ;;
"daemons/lvmetad/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/lvmetad/Makefile" ;;
"daemons/lvmpolld/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/lvmpolld/Makefile" ;;
"conf/Makefile") CONFIG_FILES="$CONFIG_FILES conf/Makefile" ;;
"conf/example.conf") CONFIG_FILES="$CONFIG_FILES conf/example.conf" ;;
"conf/lvmlocal.conf") CONFIG_FILES="$CONFIG_FILES conf/lvmlocal.conf" ;;
@@ -13998,9 +13894,6 @@ do
"scripts/lvm2_lvmetad_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_init_red_hat" ;;
"scripts/lvm2_lvmetad_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.service" ;;
"scripts/lvm2_lvmetad_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.socket" ;;
"scripts/lvm2_lvmpolld_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmpolld_init_red_hat" ;;
"scripts/lvm2_lvmpolld_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmpolld_systemd_red_hat.service" ;;
"scripts/lvm2_lvmpolld_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmpolld_systemd_red_hat.socket" ;;
"scripts/lvm2_monitoring_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_init_red_hat" ;;
"scripts/lvm2_monitoring_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_systemd_red_hat.service" ;;
"scripts/lvm2_pvscan_systemd_red_hat@.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_pvscan_systemd_red_hat@.service" ;;
@@ -14607,22 +14500,14 @@ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
if test -n "$THIN_CONFIGURE_WARN"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Support for thin provisioning is limited since some thin provisioning tools are missing!" >&5
test -n "$THIN_CONFIGURE_WARN" && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Support for thin provisioning is limited since some thin provisioning tools are missing!" >&5
$as_echo "$as_me: WARNING: Support for thin provisioning is limited since some thin provisioning tools are missing!" >&2;}
fi
if test -n "$THIN_CHECK_VERSION_WARN"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You should also install thin_check vsn 0.3.2 (or later) to use lvm2 thin provisioning" >&5
test -n "$THIN_CHECK_VERSION_WARN" && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You should also install thin_check vsn 0.3.2 (or later) to use lvm2 thin provisioning" >&5
$as_echo "$as_me: WARNING: You should also install thin_check vsn 0.3.2 (or later) to use lvm2 thin provisioning" >&2;}
fi
if test -n "$CACHE_CONFIGURE_WARN"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Support for cache is limited since some cache tools are missing!" >&5
test -n "$CACHE_CONFIGURE_WARN" && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Support for cache is limited since some cache tools are missing!" >&5
$as_echo "$as_me: WARNING: Support for cache is limited since some cache tools are missing!" >&2;}
fi
if test "$ODIRECT" != yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: O_DIRECT disabled: low-memory pvmove may lock up" >&5
test "$ODIRECT" = yes || { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: O_DIRECT disabled: low-memory pvmove may lock up" >&5
$as_echo "$as_me: WARNING: O_DIRECT disabled: low-memory pvmove may lock up" >&2;}
fi

View File

@@ -1,6 +1,6 @@
###############################################################################
## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved.
## Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
## Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
##
## This copyrighted material is made available to anyone wishing to use,
## modify, copy, or redistribute it subject to the terms and conditions
@@ -26,9 +26,10 @@ AC_CONFIG_AUX_DIR(autoconf)
dnl -- Get system type
AC_CANONICAL_TARGET([])
AS_IF([test -z "$CFLAGS"], [COPTIMISE_FLAG="-O2"])
case "$host_os" in
linux*)
CFLAGS="$CFLAGS"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
ELDFLAGS="-Wl,--export-dynamic"
# FIXME Generate list and use --dynamic-list=.dlopen.sym
@@ -38,7 +39,6 @@ case "$host_os" in
LIB_SUFFIX=so
DEVMAPPER=yes
LVMETAD=no
LVMPOLLD=no
ODIRECT=yes
DM_IOCTLS=yes
SELINUX=yes
@@ -48,6 +48,7 @@ case "$host_os" in
;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS"
ELDFLAGS=
CLDWHOLEARCHIVE="-all_load"
@@ -67,12 +68,8 @@ esac
dnl -- Checks for programs.
AC_PROG_SED
AC_PROG_AWK
save_CFLAGS=$CFLAGS
save_CXXFLAGS=$CXXFLAGS
AC_PROG_CC
AC_PROG_CXX
CFLAGS=$save_CFLAGS
CXXFLAGS=$save_CXXFLAGS
dnl probably no longer needed in 2008, but...
AC_PROG_GCC_TRADITIONAL
@@ -648,32 +645,28 @@ pkg_config_init() {
}
################################################################################
AC_MSG_CHECKING(for default run directory)
RUN_DIR="/run"
test -d "/run" || RUN_DIR="/var/run"
AC_MSG_RESULT($RUN_DIR)
dnl -- Set up pidfile and run directory
AH_TEMPLATE(DEFAULT_PID_DIR)
AC_ARG_WITH(default-pid-dir,
AC_HELP_STRING([--with-default-pid-dir=PID_DIR],
[Default directory to keep PID files in. [autodetect]]),
DEFAULT_PID_DIR="$withval", DEFAULT_PID_DIR=$RUN_DIR)
[Default directory to keep PID files in. [/var/run]]),
DEFAULT_PID_DIR="$withval", DEFAULT_PID_DIR="/var/run")
AC_DEFINE_UNQUOTED(DEFAULT_PID_DIR, ["$DEFAULT_PID_DIR"],
[Default directory to keep PID files in.])
AH_TEMPLATE(DEFAULT_DM_RUN_DIR, [Name of default DM run directory.])
AC_ARG_WITH(default-dm-run-dir,
AC_HELP_STRING([--with-default-dm-run-dir=DM_RUN_DIR],
[ Default DM run directory. [autodetect]]),
DEFAULT_DM_RUN_DIR="$withval", DEFAULT_DM_RUN_DIR=$RUN_DIR)
[ Default DM run directory. [/var/run]]),
DEFAULT_DM_RUN_DIR="$withval", DEFAULT_DM_RUN_DIR="/var/run")
AC_DEFINE_UNQUOTED(DEFAULT_DM_RUN_DIR, ["$DEFAULT_DM_RUN_DIR"],
[Default DM run directory.])
AH_TEMPLATE(DEFAULT_RUN_DIR, [Name of default LVM run directory.])
AC_ARG_WITH(default-run-dir,
AC_HELP_STRING([--with-default-run-dir=RUN_DIR],
[Default LVM run directory. [autodetect_run_dir/lvm]]),
DEFAULT_RUN_DIR="$withval", DEFAULT_RUN_DIR="$RUN_DIR/lvm")
[Default LVM run directory. [/var/run/lvm]]),
DEFAULT_RUN_DIR="$withval", DEFAULT_RUN_DIR="/var/run/lvm")
AC_DEFINE_UNQUOTED(DEFAULT_RUN_DIR, ["$DEFAULT_RUN_DIR"],
[Default LVM run directory.])
@@ -1069,15 +1062,6 @@ AC_MSG_RESULT($LVMETAD)
BUILD_LVMETAD=$LVMETAD
if test "$BUILD_LVMETAD" = yes; then
AC_MSG_CHECKING([defaults for use_lvmetad])
AC_ARG_ENABLE(use_lvmetad,
AC_HELP_STRING([--disable-use-lvmetad],
[disable usage of LVM Metadata Daemon]),
[case ${enableval} in
yes) DEFAULT_USE_LVMETAD=1 ;;
*) DEFAULT_USE_LVMETAD=0 ;;
esac], DEFAULT_USE_LVMETAD=1)
AC_MSG_RESULT($DEFAULT_USE_LVMETAD)
AC_DEFINE([LVMETAD_SUPPORT], 1, [Define to 1 to include code that uses lvmetad.])
AC_ARG_WITH(lvmetad-pidfile,
@@ -1087,47 +1071,7 @@ if test "$BUILD_LVMETAD" = yes; then
LVMETAD_PIDFILE="$DEFAULT_PID_DIR/lvmetad.pid")
AC_DEFINE_UNQUOTED(LVMETAD_PIDFILE, ["$LVMETAD_PIDFILE"],
[Path to lvmetad pidfile.])
else
DEFAULT_USE_LVMETAD=0
fi
AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMETAD, [$DEFAULT_USE_LVMETAD],
[Use lvmetad by default.])
################################################################################
dnl -- Build lvmpolld
AC_MSG_CHECKING(whether to build lvmpolld)
AC_ARG_ENABLE(lvmpolld,
AC_HELP_STRING([--enable-lvmpolld],
[enable the LVM Polling Daemon]),
LVMPOLLD=$enableval)
AC_MSG_RESULT($LVMPOLLD)
BUILD_LVMPOLLD=$LVMPOLLD
if test "$BUILD_LVMPOLLD" = yes; then
AC_MSG_CHECKING([defaults for use_lvmpolld])
AC_ARG_ENABLE(use_lvmpolld,
AC_HELP_STRING([--disable-use-lvmpolld],
[disable usage of LVM Poll Daemon]),
[case ${enableval} in
yes) DEFAULT_USE_LVMPOLLD=1 ;;
*) DEFAULT_USE_LVMPOLLD=0 ;;
esac], DEFAULT_USE_LVMPOLLD=1)
AC_MSG_RESULT($DEFAULT_USE_LVMPOLLD)
AC_DEFINE([LVMPOLLD_SUPPORT], 1, [Define to 1 to include code that uses lvmpolld.])
AC_ARG_WITH(lvmpolld-pidfile,
AC_HELP_STRING([--with-lvmpolld-pidfile=PATH],
[lvmpolld pidfile [PID_DIR/lvmpolld.pid]]),
LVMPOLLD_PIDFILE=$withval,
LVMPOLLD_PIDFILE="$DEFAULT_PID_DIR/lvmpolld.pid")
AC_DEFINE_UNQUOTED(LVMPOLLD_PIDFILE, ["$LVMPOLLD_PIDFILE"],
[Path to lvmpolld pidfile.])
else
DEFAULT_USE_LVMPOLLD=0
fi
AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMPOLLD, [$DEFAULT_USE_LVMPOLLD],
[Use lvmpolld by default.])
################################################################################
dnl -- Enable blkid wiping functionality
@@ -1739,7 +1683,6 @@ AC_SUBST(BLKID_WIPING)
AC_SUBST(BUILD_CMIRRORD)
AC_SUBST(BUILD_DMEVENTD)
AC_SUBST(BUILD_LVMETAD)
AC_SUBST(BUILD_LVMPOLLD)
AC_SUBST(CACHE)
AC_SUBST(CFLAGS)
AC_SUBST(CFLOW_CMD)
@@ -1776,8 +1719,6 @@ AC_SUBST(DEFAULT_RAID10_SEGTYPE)
AC_SUBST(DEFAULT_RUN_DIR)
AC_SUBST(DEFAULT_SPARSE_SEGTYPE)
AC_SUBST(DEFAULT_SYS_DIR)
AC_SUBST(DEFAULT_USE_LVMETAD)
AC_SUBST(DEFAULT_USE_LVMPOLLD)
AC_SUBST(DEVMAPPER)
AC_SUBST(DLM_CFLAGS)
AC_SUBST(DLM_LIBS)
@@ -1860,7 +1801,6 @@ AC_SUBST(VALGRIND_POOL)
AC_SUBST(WRITE_INSTALL)
AC_SUBST(DMEVENTD_PIDFILE)
AC_SUBST(LVMETAD_PIDFILE)
AC_SUBST(LVMPOLLD_PIDFILE)
AC_SUBST(CLVMD_PIDFILE)
AC_SUBST(CMIRRORD_PIDFILE)
AC_SUBST(interface)
@@ -1894,7 +1834,6 @@ daemons/dmeventd/plugins/mirror/Makefile
daemons/dmeventd/plugins/snapshot/Makefile
daemons/dmeventd/plugins/thin/Makefile
daemons/lvmetad/Makefile
daemons/lvmpolld/Makefile
conf/Makefile
conf/example.conf
conf/lvmlocal.conf
@@ -1938,9 +1877,6 @@ scripts/lvm2_cmirrord_systemd_red_hat.service
scripts/lvm2_lvmetad_init_red_hat
scripts/lvm2_lvmetad_systemd_red_hat.service
scripts/lvm2_lvmetad_systemd_red_hat.socket
scripts/lvm2_lvmpolld_init_red_hat
scripts/lvm2_lvmpolld_systemd_red_hat.service
scripts/lvm2_lvmpolld_systemd_red_hat.socket
scripts/lvm2_monitoring_init_red_hat
scripts/lvm2_monitoring_systemd_red_hat.service
scripts/lvm2_pvscan_systemd_red_hat@.service
@@ -1957,14 +1893,10 @@ unit-tests/mm/Makefile
])
AC_OUTPUT
AS_IF([test -n "$THIN_CONFIGURE_WARN"],
[AC_MSG_WARN([Support for thin provisioning is limited since some thin provisioning tools are missing!])])
test -n "$THIN_CONFIGURE_WARN" && AC_MSG_WARN([Support for thin provisioning is limited since some thin provisioning tools are missing!])
AS_IF([test -n "$THIN_CHECK_VERSION_WARN"],
[AC_MSG_WARN([You should also install thin_check vsn 0.3.2 (or later) to use lvm2 thin provisioning])])
test -n "$THIN_CHECK_VERSION_WARN" && AC_MSG_WARN([You should also install thin_check vsn 0.3.2 (or later) to use lvm2 thin provisioning])
AS_IF([test -n "$CACHE_CONFIGURE_WARN"],
[AC_MSG_WARN([Support for cache is limited since some cache tools are missing!])])
test -n "$CACHE_CONFIGURE_WARN" && AC_MSG_WARN([Support for cache is limited since some cache tools are missing!])
AS_IF([test "$ODIRECT" != yes],
[AC_MSG_WARN([O_DIRECT disabled: low-memory pvmove may lock up])])
test "$ODIRECT" = yes || AC_MSG_WARN([O_DIRECT disabled: low-memory pvmove may lock up])

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -15,7 +15,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
.PHONY: dmeventd clvmd cmirrord lvmetad lvmpolld
.PHONY: dmeventd clvmd cmirrord lvmetad
ifneq ("@CLVMD@", "none")
SUBDIRS += clvmd
@@ -36,12 +36,8 @@ ifeq ("@BUILD_LVMETAD@", "yes")
SUBDIRS += lvmetad
endif
ifeq ("@BUILD_LVMPOLLD@", "yes")
SUBDIRS += lvmpolld
endif
ifeq ($(MAKECMDGOALS),distclean)
SUBDIRS = clvmd cmirrord dmeventd lvmetad lvmpolld
SUBDIRS = clvmd cmirrord dmeventd lvmetad
endif
include $(top_builddir)/make.tmpl

View File

@@ -36,6 +36,10 @@ SOURCES = \
lvm-functions.c \
refresh_clvmd.c
ifeq ("@DEBUG@", "yes")
DEFS += -DDEBUG
endif
ifneq (,$(findstring cman,, "@CLVMD@,"))
SOURCES += clvmd-cman.c
LMLIBS += $(CMAN_LIBS) $(CONFDB_LIBS) $(DLM_LIBS)

View File

@@ -172,7 +172,6 @@ static void usage(const char *prog, FILE *file)
#ifdef USE_SINGLENODE
"singlenode "
#endif
"\n"
" -R Tell all running clvmds in the cluster to reload their device cache\n"
" -S Restart clvmd, preserving exclusive locks\n"
" -t<secs> Command timeout (default: 60 seconds)\n"

View File

@@ -18,7 +18,7 @@ top_builddir = @top_builddir@
SOURCES = lvmetad-core.c
SOURCES2 = testclient.c
TARGETS = lvmetad
TARGETS = lvmetad lvmetad-testclient
.PHONY: install_lvmetad

View File

@@ -809,7 +809,8 @@ static response pv_gone(lvmetad_state *s, request r)
int64_t device = daemon_request_int(r, "device", 0);
int64_t alt_device = 0;
struct dm_config_tree *pvmeta;
char *vgid;
struct dm_config_node *pvmeta_tmp;
char *pvid_old, *vgid;
DEBUGLOG(s, "pv_gone: %s / %" PRIu64, pvid, device);
@@ -824,6 +825,7 @@ static response pv_gone(lvmetad_state *s, request r)
DEBUGLOG(s, "pv_gone (updated): %s / %" PRIu64, pvid, device);
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
@@ -950,8 +952,8 @@ static response pv_found(lvmetad_state *s, request r)
altdev->v->v.i = device_old_pvid;
break;
}
};
altdev_v = altdev->v;
};
altdev_v = altdev->v;
while (altdev_v) {
if (altdev_v->next && altdev_v->next->v.i == device)
altdev_v->next = altdev_v->next->next;

View File

@@ -1,49 +0,0 @@
#
# Copyright (C) 2014-2015 Red Hat, Inc.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU Lesser General Public License v.2.1.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SOURCES = lvmpolld-core.c lvmpolld-data-utils.c lvmpolld-cmd-utils.c
TARGETS = lvmpolld
.PHONY: install_lvmpolld
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = $(LIB_NAME).cflow
CFLOW_TARGET = lvmpolld
include $(top_builddir)/make.tmpl
INCLUDES += -I$(top_srcdir)/libdaemon/server
LVMLIBS = -ldaemonserver $(LVMINTERNAL_LIBS) -ldevmapper
LIBS += $(PTHREAD_LIBS)
LDFLAGS += -L$(top_builddir)/libdaemon/server $(DAEMON_LDFLAGS)
CLDFLAGS += -L$(top_builddir)/libdaemon/server
CFLAGS += $(DAEMON_CFLAGS)
lvmpolld: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
$(DL_LIBS) $(LVMLIBS) $(LIBS)
install_lvmpolld: lvmpolld
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
install_lvm2: install_lvmpolld
install: install_lvm2

View File

@@ -1,144 +0,0 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lvmpolld-common.h"
/* extract this info from autoconf/automake files */
#define LVPOLL_CMD "lvpoll"
#define MIN_ARGV_SIZE 8
static const char *const const polling_ops[] = { [PVMOVE] = LVMPD_REQ_PVMOVE,
[CONVERT] = LVMPD_REQ_CONVERT,
[MERGE] = LVMPD_REQ_MERGE,
[MERGE_THIN] = LVMPD_REQ_MERGE_THIN };
const char *polling_op(enum poll_type type)
{
return type < POLL_TYPE_MAX ? polling_ops[type] : "<undefined>";
}
static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind)
{
const char **newargv = *cmdargv;
if (*ind && !(*ind % MIN_ARGV_SIZE)) {
newargv = dm_realloc(*cmdargv, (*ind / MIN_ARGV_SIZE + 1) * MIN_ARGV_SIZE * sizeof(char *));
if (!newargv)
return 0;
*cmdargv = newargv;
}
*(*cmdargv + (*ind)++) = str;
return 1;
}
const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary, unsigned abort_polling, unsigned handle_missing_pvs)
{
unsigned i = 0;
const char **cmd_argv = dm_malloc(MIN_ARGV_SIZE * sizeof(char *));
if (!cmd_argv)
return NULL;
/* path to lvm2 binary */
if (!add_to_cmd_arr(&cmd_argv, lvm_binary, &i))
goto err;
/* cmd to execute */
if (!add_to_cmd_arr(&cmd_argv, LVPOLL_CMD, &i))
goto err;
/* transfer internal polling interval */
if (pdlv->sinterval &&
(!add_to_cmd_arr(&cmd_argv, "--interval", &i) ||
!add_to_cmd_arr(&cmd_argv, pdlv->sinterval, &i)))
goto err;
/* pass abort param */
if (abort_polling &&
!add_to_cmd_arr(&cmd_argv, "--abort", &i))
goto err;
/* pass handle-missing-pvs. used by mirror polling operation */
if (handle_missing_pvs &&
!add_to_cmd_arr(&cmd_argv, "--handlemissingpvs", &i))
goto err;
/* one of: "convert", "pvmove", "merge", "merge_thin" */
if (!add_to_cmd_arr(&cmd_argv, "--polloperation", &i) ||
!add_to_cmd_arr(&cmd_argv, polling_ops[pdlv->type], &i))
goto err;
/* vg/lv name */
if (!add_to_cmd_arr(&cmd_argv, pdlv->lvname, &i))
goto err;
/* disable metadata backup */
if (!add_to_cmd_arr(&cmd_argv, "-An", &i))
goto err;
/* terminating NULL */
if (!add_to_cmd_arr(&cmd_argv, NULL, &i))
goto err;
return cmd_argv;
err:
dm_free(cmd_argv);
return NULL;
}
/* FIXME: in fact exclude should be va list */
static int copy_env(const char ***cmd_envp, unsigned *i, const char *exclude)
{
const char * const* tmp = (const char * const*) environ;
if (!tmp)
return 0;
while (*tmp) {
if (strncmp(*tmp, exclude, strlen(exclude)) && !add_to_cmd_arr(cmd_envp, *tmp, i))
return 0;
tmp++;
}
return 1;
}
const char **cmdenvp_ctr(const struct lvmpolld_lv *pdlv)
{
unsigned i = 0;
const char **cmd_envp = dm_malloc(MIN_ARGV_SIZE * sizeof(char *));
if (!cmd_envp)
return NULL;
/* copy whole environment from lvmpolld, exclude LVM_SYSTEM_DIR if set */
if (!copy_env(&cmd_envp, &i, "LVM_SYSTEM_DIR="))
goto err;
/* Add per client LVM_SYSTEM_DIR variable if set */
if (*pdlv->lvm_system_dir_env && !add_to_cmd_arr(&cmd_envp, pdlv->lvm_system_dir_env, &i))
goto err;
/* terminating NULL */
if (!add_to_cmd_arr(&cmd_envp, NULL, &i))
goto err;
return cmd_envp;
err:
dm_free(cmd_envp);
return NULL;
}

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVMPOLLD_CMD_UTILS_H
#define _LVM_LVMPOLLD_CMD_UTILS_H
#include "lvmpolld-data-utils.h"
const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary, unsigned abort, unsigned handle_missing_pvs);
const char **cmdenvp_ctr(const struct lvmpolld_lv *pdlv);
const char *polling_op(enum poll_type);
#endif /* _LVM_LVMPOLLD_CMD_UTILS_H */

View File

@@ -1,36 +0,0 @@
/*
* Copyright (C) 2010-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This file must be included first by every lvmpolld source file.
*/
#ifndef _LVM_LVMPOLLD_COMMON_H
#define _LVM_LVMPOLLD_COMMON_H
#include "configure.h"
#define _REENTRANT
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
#include "libdevmapper.h"
#include "lvmpolld-cmd-utils.h"
#include "lvmpolld-protocol.h"
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#endif /* _LVM_LVMPOLLD_COMMON_H */

View File

@@ -1,983 +0,0 @@
/*
* Copyright (C) 2014-2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lvmpolld-common.h"
#include "lvm-version.h"
#include "daemon-server.h"
#include "daemon-log.h"
#include <getopt.h>
#include <poll.h>
#include <wait.h>
#define LVMPOLLD_SOCKET DEFAULT_RUN_DIR "/lvmpolld.socket"
#define PD_LOG_PREFIX "LVMPOLLD"
#define LVM2_LOG_PREFIX "\tLVPOLL"
/* predefined reason for response = "failed" case */
#define REASON_REQ_NOT_IMPLEMENTED "request not implemented"
#define REASON_MISSING_LVID "request requires lvid set"
#define REASON_MISSING_LVNAME "request requires lvname set"
#define REASON_MISSING_VGNAME "request requires vgname set"
#define REASON_POLLING_FAILED "polling of lvm command failed"
#define REASON_ILLEGAL_ABORT_REQUEST "abort only supported with PVMOVE polling operation"
#define REASON_DIFFERENT_OPERATION_IN_PROGRESS "Different operation on LV already in progress"
#define REASON_INVALID_INTERVAL "request requires interval set"
#define REASON_ENOMEM "not enough memory"
struct lvmpolld_state {
daemon_idle *idle;
log_state *log;
const char *log_config;
const char *lvm_binary;
struct lvmpolld_store *id_to_pdlv_abort;
struct lvmpolld_store *id_to_pdlv_poll;
};
static pthread_key_t key;
static const char *_strerror_r(int errnum, struct lvmpolld_thread_data *data)
{
#ifdef _GNU_SOURCE
return strerror_r(errnum, data->buf, sizeof(data->buf)); /* never returns NULL */
#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
return strerror_r(errnum, data->buf, sizeof(data->buf)) ? "" : data->buf;
#else
# warning "Can't decide proper strerror_r implementation. lvmpolld will not issue specific system error messages"
return "";
#endif
}
static void _usage(const char *prog, FILE *file)
{
fprintf(file, "Usage:\n"
"%s [-V] [-h] [-f] [-l {all|wire|debug}] [-s path] [-B path] [-p path] [-t secs]\n"
"%s --dump [-s path]\n"
" -V|--version Show version info\n"
" -h|--help Show this help information\n"
" -f|--foreground Don't fork, run in the foreground\n"
" --dump Dump full lvmpolld state\n"
" -l|--log Logging message level (-l {all|wire|debug})\n"
" -p|--pidfile Set path to the pidfile\n"
" -s|--socket Set path to the communication socket\n"
" -B|--binary Path to lvm2 binary\n"
" -t|--timeout Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog, prog);
}
static int _init(struct daemon_state *s)
{
struct lvmpolld_state *ls = s->private;
ls->log = s->log;
if (!daemon_log_parse(ls->log, DAEMON_LOG_OUTLET_STDERR, ls->log_config, 1))
return 0;
if (pthread_key_create(&key, lvmpolld_thread_data_destroy)) {
FATAL(ls, "%s: %s", PD_LOG_PREFIX, "Failed to create pthread key");
return 0;
}
ls->id_to_pdlv_poll = pdst_init("polling");
ls->id_to_pdlv_abort = pdst_init("abort");
if (!ls->id_to_pdlv_poll || !ls->id_to_pdlv_abort) {
FATAL(ls, "%s: %s", PD_LOG_PREFIX, "Failed to allocate internal data structures");
return 0;
}
ls->lvm_binary = ls->lvm_binary ?: LVM_PATH;
if (access(ls->lvm_binary, X_OK)) {
FATAL(ls, "%s: %s %s", PD_LOG_PREFIX, "Execute access rights denied on", ls->lvm_binary);
return 0;
}
if (ls->idle)
ls->idle->is_idle = 1;
return 1;
}
static void _lvmpolld_stores_lock(struct lvmpolld_state *ls)
{
pdst_lock(ls->id_to_pdlv_poll);
pdst_lock(ls->id_to_pdlv_abort);
}
static void _lvmpolld_stores_unlock(struct lvmpolld_state *ls)
{
pdst_unlock(ls->id_to_pdlv_abort);
pdst_unlock(ls->id_to_pdlv_poll);
}
static void _lvmpolld_global_lock(struct lvmpolld_state *ls)
{
_lvmpolld_stores_lock(ls);
pdst_locked_lock_all_pdlvs(ls->id_to_pdlv_poll);
pdst_locked_lock_all_pdlvs(ls->id_to_pdlv_abort);
}
static void _lvmpolld_global_unlock(struct lvmpolld_state *ls)
{
pdst_locked_unlock_all_pdlvs(ls->id_to_pdlv_abort);
pdst_locked_unlock_all_pdlvs(ls->id_to_pdlv_poll);
_lvmpolld_stores_unlock(ls);
}
static int _fini(struct daemon_state *s)
{
int done;
const struct timespec t = { .tv_nsec = 250000000 }; /* .25 sec */
struct lvmpolld_state *ls = s->private;
DEBUGLOG(s, "fini");
DEBUGLOG(s, "sending cancel requests");
_lvmpolld_global_lock(ls);
pdst_locked_send_cancel(ls->id_to_pdlv_poll);
pdst_locked_send_cancel(ls->id_to_pdlv_abort);
_lvmpolld_global_unlock(ls);
DEBUGLOG(s, "waiting for background threads to finish");
while(1) {
_lvmpolld_stores_lock(ls);
done = !pdst_locked_get_active_count(ls->id_to_pdlv_poll) &&
!pdst_locked_get_active_count(ls->id_to_pdlv_abort);
_lvmpolld_stores_unlock(ls);
if (done)
break;
nanosleep(&t, NULL);
}
DEBUGLOG(s, "destroying internal data structures");
_lvmpolld_stores_lock(ls);
pdst_locked_destroy_all_pdlvs(ls->id_to_pdlv_poll);
pdst_locked_destroy_all_pdlvs(ls->id_to_pdlv_abort);
_lvmpolld_stores_unlock(ls);
pdst_destroy(ls->id_to_pdlv_poll);
pdst_destroy(ls->id_to_pdlv_abort);
pthread_key_delete(key);
return 1;
}
static response reply(const char *res, const char *reason)
{
return daemon_reply_simple(res, "reason = %s", reason, NULL);
}
static int read_single_line(struct lvmpolld_thread_data *data, int err)
{
ssize_t r = getline(&data->line, &data->line_size, err ? data->ferr : data->fout);
if (r > 0 && *(data->line + r - 1) == '\n')
*(data->line + r - 1) = '\0';
return (r > 0);
}
static void update_idle_state(struct lvmpolld_state *ls)
{
if (!ls->idle)
return;
_lvmpolld_stores_lock(ls);
ls->idle->is_idle = !pdst_locked_get_active_count(ls->id_to_pdlv_poll) &&
!pdst_locked_get_active_count(ls->id_to_pdlv_abort);
_lvmpolld_stores_unlock(ls);
DEBUGLOG(ls, "%s: %s %s%s", PD_LOG_PREFIX, "daemon is", ls->idle->is_idle ? "" : "not ", "idle");
}
/* make this configurable */
#define MAX_TIMEOUT 2
static int poll_for_output(struct lvmpolld_lv *pdlv, struct lvmpolld_thread_data *data)
{
int ch_stat, r, err = 1, fds_count = 2, timeout = 0;
pid_t pid;
struct lvmpolld_cmd_stat cmd_state = { .retcode = -1, .signal = 0 };
struct pollfd fds[] = { { .fd = data->outpipe[0], .events = POLLIN },
{ .fd = data->errpipe[0], .events = POLLIN } };
if (!(data->fout = fdopen(data->outpipe[0], "r")) || !(data->ferr = fdopen(data->errpipe[0], "r"))) {
ERROR(pdlv->ls, "%s: %s: (%d) %s", PD_LOG_PREFIX, "failed to open file stream",
errno, _strerror_r(errno, data));
goto out;
}
while (1) {
do {
r = poll(fds, 2, pdlv_get_timeout(pdlv) * 1000);
} while (r < 0 && errno == EINTR);
DEBUGLOG(pdlv->ls, "%s: %s %d", PD_LOG_PREFIX, "poll() returned", r);
if (r < 0) {
ERROR(pdlv->ls, "%s: %s (PID %d) failed: (%d) %s",
PD_LOG_PREFIX, "poll() for LVM2 cmd", pdlv->cmd_pid,
errno, _strerror_r(errno, data));
goto out;
} else if (!r) {
timeout++;
WARN(pdlv->ls, "%s: %s (PID %d) %s", PD_LOG_PREFIX,
"polling for output of the lvm cmd", pdlv->cmd_pid,
"has timed out");
if (timeout > MAX_TIMEOUT) {
ERROR(pdlv->ls, "%s: %s (PID %d) (no output for %d seconds)",
PD_LOG_PREFIX,
"LVM2 cmd is unresponsive too long",
pdlv->cmd_pid,
timeout * pdlv_get_timeout(pdlv));
goto out;
}
continue; /* while(1) */
}
timeout = 0;
/* handle the command's STDOUT */
if (fds[0].revents & POLLIN) {
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "caught input data in STDOUT");
assert(read_single_line(data, 0)); /* may block indef. anyway */
INFO(pdlv->ls, "%s: PID %d: %s: '%s'", LVM2_LOG_PREFIX,
pdlv->cmd_pid, "STDOUT", data->line);
} else if (fds[0].revents) {
if (fds[0].revents & POLLHUP)
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "caught POLLHUP");
else
WARN(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "poll for command's STDOUT failed");
fds[0].fd = -1;
fds_count--;
}
/* handle the command's STDERR */
if (fds[1].revents & POLLIN) {
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX,
"caught input data in STDERR");
assert(read_single_line(data, 1)); /* may block indef. anyway */
INFO(pdlv->ls, "%s: PID %d: %s: '%s'", LVM2_LOG_PREFIX,
pdlv->cmd_pid, "STDERR", data->line);
} else if (fds[1].revents) {
if (fds[1].revents & POLLHUP)
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "caught err POLLHUP");
else
WARN(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "poll for command's STDOUT failed");
fds[1].fd = -1;
fds_count--;
}
do {
/*
* fds_count == 0 means polling reached EOF
* or received error on both descriptors.
* In such case, just wait for command to finish
*/
pid = waitpid(pdlv->cmd_pid, &ch_stat, fds_count ? WNOHANG : 0);
} while (pid < 0 && errno == EINTR);
if (pid) {
if (pid < 0) {
ERROR(pdlv->ls, "%s: %s (PID %d) failed: (%d) %s",
PD_LOG_PREFIX, "waitpid() for lvm2 cmd",
pdlv->cmd_pid, errno,
_strerror_r(errno, data));
goto out;
}
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "child exited");
break;
}
} /* while(1) */
DEBUGLOG(pdlv->ls, "%s: %s", PD_LOG_PREFIX, "about to collect remaining lines");
if (fds[0].fd >= 0)
while (read_single_line(data, 0)) {
assert(r > 0);
INFO(pdlv->ls, "%s: PID %d: %s: %s", LVM2_LOG_PREFIX, pdlv->cmd_pid, "STDOUT", data->line);
}
if (fds[1].fd >= 0)
while (read_single_line(data, 1)) {
assert(r > 0);
INFO(pdlv->ls, "%s: PID %d: %s: %s", LVM2_LOG_PREFIX, pdlv->cmd_pid, "STDERR", data->line);
}
if (WIFEXITED(ch_stat)) {
INFO(pdlv->ls, "%s: %s (PID %d) %s (%d)", PD_LOG_PREFIX,
"lvm2 cmd", pdlv->cmd_pid, "exited with", WEXITSTATUS(ch_stat));
cmd_state.retcode = WEXITSTATUS(ch_stat);
} else if (WIFSIGNALED(ch_stat)) {
WARN(pdlv->ls, "%s: %s (PID %d) %s (%d)", PD_LOG_PREFIX,
"lvm2 cmd", pdlv->cmd_pid, "got terminated by signal",
WTERMSIG(ch_stat));
cmd_state.signal = WTERMSIG(ch_stat);
}
err = 0;
out:
if (!err)
pdlv_set_cmd_state(pdlv, &cmd_state);
return err;
}
static void debug_print(struct lvmpolld_state *ls, const char * const* ptr)
{
const char * const* tmp = ptr;
if (!tmp)
return;
while (*tmp) {
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, *tmp);
tmp++;
}
}
static void *fork_and_poll(void *args)
{
int outfd, errfd, state;
struct lvmpolld_thread_data *data;
pid_t r;
int error = 1;
struct lvmpolld_lv *pdlv = (struct lvmpolld_lv *) args;
struct lvmpolld_state *ls = pdlv->ls;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
data = lvmpolld_thread_data_constructor(pdlv);
pthread_setspecific(key, data);
pthread_setcancelstate(state, &state);
if (!data) {
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "Failed to initialize per-thread data");
goto err;
}
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, "cmd line arguments:");
debug_print(ls, pdlv->cmdargv);
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, "---end---");
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, "cmd environment variables:");
debug_print(ls, pdlv->cmdenvp);
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, "---end---");
outfd = data->outpipe[1];
errfd = data->errpipe[1];
r = fork();
if (!r) {
/* child */
/* !!! Do not touch any posix thread primitives !!! */
if ((dup2(outfd, STDOUT_FILENO ) != STDOUT_FILENO) ||
(dup2(errfd, STDERR_FILENO ) != STDERR_FILENO))
_exit(LVMPD_RET_DUP_FAILED);
execve(*(pdlv->cmdargv), (char *const *)pdlv->cmdargv, (char *const *)pdlv->cmdenvp);
_exit(LVMPD_RET_EXC_FAILED);
} else {
/* parent */
if (r == -1) {
ERROR(ls, "%s: %s: (%d) %s", PD_LOG_PREFIX, "fork failed",
errno, _strerror_r(errno, data));
goto err;
}
INFO(ls, "%s: LVM2 cmd \"%s\" (PID: %d)", PD_LOG_PREFIX, *(pdlv->cmdargv), r);
pdlv->cmd_pid = r;
/* failure to close write end of any pipe will result in broken polling */
if (close(data->outpipe[1])) {
ERROR(ls, "%s: %s: (%d) %s", PD_LOG_PREFIX, "failed to close write end of pipe",
errno, _strerror_r(errno, data));
goto err;
}
data->outpipe[1] = -1;
if (close(data->errpipe[1])) {
ERROR(ls, "%s: %s: (%d) %s", PD_LOG_PREFIX, "failed to close write end of err pipe",
errno, _strerror_r(errno, data));
goto err;
}
data->errpipe[1] = -1;
error = poll_for_output(pdlv, data);
DEBUGLOG(ls, "%s: %s", PD_LOG_PREFIX, "polling for lvpoll output has finished");
}
err:
r = 0;
pdst_lock(pdlv->pdst);
if (error) {
/* last reader is responsible for pdlv cleanup */
r = pdlv->cmd_pid;
pdlv_set_error(pdlv, 1);
}
pdlv_set_polling_finished(pdlv, 1);
if (data)
data->pdlv = NULL;
pdst_locked_dec(pdlv->pdst);
pdst_unlock(pdlv->pdst);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state);
lvmpolld_thread_data_destroy(data);
pthread_setspecific(key, NULL);
pthread_setcancelstate(state, &state);
update_idle_state(ls);
/*
* This is unfortunate case where we
* know nothing about state of lvm cmd and
* (eventually) ongoing progress.
*
* harvest zombies
*/
if (r)
while(waitpid(r, NULL, 0) < 0 && errno == EINTR);
return NULL;
}
static response progress_info(client_handle h, struct lvmpolld_state *ls, request req)
{
char *id;
struct lvmpolld_lv *pdlv;
struct lvmpolld_store *pdst;
struct lvmpolld_lv_state st;
response r;
const char *lvid = daemon_request_str(req, LVMPD_PARM_LVID, NULL);
const char *sysdir = daemon_request_str(req, LVMPD_PARM_SYSDIR, NULL);
unsigned abort_polling = daemon_request_int(req, LVMPD_PARM_ABORT, 0);
if (!lvid)
return reply(LVMPD_RESP_FAILED, REASON_MISSING_LVID);
id = construct_id(sysdir, lvid);
if (!id) {
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "progress_info request failed to construct ID.");
return reply(LVMPD_RESP_FAILED, REASON_ENOMEM);
}
DEBUGLOG(ls, "%s: %s: %s", PD_LOG_PREFIX, "ID", id);
pdst = abort_polling ? ls->id_to_pdlv_abort : ls->id_to_pdlv_poll;
pdst_lock(pdst);
pdlv = pdst_locked_lookup(pdst, id);
if (pdlv) {
/*
* with store lock held, I'm the only reader accessing the pdlv
*/
st = pdlv_get_status(pdlv);
if (st.error || st.polling_finished) {
INFO(ls, "%s: %s %s", PD_LOG_PREFIX,
"Polling finished. Removing related data structure for LV",
lvid);
pdst_locked_remove(pdst, id);
pdlv_destroy(pdlv);
}
}
/* pdlv must not be dereferenced from now on */
pdst_unlock(pdst);
dm_free(id);
if (pdlv) {
if (st.error)
return reply(LVMPD_RESP_FAILED, REASON_POLLING_FAILED);
if (st.polling_finished)
r = daemon_reply_simple(LVMPD_RESP_FINISHED,
"reason = %s", st.cmd_state.signal ? LVMPD_REAS_SIGNAL : LVMPD_REAS_RETCODE,
LVMPD_PARM_VALUE " = %d", st.cmd_state.signal ?: st.cmd_state.retcode,
NULL);
else
r = daemon_reply_simple(LVMPD_RESP_IN_PROGRESS, NULL);
}
else
r = daemon_reply_simple(LVMPD_RESP_NOT_FOUND, NULL);
return r;
}
static struct lvmpolld_lv *construct_pdlv(request req, struct lvmpolld_state *ls,
struct lvmpolld_store *pdst,
const char *interval, const char *id,
const char *vgname, const char *lvname,
const char *sysdir, enum poll_type type,
unsigned abort_polling, unsigned uinterval)
{
const char **cmdargv, **cmdenvp;
struct lvmpolld_lv *pdlv;
unsigned handle_missing_pvs = daemon_request_int(req, LVMPD_PARM_HANDLE_MISSING_PVS, 0);
pdlv = pdlv_create(ls, id, vgname, lvname, sysdir, type,
interval, uinterval, pdst);
if (!pdlv) {
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "failed to create internal LV data structure.");
return NULL;
}
cmdargv = cmdargv_ctr(pdlv, pdlv->ls->lvm_binary, abort_polling, handle_missing_pvs);
if (!cmdargv) {
pdlv_destroy(pdlv);
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "failed to construct cmd arguments for lvpoll command");
return NULL;
}
cmdenvp = cmdenvp_ctr(pdlv);
if (!cmdenvp) {
pdlv_destroy(pdlv);
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "failed to construct cmd environment for lvpoll command");
return NULL;
}
pdlv->cmdargv = cmdargv;
pdlv->cmdenvp = cmdenvp;
return pdlv;
}
static int spawn_detached_thread(struct lvmpolld_lv *pdlv)
{
int r;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
r = pthread_create(&pdlv->tid, &attr, fork_and_poll, (void *)pdlv);
pthread_attr_destroy(&attr);
return !r;
}
static response poll_init(client_handle h, struct lvmpolld_state *ls, request req, enum poll_type type)
{
char *id;
struct lvmpolld_lv *pdlv;
struct lvmpolld_store *pdst;
unsigned uinterval;
const char *interval = daemon_request_str(req, LVMPD_PARM_INTERVAL, NULL);
const char *lvid = daemon_request_str(req, LVMPD_PARM_LVID, NULL);
const char *lvname = daemon_request_str(req, LVMPD_PARM_LVNAME, NULL);
const char *vgname = daemon_request_str(req, LVMPD_PARM_VGNAME, NULL);
const char *sysdir = daemon_request_str(req, LVMPD_PARM_SYSDIR, NULL);
unsigned abort_polling = daemon_request_int(req, LVMPD_PARM_ABORT, 0);
assert(type < POLL_TYPE_MAX);
if (abort_polling && type != PVMOVE)
return reply(LVMPD_RESP_EINVAL, REASON_ILLEGAL_ABORT_REQUEST);
if (!interval || strpbrk(interval, "-") || sscanf(interval, "%u", &uinterval) != 1)
return reply(LVMPD_RESP_EINVAL, REASON_INVALID_INTERVAL);
if (!lvname)
return reply(LVMPD_RESP_FAILED, REASON_MISSING_LVNAME);
if (!lvid)
return reply(LVMPD_RESP_FAILED, REASON_MISSING_LVID);
if (!vgname)
return reply(LVMPD_RESP_FAILED, REASON_MISSING_VGNAME);
id = construct_id(sysdir, lvid);
if (!id) {
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "poll_init request failed to construct ID.");
return reply(LVMPD_RESP_FAILED, REASON_ENOMEM);
}
DEBUGLOG(ls, "%s: %s=%s", PD_LOG_PREFIX, "ID", id);
pdst = abort_polling ? ls->id_to_pdlv_abort : ls->id_to_pdlv_poll;
pdst_lock(pdst);
pdlv = pdst_locked_lookup(pdst, id);
if (pdlv && pdlv_get_polling_finished(pdlv)) {
WARN(ls, "%s: %s %s", PD_LOG_PREFIX, "Force removal of uncollected info for LV",
lvid);
/*
* lvmpolld has to remove uncollected results in this case.
* otherwise it would have to refuse request for new polling
* lv with same id.
*/
pdst_locked_remove(pdst, id);
pdlv_destroy(pdlv);
pdlv = NULL;
}
if (pdlv) {
if (!pdlv_is_type(pdlv, type)) {
pdst_unlock(pdst);
ERROR(ls, "%s: %s '%s': expected: %s, requested: %s",
PD_LOG_PREFIX, "poll operation type mismatch on LV identified by",
id,
polling_op(pdlv_get_type(pdlv)), polling_op(type));
dm_free(id);
return reply(LVMPD_RESP_EINVAL,
REASON_DIFFERENT_OPERATION_IN_PROGRESS);
}
pdlv->init_rq_count++; /* safe. protected by store lock */
} else {
pdlv = construct_pdlv(req, ls, pdst, interval, id, vgname,
lvname, sysdir, type, abort_polling, 2 * uinterval);
if (!pdlv) {
pdst_unlock(pdst);
dm_free(id);
return reply(LVMPD_RESP_FAILED, REASON_ENOMEM);
}
if (!pdst_locked_insert(pdst, id, pdlv)) {
pdlv_destroy(pdlv);
pdst_unlock(pdst);
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "couldn't store internal LV data structure");
dm_free(id);
return reply(LVMPD_RESP_FAILED, REASON_ENOMEM);
}
if (!spawn_detached_thread(pdlv)) {
ERROR(ls, "%s: %s", PD_LOG_PREFIX, "failed to spawn detached monitoring thread");
pdst_locked_remove(pdst, id);
pdlv_destroy(pdlv);
pdst_unlock(pdst);
dm_free(id);
return reply(LVMPD_RESP_FAILED, REASON_ENOMEM);
}
pdst_locked_inc(pdst);
if (ls->idle)
ls->idle->is_idle = 0;
}
pdst_unlock(pdst);
dm_free(id);
return daemon_reply_simple(LVMPD_RESP_OK, NULL);
}
static response dump_state(client_handle h, struct lvmpolld_state *ls, request r)
{
response res = { 0 };
struct buffer *b = &res.buffer;
buffer_init(b);
_lvmpolld_global_lock(ls);
buffer_append(b, "# Registered polling operations\n\n");
buffer_append(b, "poll {\n");
pdst_locked_dump(ls->id_to_pdlv_poll, b);
buffer_append(b, "}\n\n");
buffer_append(b, "# Registered abort operations\n\n");
buffer_append(b, "abort {\n");
pdst_locked_dump(ls->id_to_pdlv_abort, b);
buffer_append(b, "}");
_lvmpolld_global_unlock(ls);
return res;
}
static response _handler(struct daemon_state s, client_handle h, request r)
{
struct lvmpolld_state *ls = s.private;
const char *rq = daemon_request_str(r, "request", "NONE");
if (!strcmp(rq, LVMPD_REQ_PVMOVE))
return poll_init(h, ls, r, PVMOVE);
else if (!strcmp(rq, LVMPD_REQ_CONVERT))
return poll_init(h, ls, r, CONVERT);
else if (!strcmp(rq, LVMPD_REQ_MERGE))
return poll_init(h, ls, r, MERGE);
else if (!strcmp(rq, LVMPD_REQ_MERGE_THIN))
return poll_init(h, ls, r, MERGE_THIN);
else if (!strcmp(rq, LVMPD_REQ_PROGRESS))
return progress_info(h, ls, r);
else if (!strcmp(rq, LVMPD_REQ_DUMP))
return dump_state(h, ls, r);
else
return reply(LVMPD_RESP_EINVAL, REASON_REQ_NOT_IMPLEMENTED);
}
static int process_timeout_arg(const char *str, unsigned *max_timeouts)
{
char *endptr;
unsigned long l;
l = strtoul(str, &endptr, 10);
if (errno || *endptr || l >= UINT_MAX)
return 0;
*max_timeouts = (unsigned) l;
return 1;
}
/* Client functionality */
typedef int (*action_fn_t) (void *args);
struct log_line_baton {
const char *prefix;
};
daemon_handle _lvmpolld = { .error = 0 };
static daemon_handle _lvmpolld_open(const char *socket)
{
daemon_info lvmpolld_info = {
.path = "lvmpolld",
.socket = socket ?: DEFAULT_RUN_DIR "/lvmpolld.socket",
.protocol = LVMPOLLD_PROTOCOL,
.protocol_version = LVMPOLLD_PROTOCOL_VERSION
};
return daemon_open(lvmpolld_info);
}
static void _log_line(const char *line, void *baton) {
struct log_line_baton *b = baton;
fprintf(stdout, "%s%s\n", b->prefix, line);
}
static int printout_raw_response(const char *prefix, const char *msg)
{
struct log_line_baton b = { .prefix = prefix };
char *buf;
char *pos;
buf = dm_strdup(msg);
pos = buf;
if (!buf)
return 0;
while (pos) {
char *next = strchr(pos, '\n');
if (next)
*next = 0;
_log_line(pos, &b);
pos = next ? next + 1 : 0;
}
dm_free(buf);
return 1;
}
/* place all action implementations below */
static int action_dump(void *args __attribute__((unused)))
{
daemon_request req;
daemon_reply repl;
int r = 0;
req = daemon_request_make(LVMPD_REQ_DUMP);
if (!req.cft) {
fprintf(stderr, "Failed to create lvmpolld " LVMPD_REQ_DUMP " request.\n");
goto out_req;
}
repl = daemon_send(_lvmpolld, req);
if (repl.error) {
fprintf(stderr, "Failed to send a request or receive response.\n");
goto out_rep;
}
/*
* This is dumb copy & paste from libdaemon log routines.
*/
if (!printout_raw_response(" ", repl.buffer.mem)) {
fprintf(stderr, "Failed to print out the response.\n");
goto out_rep;
}
r = 1;
out_rep:
daemon_reply_destroy(repl);
out_req:
daemon_request_destroy(req);
return r;
}
enum action_index {
ACTION_DUMP = 0,
ACTION_MAX /* keep at the end */
};
static const action_fn_t const actions[] = { [ACTION_DUMP] = action_dump };
static int _make_action(enum action_index idx, void *args)
{
return idx < ACTION_MAX ? actions[idx](args) : 0;
}
static int _lvmpolld_client(const char *socket, unsigned action)
{
int r;
_lvmpolld = _lvmpolld_open(socket);
if (_lvmpolld.error || _lvmpolld.socket_fd < 0) {
fprintf(stderr, "Failed to establish connection with lvmpolld.\n");
return 0;
}
r = _make_action(action, NULL);
daemon_close(_lvmpolld);
return r ? EXIT_SUCCESS : EXIT_FAILURE;
}
static int action_idx = ACTION_MAX;
static struct option long_options[] = {
/* Have actions always at the beginning of the array. */
{"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */
/* other options */
{"binary", required_argument, 0, 'B' },
{"foreground", no_argument, 0, 'f' },
{"help", no_argument, 0, 'h' },
{"log", required_argument, 0, 'l' },
{"pidfile", required_argument, 0, 'p' },
{"socket", required_argument, 0, 's' },
{"timeout", required_argument, 0, 't' },
{"version", no_argument, 0, 'V' },
{0, 0, 0, 0 }
};
int main(int argc, char *argv[])
{
int opt;
int option_index = 0;
int client = 0, server = 0;
unsigned action = ACTION_MAX;
struct timeval timeout;
daemon_idle di = { .ptimeout = &timeout };
struct lvmpolld_state ls = { .log_config = "" };
daemon_state s = {
.daemon_fini = _fini,
.daemon_init = _init,
.handler = _handler,
.name = "lvmpolld",
.pidfile = getenv("LVM_LVMPOLLD_PIDFILE") ?: LVMPOLLD_PIDFILE,
.private = &ls,
.protocol = LVMPOLLD_PROTOCOL,
.protocol_version = LVMPOLLD_PROTOCOL_VERSION,
.socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET,
};
while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
switch (opt) {
case 0 :
if (action < ACTION_MAX) {
fprintf(stderr, "Can't perform more actions. Action already requested: %s\n",
long_options[action].name);
_usage(argv[0], stderr);
exit(EXIT_FAILURE);
}
action = action_idx;
client = 1;
break;
case '?':
_usage(argv[0], stderr);
exit(EXIT_FAILURE);
case 'B': /* --binary */
ls.lvm_binary = optarg;
server = 1;
break;
case 'V': /* --version */
printf("lvmpolld version: " LVM_VERSION "\n");
exit(EXIT_SUCCESS);
case 'f': /* --foreground */
s.foreground = 1;
server = 1;
break;
case 'h': /* --help */
_usage(argv[0], stdout);
exit(EXIT_SUCCESS);
case 'l': /* --log */
ls.log_config = optarg;
server = 1;
break;
case 'p': /* --pidfile */
s.pidfile = optarg;
server = 1;
break;
case 's': /* --socket */
s.socket_path = optarg;
break;
case 't': /* --timeout in seconds */
if (!process_timeout_arg(optarg, &di.max_timeouts)) {
fprintf(stderr, "Invalid value of timeout parameter");
exit(EXIT_FAILURE);
}
/* 0 equals to wait indefinitely */
if (di.max_timeouts)
s.idle = ls.idle = &di;
server = 1;
break;
}
}
if (client && server) {
fprintf(stderr, "Invalid combination of client and server parameters.\n\n");
_usage(argv[0], stdout);
exit(EXIT_FAILURE);
}
if (client)
return _lvmpolld_client(s.socket_path, action);
/* Server */
daemon_start(s);
return EXIT_SUCCESS;
}

View File

@@ -1,389 +0,0 @@
/*
* Copyright (C) 2014-2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lvmpolld-common.h"
#include "config-util.h"
#include <fcntl.h>
#include <signal.h>
static char *_construct_full_lvname(const char *vgname, const char *lvname)
{
char *name;
size_t l;
l = strlen(vgname) + strlen(lvname) + 2; /* vg/lv and \0 */
name = (char *) dm_malloc(l * sizeof(char));
if (!name)
return NULL;
if (dm_snprintf(name, l, "%s/%s", vgname, lvname) < 0) {
dm_free(name);
name = NULL;
}
return name;
}
static char *_construct_lvm_system_dir_env(const char *sysdir)
{
/*
* Store either "LVM_SYSTEM_DIR=/path/to..."
* - or -
* just single char to store NULL byte
*/
size_t l = sysdir ? strlen(sysdir) + 16 : 1;
char *env = (char *) dm_malloc(l * sizeof(char));
if (!env)
return NULL;
*env = '\0';
if (sysdir && dm_snprintf(env, l, "LVM_SYSTEM_DIR=%s", sysdir) < 0) {
dm_free(env);
env = NULL;
}
return env;
}
static const char *_get_lvid(const char *lvmpolld_id, const char *sysdir)
{
return lvmpolld_id ? (lvmpolld_id + (sysdir ? strlen(sysdir) : 0)) : NULL;
}
char *construct_id(const char *sysdir, const char *uuid)
{
char *id;
int r;
size_t l;
l = strlen(uuid) + (sysdir ? strlen(sysdir) : 0) + 1;
id = (char *) dm_malloc(l * sizeof(char));
if (!id)
return NULL;
r = sysdir ? dm_snprintf(id, l, "%s%s", sysdir, uuid) :
dm_snprintf(id, l, "%s", uuid);
if (r < 0) {
dm_free(id);
id = NULL;
}
return id;
}
struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id,
const char *vgname, const char *lvname,
const char *sysdir, enum poll_type type,
const char *sinterval, unsigned pdtimeout,
struct lvmpolld_store *pdst)
{
char *lvmpolld_id = dm_strdup(id), /* copy */
*full_lvname = _construct_full_lvname(vgname, lvname), /* copy */
*lvm_system_dir_env = _construct_lvm_system_dir_env(sysdir); /* copy */
struct lvmpolld_lv tmp = {
.ls = ls,
.type = type,
.lvmpolld_id = lvmpolld_id,
.lvid = _get_lvid(lvmpolld_id, sysdir),
.lvname = full_lvname,
.lvm_system_dir_env = lvm_system_dir_env,
.sinterval = dm_strdup(sinterval), /* copy */
.pdtimeout = pdtimeout < MIN_POLLING_TIMEOUT ? MIN_POLLING_TIMEOUT : pdtimeout,
.cmd_state = { .retcode = -1, .signal = 0 },
.pdst = pdst,
.init_rq_count = 1
}, *pdlv = (struct lvmpolld_lv *) dm_malloc(sizeof(struct lvmpolld_lv));
if (!pdlv || !tmp.lvid || !tmp.lvname || !tmp.lvm_system_dir_env || !tmp.sinterval)
goto err;
memcpy(pdlv, &tmp, sizeof(*pdlv));
if (pthread_mutex_init(&pdlv->lock, NULL))
goto err;
return pdlv;
err:
dm_free((void *)full_lvname);
dm_free((void *)lvmpolld_id);
dm_free((void *)lvm_system_dir_env);
dm_free((void *)tmp.sinterval);
dm_free((void *)pdlv);
return NULL;
}
void pdlv_destroy(struct lvmpolld_lv *pdlv)
{
dm_free((void *)pdlv->lvmpolld_id);
dm_free((void *)pdlv->lvname);
dm_free((void *)pdlv->sinterval);
dm_free((void *)pdlv->lvm_system_dir_env);
dm_free((void *)pdlv->cmdargv);
dm_free((void *)pdlv->cmdenvp);
pthread_mutex_destroy(&pdlv->lock);
dm_free((void *)pdlv);
}
unsigned pdlv_get_polling_finished(struct lvmpolld_lv *pdlv)
{
unsigned ret;
pdlv_lock(pdlv);
ret = pdlv->polling_finished;
pdlv_unlock(pdlv);
return ret;
}
struct lvmpolld_lv_state pdlv_get_status(struct lvmpolld_lv *pdlv)
{
struct lvmpolld_lv_state r;
pdlv_lock(pdlv);
r.error = pdlv_locked_error(pdlv);
r.polling_finished = pdlv_locked_polling_finished(pdlv);
r.cmd_state = pdlv_locked_cmd_state(pdlv);
pdlv_unlock(pdlv);
return r;
}
void pdlv_set_cmd_state(struct lvmpolld_lv *pdlv, const struct lvmpolld_cmd_stat *cmd_state)
{
pdlv_lock(pdlv);
pdlv->cmd_state = *cmd_state;
pdlv_unlock(pdlv);
}
void pdlv_set_error(struct lvmpolld_lv *pdlv, unsigned error)
{
pdlv_lock(pdlv);
pdlv->error = error;
pdlv_unlock(pdlv);
}
void pdlv_set_polling_finished(struct lvmpolld_lv *pdlv, unsigned finished)
{
pdlv_lock(pdlv);
pdlv->polling_finished = finished;
pdlv_unlock(pdlv);
}
struct lvmpolld_store *pdst_init(const char *name)
{
struct lvmpolld_store *pdst = (struct lvmpolld_store *) dm_malloc(sizeof(struct lvmpolld_store));
if (!pdst)
return NULL;
pdst->store = dm_hash_create(32);
if (!pdst->store)
goto err_hash;
if (pthread_mutex_init(&pdst->lock, NULL))
goto err_mutex;
pdst->name = name;
pdst->active_polling_count = 0;
return pdst;
err_mutex:
dm_hash_destroy(pdst->store);
err_hash:
dm_free(pdst);
return NULL;
}
void pdst_destroy(struct lvmpolld_store *pdst)
{
if (!pdst)
return;
dm_hash_destroy(pdst->store);
pthread_mutex_destroy(&pdst->lock);
dm_free(pdst);
}
void pdst_locked_lock_all_pdlvs(const struct lvmpolld_store *pdst)
{
struct dm_hash_node *n;
dm_hash_iterate(n, pdst->store)
pdlv_lock(dm_hash_get_data(pdst->store, n));
}
void pdst_locked_unlock_all_pdlvs(const struct lvmpolld_store *pdst)
{
struct dm_hash_node *n;
dm_hash_iterate(n, pdst->store)
pdlv_unlock(dm_hash_get_data(pdst->store, n));
}
static void _pdlv_locked_dump(struct buffer *buff, const struct lvmpolld_lv *pdlv)
{
char tmp[1024];
const struct lvmpolld_cmd_stat *cmd_state = &pdlv->cmd_state;
/* pdlv-section { */
if (dm_snprintf(tmp, sizeof(tmp), "\t%s {\n", pdlv->lvmpolld_id) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tlvid=\"%s\"\n", pdlv->lvid) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\ttype=\"%s\"\n", polling_op(pdlv->type)) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tlvname=\"%s\"\n", pdlv->lvname) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tlvmpolld_internal_timeout=%d\n", pdlv->pdtimeout) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tlvm_command_interval=\"%s\"\n", pdlv->sinterval ?: "<undefined>") > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tLVM_SYSTEM_DIR=\"%s\"\n",
(*pdlv->lvm_system_dir_env ? (pdlv->lvm_system_dir_env + strlen("LVM_SYSTEM_DIR=")) : "<undefined>")) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tlvm_command_pid=%d\n", pdlv->cmd_pid) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tpolling_finished=%d\n", pdlv->polling_finished) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\terror_occured=%d\n", pdlv->error) > 0)
buffer_append(buff, tmp);
if (dm_snprintf(tmp, sizeof(tmp), "\t\tinit_requests_count=%d\n", pdlv->init_rq_count) > 0)
buffer_append(buff, tmp);
/* lvm_commmand-section { */
buffer_append(buff, "\t\tlvm_command {\n");
if (cmd_state->retcode == -1 && !cmd_state->signal)
buffer_append(buff, "\t\t\tstate=\"" LVMPD_RESP_IN_PROGRESS "\"\n");
else {
buffer_append(buff, "\t\t\tstate=\"" LVMPD_RESP_FINISHED "\"\n");
if (dm_snprintf(tmp, sizeof(tmp), "\t\t\treason=\"%s\"\n\t\t\tvalue=%d\n",
(cmd_state->signal ? LVMPD_REAS_SIGNAL : LVMPD_REAS_RETCODE),
(cmd_state->signal ?: cmd_state->retcode)) > 0)
buffer_append(buff, tmp);
}
buffer_append(buff, "\t\t}\n");
/* } lvm_commmand-section */
buffer_append(buff, "\t}\n");
/* } pdlv-section */
}
void pdst_locked_dump(const struct lvmpolld_store *pdst, struct buffer *buff)
{
struct dm_hash_node *n;
dm_hash_iterate(n, pdst->store)
_pdlv_locked_dump(buff, dm_hash_get_data(pdst->store, n));
}
void pdst_locked_send_cancel(const struct lvmpolld_store *pdst)
{
struct lvmpolld_lv *pdlv;
struct dm_hash_node *n;
dm_hash_iterate(n, pdst->store) {
pdlv = dm_hash_get_data(pdst->store, n);
if (!pdlv_locked_polling_finished(pdlv))
pthread_cancel(pdlv->tid);
}
}
void pdst_locked_destroy_all_pdlvs(const struct lvmpolld_store *pdst)
{
struct dm_hash_node *n;
dm_hash_iterate(n, pdst->store)
pdlv_destroy(dm_hash_get_data(pdst->store, n));
}
struct lvmpolld_thread_data *lvmpolld_thread_data_constructor(struct lvmpolld_lv *pdlv)
{
struct lvmpolld_thread_data *data = (struct lvmpolld_thread_data *) dm_malloc(sizeof(struct lvmpolld_thread_data));
if (!data)
return NULL;
data->pdlv = NULL;
data->line = NULL;
data->fout = data->ferr = NULL;
data->outpipe[0] = data->outpipe[1] = data->errpipe[0] = data->errpipe[1] = -1;
if (pipe(data->outpipe) || pipe(data->errpipe)) {
lvmpolld_thread_data_destroy(data);
return NULL;
}
if (fcntl(data->outpipe[0], F_SETFD, FD_CLOEXEC) ||
fcntl(data->outpipe[1], F_SETFD, FD_CLOEXEC) ||
fcntl(data->errpipe[0], F_SETFD, FD_CLOEXEC) ||
fcntl(data->errpipe[1], F_SETFD, FD_CLOEXEC)) {
lvmpolld_thread_data_destroy(data);
return NULL;
}
data->pdlv = pdlv;
return data;
}
void lvmpolld_thread_data_destroy(void *thread_private)
{
struct lvmpolld_thread_data *data = (struct lvmpolld_thread_data *) thread_private;
if (!data)
return;
if (data->pdlv) {
pdst_lock(data->pdlv->pdst);
/*
* FIXME: skip this step if lvmpolld is activated
* by systemd.
*/
if (!pdlv_get_polling_finished(data->pdlv))
kill(data->pdlv->cmd_pid, SIGTERM);
pdlv_set_polling_finished(data->pdlv, 1);
pdst_locked_dec(data->pdlv->pdst);
pdst_unlock(data->pdlv->pdst);
}
dm_free(data->line);
if (data->fout && !fclose(data->fout))
data->outpipe[0] = -1;
if (data->ferr && !fclose(data->ferr))
data->errpipe[0] = -1;
if (data->outpipe[0] >= 0)
close(data->outpipe[0]);
if (data->outpipe[1] >= 0)
close(data->outpipe[1]);
if (data->errpipe[0] >= 0)
close(data->errpipe[0]);
if (data->errpipe[1] >= 0)
close(data->errpipe[1]);
dm_free(data);
}

View File

@@ -1,215 +0,0 @@
/*
* Copyright (C) 2014-2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVMPOLLD_DATA_UTILS_H
#define _LVM_LVMPOLLD_DATA_UTILS_H
#include <pthread.h>
struct buffer;
struct lvmpolld_state;
enum poll_type {
PVMOVE = 0,
CONVERT,
MERGE,
MERGE_THIN,
POLL_TYPE_MAX
};
struct lvmpolld_cmd_stat {
int retcode;
int signal;
};
struct lvmpolld_store {
pthread_mutex_t lock;
void *store;
const char *name;
unsigned active_polling_count;
};
struct lvmpolld_lv {
/*
* accessing following vars doesn't
* require struct lvmpolld_lv lock
*/
struct lvmpolld_state *const ls;
const enum poll_type type;
const char *const lvid;
const char *const lvmpolld_id;
const char *const lvname; /* full vg/lv name */
const unsigned pdtimeout; /* in seconds */
const char *const sinterval;
const char *const lvm_system_dir_env;
struct lvmpolld_store *const pdst;
const char *const *cmdargv;
const char *const *cmdenvp;
/* only used by write */
pid_t cmd_pid;
pthread_t tid;
pthread_mutex_t lock;
/* block of shared variables protected by lock */
struct lvmpolld_cmd_stat cmd_state;
unsigned init_rq_count; /* for debuging purposes only */
unsigned polling_finished:1; /* no more updates */
unsigned error:1; /* unrecoverable error occured in lvmpolld */
};
typedef void (*lvmpolld_parse_output_fn_t) (struct lvmpolld_lv *pdlv, const char *line);
/* TODO: replace with configuration option */
#define MIN_POLLING_TIMEOUT 60
struct lvmpolld_lv_state {
unsigned error:1;
unsigned polling_finished:1;
struct lvmpolld_cmd_stat cmd_state;
};
struct lvmpolld_thread_data {
char *line;
size_t line_size;
int outpipe[2];
int errpipe[2];
FILE *fout;
FILE *ferr;
char buf[1024];
struct lvmpolld_lv *pdlv;
};
char *construct_id(const char *sysdir, const char *lvid);
/* LVMPOLLD_LV_T section */
/* only call with appropriate struct lvmpolld_store lock held */
struct lvmpolld_lv *pdlv_create(struct lvmpolld_state *ls, const char *id,
const char *vgname, const char *lvname,
const char *sysdir, enum poll_type type,
const char *sinterval, unsigned pdtimeout,
struct lvmpolld_store *pdst);
/* only call with appropriate struct lvmpolld_store lock held */
void pdlv_destroy(struct lvmpolld_lv *pdlv);
static inline void pdlv_lock(struct lvmpolld_lv *pdlv)
{
pthread_mutex_lock(&pdlv->lock);
}
static inline void pdlv_unlock(struct lvmpolld_lv *pdlv)
{
pthread_mutex_unlock(&pdlv->lock);
}
/*
* no struct lvmpolld_lv lock required section
*/
static inline int pdlv_is_type(const struct lvmpolld_lv *pdlv, enum poll_type type)
{
return pdlv->type == type;
}
static inline unsigned pdlv_get_timeout(const struct lvmpolld_lv *pdlv)
{
return pdlv->pdtimeout;
}
static inline enum poll_type pdlv_get_type(const struct lvmpolld_lv *pdlv)
{
return pdlv->type;
}
unsigned pdlv_get_polling_finished(struct lvmpolld_lv *pdlv);
struct lvmpolld_lv_state pdlv_get_status(struct lvmpolld_lv *pdlv);
void pdlv_set_cmd_state(struct lvmpolld_lv *pdlv, const struct lvmpolld_cmd_stat *cmd_state);
void pdlv_set_error(struct lvmpolld_lv *pdlv, unsigned error);
void pdlv_set_polling_finished(struct lvmpolld_lv *pdlv, unsigned finished);
/*
* struct lvmpolld_lv lock required section
*/
static inline struct lvmpolld_cmd_stat pdlv_locked_cmd_state(const struct lvmpolld_lv *pdlv)
{
return pdlv->cmd_state;
}
static inline int pdlv_locked_polling_finished(const struct lvmpolld_lv *pdlv)
{
return pdlv->polling_finished;
}
static inline unsigned pdlv_locked_error(const struct lvmpolld_lv *pdlv)
{
return pdlv->error;
}
/* struct lvmpolld_store manipulation routines */
struct lvmpolld_store *pdst_init(const char *name);
void pdst_destroy(struct lvmpolld_store *pdst);
void pdst_locked_dump(const struct lvmpolld_store *pdst, struct buffer *buff);
void pdst_locked_lock_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_unlock_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_destroy_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_send_cancel(const struct lvmpolld_store *pdst);
static inline void pdst_lock(struct lvmpolld_store *pdst)
{
pthread_mutex_lock(&pdst->lock);
}
static inline void pdst_unlock(struct lvmpolld_store *pdst)
{
pthread_mutex_unlock(&pdst->lock);
}
static inline void pdst_locked_inc(struct lvmpolld_store *pdst)
{
pdst->active_polling_count++;
}
static inline void pdst_locked_dec(struct lvmpolld_store *pdst)
{
pdst->active_polling_count--;
}
static inline unsigned pdst_locked_get_active_count(const struct lvmpolld_store *pdst)
{
return pdst->active_polling_count;
}
static inline int pdst_locked_insert(struct lvmpolld_store *pdst, const char *key, struct lvmpolld_lv *pdlv)
{
return dm_hash_insert(pdst->store, key, pdlv);
}
static inline struct lvmpolld_lv *pdst_locked_lookup(struct lvmpolld_store *pdst, const char *key)
{
return dm_hash_lookup(pdst->store, key);
}
static inline void pdst_locked_remove(struct lvmpolld_store *pdst, const char *key)
{
dm_hash_remove(pdst->store, key);
}
struct lvmpolld_thread_data *lvmpolld_thread_data_constructor(struct lvmpolld_lv *pdlv);
void lvmpolld_thread_data_destroy(void *thread_private);
#endif /* _LVM_LVMPOLLD_DATA_UTILS_H */

View File

@@ -1,52 +0,0 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVMPOLLD_PROTOCOL_H
#define _LVM_LVMPOLLD_PROTOCOL_H
#include "polling_ops.h"
#define LVMPOLLD_PROTOCOL "lvmpolld"
#define LVMPOLLD_PROTOCOL_VERSION 1
#define LVMPD_REQ_CONVERT CONVERT_POLL
#define LVMPD_REQ_DUMP "dump"
#define LVMPD_REQ_MERGE MERGE_POLL
#define LVMPD_REQ_MERGE_THIN MERGE_THIN_POLL
#define LVMPD_REQ_PROGRESS "progress_info"
#define LVMPD_REQ_PVMOVE PVMOVE_POLL
#define LVMPD_PARM_ABORT "abort"
#define LVMPD_PARM_HANDLE_MISSING_PVS "handle_missing_pvs"
#define LVMPD_PARM_INTERVAL "interval"
#define LVMPD_PARM_LVID "lvid"
#define LVMPD_PARM_LVNAME "lvname"
#define LVMPD_PARM_SYSDIR "sysdir"
#define LVMPD_PARM_VALUE "value" /* either retcode or signal value */
#define LVMPD_PARM_VGNAME "vgname"
#define LVMPD_RESP_FAILED "failed"
#define LVMPD_RESP_FINISHED "finished"
#define LVMPD_RESP_IN_PROGRESS "in_progress"
#define LVMPD_RESP_EINVAL "invalid"
#define LVMPD_RESP_NOT_FOUND "not_found"
#define LVMPD_RESP_OK "OK"
#define LVMPD_REAS_RETCODE "retcode" /* lvm cmd ret code */
#define LVMPD_REAS_SIGNAL "signal" /* lvm cmd terminating singal */
#define LVMPD_RET_DUP_FAILED 100
#define LVMPD_RET_EXC_FAILED 101
#endif /* _LVM_LVMPOLLD_PROTOCOL_H */

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_TOOL_POLLING_OPS_H
#define _LVM_TOOL_POLLING_OPS_H
/* this file is also part of lvmpolld protocol */
#define PVMOVE_POLL "pvmove"
#define CONVERT_POLL "convert"
#define MERGE_POLL "merge"
#define MERGE_THIN_POLL "merge_thin"
#endif /* _LVM_TOOL_POLLING_OPS_H */

View File

@@ -1,81 +0,0 @@
LVM poll daemon overview
========================
(last updated: 2015-05-09)
LVM poll daemon (lvmpolld) is the alternative for lvm2 classical polling
mechanisms. The motivation behind new lvmpolld was to create persistent
system service that would be more durable and transparent. It's suited
particularly for any systemd enabled distribution.
Before lvmpolld any background polling process originating in a lvm2 command
initiated inside cgroup of a systemd service could get killed if the main
process (service) exited in such cgroup. That could lead to premature termination
of such lvm2 polling process.
Also without lvmpolld there were no means to detect a particular polling process
suited for monitoring of specific operation is already in-progress and therefore
it's not desirable to start next one with exactly same task. lvmpolld is able to
detect such duplicate requests and not spawn such redundant process.
lvmpolld is primarily targeted for systems with systemd as init process. For systems
without systemd there's no need to install lvmpolld because there is no issue
with observation described in second paragraph. You can still benefit from
avoiding duplicate polling process being spawned, but without systemd lvmpolld
can't easily be run on-demand (activated by a socket maintained by systemd).
lvmpolld implement shutdown on idle and can shutdown automatically when idle
for requested time. 60 second is recommended default here. This behaviour can be
turned off if found useless.
Data structures
---------------
a) Logical Volume (struct lvmpolld_lv)
Each operation is identified by LV. Internal identifier within lvmpolld
is full LV uuid (vg_uuid+lv_uuid) prefixed with LVM_SYSTEM_DIR if set by client.
such full identifier may look like:
"/etc/lvm/lvm.confWFd2dU67S8Av29IcJCnYzqQirdfElnxzhCdzEh7EJrfCn9R1TIQjIj58weUZDre4"
or without LVM_SYSTEM_DIR being set explicitly:
"WFd2dU67S8Av29IcJCnYzqQirdfElnxzhCdzEh7EJrfCn9R1TIQjIj58weUZDre4"
LV carries various metadata about polling operation. The most significant are:
VG name
LV name
polling interval (usually --interval passed to lvm2 command or default from lvm2
configuration)
operation type (one of: pvmove, convert, merge, thin_merge)
LVM_SYSTEM_DIR (if set, this is also passed among environment variables of lvpoll
command spawned by lvmpolld)
b) LV stores (struct lvmpolld_store)
lvmpolld uses two stores for Logical volumes (struct lvmpolld_lv). One store for polling
operations in-progress. These operations are as of now: PV move, mirror up-conversion,
classical snapshot merge, thin snapshot merge.
The second store is suited only for pvmove --abort operations in-progress. Both
stores are independent and identical LVs (pvmove /dev/sda3 and pvmove --abort /dev/sda3)
can be run concurently from lvmpolld point of view (on lvm2 side the consistency is
guaranteed by lvm2 locking mechanism).
Locking order
-------------
There are two types of locks in lvmpolld. Each store has own store lock and each LV has
own lv lock.
Locking order is:
1) store lock
2) LV lock
Each LV has to be inside a store. When daemon requires to take both locks it has
to take a store lock first and LV lock has to be taken afterwards (after the
appropriate store lock where the LV is being stored :))

View File

@@ -1,8 +1,6 @@
@top_srcdir@/daemons/clvmd/clvm.h
@top_srcdir@/daemons/dmeventd/libdevmapper-event.h
@top_srcdir@/daemons/lvmetad/lvmetad-client.h
@top_srcdir@/daemons/lvmpolld/lvmpolld-protocol.h
@top_srcdir@/daemons/lvmpolld/polling_ops.h
@top_srcdir@/liblvm/lvm2app.h
@top_srcdir@/lib/activate/activate.h
@top_srcdir@/lib/activate/targets.h
@@ -31,8 +29,6 @@
@top_srcdir@/lib/locking/locking.h
@top_srcdir@/lib/log/log.h
@top_srcdir@/lib/log/lvm-logging.h
@top_srcdir@/lib/lvmpolld/lvmpolld-client.h
@top_srcdir@/lib/lvmpolld/polldaemon.h
@top_srcdir@/lib/metadata/lv.h
@top_srcdir@/lib/metadata/lv_alloc.h
@top_srcdir@/lib/metadata/metadata.h

View File

@@ -196,11 +196,6 @@ ifeq ("@BUILD_LVMETAD@", "yes")
cache/lvmetad.c
endif
ifeq ("@BUILD_LVMPOLLD@", "yes")
SOURCES +=\
lvmpolld/lvmpolld-client.c
endif
ifeq ("@DMEVENTD@", "yes")
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd
LIBS += -ldevmapper-event

338
lib/cache/lvmcache.c vendored
View File

@@ -67,7 +67,6 @@ struct lvmcache_vginfo {
unsigned vg_use_count; /* Counter of vg reusage */
unsigned precommitted; /* Is vgmetadata live or precommitted? */
unsigned cached_vg_invalidated; /* Signal to regenerate cached_vg */
unsigned preferred_duplicates; /* preferred duplicate pvs have been set */
};
static struct dm_hash_table *_pvid_hash = NULL;
@@ -116,47 +115,6 @@ int lvmcache_init(void)
return 1;
}
/*
* Once PV info has been populated in lvmcache and
* lvmcache has chosen preferred duplicate devices,
* set this flag so that lvmcache will not try to
* compare and choose preferred duplicate devices
* again (which may result in different preferred
* devices.) PV info can be populated in lvmcache
* multiple times, each time causing lvmcache to
* compare the duplicate devices, so we need to
* record that the comparison/preferences have
* already been done, so the preferrences from the
* first time through are not changed.
*
* This is something of a hack to work around the
* fact that the code isn't really designed to
* handle duplicate PVs, and the fact that lvmetad
* has its own way of picking a preferred duplicate
* and lvmcache has another way based on having
* more information than lvmetad does.
*
* If we come up with a better overall method to
* handle duplicate PVs, then this can probably be
* removed.
*
* FIXME: if we want to make lvmetad work with clvmd,
* then this may need to be changed to set
* preferred_duplicates back to 0.
*/
void lvmcache_set_preferred_duplicates(const char *vgid)
{
struct lvmcache_vginfo *vginfo;
if (!(vginfo = lvmcache_vginfo_from_vgid(vgid))) {
stack;
return;
}
vginfo->preferred_duplicates = 1;
}
void lvmcache_seed_infos_from_lvmetad(struct cmd_context *cmd)
{
if (!lvmetad_active() || _has_scanned)
@@ -905,37 +863,6 @@ int lvmcache_vginfo_holders_dec_and_test_for_zero(struct lvmcache_vginfo *vginfo
}
// #endif
int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
struct dm_list *vgnameids)
{
struct vgnameid_list *vgnl;
struct lvmcache_vginfo *vginfo;
lvmcache_label_scan(cmd, 0);
dm_list_iterate_items(vginfo, &_vginfos) {
if (!include_internal && is_orphan_vg(vginfo->vgname))
continue;
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
log_error("vgnameid_list allocation failed.");
return 0;
}
vgnl->vgid = dm_pool_strdup(cmd->mem, vginfo->vgid);
vgnl->vg_name = dm_pool_strdup(cmd->mem, vginfo->vgname);
if (!vgnl->vgid || !vgnl->vg_name) {
log_error("vgnameid_list member allocation failed.");
return 0;
}
dm_list_add(vgnameids, &vgnl->list);
}
return 1;
}
struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,
int include_internal)
{
@@ -1602,64 +1529,6 @@ void lvmcache_replace_dev(struct cmd_context *cmd, struct physical_volume *pv,
pv->dev = dev;
}
/*
* We can see multiple different devices with the
* same pvid, i.e. duplicates.
*
* There may be different reasons for seeing two
* devices with the same pvid:
* - multipath showing two paths to the same thing
* - one device copied to another, e.g. with dd,
* also referred to as cloned devices.
* - a "subsystem" taking a device and creating
* another device of its own that represents the
* underlying device it is using, e.g. using dm
* to create an identity mapping of a PV.
*
* Given duplicate devices, we have to choose one
* of them to be the "preferred" dev, i.e. the one
* that will be referenced in lvmcache, by pv->dev.
* We can keep the existing dev, that's currently
* used in lvmcache, or we can replace the existing
* dev with the new duplicate.
*
* Regardless of which device is preferred, we need
* to print messages explaining which devices were
* found so that a user can sort out for themselves
* what has happened if the preferred device is not
* the one they are interested in.
*
* If a user wants to use the non-preferred device,
* they will need to filter out the device that
* lvm is preferring.
*
* The dev_subsystem calls check if the major number
* of the dev is part of a subsystem like DM/MD/DRBD.
* A dev that's part of a subsystem is preferred over a
* duplicate of that dev that is not part of a
* subsystem.
*
* The has_holders calls check if the device is being
* used by another, and prefers one that's being used.
*
* FIXME: why do we prefer a device without holders
* over a device with holders? We should understand
* the reason for that choice.
*
* FIXME: there may be other reasons to prefer one
* device over another:
*
* . are there other use/open counts we could check
* beyond the holders?
*
* . check if either is bad/usable and prefer
* the good one?
*
* . prefer the one with smaller minor number?
* Might avoid disturbing things due to a new
* transient duplicate?
*/
struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
struct device *dev,
const char *vgname, const char *vgid,
@@ -1707,168 +1576,54 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
lvmcache_del_bas(info);
} else {
if (existing->dev != dev) {
int old_in_subsystem = 0;
int new_in_subsystem = 0;
int old_is_dm = 0;
int new_is_dm = 0;
int old_has_holders = 0;
int new_has_holders = 0;
/*
* Here are different devices with the same pvid:
* duplicates. See comment above.
*/
/*
* This flag tells the process_each_pv code to search
* the devices list for duplicates, so that devices
* can be processed together with their duplicates
* (while processing the VG, rather than reporting
* pv->dev under the VG, and its duplicate outside
* the VG context.)
*/
_found_duplicate_pvs = 1;
/*
* The new dev may not have pvid set.
* The process_each_pv code needs to have the pvid
* set in each device to detect that the devices
* are duplicates.
*/
strncpy(dev->pvid, pvid_s, sizeof(dev->pvid));
/*
* Now decide if we are going to ignore the new
* device, or replace the existing/old device in
* lvmcache with the new one.
*/
old_in_subsystem = dev_subsystem_part_major(dt, existing->dev);
new_in_subsystem = dev_subsystem_part_major(dt, dev);
old_is_dm = dm_is_dm_major(MAJOR(existing->dev->dev));
new_is_dm = dm_is_dm_major(MAJOR(dev->dev));
old_has_holders = dm_device_has_holders(MAJOR(existing->dev->dev), MINOR(existing->dev->dev));
new_has_holders = dm_device_has_holders(MAJOR(dev->dev), MINOR(dev->dev));
if (old_has_holders && new_has_holders) {
/*
* This is not a selection of old or new, but
* just a warning to be aware of.
*/
log_warn("WARNING: duplicate PV %s is being used from both devices %s and %s",
pvid_s,
dev_name(existing->dev),
dev_name(dev));
}
if (existing->vginfo->preferred_duplicates) {
/*
* The preferred duplicate devs have already
* been chosen during a previous populating of
* lvmcache, so just use the existing preferences.
*/
log_verbose("Found duplicate PV %s: using existing dev %s",
pvid_s,
dev_name(existing->dev));
/* Is the existing entry a duplicate pvid e.g. md ? */
if (dev_subsystem_part_major(dt, existing->dev) &&
!dev_subsystem_part_major(dt, dev)) {
log_very_verbose("Ignoring duplicate PV %s on "
"%s - using %s %s",
pvid, dev_name(dev),
dev_subsystem_name(dt, existing->dev),
dev_name(existing->dev));
return NULL;
} else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
!dm_is_dm_major(MAJOR(dev->dev))) {
log_very_verbose("Ignoring duplicate PV %s on "
"%s - using dm %s",
pvid, dev_name(dev),
dev_name(existing->dev));
return NULL;
} else if (!dev_subsystem_part_major(dt, existing->dev) &&
dev_subsystem_part_major(dt, dev))
log_very_verbose("Duplicate PV %s on %s - "
"using %s %s", pvid,
dev_name(existing->dev),
dev_subsystem_name(dt, existing->dev),
dev_name(dev));
else if (!dm_is_dm_major(MAJOR(existing->dev->dev)) &&
dm_is_dm_major(MAJOR(dev->dev)))
log_very_verbose("Duplicate PV %s on %s - "
"using dm %s", pvid,
dev_name(existing->dev),
dev_name(dev));
/* FIXME If both dm, check dependencies */
//else if (dm_is_dm_major(MAJOR(existing->dev->dev)) &&
//dm_is_dm_major(MAJOR(dev->dev)))
//
else if (!strcmp(pvid_s, existing->dev->pvid)) {
log_error("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(existing->dev),
dev_name(dev));
strncpy(dev->pvid, pvid_s, sizeof(dev->pvid));
_found_duplicate_pvs = 1;
return NULL;
}
if (old_in_subsystem && !new_in_subsystem) {
/* Use old, ignore new. */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(existing->dev),
dev_name(dev));
log_warn("Using duplicate PV %s from subsystem %s, ignoring %s",
dev_name(existing->dev),
dev_subsystem_name(dt, existing->dev),
dev_name(dev));
return NULL;
} else if (!old_in_subsystem && new_in_subsystem) {
/* Use new, replace old. */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(dev),
dev_name(existing->dev));
log_warn("Using duplicate PV %s from subsystem %s, replacing %s",
dev_name(dev),
dev_subsystem_name(dt, dev),
dev_name(existing->dev));
} else if (old_has_holders && !new_has_holders) {
/* Use new, replace old. */
/* FIXME: why choose the one without olders? */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(dev),
dev_name(existing->dev));
log_warn("Using duplicate PV %s without holders, replacing %s",
dev_name(dev),
dev_name(existing->dev));
} else if (!old_has_holders && new_has_holders) {
/* Use old, ignore new. */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(existing->dev),
dev_name(dev));
log_warn("Using duplicate PV %s without holders, ignoring %s",
dev_name(existing->dev),
dev_name(dev));
return NULL;
} else if (old_is_dm && new_is_dm) {
/* Use new, replace old. */
/* FIXME: why choose the new instead of the old? */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(dev),
dev_name(existing->dev));
log_warn("Using duplicate PV %s which is last seen, replacing %s",
dev_name(dev),
dev_name(existing->dev));
} else if (!strcmp(pvid_s, existing->dev->pvid)) {
/* No criteria to use for preferring old or new. */
/* FIXME: why choose the new instead of the old? */
/* FIXME: a transient duplicate would be a reason
* to select the old instead of the new. */
log_warn("Found duplicate PV %s: using %s not %s",
pvid_s,
dev_name(dev),
dev_name(existing->dev));
log_warn("Using duplicate PV %s which is last seen, replacing %s",
dev_name(dev),
dev_name(existing->dev));
}
} else {
/*
* The new dev is the same as the existing dev.
*
* FIXME: Why can't we just return NULL here if the
* device already exists? Things don't seem to work
* if we do that for some reason.
*/
log_verbose("Found same device %s with same pvid %s",
dev_name(existing->dev), pvid_s);
}
/*
* FIXME: when could this ever happen?
* If this does happen, identify when/why here, and
* if not, remove this code.
*/
if (strcmp(pvid_s, existing->dev->pvid)) {
log_warn("Replacing dev %s pvid %s with dev %s pvid %s",
dev_name(existing->dev), existing->dev->pvid,
dev_name(dev), pvid_s);
}
/*
* Switch over to new preferred device.
*/
if (strcmp(pvid_s, existing->dev->pvid))
log_debug_cache("Updating pvid cache to %s (%s) from %s (%s)",
pvid_s, dev_name(dev),
existing->dev->pvid, dev_name(existing->dev));
/* Switch over to new preferred device */
existing->dev = dev;
info = existing;
/* Has labeller changed? */
@@ -2318,8 +2073,7 @@ int lvmcache_lookup_mda(struct lvmcache_vgsummary *vgsummary)
vgsummary->vgname = vginfo->vgname;
vgsummary->creation_host = vginfo->creation_host;
vgsummary->vgstatus = vginfo->status;
/* vginfo->vgid has 1 extra byte then vgsummary->vgid */
memcpy(&vgsummary->vgid, vginfo->vgid, sizeof(vgsummary->vgid));
memcpy((char *)&vgsummary->vgid, vginfo->vgid, sizeof(vginfo->vgid));
return 1;
}

View File

@@ -107,9 +107,6 @@ struct dm_list *lvmcache_get_vgnames(struct cmd_context *cmd,
struct dm_list *lvmcache_get_vgids(struct cmd_context *cmd,
int include_internal);
int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
struct dm_list *vgnameids);
/* Returns list of struct dm_str_list containing pool-allocated copy of pvids */
struct dm_list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname,
const char *vgid);
@@ -174,6 +171,4 @@ void lvmcache_replace_dev(struct cmd_context *cmd, struct physical_volume *pv,
int lvmcache_found_duplicate_pvs(void);
void lvmcache_set_preferred_duplicates(const char *vgid);
#endif

97
lib/cache/lvmetad.c vendored
View File

@@ -265,12 +265,11 @@ static int _read_mda(struct lvmcache_info *info,
return 0;
}
static int _pv_populate_lvmcache(struct cmd_context *cmd,
struct dm_config_node *cn,
struct format_type *fmt, dev_t fallback)
static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
struct dm_config_node *cn,
struct format_type *fmt, dev_t fallback)
{
struct device *dev, *dev_alternate, *dev_alternate_cache = NULL;
struct label *label;
struct device *dev, *dev_alternate;
struct id pvid, vgid;
char mda_id[32];
char da_id[32];
@@ -279,7 +278,7 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
struct dm_config_node *alt_devices = dm_config_find_node(cn->child, "devices_alternate");
struct dm_config_value *alt_device = NULL;
uint64_t offset, size;
struct lvmcache_info *info, *info_alternate;
struct lvmcache_info *info;
const char *pvid_txt = dm_config_find_str(cn->child, "id", NULL),
*vgid_txt = dm_config_find_str(cn->child, "vgid", NULL),
*vgname = dm_config_find_str(cn->child, "vgname", NULL),
@@ -293,7 +292,7 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
if (!fmt) {
log_error("PV %s not recognised. Is the device missing?", pvid_txt);
return 0;
return NULL;
}
dev = dev_cache_get_by_devt(devt, cmd->filter);
@@ -302,17 +301,17 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
if (!dev) {
log_warn("WARNING: Device for PV %s not found or rejected by a filter.", pvid_txt);
return 0;
return NULL;
}
if (!pvid_txt || !id_read_format(&pvid, pvid_txt)) {
log_error("Missing or ill-formatted PVID for PV: %s.", pvid_txt);
return 0;
return NULL;
}
if (vgid_txt) {
if (!id_read_format(&vgid, vgid_txt))
return_0;
return_NULL;
} else
strcpy((char*)&vgid, fmt->orphan_vg_name);
@@ -321,7 +320,7 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
if (!(info = lvmcache_add(fmt->labeller, (const char *)&pvid, dev,
vgname, (const char *)&vgid, 0)))
return_0;
return_NULL;
lvmcache_get_label(info)->sector = label_sector;
lvmcache_get_label(info)->dev = dev;
@@ -367,32 +366,16 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
while (alt_device) {
dev_alternate = dev_cache_get_by_devt(alt_device->v.i, cmd->filter);
if (dev_alternate) {
if ((info_alternate = lvmcache_add(fmt->labeller, (const char *)&pvid, dev_alternate,
vgname, (const char *)&vgid, 0))) {
dev_alternate_cache = dev_alternate;
info = info_alternate;
lvmcache_get_label(info)->dev = dev_alternate;
}
} else {
if (dev_alternate)
lvmcache_add(fmt->labeller, (const char *)&pvid, dev_alternate,
vgname, (const char *)&vgid, 0);
else
log_warn("Duplicate of PV %s dev %s exists on unknown device %"PRId64 ":%" PRId64,
pvid_txt, dev_name(dev), MAJOR(alt_device->v.i), MINOR(alt_device->v.i));
}
alt_device = alt_device->next;
}
/*
* Update lvmcache with the info about the alternate device by
* reading its label, which should update lvmcache.
*/
if (dev_alternate_cache) {
if (!label_read(dev_alternate_cache, &label, 0)) {
log_warn("No PV label found on duplicate device %s.", dev_name(dev_alternate_cache));
}
}
lvmcache_set_preferred_duplicates((const char *)&vgid);
return 1;
return info;
}
struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgname, const char *vgid)
@@ -674,56 +657,6 @@ int lvmetad_pv_list_to_lvmcache(struct cmd_context *cmd)
return 1;
}
int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids)
{
struct vgnameid_list *vgnl;
struct id vgid;
const char *vgid_txt;
const char *vg_name;
daemon_reply reply;
struct dm_config_node *cn;
log_debug_lvmetad("Asking lvmetad for complete list of known VG ids/names");
reply = _lvmetad_send("vg_list", NULL);
if (!_lvmetad_handle_reply(reply, "list VGs", "", NULL)) {
daemon_reply_destroy(reply);
return_0;
}
if ((cn = dm_config_find_node(reply.cft->root, "volume_groups"))) {
for (cn = cn->child; cn; cn = cn->sib) {
vgid_txt = cn->key;
if (!id_read_format(&vgid, vgid_txt)) {
stack;
continue;
}
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
log_error("vgnameid_list allocation failed.");
return 0;
}
if (!(vg_name = dm_config_find_str(cn->child, "name", NULL))) {
log_error("vg_list no name found.");
return 0;
}
vgnl->vgid = dm_pool_strdup(cmd->mem, (char *)&vgid);
vgnl->vg_name = dm_pool_strdup(cmd->mem, vg_name);
if (!vgnl->vgid || !vgnl->vg_name) {
log_error("vgnameid_list member allocation failed.");
return 0;
}
dm_list_add(vgnameids, &vgnl->list);
}
}
daemon_reply_destroy(reply);
return 1;
}
int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd)
{
struct volume_group *tmp;

6
lib/cache/lvmetad.h vendored
View File

@@ -142,12 +142,6 @@ int lvmetad_pv_lookup_by_dev(struct cmd_context *cmd, struct device *dev, int *f
*/
int lvmetad_vg_list_to_lvmcache(struct cmd_context *cmd);
/*
* Request a list of vgid/vgname pairs for all VGs known to lvmetad.
* Does not do vg_lookup's on each VG, and does not populate lvmcache.
*/
int lvmetad_get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids);
/*
* Find a VG by its ID or its name in the lvmetad cache. Gives NULL if the VG is
* not found.

View File

@@ -282,16 +282,9 @@ static int _cache_add_target_line(struct dev_manager *dm,
struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count __attribute__((unused)))
{
struct lv_segment *cache_pool_seg;
struct lv_segment *cache_pool_seg = first_seg(seg->pool_lv);
char *metadata_uuid, *data_uuid, *origin_uuid;
if (!seg->pool_lv || !seg_is_cache(seg)) {
log_error(INTERNAL_ERROR "Passed segment is not cache.");
return 0;
}
cache_pool_seg = first_seg(seg->pool_lv);
if (!(metadata_uuid = build_dm_uuid(mem, cache_pool_seg->metadata_lv, NULL)))
return_0;

View File

@@ -30,7 +30,6 @@
#include "lvmcache.h"
#include "lvmetad.h"
#include "archiver.h"
#include "lvmpolld-client.h"
#ifdef HAVE_LIBDL
#include "sharedlib.h"
@@ -274,8 +273,6 @@ static int _parse_debug_classes(struct cmd_context *cmd)
debug_classes |= LOG_CLASS_CACHE;
else if (!strcasecmp(cv->v.str, "locking"))
debug_classes |= LOG_CLASS_LOCKING;
else if (!strcasecmp(cv->v.str, "lvmpolld"))
debug_classes |= LOG_CLASS_LVMPOLLD;
else
log_verbose("Unrecognised value for log/debug_classes: %s", cv->v.str);
}
@@ -478,7 +475,6 @@ static int _process_config(struct cmd_context *cmd)
const struct dm_config_value *cv;
int64_t pv_min_kb;
const char *lvmetad_socket;
const char *lvmpolld_socket;
int udev_disabled = 0;
char sysfs_dir[PATH_MAX];
@@ -622,7 +618,6 @@ static int _process_config(struct cmd_context *cmd)
(find_config_tree_bool(cmd, global_detect_internal_vg_cache_corruption_CFG, NULL));
lvmetad_disconnect();
lvmpolld_disconnect();
lvmetad_socket = getenv("LVM_LVMETAD_SOCKET");
if (!lvmetad_socket)
@@ -649,13 +644,6 @@ static int _process_config(struct cmd_context *cmd)
if (!_init_system_id(cmd))
return_0;
lvmpolld_socket = getenv("LVM_LVMPOLLD_SOCKET");
if (!lvmpolld_socket)
lvmpolld_socket = DEFAULT_RUN_DIR "/lvmpolld.socket";
lvmpolld_set_socket(lvmpolld_socket);
lvmpolld_set_active(find_config_tree_bool(cmd, global_use_lvmpolld_CFG, NULL));
return 1;
}
@@ -2077,7 +2065,6 @@ void destroy_toolcontext(struct cmd_context *cmd)
lvmetad_release_token();
lvmetad_disconnect();
lvmpolld_disconnect();
release_log_memory();
activation_exit();

View File

@@ -65,11 +65,11 @@ struct config_source {
* Map each ID to respective definition of the configuration item.
*/
static struct cfg_def_item _cfg_def_items[CFG_COUNT + 1] = {
#define cfg_section(id, name, parent, flags, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, {0}, deprecated_since_version, deprecation_comment, comment},
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, deprecated_since_version, deprecation_comment, comment},
#define cfg_runtime(id, name, parent, flags, type, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, deprecation_comment, comment},
#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, {.v_UNCONFIGURED = unconfigured_value}, deprecated_since_version, deprecation_comment, comment},
#define cfg_array_runtime(id, name, parent, flags, types, since_version, deprecated_since_version, deprecation_comment, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, {.fn_UNCONFIGURED = get_default_unconfigured_##id}, deprecated_since_version, deprecation_comment, comment},
#define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_SECTION, {0}, flags, since_version, unconfigured_path, comment},
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) {id, parent, name, type, {.v_##type = default_value}, flags, since_version, unconfigured_path, comment},
#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) {id, parent, name, type, {.fn_##type = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.v_CFG_TYPE_STRING = default_value}, flags, since_version, unconfigured_path, comment},
#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) {id, parent, name, CFG_TYPE_ARRAY | types, {.fn_CFG_TYPE_STRING = get_default_##id}, flags | CFG_DEFAULT_RUN_TIME, since_version, unconfigured_path, comment},
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -604,7 +604,6 @@ struct timespec config_file_timestamp(struct dm_config_tree *cft)
}
#define cfg_def_get_item_p(id) (&_cfg_def_items[id])
#define cfg_def_get_default_unconfigured_value_hint(cmd,item) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_unconfigured_value.fn_UNCONFIGURED(cmd) : item->default_unconfigured_value.v_UNCONFIGURED)
#define cfg_def_get_default_value_hint(cmd,item,type,profile) ((item->flags & CFG_DEFAULT_RUN_TIME) ? item->default_value.fn_##type(cmd,profile) : item->default_value.v_##type)
#define cfg_def_get_default_value(cmd,item,type,profile) (item->flags & CFG_DEFAULT_UNDEFINED ? 0 : cfg_def_get_default_value_hint(cmd,item,type,profile))
@@ -826,12 +825,6 @@ static int _check_value_differs_from_default(struct cft_check_handle *handle,
float f;
const char *str;
if ((handle->ignoreunsupported && (def->flags & CFG_UNSUPPORTED)) ||
(handle->ignoreadvanced && (def->flags & CFG_ADVANCED))) {
diff = 0;
goto out;
}
/* if default value is undefined, the value used differs from default */
if (def->flags & CFG_DEFAULT_UNDEFINED) {
diff = 1;
@@ -1525,25 +1518,6 @@ static int _copy_one_line(const char *comment, char *line, int *pos, int len)
return i;
}
static int _get_config_node_version(uint16_t version_enc, char *version)
{
if (dm_snprintf(version, 9, "%u.%u.%u",
(version_enc & 0xE000) >> 13,
(version_enc & 0x1E00) >> 9,
(version_enc & 0x1FF)) == -1) {
log_error("_get_config_node_version: couldn't create version string");
return 0;
}
return 1;
}
static int _def_node_is_deprecated(cfg_def_item_t *def, struct config_def_tree_spec *spec)
{
return def->deprecated_since_version &&
(spec->version >= def->deprecated_since_version);
}
static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, void *baton)
{
struct out_baton *out = baton;
@@ -1561,37 +1535,27 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
return 0;
}
if (out->tree_spec->type == CFG_DEF_TREE_LIST)
return 1;
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
return 1;
cfg_def = cfg_def_get_item_p(cn->id);
if (out->tree_spec->withsummary || out->tree_spec->withcomments) {
if (out->tree_spec->withcomments || out->tree_spec->withfullcomments) {
_cfg_def_make_path(path, sizeof(path), cfg_def->id, cfg_def, 1);
fprintf(out->fp, "\n");
fprintf(out->fp, "%s# Configuration %s %s.\n", line, node_type_name, path);
if (out->tree_spec->withcomments &&
_def_node_is_deprecated(cfg_def, out->tree_spec))
fprintf(out->fp, "%s# %s", line, cfg_def->deprecation_comment);
if (cfg_def->comment) {
int pos = 0;
while (_copy_one_line(cfg_def->comment, commentline, &pos, strlen(cfg_def->comment))) {
fprintf(out->fp, "%s# %s\n", line, commentline);
/* withsummary prints only the first comment line. */
if (!out->tree_spec->withcomments)
/* withcomments prints only the first comment line. */
if (!out->tree_spec->withfullcomments)
break;
}
}
if (_def_node_is_deprecated(cfg_def, out->tree_spec))
fprintf(out->fp, "%s# This configuration %s is deprecated.\n", line, node_type_name);
if (cfg_def->flags & CFG_ADVANCED)
fprintf(out->fp, "%s# This configuration %s is advanced.\n", line, node_type_name);
@@ -1606,15 +1570,14 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
}
if (out->tree_spec->withversions) {
if (!_get_config_node_version(cfg_def->since_version, version))
return_0;
fprintf(out->fp, "%s# Available since version %s.\n", line, version);
if (_def_node_is_deprecated(cfg_def, out->tree_spec)) {
if (!_get_config_node_version(cfg_def->deprecated_since_version, version))
return_0;
fprintf(out->fp, "%s# Deprecated since version %s.\n", line, version);
if (dm_snprintf(version, 9, "%u.%u.%u",
(cfg_def->since_version & 0xE000) >> 13,
(cfg_def->since_version & 0x1E00) >> 9,
(cfg_def->since_version & 0x1FF)) == -1) {
log_error("_out_prefix_fn: couldn't create version string");
return 0;
}
fprintf(out->fp, "%s# Since version %s.\n", line, version);
}
return 1;
@@ -1623,55 +1586,15 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
static int _out_line_fn(const struct dm_config_node *cn, const char *line, void *baton)
{
struct out_baton *out = baton;
struct cfg_def_item *cfg_def;
char config_path[CFG_PATH_MAX_LEN];
char summary[MAX_COMMENT_LINE+1];
char version[9];
int pos = 0;
size_t len;
char *space_prefix;
struct cfg_def_item *cfg_def = cfg_def_get_item_p(cn->id);
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
return 1;
cfg_def = cfg_def_get_item_p(cn->id);
if (out->tree_spec->type == CFG_DEF_TREE_LIST) {
/* List view with node paths and summary. */
if (cfg_def->type & CFG_TYPE_SECTION)
return 1;
if (!_cfg_def_make_path(config_path, CFG_PATH_MAX_LEN, cfg_def->id, cfg_def, 1))
return_0;
if (out->tree_spec->withversions && !_get_config_node_version(cfg_def->since_version, version))
return_0;
summary[0] = '\0';
if (out->tree_spec->withsummary && cfg_def->comment)
_copy_one_line(cfg_def->comment, summary, &pos, strlen(cfg_def->comment));
fprintf(out->fp, "%s%s%s%s%s%s%s\n", config_path,
*summary || out->tree_spec->withversions ? " - ": "",
*summary ? summary : "",
*summary ? " " : "",
out->tree_spec->withversions ? "[" : "",
out->tree_spec->withversions ? version : "",
out->tree_spec->withversions ? "]" : "");
return 1;
}
/* Usual tree view with nodes and their values. */
if ((out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
(out->tree_spec->type != CFG_DEF_TREE_DIFF) &&
(cfg_def->flags & (CFG_DEFAULT_UNDEFINED | CFG_DEFAULT_COMMENTED))) {
space_prefix = ((len = strspn(line, "\t "))) ? dm_pool_strndup(out->mem, line, len) : NULL;
fprintf(out->fp, "%s%s%s\n", space_prefix ? : "", "# ", line + len);
if (space_prefix)
dm_pool_free(out->mem, space_prefix);
} else
fprintf(out->fp, "%s\n", line);
fprintf(out->fp, "%s%s\n", (out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
(out->tree_spec->type != CFG_DEF_TREE_DIFF) &&
(cfg_def->flags & CFG_DEFAULT_UNDEFINED) ? "#" : "", line);
return 1;
}
@@ -1752,10 +1675,7 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
cn->id = def->id;
if (spec->unconfigured && def->default_unconfigured_value.v_UNCONFIGURED) {
cn->v->type = DM_CFG_STRING;
cn->v->v.str = cfg_def_get_default_unconfigured_value_hint(spec->cmd, def);
} else if (!(def->type & CFG_TYPE_ARRAY)) {
if (!(def->type & CFG_TYPE_ARRAY)) {
switch (def->type) {
case CFG_TYPE_SECTION:
cn->v = NULL;
@@ -1777,6 +1697,9 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
if (!(str = cfg_def_get_default_value_hint(spec->cmd, def, CFG_TYPE_STRING, NULL)))
str = "";
cn->v->v.str = str;
if (spec->unconfigured && def->unconfigured_path)
cn->v->v.str = def->unconfigured_path;
break;
default:
log_error(INTERNAL_ERROR "_add_def_node: unknown type");
@@ -1800,11 +1723,6 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
return cn;
}
static int _should_skip_deprecated_def_node(cfg_def_item_t *def, struct config_def_tree_spec *spec)
{
return spec->ignoredeprecated && _def_node_is_deprecated(def, spec);
}
static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_id, int id)
{
cfg_def_item_t *def = cfg_def_get_item_p(id);
@@ -1824,21 +1742,18 @@ static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_
}
if ((spec->check_status[id] & CFG_USED) ||
(def->flags & CFG_NAME_VARIABLE) ||
(def->since_version > spec->version) ||
_should_skip_deprecated_def_node(def, spec))
(def->since_version > spec->version))
return 1;
break;
case CFG_DEF_TREE_NEW:
if ((def->since_version != spec->version) ||
_should_skip_deprecated_def_node(def, spec))
if (def->since_version != spec->version)
return 1;
break;
case CFG_DEF_TREE_PROFILABLE:
case CFG_DEF_TREE_PROFILABLE_CMD:
case CFG_DEF_TREE_PROFILABLE_MDA:
if (!(def->flags & CFG_PROFILABLE) ||
(def->since_version > spec->version) ||
_should_skip_deprecated_def_node(def, spec))
(def->since_version > spec->version))
return 1;
flags = def->flags & ~CFG_PROFILABLE;
if (spec->type == CFG_DEF_TREE_PROFILABLE_CMD) {
@@ -1850,8 +1765,7 @@ static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_
}
break;
default:
if ((def->since_version > spec->version) ||
_should_skip_deprecated_def_node(def, spec))
if (def->since_version > spec->version)
return 1;
break;
}
@@ -2093,11 +2007,6 @@ const char *get_default_devices_cache_dir_CFG(struct cmd_context *cmd, struct pr
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_unconfigured_devices_cache_dir_CFG(struct cmd_context *cmd)
{
return "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@";
}
const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profile *profile)
{
const char *cache_dir = NULL, *cache_file_prefix = NULL;
@@ -2132,24 +2041,6 @@ const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profil
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_unconfigured_devices_cache_CFG(struct cmd_context *cmd)
{
const char *cache_file_prefix = NULL;
static char buf[PATH_MAX];
if (find_config_tree_node(cmd, devices_cache_file_prefix_CFG, NULL))
cache_file_prefix = find_config_tree_str_allow_empty(cmd, devices_cache_file_prefix_CFG, NULL);
if (dm_snprintf(buf, sizeof(buf), "%s/%s.cache",
get_default_unconfigured_devices_cache_dir_CFG(cmd),
cache_file_prefix ? : DEFAULT_CACHE_FILE_PREFIX) < 0) {
log_error("Persistent cache filename too long.");
return NULL;
}
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2163,11 +2054,6 @@ const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct pr
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_unconfigured_backup_backup_dir_CFG(struct cmd_context *cmd)
{
return "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@";
}
const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2181,11 +2067,6 @@ const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct p
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_unconfigured_backup_archive_dir_CFG(struct cmd_context *cmd)
{
return "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@";
}
const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile)
{
static char buf[PATH_MAX];
@@ -2199,11 +2080,6 @@ const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct p
return dm_pool_strdup(cmd->mem, buf);
}
const char *get_default_unconfigured_config_profile_dir_CFG(struct cmd_context *cmd)
{
return "@DEFAULT_SYS_DIR@/@DEFAULT_PROFILE_SUBDIR@";
}
const char *get_default_activation_mirror_image_fault_policy_CFG(struct cmd_context *cmd, struct profile *profile)
{
return find_config_tree_str(cmd, activation_mirror_device_fault_policy_CFG, profile);

View File

@@ -72,7 +72,6 @@ typedef int (*t_fn_CFG_TYPE_INT) (struct cmd_context *cmd, struct profile *profi
typedef float (*t_fn_CFG_TYPE_FLOAT) (struct cmd_context *cmd, struct profile *profile);
typedef const char* (*t_fn_CFG_TYPE_STRING) (struct cmd_context *cmd, struct profile *profile);
typedef const char* (*t_fn_CFG_TYPE_ARRAY) (struct cmd_context *cmd, struct profile *profile);
typedef const char* (*t_fn_UNCONFIGURED) (struct cmd_context *cmd);
/* configuration definition item value (for item's default value) */
typedef union {
@@ -89,11 +88,6 @@ typedef union {
t_fn_CFG_TYPE_ARRAY fn_CFG_TYPE_ARRAY;
} cfg_def_value_t;
typedef union {
const char *v_UNCONFIGURED;
t_fn_UNCONFIGURED fn_UNCONFIGURED;
} cfg_def_unconfigured_value_t;
/* configuration definition item flags: */
@@ -113,26 +107,22 @@ typedef union {
#define CFG_PROFILABLE_METADATA 0x030
/* whether the default value is undefned */
#define CFG_DEFAULT_UNDEFINED 0x040
/* whether the default value is commented out on output */
#define CFG_DEFAULT_COMMENTED 0x080
/* whether the default value is calculated during run time */
#define CFG_DEFAULT_RUN_TIME 0x100
#define CFG_DEFAULT_RUN_TIME 0x080
/* whether the configuration setting is disabled (and hence defaults always used) */
#define CFG_DISABLED 0x200
#define CFG_DISABLED 0x100
/* configuration definition item structure */
typedef struct cfg_def_item {
int id; /* ID of this item */
int parent; /* ID of parent item */
const char *name; /* name of the item in configuration tree */
int type; /* configuration item type (bits of cfg_def_type_t) */
cfg_def_value_t default_value; /* default value (only for settings) */
uint16_t flags; /* configuration item definition flags */
uint16_t since_version; /* version this item appeared in */
cfg_def_unconfigured_value_t default_unconfigured_value; /* default value in terms of @FOO@, pre-configured (only for settings) */
uint16_t deprecated_since_version; /* version since this item is deprecated */
const char *deprecation_comment; /* comment about reasons for deprecation and settings that supersede this one */
const char *comment; /* comment */
int id; /* ID of this item */
int parent; /* ID of parent item */
const char *name; /* name of the item in configuration tree */
int type; /* configuration item type (bits of cfg_def_type_t) */
cfg_def_value_t default_value; /* default value (only for settings) */
uint16_t flags; /* configuration item definition flags */
uint16_t since_version; /* version this item appeared in */
const char *unconfigured_path; /* path in terms of @FOO@, pre-configured */
const char *comment; /* brief comment */
} cfg_def_item_t;
/* configuration definition tree types */
@@ -146,7 +136,6 @@ typedef enum {
CFG_DEF_TREE_PROFILABLE_CMD, /* tree of all nodes that are customizable by command profiles (subset of PROFILABLE) */
CFG_DEF_TREE_PROFILABLE_MDA, /* tree of all nodes that are customizable by metadata profiles (subset of PROFILABLE) */
CFG_DEF_TREE_DIFF, /* tree of all nodes that differ from defaults */
CFG_DEF_TREE_LIST, /* list all nodes */
} cfg_def_tree_t;
/* configuration definition tree specification */
@@ -154,14 +143,13 @@ struct config_def_tree_spec {
struct cmd_context *cmd; /* command context (for run-time defaults */
cfg_def_tree_t type; /* tree type */
uint16_t version; /* tree at this LVM2 version */
unsigned ignoreadvanced:1; /* do not include advanced configs */
unsigned ignoreadvanced:1; /* do not include advanced configs */
unsigned ignoreunsupported:1; /* do not include unsupported configs */
unsigned ignoredeprecated:1; /* do not include deprecated configs */
unsigned ignorelocal:1; /* do not include the local section */
unsigned withsummary:1; /* include first line of comments - a summary */
unsigned withcomments:1; /* include all comment lines */
unsigned withversions:1; /* include versions */
unsigned unconfigured:1; /* use unconfigured path strings */
unsigned withcomments:1; /* include first line of comment */
unsigned withfullcomments:1; /* include all comment lines */
unsigned withversions:1; /* include versions */
unsigned unconfigured:1; /* use unconfigured path strings */
uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */
};
@@ -177,11 +165,11 @@ struct config_def_tree_spec {
* Register ID for each possible item in the configuration tree.
*/
enum {
#define cfg_section(id, name, parent, flags, since_version, deprecated_since_version, deprecation_comment, comment) id,
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) id,
#define cfg_runtime(id, name, parent, flags, type, since_version, deprecated_since_version, deprecation_comment, comment) id,
#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_value, deprecated_since_version, deprecation_comment, comment) id,
#define cfg_array_runtime(id, name, parent, flags, types, since_version, deprecated_since_version, deprecation_comment, comment) id,
#define cfg_section(id, name, parent, flags, since_version, unconfigured_path, comment) id,
#define cfg(id, name, parent, flags, type, default_value, since_version, unconfigured_path, comment) id,
#define cfg_runtime(id, name, parent, flags, type, since_version, unconfigured_path, comment) id,
#define cfg_array(id, name, parent, flags, types, default_value, since_version, unconfigured_path, comment) id,
#define cfg_array_runtime(id, name, parent, flags, types, since_version, unconfigured_path, comment) id,
#include "config_settings.h"
#undef cfg_section
#undef cfg
@@ -203,8 +191,6 @@ struct cft_check_handle {
unsigned skip_if_checked:1; /* skip the check if already done before - return last state */
unsigned suppress_messages:1; /* suppress messages during the check if config item is found invalid */
unsigned check_diff:1; /* check if the value used differs from default one */
unsigned ignoreadvanced:1; /* do not include advnced configs */
unsigned ignoreunsupported:1; /* do not include unsupported configs */
uint8_t status[CFG_COUNT]; /* flags for each configuration item - the result of the check */
};
@@ -274,20 +260,12 @@ int find_config_tree_bool(struct cmd_context *cmd, int id, struct profile *profi
* value is evaluated at runtime based on command context.
*/
const char *get_default_devices_cache_dir_CFG(struct cmd_context *cmd, struct profile *profile);
const char *get_default_unconfigured_devices_cache_dir_CFG(struct cmd_context *cmd);
const char *get_default_devices_cache_CFG(struct cmd_context *cmd, struct profile *profile);
const char *get_default_unconfigured_devices_cache_CFG(struct cmd_context *cmd);
const char *get_default_backup_backup_dir_CFG(struct cmd_context *cmd, struct profile *profile);
const char *get_default_unconfigured_backup_backup_dir_CFG(struct cmd_context *cmd);
const char *get_default_backup_archive_dir_CFG(struct cmd_context *cmd, struct profile *profile);
const char *get_default_unconfigured_backup_archive_dir_CFG(struct cmd_context *cmd);
const char *get_default_config_profile_dir_CFG(struct cmd_context *cmd, struct profile *profile);
const char *get_default_unconfigured_config_profile_dir_CFG(struct cmd_context *cmd);
const char *get_default_activation_mirror_image_fault_policy_CFG(struct cmd_context *cmd, struct profile *profile);
#define get_default_unconfigured_activation_mirror_image_fault_policy_CFG NULL
int get_default_allocation_thin_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile);
#define get_default_unconfigured_allocation_thin_pool_chunk_size_CFG NULL
int get_default_allocation_cache_pool_chunk_size_CFG(struct cmd_context *cmd, struct profile *profile);
#define get_default_unconfigured_allocation_cache_pool_chunk_size_CFG NULL
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -144,8 +144,7 @@
#define DEFAULT_LOGGED_DEBUG_CLASSES (LOG_CLASS_MEM | LOG_CLASS_DEVS | \
LOG_CLASS_ACTIVATION | LOG_CLASS_ALLOC | LOG_CLASS_LVMETAD | \
LOG_CLASS_METADATA | LOG_CLASS_CACHE | LOG_CLASS_LOCKING | \
LOG_CLASS_LVMPOLLD)
LOG_CLASS_METADATA | LOG_CLASS_CACHE | LOG_CLASS_LOCKING)
#define DEFAULT_SYSLOG 1
#define DEFAULT_VERBOSE 0

View File

@@ -225,9 +225,6 @@ int dev_subsystem_part_major(struct dev_types *dt, struct device *dev)
const char *dev_subsystem_name(struct dev_types *dt, struct device *dev)
{
if (MAJOR(dev->dev) == dt->device_mapper_major)
return "DM";
if (MAJOR(dev->dev) == dt->md_major)
return "MD";
@@ -433,7 +430,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
*/
if ((parts = dt->dev_type_array[major].max_partitions) > 1) {
if ((residue = minor % parts)) {
*result = MKDEV((dev_t)major, (dev_t)(minor - residue));
*result = MKDEV((dev_t)major, (minor - residue));
ret = 2;
} else {
*result = dev->dev;
@@ -510,7 +507,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
path, buffer);
goto out;
}
*result = MKDEV((dev_t)major, (dev_t)minor);
*result = MKDEV((dev_t)major, minor);
ret = 2;
out:
if (fp && fclose(fp))

View File

@@ -180,7 +180,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
}
/* Is VG being imported? */
if (vg && !vg_is_exported(vg) && vg->lvm1_system_id && *vg->lvm1_system_id &&
if (vg && !vg_is_exported(vg) && *vg->lvm1_system_id &&
!strncmp(vg->lvm1_system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG))
return_0;
@@ -192,7 +192,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
return_0;
/* Update internal system_id if we changed it */
if (vg && vg->lvm1_system_id &&
if (vg &&
(!*vg->lvm1_system_id ||
strncmp(vg->lvm1_system_id, (char *)pvd->system_id, sizeof(pvd->system_id))))
strncpy(vg->lvm1_system_id, (char *)pvd->system_id, NAME_LEN);

View File

@@ -1603,9 +1603,9 @@ static int _text_pv_initialise(const struct format_type *fmt,
if (rp->extent_count)
pv->pe_count = rp->extent_count;
if ((pv->pe_start + pv->pe_count * (uint64_t)pv->pe_size - 1) > pv->size) {
if ((pv->pe_start + pv->pe_count * pv->pe_size - 1) > (pv->size << SECTOR_SHIFT)) {
log_error("Physical extents end beyond end of device %s.",
pv_dev_name(pv));
pv_dev_name(pv));
return 0;
}
@@ -2172,7 +2172,7 @@ static int _text_pv_add_metadata_area(const struct format_type *fmt,
* LABEL_SCAN_SIZE.
*/
pe_end = pv->pe_count ? (pv->pe_start +
pv->pe_count * (uint64_t)pv->pe_size - 1) << SECTOR_SHIFT
pv->pe_count * pv->pe_size - 1) << SECTOR_SHIFT
: 0;
if (pe_start || pe_start_locked) {

View File

@@ -251,7 +251,7 @@ static int _read_pv(struct format_instance *fid,
_read_uint64(pvn, "ba_start", &ba_start);
_read_uint64(pvn, "ba_size", &size);
if (ba_start && size) {
log_debug_metadata("Found bootloader area specification for PV %s "
log_debug("Found bootloader area specification for PV %s "
"in metadata: ba_start=%" PRIu64 ", ba_size=%" PRIu64 ".",
pv_dev_name(pv), ba_start, size);
pv->ba_start = ba_start;

View File

@@ -418,8 +418,8 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf,
if (!(ext_version = xlate32(pvhdr_ext->version)))
goto out;
log_debug_metadata("%s: PV header extension version %" PRIu32 " found",
dev_name(dev), ext_version);
log_debug("%s: PV header extension version %" PRIu32 " found",
dev_name(dev), ext_version);
/* Bootloader areas */
dlocn_xl = pvhdr_ext->bootloader_areas_xl;

View File

@@ -67,7 +67,6 @@
#define LOG_CLASS_METADATA 0x0020 /* "metadata" */
#define LOG_CLASS_CACHE 0x0040 /* "cache" */
#define LOG_CLASS_LOCKING 0x0080 /* "locking" */
#define LOG_CLASS_LVMPOLLD 0x0100 /* "lvmpolld" */
#define log_debug(x...) LOG_LINE(_LOG_DEBUG, x)
#define log_debug_mem(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_MEM, x)
@@ -78,7 +77,6 @@
#define log_debug_metadata(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_METADATA, x)
#define log_debug_cache(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_CACHE, x)
#define log_debug_locking(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_LOCKING, x)
#define log_debug_lvmpolld(x...) LOG_LINE_WITH_CLASS(_LOG_DEBUG, LOG_CLASS_LVMPOLLD, x)
#define log_info(x...) LOG_LINE(_LOG_INFO, x)
#define log_notice(x...) LOG_LINE(_LOG_NOTICE, x)

View File

@@ -1,353 +0,0 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "daemon-io.h"
#include "lvmpolld-client.h"
#include "lvmpolld-protocol.h"
#include "metadata-exported.h"
#include "polldaemon.h"
#include "toolcontext.h"
#include "lvm2cmd.h"
struct progress_info {
unsigned error:1;
unsigned finished:1;
int cmd_signal;
int cmd_retcode;
};
static int _lvmpolld_use;
static int _lvmpolld_connected;
static const char* _lvmpolld_socket;
static daemon_handle _lvmpolld = { .error = 0 };
static daemon_handle _lvmpolld_open(const char *socket)
{
daemon_info lvmpolld_info = {
.path = "lvmpolld",
.socket = socket ?: LVMPOLLD_SOCKET,
.protocol = LVMPOLLD_PROTOCOL,
.protocol_version = LVMPOLLD_PROTOCOL_VERSION
};
return daemon_open(lvmpolld_info);
}
void lvmpolld_set_active(int active)
{
_lvmpolld_use = active;
}
void lvmpolld_set_socket(const char *socket)
{
_lvmpolld_socket = socket;
}
static void _lvmpolld_connect_or_warn(void)
{
if (!_lvmpolld_connected && !_lvmpolld.error) {
_lvmpolld = _lvmpolld_open(_lvmpolld_socket);
if ( _lvmpolld.socket_fd >= 0 && !_lvmpolld.error) {
log_debug_lvmpolld("Sucessfully connected to lvmpolld on fd %d.", _lvmpolld.socket_fd);
_lvmpolld_connected = 1;
} else {
log_warn("WARNING: Failed to connect to lvmpolld. Proceeding with polling without using lvmpolld.");
log_warn("WARNING: Check global/use_lvmpolld in lvm.conf or the lvmpolld daemon state.");
}
}
}
int lvmpolld_use(void)
{
if (!_lvmpolld_use || !_lvmpolld_socket)
return 0;
_lvmpolld_connect_or_warn();
return _lvmpolld_connected;
}
void lvmpolld_disconnect(void)
{
if (_lvmpolld_connected) {
daemon_close(_lvmpolld);
_lvmpolld_connected = 0;
}
}
static void _explain_error_codes(int retcode)
{
switch (retcode) {
/* LVM2 return codes */
case LVM2_NO_SUCH_COMMAND:
log_error("LVM command run by lvmpolld responded with: 'No such command.'");
break;
case LVM2_INVALID_PARAMETERS:
log_error("LVM command run by lvmpolld failed due to invalid parameters.");
break;
case LVM2_PROCESSING_FAILED:
log_error("LVM command executed by lvmpolld failed.");
break;
/* lvmpolld specific return codes */
case LVMPD_RET_DUP_FAILED:
log_error("lvmpolld failed to duplicate file descriptors.");
case LVMPD_RET_EXC_FAILED:
log_error("lvmpolld failed to exec() lvm binary.");
break;
default:
log_error("lvmpolld responded with unexpected return code.");
}
log_print_unless_silent("For more information see lvmpolld messages in syslog or lvmpolld log file.");
}
static void _process_error_response(daemon_reply rep)
{
if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_FAILED))
log_error("lvmpolld failed to process a request. The reason was: %s.",
daemon_reply_str(rep, "reason", "<empty>"));
else if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_EINVAL))
log_error("lvmpolld couldn't handle a request. "
"It might be due to daemon internal state. The reason was: %s.",
daemon_reply_str(rep, "reason", "<empty>"));
else
log_error("Unexpected response %s. The reason: %s.",
daemon_reply_str(rep, "response", "<empty>"),
daemon_reply_str(rep, "reason", "<empty>"));
log_print_unless_silent("For more information see lvmpolld messages in syslog or lvmpolld log file.");
}
static struct progress_info _request_progress_info(const char *uuid, unsigned abort_polling)
{
daemon_reply rep;
const char *e = getenv("LVM_SYSTEM_DIR");
struct progress_info ret = { .error = 1, .finished = 1 };
daemon_request req = daemon_request_make(LVMPD_REQ_PROGRESS);
if (!daemon_request_extend(req, LVMPD_PARM_LVID " = %s", uuid, NULL)) {
log_error("Failed to create " LVMPD_REQ_PROGRESS " request.");
goto out_req;
}
if (abort_polling &&
!daemon_request_extend(req, LVMPD_PARM_ABORT " = %d", abort_polling, NULL)) {
log_error("Failed to create " LVMPD_REQ_PROGRESS " request.");
goto out_req;
}
if (e &&
!(daemon_request_extend(req, LVMPD_PARM_SYSDIR " = %s",
e, NULL))) {
log_error("Failed to create " LVMPD_REQ_PROGRESS " request.");
goto out_req;
}
rep = daemon_send(_lvmpolld, req);
if (rep.error) {
log_error("Failed to process request with error %s (errno: %d).",
strerror(rep.error), rep.error);
goto out_rep;
}
if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_IN_PROGRESS)) {
ret.finished = 0;
ret.error = 0;
} else if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_FINISHED)) {
if (!strcmp(daemon_reply_str(rep, "reason", ""), LVMPD_REAS_SIGNAL))
ret.cmd_signal = daemon_reply_int(rep, LVMPD_PARM_VALUE, 0);
else
ret.cmd_retcode = daemon_reply_int(rep, LVMPD_PARM_VALUE, -1);
ret.error = 0;
} else if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_NOT_FOUND)) {
log_verbose("No polling operation in progress regarding LV %s.", uuid);
ret.error = 0;
} else {
_process_error_response(rep);
stack;
}
out_rep:
daemon_reply_destroy(rep);
out_req:
daemon_request_destroy(req);
return ret;
}
/*
* interval in seconds long
* enough for more than a year
* of waiting
*/
#define INTERV_SIZE 10
static int _process_poll_init(const struct cmd_context *cmd, const char *poll_type,
const struct poll_operation_id *id, const struct daemon_parms *parms)
{
char *str;
daemon_reply rep;
daemon_request req;
const char *e = getenv("LVM_SYSTEM_DIR");
int r = 0;
str = dm_malloc(INTERV_SIZE * sizeof(char));
if (!str)
return r;
if (snprintf(str, INTERV_SIZE, "%u", parms->interval) >= INTERV_SIZE) {
log_warn("Interval string conversion got truncated.");
str[INTERV_SIZE - 1] = '\0';
}
req = daemon_request_make(poll_type);
if (!daemon_request_extend(req, LVMPD_PARM_LVID " = %s", id->uuid,
LVMPD_PARM_VGNAME " = %s", id->vg_name,
LVMPD_PARM_LVNAME " = %s", id->lv_name,
LVMPD_PARM_INTERVAL " = %s", str,
"cmdline = %s", cmd->cmd_line, /* FIXME: debug param only */
NULL)) {
log_error("Failed to create %s request.", poll_type);
goto out_req;
}
if (parms->aborting &&
!(daemon_request_extend(req, LVMPD_PARM_ABORT " = %d", parms->aborting, NULL))) {
log_error("Failed to create %s request." , poll_type);
goto out_req;
}
if (cmd->handles_missing_pvs &&
!(daemon_request_extend(req, LVMPD_PARM_HANDLE_MISSING_PVS " = %d",
cmd->handles_missing_pvs, NULL))) {
log_error("Failed to create %s request." , poll_type);
goto out_req;
}
if (e &&
!(daemon_request_extend(req, LVMPD_PARM_SYSDIR " = %s",
e, NULL))) {
log_error("Failed to create %s request." , poll_type);
goto out_req;
}
rep = daemon_send(_lvmpolld, req);
if (rep.error) {
log_error("Failed to process request with error %s (errno: %d).",
strerror(rep.error), rep.error);
goto out_rep;
}
if (!strcmp(daemon_reply_str(rep, "response", ""), LVMPD_RESP_OK))
r = 1;
else {
_process_error_response(rep);
stack;
}
out_rep:
daemon_reply_destroy(rep);
out_req:
daemon_request_destroy(req);
dm_free(str);
return r;
}
int lvmpolld_poll_init(const struct cmd_context *cmd, const struct poll_operation_id *id,
const struct daemon_parms *parms)
{
int r = 0;
if (!id->uuid) {
log_error(INTERNAL_ERROR "Use of lvmpolld requires uuid set");
return 0;
}
if (!id->vg_name) {
log_error(INTERNAL_ERROR "Use of lvmpolld requires vgname set");
return 0;
}
if (!id->lv_name) {
log_error(INTERNAL_ERROR "Use of lvmpolld requires lvname set");
return 0;
}
if (parms->lv_type & PVMOVE) {
log_debug_lvmpolld("Asking lvmpolld for pvmove%s on %s/%s.",
parms->aborting ? " abort" : "", id->vg_name, id->lv_name);
r = _process_poll_init(cmd, LVMPD_REQ_PVMOVE, id, parms);
} else if (parms->lv_type & CONVERTING) {
log_debug_lvmpolld("Asking lvmpolld for mirror conversion on %s/%s.",
id->vg_name, id->lv_name);
r = _process_poll_init(cmd, LVMPD_REQ_CONVERT, id, parms);
} else if (parms->lv_type & MERGING) {
if (parms->lv_type & SNAPSHOT) {
log_debug_lvmpolld("Asking lvmpolld for snapshot merge on %s/%s.",
id->vg_name, id->lv_name);
r = _process_poll_init(cmd, LVMPD_REQ_MERGE, id, parms);
}
else if (parms->lv_type & THIN_VOLUME) {
log_debug_lvmpolld("Asking lvmpolld for thin snapshot merge on %s/%s.",
id->vg_name, id->lv_name);
r = _process_poll_init(cmd, LVMPD_REQ_MERGE_THIN, id, parms);
}
else {
log_error(INTERNAL_ERROR "Unsupported poll operation.");
}
} else
log_error(INTERNAL_ERROR "Unsupported poll operation");
return r;
}
int lvmpolld_request_info(const struct poll_operation_id *id, const struct daemon_parms *parms, unsigned *finished)
{
struct progress_info info;
int ret = 0;
*finished = 1;
if (!id->uuid) {
log_error(INTERNAL_ERROR "use of lvmpolld requires uuid being set");
return 0;
}
info = _request_progress_info(id->uuid, parms->aborting);
*finished = info.finished;
if (info.error)
return_0;
if (info.finished) {
if (info.cmd_signal)
log_error("Command executed by lvmpolld got terminated by signal (%d).",
info.cmd_signal);
else if (info.cmd_retcode)
_explain_error_codes(info.cmd_retcode);
else {
log_verbose("Polling finished successfully.");
ret = 1;
}
} else
ret = 1;
return ret;
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright (C) 2014-2015 Red Hat, Inc.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVMPOLLD_CLIENT_H
#define _LVM_LVMPOLLD_CLIENT_H
# ifdef LVMPOLLD_SUPPORT
# include "daemon-client.h"
# define LVMPOLLD_SOCKET DEFAULT_RUN_DIR "/lvmpolld.socket"
struct cmd_context;
struct poll_operation_id;
struct daemon_parms;
void lvmpolld_disconnect(void);
int lvmpolld_poll_init(const struct cmd_context *cmd, const struct poll_operation_id *id,
const struct daemon_parms *parms);
int lvmpolld_request_info(const struct poll_operation_id *id, const struct daemon_parms *parms,
unsigned *finished);
int lvmpolld_use(void);
void lvmpolld_set_active(int active);
void lvmpolld_set_socket(const char *socket);
# else
# define lvmpolld_disconnect() do {} while (0)
# define lvmpolld_poll_init(cmd, id, parms) (0)
# define lvmpolld_request_info(id, parms, finished) (0)
# define lvmpolld_use() (0)
# define lvmpolld_set_active(active) do {} while (0)
# define lvmpolld_set_socket(socket) do {} while (0)
# endif /* LVMPOLLD_SUPPORT */
#endif /* _LVM_LVMPOLLD_CLIENT_H */

View File

@@ -774,6 +774,9 @@ int get_default_region_size(struct cmd_context *cmd)
{
int region_size = _get_default_region_size(cmd);
if (region_size > INT32_MAX)
region_size = INT32_MAX;
if (region_size & (region_size - 1)) {
region_size = _round_down_pow2(region_size);
log_verbose("Reducing mirror region size to %u kiB (power of 2).",

View File

@@ -494,12 +494,6 @@ struct vg_list {
struct volume_group *vg;
};
struct vgnameid_list {
struct dm_list list;
const char *vg_name;
const char *vgid;
};
#define PV_PE_START_CALC ((uint64_t) -1) /* Calculate pe_start value */
struct pvcreate_restorable_params {
@@ -612,8 +606,6 @@ void lv_set_hidden(struct logical_volume *lv);
struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal);
struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
const char *only_this_vgname, int include_internal);
int scan_vgs_for_pvs(struct cmd_context *cmd, uint32_t warn_flags);
int pv_write(struct cmd_context *cmd, struct physical_volume *pv, int allow_non_orphan);

View File

@@ -1504,7 +1504,7 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name,
goto out;
}
if (*wiped)
if (wiped)
filter_refresh_needed = scan_needed = 1;
if (sigint_caught())
@@ -4017,54 +4017,6 @@ struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal)
return lvmcache_get_vgids(cmd, include_internal);
}
int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
const char *only_this_vgname, int include_internal)
{
struct vgnameid_list *vgnl;
struct format_type *fmt;
if (only_this_vgname) {
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
log_error("vgnameid_list allocation failed.");
return 0;
}
vgnl->vg_name = dm_pool_strdup(cmd->mem, only_this_vgname);
vgnl->vgid = NULL;
dm_list_add(vgnameids, &vgnl->list);
return 1;
}
if (lvmetad_active()) {
/*
* This just gets the list of names/ids from lvmetad
* and does not populate lvmcache.
*/
lvmetad_get_vgnameids(cmd, vgnameids);
if (include_internal) {
dm_list_iterate_items(fmt, &cmd->formats) {
if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
log_error("vgnameid_list allocation failed.");
return 0;
}
vgnl->vg_name = dm_pool_strdup(cmd->mem, fmt->orphan_vg_name);
vgnl->vgid = NULL;
dm_list_add(vgnameids, &vgnl->list);
}
}
} else {
/*
* The non-lvmetad case. This function begins by calling
* lvmcache_label_scan() to populate lvmcache.
*/
lvmcache_get_vgnameids(cmd, include_internal, vgnameids);
}
return 1;
}
static int _get_pvs(struct cmd_context *cmd, uint32_t warn_flags,
struct dm_list *pvslist, struct dm_list *vgslist)
{

View File

@@ -164,7 +164,7 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
uint64_t region_max;
uint64_t region_min, region_min_pow2;
region_max = (UINT64_C(1) << (ffs((int)extents) - 1)) * (UINT64_C(1) << (ffs((int)extent_size) - 1));
region_max = (1 << (ffs((int)extents) - 1)) * (uint64_t) (1 << (ffs((int)extent_size) - 1));
if (region_max < UINT32_MAX && region_size > region_max) {
region_size = (uint32_t) region_max;
@@ -1904,7 +1904,7 @@ static int _form_mirror(struct cmd_context *cmd, struct alloc_handle *ah,
}
if (!_create_mimage_lvs(ah, mirrors, stripes, stripe_size, lv, img_lvs, log))
return_0;
return 0;
if (!lv_add_mirror_lvs(lv, img_lvs, mirrors,
MIRROR_IMAGE | (lv->status & LOCKED),

View File

@@ -93,22 +93,6 @@ static int _raid_in_sync(struct logical_volume *lv)
lv->vg->name, lv->name);
return 0;
}
if (sync_percent == DM_PERCENT_0) {
/*
* FIXME We repeat the status read here to workaround an
* unresolved kernel bug when we see 0 even though the
* the array is 100% in sync.
* https://bugzilla.redhat.com/1210637
*/
if (!lv_raid_percent(lv, &sync_percent)) {
log_error("Unable to determine sync status of %s/%s.",
lv->vg->name, lv->name);
return 0;
}
if (sync_percent == DM_PERCENT_100)
log_warn("WARNING: Sync status for %s is inconsistent.",
display_lvname(lv));
}
return (sync_percent == DM_PERCENT_100) ? 1 : 0;
}

View File

@@ -95,12 +95,6 @@
/* Path to LVM system directory. */
#undef DEFAULT_SYS_DIR
/* Use lvmetad by default. */
#undef DEFAULT_USE_LVMETAD
/* Use lvmpolld by default. */
#undef DEFAULT_USE_LVMPOLLD
/* Define to 1 to enable LVM2 device-mapper interaction. */
#undef DEVMAPPER_SUPPORT
@@ -506,12 +500,6 @@
/* Define to 1 to include code that uses lvmetad. */
#undef LVMETAD_SUPPORT
/* Path to lvmpolld pidfile. */
#undef LVMPOLLD_PIDFILE
/* Define to 1 to include code that uses lvmpolld. */
#undef LVMPOLLD_SUPPORT
/* Path to lvm binary. */
#undef LVM_PATH

View File

@@ -30,17 +30,6 @@
#define PRIptrdiff_t "td"
#define PRIpid_t PRId32
#if defined(__GNUC__)
#define DM_EXPORTED_SYMBOL(func, ver) \
__asm__(".symver " #func "_v" #ver ", " #func "@@DM_" #ver )
#define DM_EXPORTED_SYMBOL_BASE(func) \
__asm__(".symver " #func "_base, " #func "@Base" )
#else
#define DM_EXPORTED_SYMBOL(func, ver)
#define DM_EXPORTED_SYMBOL_BASE(func)
#endif
#include "intl.h"
#include "libdevmapper.h"
#include "util.h"

View File

@@ -21,6 +21,7 @@
#include <sys/file.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/time.h>
/*
* Creates a temporary filename, and opens a descriptor to the

View File

@@ -26,11 +26,9 @@ struct lvm_property_type {
unsigned is_settable:1;
unsigned is_string:1;
unsigned is_integer:1;
unsigned is_signed:1;
union {
const char *string;
uint64_t integer;
int64_t signed_integer;
} value;
int (*get) (const void *obj, struct lvm_property_type *prop);
int (*set) (void *obj, struct lvm_property_type *prop);
@@ -128,10 +126,9 @@ static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
#define SIZ 4
#define PCT 5
#define STR_LIST 6
#define SNUM 7 /* Signed Number */
#define FIELD_MODIFIABLE 0x00000001
#define FIELD(type, strct, field_type, head, field, width, fn, id, desc, settable) \
{ type, #id, settable, (field_type == STR || field_type == STR_LIST), ((field_type == NUM) || (field_type == BIN) || (field_type == SIZ) || (field_type == PCT) || (field_type == SNUM)), ((field_type == SNUM) || (field_type == PCT)), { .integer = 0 }, _ ## id ## _get, _ ## id ## _set },
{ type, #id, settable, field_type == STR, ((field_type == NUM) || (field_type == BIN) || (field_type == SIZ) || (field_type == PCT)), { .integer = 0 }, _ ## id ## _get, _ ## id ## _set },
#endif

View File

@@ -56,8 +56,8 @@ FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the
FIELD(LVS, lv, BIN, "ActLocal", lvid, 10, lvactivelocally, lv_active_locally, "Set if the LV is active locally.", 0)
FIELD(LVS, lv, BIN, "ActRemote", lvid, 10, lvactiveremotely, lv_active_remotely, "Set if the LV is active remotely.", 0)
FIELD(LVS, lv, BIN, "ActExcl", lvid, 10, lvactiveexclusively, lv_active_exclusively, "Set if the LV is active exclusively.", 0)
FIELD(LVS, lv, SNUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, SNUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, SIZ, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0)
FIELD(LVS, lv, SIZ, "LSize", size, 5, size64, lv_size, "Size of LV in current units.", 0)
FIELD(LVS, lv, SIZ, "MSize", lvid, 6, lvmetadatasize, lv_metadata_size, "For thin and cache pools, the size of the LV that holds the metadata.", 0)
@@ -88,8 +88,8 @@ FIELD(LVS, lv, STR, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV,
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
FIELD(LVS, lv, STR_LIST, "Modules", lvid, 7, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
FIELD(LVSINFO, lv, SNUM, "KMaj", lvid, 4, lvkmaj, lv_kernel_major, "Currently assigned major number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, SNUM, "KMin", lvid, 4, lvkmin, lv_kernel_minor, "Currently assigned minor number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, NUM, "KMaj", lvid, 4, lvkmaj, lv_kernel_major, "Currently assigned major number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, NUM, "KMin", lvid, 4, lvkmin, lv_kernel_minor, "Currently assigned minor number or -1 if LV is not active.", 0)
FIELD(LVSINFO, lv, SIZ, "KRahead", lvid, 7, lvkreadahead, lv_kernel_read_ahead, "Currently-in-use read ahead setting in current units.", 0)
FIELD(LVSINFO, lv, STR, "LPerms", lvid, 8, lvpermissions, lv_permissions, "LV permissions.", 0)
FIELD(LVSINFO, lv, BIN, "Suspended", lvid, 10, lvsuspended, lv_suspended, "Set if LV is suspended.", 0)

View File

@@ -462,7 +462,7 @@ GET_PVSEG_NUM_PROPERTY_FN(pvseg_size, (SECTOR_SIZE * pvseg->len))
struct lvm_property_type _properties[] = {
#include "columns.h"
{ 0, "", 0, 0, 0, 0, { .integer = 0 }, prop_not_implemented_get, prop_not_implemented_set },
{ 0, "", 0, 0, 0, { .integer = 0 }, prop_not_implemented_get, prop_not_implemented_set },
};
#undef STR
@@ -471,7 +471,6 @@ struct lvm_property_type _properties[] = {
#undef SIZ
#undef PCT
#undef STR_LIST
#undef SNUM
#undef FIELD
int lvseg_get_property(const struct lv_segment *lvseg,

View File

@@ -2057,7 +2057,6 @@ static const struct dm_report_object_type _devtypes_report_types[] = {
#define SIZ DM_REPORT_FIELD_TYPE_SIZE
#define PCT DM_REPORT_FIELD_TYPE_PERCENT
#define STR_LIST DM_REPORT_FIELD_TYPE_STRING_LIST
#define SNUM DM_REPORT_FIELD_TYPE_NUMBER
#define FIELD(type, strct, sorttype, head, field, width, func, id, desc, writeable) \
{type, sorttype, offsetof(type_ ## strct, field), width, \
#id, head, &_ ## func ## _disp, desc},
@@ -2086,7 +2085,6 @@ static const struct dm_report_field_type _devtypes_fields[] = {
#undef BIN
#undef SIZ
#undef STR_LIST
#undef SNUM
#undef FIELD
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,

View File

@@ -19,7 +19,7 @@ top_builddir = @top_builddir@
SUBDIRS += client
ifeq (yes, $(shell test @BUILD_LVMETAD@ == yes -o @BUILD_LVMPOLLD@ == yes && echo yes))
ifeq ("@BUILD_LVMETAD@", "yes")
SUBDIRS += server
server: client
endif

View File

@@ -80,29 +80,6 @@ static void _exit_handler(int sig __attribute__((unused)))
# include <stdio.h>
static int _is_idle(daemon_state s)
{
return s.idle && s.idle->is_idle && !s.threads->next;
}
static struct timeval *_get_timeout(daemon_state s)
{
return s.idle ? s.idle->ptimeout : NULL;
}
static void _reset_timeout(daemon_state s)
{
if (s.idle) {
s.idle->ptimeout->tv_sec = 1;
s.idle->ptimeout->tv_usec = 0;
}
}
static unsigned _get_max_timeouts(daemon_state s)
{
return s.idle ? s.idle->max_timeouts : 0;
}
static int _set_oom_adj(const char *oom_adj_path, int val)
{
FILE *fp;
@@ -261,12 +238,12 @@ static int _open_socket(daemon_state s)
}
/* Socket already exists. If it's stale, remove it. */
if (lstat(sockaddr.sun_path, &buf)) {
if (stat(sockaddr.sun_path, &buf)) {
perror("stat failed");
goto error;
}
if (!S_ISSOCK(buf.st_mode)) {
if (S_ISSOCK(buf.st_mode)) {
fprintf(stderr, "%s: not a socket\n", sockaddr.sun_path);
goto error;
}
@@ -536,7 +513,6 @@ void daemon_start(daemon_state s)
int failed = 0;
log_state _log = { { 0 } };
thread_state _threads = { .next = NULL };
unsigned timeout_count = 0;
/*
* Switch to C locale to avoid reading large locale-archive file used by
@@ -568,10 +544,8 @@ void daemon_start(daemon_state s)
* NB. Take care to not keep stale locks around. Best not exit(...)
* after this point.
*/
if (dm_create_lockfile(s.pidfile) == 0) {
ERROR(&s, "Failed to acquire lock on %s. Already running?\n", s.pidfile);
if (dm_create_lockfile(s.pidfile) == 0)
exit(EXIT_ALREADYRUNNING);
}
(void) dm_prepare_selinux_context(NULL, 0);
}
@@ -597,8 +571,8 @@ void daemon_start(daemon_state s)
}
/* Set Close-on-exec */
if (!failed && fcntl(s.socket_fd, F_SETFD, 1))
ERROR(&s, "setting CLOEXEC on socket fd %d failed: %s\n", s.socket_fd, strerror(errno));
if (fcntl(s.socket_fd, F_SETFD, 1))
fprintf(stderr, "setting CLOEXEC on socket fd %d failed: %s\n", s.socket_fd, strerror(errno));
/* Signal parent, letting them know we are ready to go. */
if (!s.foreground)
@@ -609,28 +583,15 @@ void daemon_start(daemon_state s)
failed = 1;
while (!_shutdown_requested && !failed) {
_reset_timeout(s);
fd_set in;
FD_ZERO(&in);
FD_SET(s.socket_fd, &in);
if (select(FD_SETSIZE, &in, NULL, NULL, _get_timeout(s)) < 0 && errno != EINTR)
if (select(FD_SETSIZE, &in, NULL, NULL, NULL) < 0 && errno != EINTR)
perror("select error");
if (FD_ISSET(s.socket_fd, &in)) {
timeout_count = 0;
if (FD_ISSET(s.socket_fd, &in))
if (!_shutdown_requested && !handle_connect(s))
ERROR(&s, "Failed to handle a client connection.");
}
reap(s, 0);
/* s.idle == NULL equals no shutdown on timeout */
if (_is_idle(s)) {
DEBUGLOG(&s, "timeout occured");
if (++timeout_count >= _get_max_timeouts(s)) {
INFO(&s, "Inactive for %d seconds. Exiting.", timeout_count);
break;
}
}
}
INFO(&s, "%s waiting for client threads to finish", s.name);

View File

@@ -35,21 +35,6 @@ typedef struct {
struct buffer buffer;
} response;
struct timeval;
/*
* is_idle: daemon implementation sets it to true when no background task
* is running
* max_timeouts: how many seconds do daemon allow to be idle before it shutdowns
* ptimeout: internal variable passed to select(). has to be reset to 1 second
* before each select
*/
typedef struct {
volatile unsigned is_idle;
unsigned max_timeouts;
struct timeval *ptimeout;
} daemon_idle;
struct daemon_state;
/*
@@ -113,10 +98,6 @@ typedef struct daemon_state {
log_state *log;
struct thread_state *threads;
/* suport for shutdown on idle */
daemon_idle *idle;
void *private; /* the global daemon state */
} daemon_state;

View File

@@ -1,3 +1,3 @@
dm_log
dm_log_with_errno
dm_task_get_info_with_deferred_remove
dm_task_get_info

View File

@@ -1,287 +0,0 @@
dm_asprintf
dm_basename
dm_bit_and
dm_bit_get_first
dm_bit_get_next
dm_bitset_create
dm_bitset_destroy
dm_bitset_equal
dm_bit_union
dm_bounds_check_debug
dm_build_dm_name
dm_build_dm_uuid
dm_config_clone_node
dm_config_clone_node_with_mem
dm_config_create
dm_config_create_node
dm_config_create_value
dm_config_destroy
dm_config_find_bool
dm_config_find_float
dm_config_find_int
dm_config_find_int64
dm_config_find_node
dm_config_find_str
dm_config_find_str_allow_empty
dm_config_flatten
dm_config_from_string
dm_config_get_custom
dm_config_get_list
dm_config_get_section
dm_config_get_str
dm_config_get_uint32
dm_config_get_uint64
dm_config_has_node
dm_config_insert_cascaded_tree
dm_config_maybe_section
dm_config_memory
dm_config_parent_name
dm_config_parse
dm_config_remove_cascaded_tree
dm_config_remove_node
dm_config_set_custom
dm_config_tree_find_bool
dm_config_tree_find_float
dm_config_tree_find_int
dm_config_tree_find_int64
dm_config_tree_find_node
dm_config_tree_find_str
dm_config_tree_find_str_allow_empty
dm_config_value_is_bool
dm_config_write_node
dm_config_write_node_out
dm_config_write_one_node
dm_config_write_one_node_out
dm_cookie_supported
dm_count_chars
dm_create_dir
dm_create_lockfile
dm_daemon_is_running
dm_device_get_name
dm_device_has_holders
dm_device_has_mounted_fs
dm_dir
dm_driver_version
dm_dump_memory_debug
dm_escaped_len
dm_escape_double_quotes
dm_fclose
dm_format_dev
dm_free_aux
dm_get_library_version
dm_get_name_mangling_mode
dm_get_next_target
dm_get_status_cache
dm_get_status_raid
dm_get_status_snapshot
dm_get_status_thin
dm_get_status_thin_pool
dm_get_suspended_counter
dm_hash_create
dm_hash_destroy
dm_hash_get_data
dm_hash_get_first
dm_hash_get_key
dm_hash_get_next
dm_hash_get_num_entries
dm_hash_insert
dm_hash_insert_binary
dm_hash_iter
dm_hash_lookup
dm_hash_lookup_binary
dm_hash_remove
dm_hash_remove_binary
dm_hash_wipe
dm_is_dm_major
dm_is_empty_dir
dm_lib_exit
dm_lib_init
dm_lib_release
dm_list_add
dm_list_add_h
dm_list_del
dm_list_empty
dm_list_end
dm_list_first
dm_list_init
dm_list_last
dm_list_move
dm_list_next
dm_list_prev
dm_list_size
dm_list_splice
dm_list_start
dm_log
dm_log_init
dm_log_init_verbose
dm_log_is_non_default
dm_log_with_errno
dm_log_with_errno_init
dm_make_percent
dm_malloc_aux
dm_malloc_aux_debug
dm_mknodes
dm_mountinfo_read
dm_percent_to_float
dm_pool_abandon_object
dm_pool_alloc
dm_pool_alloc_aligned
dm_pool_begin_object
dm_pool_create
dm_pool_destroy
dm_pool_empty
dm_pool_end_object
dm_pool_free
dm_pool_grow_object
dm_pool_lock
dm_pool_locked
dm_pool_strdup
dm_pool_strndup
dm_pool_unlock
dm_pool_zalloc
dm_prepare_selinux_context
dm_realloc_aux
dm_regex_create
dm_regex_fingerprint
dm_regex_match
dm_report_compact_fields
dm_report_field_int
dm_report_field_int32
dm_report_field_percent
dm_report_field_set_value
dm_report_field_string
dm_report_field_string_list
dm_report_field_string_list_unsorted
dm_report_field_uint32
dm_report_field_uint64
dm_report_free
dm_report_init
dm_report_init_with_selection
dm_report_object
dm_report_object_is_selected
dm_report_output
dm_report_set_output_field_name_prefix
dm_set_dev_dir
dm_set_name_mangling_mode
dm_set_selinux_context
dm_set_sysfs_dir
dm_set_uuid_prefix
dm_snprintf
dm_split_lvm_name
dm_split_words
dm_strdup_aux
dm_strncpy
dm_sysfs_dir
dm_task_add_target
dm_task_create
dm_task_deferred_remove
dm_task_destroy
dm_task_enable_checks
dm_task_get_deps
dm_task_get_driver_version
dm_task_get_info
dm_task_get_info_with_deferred_remove
dm_task_get_message_response
dm_task_get_name
dm_task_get_name_mangled
dm_task_get_names
dm_task_get_name_unmangled
dm_task_get_read_ahead
dm_task_get_uuid
dm_task_get_uuid_mangled
dm_task_get_uuid_unmangled
dm_task_get_versions
dm_task_no_flush
dm_task_no_open_count
dm_task_query_inactive_table
dm_task_retry_remove
dm_task_run
dm_task_secure_data
dm_task_set_add_node
dm_task_set_cookie
dm_task_set_event_nr
dm_task_set_geometry
dm_task_set_gid
dm_task_set_major
dm_task_set_major_minor
dm_task_set_message
dm_task_set_minor
dm_task_set_mode
dm_task_set_name
dm_task_set_newname
dm_task_set_newuuid
dm_task_set_read_ahead
dm_task_set_ro
dm_task_set_sector
dm_task_set_uid
dm_task_set_uuid
dm_task_skip_lockfs
dm_task_suppress_identical_reload
dm_task_update_nodes
dm_tree_activate_children
dm_tree_add_dev
dm_tree_add_dev_with_udev_flags
dm_tree_add_new_dev
dm_tree_add_new_dev_with_udev_flags
dm_tree_create
dm_tree_deactivate_children
dm_tree_find_node
dm_tree_find_node_by_uuid
dm_tree_free
dm_tree_get_cookie
dm_tree_children_use_uuid
dm_tree_next_child
dm_tree_node_add_cache_target
dm_tree_node_add_crypt_target
dm_tree_node_add_error_target
dm_tree_node_add_linear_target
dm_tree_node_add_mirror_target
dm_tree_node_add_mirror_target_log
dm_tree_node_add_null_area
dm_tree_node_add_raid_target
dm_tree_node_add_raid_target_with_params
dm_tree_node_add_replicator_dev_target
dm_tree_node_add_replicator_target
dm_tree_node_add_snapshot_merge_target
dm_tree_node_add_snapshot_origin_target
dm_tree_node_add_snapshot_target
dm_tree_node_add_striped_target
dm_tree_node_add_target_area
dm_tree_node_add_thin_pool_message
dm_tree_node_add_thin_pool_target
dm_tree_node_add_thin_target
dm_tree_node_add_zero_target
dm_tree_node_get_context
dm_tree_node_get_info
dm_tree_node_get_name
dm_tree_node_get_uuid
dm_tree_node_num_children
dm_tree_node_set_callback
dm_tree_node_set_presuspend_node
dm_tree_node_set_read_ahead
dm_tree_node_set_thin_external_origin
dm_tree_node_set_thin_pool_discard
dm_tree_node_set_thin_pool_error_if_no_space
dm_tree_node_set_udev_flags
dm_tree_node_size_changed
dm_tree_preload_children
dm_tree_retry_remove
dm_tree_set_cookie
dm_tree_set_optional_uuid_suffixes
dm_tree_skip_lockfs
dm_tree_suspend_children
dm_tree_use_no_flush_suspend
dm_udev_complete
dm_udev_create_cookie
dm_udev_get_checking
dm_udev_get_sync_support
dm_udev_set_checking
dm_udev_set_sync_support
dm_udev_wait
dm_unescape_colons_and_at_signs
dm_unescape_double_quotes
dm_units_to_factor
dm_uuid_prefix
dm_vasprintf
dm_zalloc_aux
dm_zalloc_aux_debug

View File

@@ -1 +0,0 @@
dm_task_get_info

View File

@@ -33,7 +33,8 @@ SOURCES =\
regex/ttree.c \
$(interface)/libdm-iface.c
INCLUDES = -I$(srcdir)/$(interface)
INCLUDES = -I$(srcdir)/$(interface) -I$(srcdir)
CFLAGS += $(UDEV_CFLAGS) $(VALGRIND_CFLAGS)
ifeq ("@STATIC_LINK@", "yes")
LIB_STATIC = $(interface)/libdevmapper.a
@@ -41,7 +42,7 @@ endif
LIB_SHARED = $(interface)/libdevmapper.$(LIB_SUFFIX)
LIB_VERSION = $(LIB_VERSION_DM)
TARGETS = libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
TARGETS += libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
CFLOW_LIST = $(SOURCES)
CFLOW_LIST_TARGET = libdevmapper.cflow
@@ -51,8 +52,6 @@ EXPORTED_FN_PREFIX = dm
include $(top_builddir)/make.tmpl
CFLAGS += $(UDEV_CFLAGS) $(VALGRIND_CFLAGS)
DEFS += -DDM_DEVICE_UID=@DM_DEVICE_UID@ -DDM_DEVICE_GID=@DM_DEVICE_GID@ \
-DDM_DEVICE_MODE=@DM_DEVICE_MODE@

View File

@@ -245,7 +245,7 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
return -1;
}
if (major && buf.st_rdev != MKDEV((dev_t)major, (dev_t)minor)) {
if (major && buf.st_rdev != MKDEV((dev_t)major, minor)) {
log_verbose("%s: Wrong device number: (%u, %u) instead of "
"(%u, %u)", control,
MAJOR(buf.st_mode), MINOR(buf.st_mode),
@@ -288,7 +288,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
(void) dm_prepare_selinux_context(control, S_IFCHR);
old_umask = umask(DM_CONTROL_NODE_UMASK);
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
MKDEV((dev_t)major, (dev_t)minor)) < 0) {
MKDEV((dev_t)major, minor)) < 0) {
log_sys_error("mknod", control);
(void) dm_prepare_selinux_context(NULL, 0);
return 0;
@@ -666,13 +666,7 @@ int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
return 1;
}
#if defined(__GNUC__)
int dm_task_get_info_v1_02_97(struct dm_task *dmt, struct dm_info *info);
DM_EXPORTED_SYMBOL(dm_task_get_info, 1_02_97);
int dm_task_get_info_v1_02_97(struct dm_task *dmt, struct dm_info *info)
#else
int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
#endif
{
if (!dmt->dmi.v4)
return 0;
@@ -689,7 +683,6 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
info->inactive_table = dmt->dmi.v4->flags & DM_INACTIVE_PRESENT_FLAG ?
1 : 0;
info->deferred_remove = dmt->dmi.v4->flags & DM_DEFERRED_REMOVE;
info->internal_suspend = (dmt->dmi.v4->flags & DM_INTERNAL_SUSPEND_FLAG) ? 1 : 0;
info->target_count = dmt->dmi.v4->target_count;
info->open_count = dmt->dmi.v4->open_count;
info->event_nr = dmt->dmi.v4->event_nr;
@@ -1149,7 +1142,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
}
dmi->flags |= DM_PERSISTENT_DEV_FLAG;
dmi->dev = MKDEV((dev_t)dmt->major, (dev_t)dmt->minor);
dmi->dev = MKDEV((dev_t)dmt->major, dmt->minor);
}
/* Does driver support device number referencing? */
@@ -2068,12 +2061,6 @@ void dm_lib_exit(void)
_version_checked = 0;
}
#if defined(__GNUC__)
/*
* Maintain binary backward compatibility.
* Version script mechanism works with 'gcc' compatible compilers only.
*/
/*
* This following code is here to retain ABI compatibility after adding
* the field deferred_remove to struct dm_info in version 1.02.89.
@@ -2089,31 +2076,16 @@ void dm_lib_exit(void)
* N.B. Keep this function at the end of the file to make sure that
* no code in this file accidentally calls it.
*/
int dm_task_get_info_base(struct dm_task *dmt, struct dm_info *info);
DM_EXPORTED_SYMBOL_BASE(dm_task_get_info);
int dm_task_get_info_base(struct dm_task *dmt, struct dm_info *info)
#undef dm_task_get_info
int dm_task_get_info(struct dm_task *dmt, struct dm_info *info);
int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
{
struct dm_info new_info;
if (!dm_task_get_info_v1_02_97(dmt, &new_info))
if (!dm_task_get_info_with_deferred_remove(dmt, &new_info))
return 0;
memcpy(info, &new_info, offsetof(struct dm_info, deferred_remove));
return 1;
}
int dm_task_get_info_with_deferred_remove(struct dm_task *dmt, struct dm_info *info);
int dm_task_get_info_with_deferred_remove(struct dm_task *dmt, struct dm_info *info)
{
struct dm_info new_info;
if (!dm_task_get_info_v1_02_97(dmt, &new_info))
return 0;
memcpy(info, &new_info, offsetof(struct dm_info, internal_suspend));
return 1;
}
#endif

View File

@@ -151,7 +151,6 @@ struct dm_info {
int32_t target_count;
int deferred_remove;
int internal_suspend;
};
struct dm_deps {
@@ -175,6 +174,8 @@ struct dm_versions {
int dm_get_library_version(char *version, size_t size);
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
#define dm_task_get_info dm_task_get_info_with_deferred_remove
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
/*

View File

@@ -110,7 +110,7 @@ void dm_lib_init(void)
__attribute__((format(printf, 5, 0)))
static void _default_log_line(int level,
const char *file __attribute__((unused)),
int line __attribute__((unused)), int dm_errno_or_class,
int line __attribute__((unused)), int dm_errno_or_class,
const char *f, va_list ap)
{
static int _abort_on_internal_errors = -1;
@@ -138,7 +138,7 @@ static void _default_log_line(int level,
__attribute__((format(printf, 5, 6)))
static void _default_log_with_errno(int level,
const char *file __attribute__((unused)),
int line __attribute__((unused)), int dm_errno_or_class,
int line __attribute__((unused)), int dm_errno_or_class,
const char *f, ...)
{
va_list ap;
@@ -959,7 +959,7 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
{
char path[PATH_MAX];
struct stat info;
dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
dev_t dev = MKDEV((dev_t)major, minor);
mode_t old_mask;
if (!_build_dev_path(path, sizeof(path), dev_name))

View File

@@ -511,7 +511,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
dm_list_init(&node->activated);
dm_list_init(&node->props.segs);
dev = MKDEV((dev_t)info->major, (dev_t)info->minor);
dev = MKDEV((dev_t)info->major, info->minor);
if (!dm_hash_insert_binary(dtree->devs, (const char *) &dev,
sizeof(dev), node)) {
@@ -535,7 +535,7 @@ static struct dm_tree_node *_create_dm_tree_node(struct dm_tree *dtree,
static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
uint32_t major, uint32_t minor)
{
dev_t dev = MKDEV((dev_t)major, (dev_t)minor);
dev_t dev = MKDEV((dev_t)major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
sizeof(dev));

View File

@@ -199,10 +199,10 @@ retry_fcntl:
fail_close_unlink:
if (unlink(lockfile))
log_sys_debug("unlink", lockfile);
stack;
fail_close:
if (close(fd))
log_sys_debug("close", lockfile);
stack;
return 0;
}

View File

@@ -1270,7 +1270,7 @@ static int _do_check_value_is_reserved(unsigned type, const void *reserved_value
if ((*(uint64_t *)value1 == *(uint64_t *) reserved_value) ||
(value2 && (*(uint64_t *)value2 == *(uint64_t *) reserved_value)))
return 1;
break;
break;
case DM_REPORT_FIELD_TYPE_STRING:
if ((!strcmp((const char *)value1, (const char *) reserved_value)) ||
(value2 && (!strcmp((const char *)value2, (const char *) reserved_value))))

View File

@@ -231,12 +231,10 @@ typedef struct lvm_property_value {
uint32_t is_string:1;
uint32_t is_integer:1;
uint32_t is_valid:1;
uint32_t is_signed:1;
uint32_t padding:27;
uint32_t padding:28;
union {
const char *string;
uint64_t integer;
int64_t signed_integer;
} value;
} lvm_property_value_t;

View File

@@ -96,7 +96,6 @@ lvm_t lvm_init(const char *system_dir)
void lvm_quit(lvm_t libh)
{
struct saved_env e = store_user_env((struct cmd_context *)libh);
fin_locking();
destroy_toolcontext((struct cmd_context *)libh);
udev_fin_library_context();
restore_user_env(&e);

View File

@@ -88,7 +88,6 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
v.is_settable = prop.is_settable;
v.is_string = prop.is_string;
v.is_integer = prop.is_integer;
v.is_signed = prop.is_signed;
if (v.is_string)
v.value.string = prop.value.string;
if (v.is_integer)

View File

@@ -41,7 +41,7 @@ SET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)
struct lvm_property_type _lib_properties[] = {
#include "lvm_prop_fields.h"
{ 0, "", 0, 0, 0, 0, { .integer = 0 }, prop_not_implemented_get,
{ 0, "", 0, 0, 0, { .integer = 0 }, prop_not_implemented_get,
prop_not_implemented_set },
};

View File

@@ -46,11 +46,11 @@ LIBS = @LIBS@
STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
DEFS += @DEFS@
# FIXME set this only where it's needed, not globally?
CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
LDFLAGS ?= @COPTIMISE_FLAG@ @LDFLAGS@
CFLAGS += @CFLAGS@
CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
LDFLAGS += @LDFLAGS@
LIB_SUFFIX = @LIB_SUFFIX@
LVMINTERNAL_LIBS = -llvm-internal $(DAEMON_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
DL_LIBS = @DL_LIBS@
@@ -116,7 +116,6 @@ vpath %.exported_symbols $(srcdir)
interface = @interface@
interfacebuilddir = $(top_builddir)/libdm/$(interface)
rpmbuilddir = $(abs_top_builddir)/build
# The number of jobs to run, if blank, defaults to the make standard
ifndef MAKEFLAGS
@@ -204,13 +203,8 @@ endif
#WFLAGS += -pedantic -std=gnu99
#DEFS += -DDEBUG_CRC32
#
# Avoid recursive extension of CFLAGS
# by checking whether CFLAGS already has fPIC string
#
ifeq (,$(findstring fPIC,$(CFLAGS)))
CFLAGS += -fPIC
CFLAGS += -fPIC @COPTIMISE_FLAG@
LDFLAGS += @COPTIMISE_FLAG@
ifeq ("@DEBUG@", "yes")
CFLAGS += -g -fno-omit-frame-pointer
@@ -221,10 +215,6 @@ ifeq ("@DEBUG@", "yes")
endif
endif
# end of fPIC protection
endif
ifeq ("@INTL@", "yes")
DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
endif
@@ -274,7 +264,7 @@ LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)
LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_srcdir)/VERSION)
INCLUDES += -I$(srcdir) -I$(top_builddir)/include
INCLUDES += -I. -I$(top_builddir)/include
INC_LNS = $(top_builddir)/include/.symlinks_created
@@ -407,6 +397,8 @@ cflow: $(CFLOW_TARGET).cflow $(CFLOW_TARGET).tree $(CFLOW_TARGET).rxref $(CFLOW_
endif
endif
$(TARGETS): $(OBJECTS)
%.o: %.c
$(CC) -c $(INCLUDES) $(DEFS) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
@@ -414,7 +406,7 @@ endif
$(CXX) -c $(INCLUDES) $(DEFS) $(WFLAGS) $(CXXFLAGS) $(CXXFLAGS_$@) $< -o $@
%.pot: %.c Makefile
$(CC) -E $(INCLUDES) $(BLKID_CFLAGS) $(VALGRIND_CFLAGS) $(UDEV_CFLAGS) -include $(top_builddir)/include/pogen.h \
$(CC) -E $(INCLUDES) -include $(top_builddir)/include/pogen.h \
$(DEFS) $(WFLAGS) $(CFLAGS) $< > $@
%.so: %.o
@@ -473,7 +465,6 @@ $(LIB_STATIC): $(OBJECTS)
$(MSGFMT) -o $@ $<
cleandir:
test -z "$(CLEAN_DIRS)" || $(RM) -r $(CLEAN_DIRS)
$(RM) $(OBJECTS) $(TARGETS) $(CLEAN_TARGETS) $(CLEAN_CFLOW) $(LDDEPS) \
$(POTFILES) $(SOURCES:%.c=%.d) $(SOURCES:%.c=%.gcno) $(SOURCES:%.c=%.gcda) \
$(SOURCES2:%.c=%.o) $(SOURCES2:%.c=%.d) $(SOURCES2:%.c=%.gcno) $(SOURCES2:%.c=%.gcda) \
@@ -485,7 +476,7 @@ distclean: cleandir $(SUBDIRS.distclean)
test -z "$(DISTCLEAN_DIRS)" || $(RM) -r $(DISTCLEAN_DIRS)
$(RM) $(DISTCLEAN_TARGETS) Makefile
.exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols $(DEPS)
.exported_symbols_generated: $(EXPORTED_HEADER) .exported_symbols
set -e; \
( cat $(srcdir)/.exported_symbols; \
if test x$(EXPORTED_HEADER) != x; then \
@@ -494,30 +485,13 @@ distclean: cleandir $(SUBDIRS.distclean)
fi \
) > $@
EXPORTED_UC := $(shell echo $(EXPORTED_FN_PREFIX) | tr '[a-z]' '[A-Z]')
EXPORTED_FILES := $(wildcard $(srcdir)/.exported_symbols.Base $(srcdir)/.exported_symbols.$(EXPORTED_UC)_[0-9_]*[0-9])
ifeq (0,$(words $(EXPORTED_FILES)))
.export.sym: .exported_symbols_generated
set -e; (echo "Base {"; echo " global:"; \
$(SED) "s/^/ /;s/$$/;/" < $<; \
sed "s/^/ /;s/$$/;/" < $<; \
echo " local:"; echo " *;"; echo "};") > $@
else
.export.sym: .exported_symbols_generated $(EXPORTED_FILES)
set -e; \
R=$(shell sort $^ | uniq -u);\
test -z "$$R" || { echo "Mismatch between symbols in shared library and lists in .exported_symbols.* files: $$R"; false; } ;\
(for i in $(EXPORTED_FILES) ; do\
echo "$${i##*.} {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" < $$i;\
test "$$i" = Base && { echo " local:"; echo " *;"; };\
echo "};";\
done ) > $@
endif
ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov \
help check check_local check_cluster check_lvmetad check_lvmpolld))
help check check_local check_cluster check_lvmetad))
ifdef SOURCES
-include $(SOURCES:.c=.d) $(CXXSOURCES:.cpp=.d)
endif

View File

@@ -40,23 +40,17 @@ else
LVMETAD =
endif
ifeq ("@BUILD_LVMPOLLD@", "yes")
LVMPOLLD = lvmpolld.8
else
LVMPOLLD =
endif
MAN5=lvm.conf.5
MAN7=lvmsystemid.7
MAN8=lvm-config.8 lvm-dumpconfig.8 lvm-lvpoll.8 \
lvchange.8 lvmconfig.8 lvconvert.8 lvcreate.8 lvdisplay.8 lvextend.8 \
lvm.8 lvmchange.8 lvmconf.8 lvmdiskscan.8 lvmdump.8 lvmsadc.8 lvmsar.8 \
MAN8=lvm-dumpconfig.8 \
lvchange.8 lvconvert.8 lvcreate.8 lvdisplay.8 lvextend.8 lvm.8 \
lvmchange.8 lvmconf.8 lvmdiskscan.8 lvmdump.8 lvmsadc.8 lvmsar.8 \
lvreduce.8 lvremove.8 lvrename.8 lvresize.8 lvs.8 \
lvscan.8 pvchange.8 pvck.8 pvcreate.8 pvdisplay.8 pvmove.8 pvremove.8 \
pvresize.8 pvs.8 pvscan.8 vgcfgbackup.8 vgcfgrestore.8 vgchange.8 \
vgck.8 vgcreate.8 vgconvert.8 vgdisplay.8 vgexport.8 vgextend.8 \
vgimport.8 vgimportclone.8 vgmerge.8 vgmknodes.8 vgreduce.8 vgremove.8 \
vgrename.8 vgs.8 vgscan.8 vgsplit.8 $(FSADMMAN) $(LVMETAD) $(LVMPOLLD)
vgrename.8 vgs.8 vgscan.8 vgsplit.8 $(FSADMMAN) $(LVMETAD)
ifneq ("@CLVMD@", "none")
MAN8CLUSTER=clvmd.8

View File

@@ -118,7 +118,7 @@ Display the version of the cluster LVM daemon.
.SH ENVIRONMENT VARIABLES
.TP
.B LVM_CLVMD_BINARY
The CLVMD binary to use when \fBclvmd\fP restart is requested.
The CLVMD binary to use when \fBclmvd\fP restart is requested.
Defaults to #CLVMD_PATH#.
.TP
.B LVM_BINARY

View File

@@ -220,11 +220,11 @@ Run the daemon in the background.
.BR \-H ", " \-\-cache ", " \-\-type\ \fIcache
Converts logical volume to a cached LV with the use of cache pool
specified with \fB\-\-cachepool\fP.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(8).
.TP
.BR \-\-cachepool " " \fICachePoolLV
This argument is necessary when converting a logical volume to a cache LV.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(8).
.TP
.BR \-m ", " \-\-mirrors " " \fIMirrors
Specifies the degree of the mirror you wish to create.

View File

@@ -91,8 +91,7 @@ lvcreate \- create a logical volume in an existing volume group
.RB [ \-\-type
.IR SegmentType ]
.RB [ \-v | \-\-verbose ]
.RB [ \-W | \-\-wipesignatures
.RI { y | n }]
.RB [ \-W | \-\-wipesignatures ]
.RB [ \-Z | \-\-zero
.RI { y | n }]
.RI [ VolumeGroup { Name | Path }

View File

@@ -1 +0,0 @@
.so man8/lvmconfig.8

View File

@@ -1 +1,162 @@
.so man8/lvmconfig.8
.TH "LVM-DUMPCONFIG" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
.SH "NAME"
lvm-dumpconfig \(em dump LVM configuration
.SH SYNOPSIS
.B lvm dumpconfig
.RB [ \-f | \-\-file
.IR filename ]
.RB [ \-\-type
.RI { current | default | diff | missing | new | profilable | profilable-command | profilable-metadata }
.RB [ \-\-atversion
.IR version ]
.RB [ \-\-ignoreadvanced ]
.RB [ \-\-ignoreunsupported ]
.RB [ \-\-ignorelocal ]
.RB [ \-\-config
.IR ConfigurationString ]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-\-profile
.IR ProfileName ]
.RB [ \-\-metadataprofile
.IR ProfileName ]
.RB [ \-\-mergedconfig ]
.RB [ \-\-validate ]
.RB [ \-\-withcomments ]
.RB [ \-\-withfullcomments ]
.RB [ \-\-withversions ]
.RB [ ConfigurationNode... ]
.SH DESCRIPTION
lvm dumpconfig produces formatted output with LVM configuration tree.
.SH OPTIONS
.TP
.BR \-f ", " \-\-file " \fIfilename"
Dump configuration to a file named 'filename'.
.TP
.IR \fB\-\-type " {" current | default | diff | missing | new | profilable }
Select the type of configuration to dump. The configuration settings dumped
have either default values or currently used values assigned based on the
type selected (if no type is selected, \fB\-\-type current\fP is used
by default). Whenever a configuration setting with a default value is
commented out, it means the setting does not have any concrete default
value defined. All output can be saved and reused as proper \fBlvm.conf\fP(5)
file.
.RS
.IP current 3
Dump current \fBlvm.conf\fP configuration merged with any \fBtag config\fP
if used. See also \fBlvm.conf\fP(5) for more info about LVM configuration methods.
.IP default 3
Dump all possible configuration settings with default values assigned.
.IP diff 3
Dump all configuration settings for which the values used differ from defaults.
The value assigned for each configuration setting is the value currently used.
This is actually minimal LVM configuration which can be used without
a change to current configured behaviour.
.IP missing 3
Dump all configuration settings with default values assigned which are
missing in the configuration currently used and for which LVM automatically
fallbacks to using these default values.
.IP new 3
Dump all new configuration settings introduced in current LVM version
or specific version as defined by \fB\-\-atversion\fP option.
.IP profilable 3
Dump all profilable configuration settings with default values assigned.
See \fBlvm.conf\fP(5) for more info about \fBprofile config\fP method.
.IP profilable-command 3
Dump all profilable configuration settings with default values assigned
that can be used in command profile. This is a subset of settings dumped
by \fB\-\-type \-\-profilable\fP.
.IP profilable-metadata 3
Dump all profilable configuration settings with default values assigned
that can be used in metadata profile. This is a subset of settings dumped
by \fB\-\-type \-\-profilable\fP.
.RE
.TP
.BI \-\-atversion " version"
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
When configuration is dumped, the configuration settings recognized
at this LVM version will be considered only. This can be used
to dump a configuration that certain LVM version understands and
which does not contain any newer settings for which LVM would
issue a warning message when checking the configuration.
.TP
.B \-\-ignoreadvanced
Ignore advanced configuration settings on dump.
.TP
.B \-\-ignoreunsupported
Ignore unsupported configuration settings on dump. These settings are
either used for debugging purposes only or their support is not yet
complete and they are not meant to be used in production.
.TP
.B \-\-ignorelocal
Ignore local section.
.TP
.BI \-\-config " ConfigurationString"
Use \fBConfigurationString\fP to override existing configuration.
This configuration is then applied for dumpconfig command itself.
See also \fBlvm.conf\fP(5) for more info about \fBconfig cascade\fP.
.TP
.BI \-\-commandprofile " ProfileName"
Use \fBProfileName\fP to override existing configuration.
This configuration is then applied for dumpconfig command itself.
See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for
more info about \fBconfig cascade\fP.
.TP
.BI \-\-profile " ProfileName"
The same as using \fB\-\-commandprofile\fP but the configuration is not
applied for dumpconfig command itself.
.TP
.BI \-\-metadataprofile " ProfileName"
Use \fBProfileName\fP to override existing configuration.
The configuration defined in metadata profile has no effect for
dumpconfig command itself, the dumpconfig dumps the configuration only.
See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for more
info about \fBconfig cascade\fP.
.TP
.B \-\-mergedconfig
When the dumpconfig command is run with the \fB\-\-config\fP option
and/or \fB\-\-commandprofile\fP (or using \fBLVM_COMMAND_PROFILE\fP
environment variable), \fB\-\-profile\fP, \fB\-\-metadataprofile\fP
option, merge all the contents of the \fBconfig cascade\fP before dumping it.
Without the \fB\-\-mergeconfig\fP option used, only the configuration at
the front of the cascade is dumped. See also \fBlvm.conf\fP(5) for more
info about \fBconfig cascade\fP.
.TP
.B \-\-validate
Validate current configuration used and exit with appropriate
return code. The validation is done only for the configuration
at the front of the \fBconfig cascade\fP. To validate the whole
merged configuration tree, use also the \fB\-\-mergedconfig\fP option.
The validation is done even if \fBconfig/checks\fP \fBlvm.conf\fP(5)
option is disabled.
.TP
.B \-\-withcomments
Dump a one line comment for each configuration node.
.TP
.B \-\-withfullcomments
Dump a full comment for each configuration node.
.TP
.B \-\-withversions
Also dump a comment containing the version of introduction for
each configuration node.
.SH SEE ALSO
.BR lvm (8)
.BR lvm.conf (5)

View File

@@ -1,89 +0,0 @@
.TH "LVPOLL" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" \" -*- nroff -*-
.SH NAME
lvpoll \(em Internal command used by lvmpolld to complete some Logical Volume operations.
.SH SYNOPSIS
.B lvm lvpoll
.BR \-\-polloperation
.RI { pvmove | convert | merge | merge_thin }
.RB [ \-\-abort ]
.RB [ \-A | \-\-autobackup
.RI { y | n }]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-d | \-\-debug ]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-\-handlemissingpvs ]
.RB [ \-i | \-\-interval
.IR Seconds ]
.RB [ \-t | \-\-test ]
.RB [ \-v | \-\-verbose ]
.RB [ \-\-version ]
.IR LogicalVolume [ Path ]
.SH DESCRIPTION
\fBlvpoll\fP is an internal command used by \fBlvmpolld\fP(8) to monitor and
complete \fBlvconvert\fP(8) and \fBpvmove\fP(8) operations.
\fBlvpoll\fP itself does not initiate these operations and
you should never normally need to invoke it directly.
.I LogicalVolume
The Logical Volume undergoing conversion or, in the case of pvmove, the name of
the internal pvmove Logical Volume (see \fBEXAMPLES\fP).
.SH OPTIONS
See \fBlvm\fP(8) for common options.
.TP
.BR \-\-polloperation " {" \fIconvert | \fImerge | \fImerge_thin | \fIpvmove }
Mandatory option.
\fIpvmove\fP refers to a pvmove operation that is moving data.
\fIconvert\fP refers to an operation that is increasing the number of redundant copies of data maintained by a mirror.
\fImerge\fP indicates a merge operation that doesn't involve thin volumes.
\fImerge_thin\fP indicates a merge operation involving thin snapshots.
\fBpvmove\fP(8) and \fBlvconvert\fP(8) describe how to initiate these operations.
.TP
.B \-\-abort
Abort pvmove in progress. See \fBpvmove\fP(8).
.TP
.B \-\-handlemissingpvs
Used when the polling operation needs to handle missing PVs to be able to
continue. This can happen when \fBlvconvert\fP(8) is repairing a mirror
with one or more faulty devices.
.TP
.BR \-i ", " \-\-interval " "\fISeconds
Report progress at regular intervals
.SH EXAMPLES
Resume polling of a pvmove operation identified by the Logical Volume vg00/pvmove0:
.sp
.B lvm lvpoll --polloperation pvmove vg00/pvmove0
.P
Abort the same pvmove operation:
.sp
.B lvm lvpoll --polloperation pvmove --abort vg00/pvmove0
.P
To find out the name of the pvmove Logical Volume resulting from an original
\fBpvmove /dev/sda1\fP command you may use the following \fBlvs\fP command.
(Remove the parentheses from the LV name.)
.sp
.B lvs -a -S move_pv=/dev/sda1
.P
Resume polling of mirror conversion vg00/lvmirror:
.sp
.B lvm lvpoll --polloperation convert vg00/lvmirror
.P
Complete mirror repair:
.sp
.B lvm lvpoll --polloperation convert vg/damaged_mirror --handlemissingpvs
.P
Process snapshot merge:
.sp
.B lvm lvpoll --polloperation merge vg/snapshot_old
.P
Finish thin snapshot merge:
.sp
.B lvm lvpoll --polloperation merge_thin vg/thin_snapshot
.SH SEE ALSO
.BR lvconvert (8),
.BR lvm (8),
.BR lvmpolld (8),
.BR lvs (8),
.BR pvmove (8)

View File

@@ -43,18 +43,15 @@ path of \fBlvm\fP.
The following commands are built into lvm without links normally
being created in the filesystem for them.
.TP
\fBconfig\fP \(em The same as \fBlvmconfig\fP(8) below.
\fBdumpconfig\fP \(em Display the configuration information after
loading \fBlvm.conf\fP(5) and any other configuration files.
.TP
\fBdevtypes\fP \(em Display the recognised built-in block device types.
.TP
\fBdumpconfig\fP \(em The same as \fBlvmconfig\fP(8) below.
.TP
\fBformats\fP \(em Display recognised metadata formats.
.TP
\fBhelp\fP \(em Display the help text.
.TP
\fBlvpoll\fP \(em Internal command used by lvmpolld to complete some Logical Volume operations.
.TP
\fBpvdata\fP \(em Not implemented in LVM2.
.TP
\fBsegtypes\fP \(em Display recognised Logical Volume segment types.
@@ -139,9 +136,6 @@ Volumes.
.TP
\fBlvmchange\fP \(em Change attributes of the Logical Volume Manager.
.TP
\fBlvmconfig\fP \(em Display the configuration information after
loading \fBlvm.conf\fP(5) and any other configuration files.
.TP
\fBlvmdiskscan\fP \(em Scan for all devices visible to LVM2.
.TP
\fBlvmdump\fP \(em Create lvm2 information dumps for diagnostic purposes.
@@ -322,8 +316,8 @@ way it fits with other LVM configuration methods.
.IR \fB\-\-profile " " \fIProfileName
A short form of \fB\-\-metadataprofile\fP for \fBvgcreate\fP, \fBlvcreate\fP,
\fBvgchange\fP and \fBlvchange\fP command and a short form of \fB\-\-commandprofile\fP
for any other command (with the exception of \fBlvmconfig\fP command where the
\-\-profile has special meaning, see \fBlvmconfig\fP(8) for more information).
for any other command (with the exception of \fBdumpconfig\fP command where the
\-\-profile has special meaning, see \fBlvm dumpconfig\fP(8) for more information).
.TP
.IR \fB\-\-config " " \fIConfigurationString
Uses the ConfigurationString as direct string representation of the configuration
@@ -527,12 +521,6 @@ Path for the lvmetad pid file.
.TP
.B LVM_LVMETAD_SOCKET
Path for the lvmetad socket file.
.TP
.B LVM_LVMPOLLD_PIDFILE
Path for the lvmpolld pid file.
.TP
.B LVM_LVMPOLLD_SOCKET
Path for the lvmpolld socket file.
.SH FILES
.I #DEFAULT_SYS_DIR#/lvm.conf
.br
@@ -541,6 +529,7 @@ Path for the lvmpolld socket file.
.BR lvm.conf (5),
.BR lvmcache (7),
.BR lvmthin (7),
.BR lvm\ dumpconfig (8),
.BR clvmd (8),
.BR dmsetup (8),
.BR lvchange (8),
@@ -548,7 +537,6 @@ Path for the lvmpolld socket file.
.BR lvdisplay (8),
.BR lvextend (8),
.BR lvmchange (8),
.BR lvmconfig (8),
.BR lvmdiskscan (8),
.BR lvreduce (8),
.BR lvremove (8),

View File

@@ -65,8 +65,8 @@ For this purpose, there's the \fBcommand_profile_template.profile\fP
(for metadata profiles) which contain all settings that are customizable
by profiles of certain type. Users are encouraged to copy these template
profiles and edit them as needed. Alternatively, the
\fBlvmconfig \-\-file <ProfileName.profile> \-\-type profilable-command <section>\fP
or \fBlvmconfig \-\-file <ProfileName.profile> \-\-type profilable-metadata <section>\fP
\fBlvm dumpconfig \-\-file <ProfileName.profile> \-\-type profilable-command <section>\fP
or \fBlvm dumpconfig \-\-file <ProfileName.profile> \-\-type profilable-metadata <section>\fP
can be used to generate a configuration with profilable settings in either
of the type for given section and save it to new ProfileName.profile
(if the section is not specified, all profilable settings are reported).
@@ -91,7 +91,7 @@ this \fBconfig cascade\fP from left to right:
No part of this cascade is compulsory. If there's no setting value found at
the end of the cascade, a default value is used for that setting.
Use \fBlvmconfig\fP to check what settings are in use and what
Use \fBlvm dumpconfig\fP to check what settings are in use and what
the default values are.
.SH SYNTAX
.LP
@@ -158,38 +158,38 @@ with a letter can be left unquoted.
.SH SETTINGS
The
.B lvmconfig
.B lvm dumpconfig
command prints the LVM configuration settings in various ways.
See the man page
.BR lvmconfig (8).
.BR lvm-dumpconfig (8).
Command to print a list of all possible config settings, with their
default values:
.br
.B lvmconfig \-\-type default
.B lvm dumpconfig \-\-type default
Command to print a list of all possible config settings, with their
default values, and a full description of each as a comment:
.br
.B lvmconfig \-\-type default --withcomments
.B lvm dumpconfig \-\-type default --withfullcomments
Command to print a list of all possible config settings, with their
current values (configured, non-default values are shown):
.br
.B lvmconfig \-\-type current
.B lvm dumpconfig \-\-type current
Command to print all config settings that have been configured with a
different value than the default (configured, non-default values are
shown):
.br
.B lvmconfig \-\-type diff
.B lvm dumpconfig \-\-type diff
Command to print a single config setting, with its default value,
and a full description, where "Section" refers to the config section,
e.g. global, and "Setting" refers to the name of the specific setting,
e.g. umask:
.br
.B lvmconfig \-\-type default --withcomments Section/Setting
.B lvm dumpconfig \-\-type default --withfullcomments Section/Setting
.SH FILES
@@ -209,5 +209,5 @@ e.g. umask:
.SH SEE ALSO
.BR lvm (8)
.BR lvmconfig (8)
.BR lvm-dumpconfig (8)

View File

@@ -1,197 +0,0 @@
.TH "LVMCONFIG" "8" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
.SH "NAME"
lvmconfig, lvm dumpconfig, lvm config \(em Display LVM configuration
.SH SYNOPSIS
.B lvmconfig
.RB [ \-f | \-\-file
.IR filename ]
.RB [ \-\-type
.RI { current | default | diff | list | missing | new | profilable | profilable-command | profilable-metadata }
.RB [ \-\-atversion
.IR version ]
.RB [ \-\-ignoreadvanced ]
.RB [ \-\-ignoreunsupported ]
.RB [ \-\-ignorelocal ]
.RB [ \-l | \-\-list ]
.RB [ \-\-config
.IR ConfigurationString ]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-\-profile
.IR ProfileName ]
.RB [ \-\-metadataprofile
.IR ProfileName ]
.RB [ \-\-mergedconfig ]
.RB [ \-\-showdeprecated ]
.RB [ \-\-showunsupported ]
.RB [ \-\-validate ]
.RB [ \-\-withsummary ]
.RB [ \-\-withcomments ]
.RB [ \-\-withversions ]
.RB [ ConfigurationNode... ]
.SH DESCRIPTION
lvmconfig produces formatted output from the LVM configuration tree.
The command was added in release 2.02.119 and has an identical longer form
\fBlvm dumpconfig\fP.
.SH OPTIONS
.TP
.BR \-f ", " \-\-file " \fIfilename"
Send output to a file named 'filename'.
.TP
.BR \-l ", " \-\-list
List configuration settings with summarizing comment. This is the same as using
\fBlvmconfig --type list --withsummary\fP.
.TP
.IR \fB\-\-type " {" current | default | diff | missing | new | profilable }
Select the type of configuration to display. The configuration settings
displayed have either default values or currently-used values assigned based on
the type selected. If no type is selected, \fB\-\-type current\fP is used
by default. Whenever a configuration setting with a default value is
commented out, it means the setting does not have any concrete default
value defined. Output can be saved and used as a proper \fBlvm.conf\fP(5)
file.
.RS
.IP current 3
Display the current \fBlvm.conf\fP configuration merged with any \fBtag
config\fP if used. See also \fBlvm.conf\fP(5) for more info about LVM
configuration methods.
.IP default 3
Display all possible configuration settings with default values assigned.
.IP diff 3
Display all configuration settings for which the values used differ from defaults.
The value assigned for each configuration setting is the value currently used.
This is actually minimal LVM configuration which can be used without
a change to current configured behaviour.
.IP list 3
Display plain list of configuration settings.
.IP missing 3
Display all configuration settings with default values assigned which are
missing in the configuration currently used and for which LVM automatically
fallbacks to using these default values.
.IP new 3
Display all new configuration settings introduced in current LVM version
or specific version as defined by \fB\-\-atversion\fP option.
.IP profilable 3
Display all profilable configuration settings with default values assigned.
See \fBlvm.conf\fP(5) for more info about \fBprofile config\fP method.
.IP profilable-command 3
Display all profilable configuration settings with default values assigned
that can be used in command profile. This is a subset of settings displayed
by \fB\-\-type \-\-profilable\fP.
.IP profilable-metadata 3
Display all profilable configuration settings with default values assigned
that can be used in metadata profile. This is a subset of settings displayed
by \fB\-\-type \-\-profilable\fP.
.RE
.TP
.BI \-\-atversion " version"
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
When configuration is displayed, the configuration settings recognized
at this LVM version will be considered only. This can be used
to display a configuration that a certain LVM version understands and
which does not contain any newer settings for which LVM would
issue a warning message when checking the configuration.
.TP
.B \-\-ignoreadvanced
Exclude advanced configuration settings from the output.
.TP
.B \-\-ignoreunsupported
Exclude unsupported configuration settings from the output. These settings are
either used for debugging and development purposes only or their support is not
yet complete and they are not meant to be used in production. The \fBcurrent\fP
and \fBdiff\fP types include unsupported settings in their output by default,
all the other types ignore unsupported settings.
.TP
.B \-\-ignorelocal
Ignore local section.
.TP
.BI \-\-config " ConfigurationString"
Use \fBConfigurationString\fP to override existing configuration.
This configuration is then applied for the lvmconfig command itself.
See also \fBlvm.conf\fP(5) for more info about \fBconfig cascade\fP.
.TP
.BI \-\-commandprofile " ProfileName"
Use \fBProfileName\fP to override existing configuration.
This configuration is then applied for the lvmconfig command itself.
See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for
more info about \fBconfig cascade\fP.
.TP
.BI \-\-profile " ProfileName"
The same as using \fB\-\-commandprofile\fP but the configuration is not
applied for the lvmconfig command itself.
.TP
.BI \-\-metadataprofile " ProfileName"
Use \fBProfileName\fP to override existing configuration.
The configuration defined in metadata profile has no effect for
the lvmconfig command itself. lvmconfig displays the configuration only.
See also \fB\-\-mergedconfig\fP option and \fBlvm.conf\fP(5) for more
info about \fBconfig cascade\fP.
.TP
.B \-\-mergedconfig
When the lvmconfig command is run with the \fB\-\-config\fP option
and/or \fB\-\-commandprofile\fP (or using \fBLVM_COMMAND_PROFILE\fP
environment variable), \fB\-\-profile\fP, \fB\-\-metadataprofile\fP
option, merge all the contents of the \fBconfig cascade\fP before displaying it.
Without the \fB\-\-mergeconfig\fP option used, only the configuration at
the front of the cascade is displayed. See also \fBlvm.conf\fP(5) for more
info about \fBconfig cascade\fP.
.TP
.B \-\-showdeprecated
Include deprecated configuration settings in the output. These settings
are always deprecated since certain version. If concrete version is specified
with \fB--atversion\fP option, deprecated settings are automatically included
if specified version is lower that the version in which the settings were
deprecated. The \fBcurrent\fP and \fBdiff\fP types include deprecated settings
int their output by default, all the other types ignore deprecated settings.
.TP
.B \-\-showunsupported
Include unsupported configuration settings in the output. These settings
are either used for debugging or development purposes only or their support
is not yet complete and they are not meant to be used in production. The
\fBcurrent\fP and \fBdiff\fP types include unsupported settings in their
output by default, all the other types ignore unsupported settings.
.TP
.B \-\-validate
Validate current configuration used and exit with appropriate
return code. The validation is done only for the configuration
at the front of the \fBconfig cascade\fP. To validate the whole
merged configuration tree, use also the \fB\-\-mergedconfig\fP option.
The validation is done even if \fBconfig/checks\fP \fBlvm.conf\fP(5)
option is disabled.
.TP
.B \-\-withsummary
Display a one line comment for each configuration node.
.TP
.B \-\-withcomments
Display a full comment for each configuration node. For deprecated
settings, also display comments about deprecation in addition.
.TP
.B \-\-withversions
Also display a comment containing the version of introduction for
each configuration node. If the setting is deprecated, also display
the version since which it is deprecated.
.SH SEE ALSO
.BR lvm (8)
.BR lvmconf (8)
.BR lvm.conf (5)

View File

@@ -10,7 +10,6 @@ lvmdump \(em create lvm2 information dumps for diagnostic purposes
.RB [ \-h ]
.RB [ \-l ]
.RB [ \-m ]
.RB [ \-p ]
.RB [ \-s ]
.RB [ \-u ]
.SH DESCRIPTION
@@ -42,8 +41,6 @@ The content of the tarball is as follows:
.br
- if enabled with \-l, lvmetad state if running
.br
- if enabled with \-p, lvmpolld state if running
.br
- if enabled with \-s, system info and context
.br
- if enabled with \-u, udev info and context
@@ -78,12 +75,6 @@ This option generates a 1:1 dump of the metadata area from all PVs visible
to the system, which can cause the dump to increase in size considerably.
However, the metadata dump may represent a valuable diagnostic resource.
.TP
.B \-p
Include \fBlvmpolld\fP(8) daemon dump if it is running. The dump contains
all in-progress operation currently monitored by the daemon and partial
history for all yet uncollected results of polling operations already finished
including reason.
.TP
.B \-s
Gather system info and context. Currently, this encompasses systemd info
and context only: overall state of systemd units present in the system,

View File

@@ -1,7 +1,6 @@
.TH LVMETAD 8 "LVM TOOLS #VERSION#" "Red Hat Inc" \" -*- nroff -*-
.SH NAME
lvmetad \(em LVM metadata cache daemon
.SH SYNOPSIS
.B lvmetad
.RB [ \-l
@@ -14,56 +13,16 @@ lvmetad \(em LVM metadata cache daemon
.RB [ \-h ]
.RB [ \-V ]
.RB [ \-? ]
.SH DESCRIPTION
lvmetad is a metadata caching daemon for LVM. The daemon receives notifications
from udev rules (which must be installed for LVM to work correctly when lvmetad
is in use). Through these notifications, lvmetad has an up-to-date and
consistent image of the volume groups available in the system.
The lvmetad daemon caches LVM metadata, so that LVM commands can read
metadata without scanning disks.
Metadata caching can be an advantage because scanning disks is time
consuming and may interfere with the normal work of the system and disks.
lvmetad does not read metadata from disks itself. The 'pvscan \-\-cache'
command scans disks, reads the LVM metadata and sends it to lvmetad.
New LVM disks that appear on the system must be scanned by pvscan before
lvmetad knows about them. If lvmetad does not know about a disk, then LVM
commands using lvmetad will also not know about it. When disks are added
or removed from the system, lvmetad must be updated.
lvmetad is usually combined with event-based system services that
automatically run pvscan \-\-cache on new disks. This way, the lvmetad
cache is automatically updated with metadata from new disks when they
appear. LVM udev rules and systemd services implement this automation.
Automatic scanning is usually combined with automatic activation. For
more information, see
.BR pvscan (8).
If lvmetad is started or restarted after disks have been added to the
system, or if the global_filter has changed, the cache must be updated by
running 'pvscan \-\-cache'.
When lvmetad is not used, LVM commands revert to scanning disks for LVM
metadata.
Use of lvmetad is enabled/disabled by:
.br
.BR lvm.conf (5)
.B global/use_lvmetad
For more information on this setting, see:
.br
.B lvmconfig \-\-withcomments global/use_lvmetad
To ignore disks from LVM at the system level, e.g. lvmetad, pvscan use:
.br
.BR lvm.conf (5)
.B devices/global_filter
For more information on this setting, see
.br
.B lvmconfig \-\-withcomments devices/global_filter
lvmetad is used by LVM only if it is enabled in \fBlvm.conf\fP(5) by specifying the
\fBglobal/use_lvmetad\fP setting. If this is not defined in the LVM configuration
explicitly then default setting is used instead (see the output of
\fBlvm dumpconfig \-\-type default global/use_lvmetad\fP command).
.SH OPTIONS
To run the daemon in a test environment both the pidfile_path and the
@@ -109,6 +68,4 @@ Path for the socket file.
.SH SEE ALSO
.BR lvm (8),
.BR lvmconfig (8),
.BR lvm.conf (5),
.BR pvscan (8)
.BR lvm.conf (5)

View File

@@ -1,90 +0,0 @@
.TH LVMPOLLD 8 "LVM TOOLS #VERSION#" "Red Hat Inc" \" -*- nroff -*-
.SH NAME
lvmpolld \(em LVM poll daemon
.SH SYNOPSIS
.B lvmpolld
.RB [ \-l | \-\-log
.RI { all | wire | debug }]
.RB [ \-p | \-\-pidfile
.IR pidfile_path ]
.RB [ \-s | \-\-socket
.IR socket_path ]
.RB [ \-B | \-\-binary
.IR lvm_binary_path ]
.RB [ \-t | \-\-timeout
.IR timeout_value ]
.RB [ \-f | \-\-foreground ]
.RB [ \-h | \-\-help ]
.RB [ \-V | \-\-version ]
.B lvmpolld
.RB [ \-\-dump ]
.SH DESCRIPTION
lvmpolld is polling daemon for LVM. The daemon receives requests for polling
of already initialised operations originating in LVM2 command line tool.
The requests for polling originate in the \fBlvconvert\fP, \fBpvmove\fP,
\fBlvchange\fP or \fBvgchange\fP LVM2 commands.
The purpose of lvmpolld is to reduce the number of spawned background processes
per otherwise unique polling operation. There should be only one. It also
eliminates the possibility of unsolicited termination of background process by
external factors.
lvmpolld is used by LVM only if it is enabled in \fBlvm.conf\fP(5) by
specifying the \fBglobal/use_lvmpolld\fP setting. If this is not defined in the
LVM configuration explicitly then default setting is used instead (see the
output of \fBlvmconfig \-\-type default global/use_lvmpolld\fP command).
.SH OPTIONS
To run the daemon in a test environment both the pidfile_path and the
socket_path should be changed from the defaults.
.TP
.BR \-f ", " \-\-foreground
Don't fork, but run in the foreground.
.TP
.BR \-h ", " \-\-help
Show help information.
.TP
.IR \fB\-l\fP ", " \fB\-\-log\fP " {" all | wire | debug }
Select the type of log messages to generate.
Messages are logged by syslog.
Additionally, when \-f is given they are also sent to standard error.
There are two classes of messages: wire and debug. Selecting 'all' supplies both
and is equivalent to a comma-separated list \-l wire,debug.
.TP
.BR \-p ", " \-\-pidfile \fIpidfile_path
Path to the pidfile. This overrides both the built-in default
(#DEFAULT_PID_DIR#/lvmpolld.pid) and the environment variable
\fBLVM_LVMPOLLD_PIDFILE\fP. This file is used to prevent more
than one instance of the daemon running simultaneously.
.TP
.BR \-s ", " \-\-socket " " \fIsocket_path
Path to the socket file. This overrides both the built-in default
(#DEFAULT_RUN_DIR#/lvmpolld.socket) and the environment variable
\fBLVM_LVMPOLLD_SOCKET\fP.
.TP
.BR \-t ", " \-\-timeout " " \fItimeout_value
The daemon may shutdown after being idle for the given time (in seconds). When the
option is omitted or the value given is zero the daemon never shutdowns on idle.
.TP
.BR \-B ", " \-\-binary " " \fIlvm_binary_path
Optional path to alternative LVM binary (default: #LVM_PATH#). Use for
testing purposes only.
.TP
.BR \-V ", " \-\-version
Display the version of lvmpolld daemon.
.TP
.B \-\-dump
Contact the running lvmpolld daemon to obtain the complete state and print it
out in a raw format.
.SH ENVIRONMENT VARIABLES
.TP
.B LVM_LVMPOLLD_PIDFILE
Path for the pid file.
.TP
.B LVM_LVMPOLLD_SOCKET
Path for the socket file.
.SH SEE ALSO
.BR lvm (8),
.BR lvm.conf (5)

View File

@@ -254,8 +254,6 @@ or vgchange to activate thin snapshots with the "k" attribute.
.br
.B Metadata space exhaustion
.br
.B Automatic extend settings
.br
.B Zeroing
.br
.B Discard
@@ -836,8 +834,7 @@ extended. (Disabling dmeventd is not recommended.)
.IP \[bu]
Automatic extension of the thin pool is too slow given the rate of writes
to thin LVs in the pool. (This can be addressed by tuning the
thin_pool_autoextend_threshold and thin_pool_autoextend_percent.
See "Automatic extend settings".)
thin_pool_autoextend_threshold and thin_pool_autoextend_percent.)
.IP \[bu]
The VG does not have enough free blocks to extend the thin pool.
@@ -880,117 +877,6 @@ repair.
4. Check and repair file system with fsck.
.SS Automatic extend settings
\&
Thin pool LVs can be extended according to preset values. The presets
determine if the LV should be extended based on how full it is, and if so
by how much. When dmeventd monitors thin pool LVs, it uses lvextend with
these presets. (See "Automatically extend thin pool LV".)
Command to extend a thin pool data LV using presets:
.br
.B lvextend \-\-use\-policies VG/ThinPoolLV
The command uses these settings:
.BR lvm.conf (5)
.B thin_pool_autoextend_threshold
.br
autoextend the LV when its usage exceeds this percent.
.BR lvm.conf (5)
.B thin_pool_autoextend_percent
.br
autoextend the LV by this much additional space.
To see the default values of these settings, run:
.B lvmconfig --type default --withcomment
.RS
.B activation/thin_pool_autoextend_threshold
.RE
.B lvmconfig --type default --withcomment
.RS
.B activation/thin_pool_autoextend_percent
.RE
To change these values globally, edit
.BR lvm.conf (5).
To change these values on a per-VG or per-LV basis, attach a "profile" to
the VG or LV. A profile is a collection of config settings, saved in a
local text file (using the lvm.conf format). lvm looks for profiles in
the profile_dir directory, e.g. /etc/lvm/profile/. Once attached to a VG
or LV, lvm will process the VG or LV using the settings from the attached
profile. A profile is named and referenced by its file name.
To use a profile to customize the lvextend settings for an LV:
.IP \[bu] 2
Create a file containing settings, saved in profile_dir.
For the profile_dir location, run:
.br
.B lvmconfig config/profile_dir
.IP \[bu] 2
Attach the profile to an LV, using the command:
.br
.B lvchange \-\-metadataprofile ProfileName VG/ThinPoolLV
.IP \[bu] 2
Extend the LV using the profile settings:
.br
.B lvextend \-\-use\-policies VG/ThinPoolLV
.P
.I Example
.br
.nf
# lvmconfig config/profile_dir
profile_dir="/etc/lvm/profile"
# cat /etc/lvm/profile/pool0extend.profile
activation {
thin_pool_autoextend_threshold=50
thin_pool_autoextend_percent=10
}
# lvchange --metadataprofile pool0extend vg/pool0
# lvextend --use-policies vg/pool0
.fi
.I Notes
.IP \[bu] 2
A profile is attached to a VG or LV by name, where the name references a
local file in profile_dir. If the VG is moved to another machine, the
file with the profile also needs to be moved.
.IP \[bu] 2
Only certain settings can be used in a VG or LV profile, see:
.br
.B lvmconfig --type profilable-metadata.
.IP \[bu] 2
An LV without a profile of its own will inherit the VG profile.
.IP \[bu] 2
Remove a profile from an LV using the command:
.br
.B lvchange --detachprofile VG/ThinPoolLV.
.IP \[bu] 2
Commands can also have profiles applied to them. The settings that can be
applied to a command are different than the settings that can be applied
to a VG or LV. See lvmconfig --type profilable-command. To apply a
profile to a command, write a profile, save it in the profile directory,
and run the command using the option: --commandprofile ProfileName.
.SS Zeroing
\&
@@ -1356,10 +1242,10 @@ skipped while mounting readonly:
mount /dev/VG/SnapLV /mnt \-o ro,nouuid,norecovery
.SH SEE ALSO
.BR lvm (8),
.BR lvm.conf (5),
.BR lvmconfig (8),
.BR lvcreate (8),
.BR lvconvert (8),
.BR lvchange (8),

View File

@@ -1,7 +1,6 @@
.TH PVSCAN 8 "LVM TOOLS #VERSION#" "Sistina Software UK" \" -*- nroff -*-
.SH NAME
pvscan \(em scan all disks for physical volumes
.SH SYNOPSIS
.B pvscan
.RB [ \-\-commandprofile
@@ -31,118 +30,9 @@ pvscan \(em scan all disks for physical volumes
.IR DevicePath
|
.IR major:minor ]...
.SH DESCRIPTION
pvscan scans all supported LVM block devices in the system for physical
volumes.
.SS Scanning with lvmetad
pvscan operates differently when used with the
.BR lvmetad (8)
daemon.
Scanning disks is required to read LVM metadata and identify LVM PVs.
Once read, lvmetad caches the metadata so that LVM commands can read it
without repeatedly scanning disks. This is helpful because scanning disks
is time consuming, and frequent scanning may interfere with the normal
work of the system and disks.
When lvmetad is not used, LVM commands revert to scanning disks to read
metadata. Any LVM command that needs metadata will scan disks for it;
running the pvscan command is not necessary for the sake of other LVM
commands.
When lvmetad is used, LVM commands avoid scanning disks by reading
metadata from lvmetad. When new disks appear, they must be scanned so
their metadata can be cached in lvmetad. This is done by the command
pvscan \-\-cache, which scans disks and passes the metadata to lvmetad.
The pvscan \-\-cache command is typically run automatically by system
services when a new device appears. Users do not generally need to run
this command if the system and lvmetad are running properly.
Many scripts contain unnecessary pvscan (or vgscan) commands for
historical reasons. To avoid disrupting the system with extraneous disk
scanning, an ordinary pvscan (without \-\-cache) will simply read metadata
from lvmetad like other LVM commands. It does not do anything beyond
displaying the current state of the cache.
.I Notes
.IP \[bu] 2
When given specific device name arguments, pvscan \-\-cache will only
read the named devices.
.IP \[bu] 2
LVM udev rules and systemd services are used to intiate automatic device
scanning.
.IP \[bu] 2
To prevent devices from being scanned by pvscan --cache, add them
to
.BR lvm.conf (5)
.B devices/global_filter.
The devices/filter setting does not
apply to system level scanning.
For more information, see:
.br
.B lvmconfig --withcomments devices/global_filter
.IP \[bu] 2
If lvmetad is started or restarted after devices are visible, or
if the global_filter has changed, then all devices must be rescanned
for metadata with the command pvscan \-\-cache.
.IP \[bu] 2
lvmetad ignores older metadata formats, e.g. lvm1, and should not be
used if they exist.
.IP \[bu] 2
To notify lvmetad about a device that is no longer present, the major and
minor numbers must be given, not the path.
.SS Automatic activation
When event-driven system services detect a new LVM device, the first step
is to automatically scan and cache the metadata from the device. This is
done by pvscan \-\-cache. A second step is to automatically activate LVs
that are present on the new device. This auto-activation is done by the
same pvscan \-\-cache command when the option '\-a|\-\-activate ay' is
included.
Auto-activation of VGs or LVs can be enabled/disabled using:
.br
.BR lvm.conf (5)
.B activation/auto_activation_volume_list
For more information, see:
.br
.B lvmconfig --withcomments activation/auto_activation_volume_list
When this setting is undefined, all LVs are auto-activated (when lvm is
fully integrated with the event-driven system services.)
When a VG or LV is not auto-activated, traditional activation using
vgchange or lvchange -a|--activate is needed.
.I Notes
.IP \[bu] 2
pvscan auto-activation can be only done in combination with \-\-cache.
.IP \[bu] 2
Auto-activation is designated by the "a" argument in '-a|--activate ay'.
This is meant to distinguish system generated commands from explicit user
commands, although it can be used in any activation command. Whenever it
is used, the auto_activation_volume_list is applied.
.IP \[bu] 2
Auto-activation is not yet supported for LVs that are part of partial or
clustered volume groups.
.P
pvscan scans all supported LVM block devices in the system for
physical volumes.
.SH OPTIONS
See \fBlvm\fP(8) for common options.
.TP
@@ -156,19 +46,37 @@ Only show physical volumes not belonging to any volume group.
Short listing format.
.TP
.BR \-u ", " \-\-uuid
Show UUIDs in addition to device names.
Show UUIDs (Uniform Unique Identifiers) in addition to device special names.
.TP
.BR \-a ", " \-\-activate " " \fIay
Automatically activate any logical volumes that are possible to activate
with the addition of the new devices.
Together with the information already cached in lvmetad, automatically activate
any logical volumes that become activatable after the scan done on one or more devices.
The logical volume to autoactivate is matched against the
activation/auto_activation_volume_list set in lvm.conf. If this list is not set, then
all volumes are considered for autoactivation. The autoactivation is not yet
supported for logical volumes that are part of partial or clustered volume groups.
.TP
.BR \-b ", " \-\-background
Run the command in the background.
.TP
.BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " | " \fImajor:minor " ]..."
Scan one or more devices and send the metadata to lvmetad.
Scan one or more devices and instruct the lvmetad daemon to update its cached
state accordingly. Called internally by udev rules.
All devices listed explicitly are processed \fBregardless\fP of any device
filters set using \fBdevices/filter\fP configuration setting. To filter
devices even in this case, the \fBdevices/global_filter\fP must be used.
If lvmetad has not yet cached any metadata or the filters have recently been
changed, then all devices may be scanned, effectively ignoring the rest of
the command line. Otherwise, if all the devices referenced on the command line
contain metadata in the default lvm2 format, other devices are not accessed.
If metadata written using the obsolete GFS pool or lvm1 format is encountered,
this is ignored and so lvmetad should not be used.
To notify lvmetad about a device that is not present in the system anymore,
\fB\-\-major\fP and \fB\-\-minor\fP pair of that device must be always supplied,
not \fBDevicePath\fP as pvscan is not able to translate the \fBDevicePath\fP
into major and minor pair which lvmetad requires.
.SH SEE ALSO
.BR lvm (8),
.BR lvmconfig (8),
.BR lvmetad (8)
.BR lvmetad (8),
.BR pvcreate (8),
.BR pvdisplay (8)

View File

@@ -194,7 +194,7 @@ let
echo "* `date +"%a %b %d %Y"` Petr Rockai <prockai@redhat.com> - $version";
echo "- AUTOMATED BUILD BY Hydra") >> spec/lvm2.spec
cp spec/* . # */ # RPM needs the spec file in the source root
mv spec/* . && rmdir spec # */ # RPM needs the spec file in the source root
# make a tarball
mkdir ../LVM2.$version
@@ -351,29 +351,24 @@ let
install_rpms = rec {
common = [ "libselinux-devel" "libsepol-devel" "ncurses-devel" "readline-devel"
"valgrind" "valgrind-devel" "gdb" "strace"
"valgrind" "gdb" "strace"
"redhat-rpm-config" # needed for rpmbuild of lvm
"which" "e2fsprogs" # needed for fsadm
"e2fsprogs-libs" "e2fsprogs-devel"
"perl-GD" # for lcov
"mdadm" # for tests with lvm2 and mdadm
"device-mapper-persistent-data" # thin and cache
"pkgconfig" # better support for config
"kernel"
];
centos63 = [ "clusterlib-devel" "openaislib-devel" "cman" "libudev-devel" "procps" "nc" ];
centos63 = [ "clusterlib-devel" "openaislib-devel" "cman" "libudev-devel" "valgrind-devel" "procps" ];
centos64 = centos63 ++ [ "corosynclib-devel" ];
centos65 = centos64;
centos66 = centos65;
centos70 = [ "dlm-devel" "dlm" "corosynclib-devel" "perl-Digest-MD5" "systemd-devel"
"socat" # used by test suite lvmpolld
"procps-ng" ];
"device-mapper-persistent-data" "procps-ng" "valgrind-devel" ];
fedora17_18 = [ "dlm-devel" "corosynclib-devel" "libblkid" "libblkid-devel"
"dlm" "systemd-devel" "perl-Digest-MD5" "kernel-modules-extra" ];
fedora17 = fedora17_18 ++ [ "libudev-devel" "nc" ];
fedora17 = fedora18 ++ [ "libudev-devel" ];
fedora18 = fedora17_18 ++ [ "socat" ];
fedora18 = [ "dlm-devel" "corosynclib-devel" "device-mapper-persistent-data"
"dlm" "systemd-devel" "perl-Digest-MD5" "kernel-modules-extra" ];
fedora18u = fedora18;
fedora19 = centos70 ++ [ "kernel-modules-extra" ];

View File

@@ -17,7 +17,7 @@ top_builddir = @top_builddir@
LANGS=de
#TARGETS=$(LANGS:%=lvm2_%.mo) $(LANGS:%=dm_%.mo)
TARGETS=$(LANGS:%=lvm2_%.mo) $(LANGS:%=dm_%.mo)
DM_POSOURCES = $(top_builddir)/tools/dmsetup.pot $(top_builddir)/libdm/*.pot \
$(top_builddir)/libdm/*/*.pot

View File

@@ -27,7 +27,7 @@ import lvm
#Dump information about PV
def print_pv(pv):
print('PV name: ', pv.getName(), ' ID: ', pv.getUuid(), 'Size: ', pv.getSize())
print 'PV name: ', pv.getName(), ' ID: ', pv.getUuid(), 'Size: ', pv.getSize()
#Dump some information about a specific volume group
@@ -35,7 +35,7 @@ def print_vg(vg_name):
#Open read only
vg = lvm.vgOpen(vg_name, 'r')
print('Volume group:', vg_name, 'Size: ', vg.getSize())
print 'Volume group:', vg_name, 'Size: ', vg.getSize()
#Retrieve a list of Physical volumes for this volume group
pv_list = vg.listPVs()
@@ -48,9 +48,9 @@ def print_vg(vg_name):
lv_list = vg.listLVs()
if len(lv_list):
for l in lv_list:
print('LV name: ', l.getName(), ' ID: ', l.getUuid())
print 'LV name: ', l.getName(), ' ID: ', l.getUuid()
else:
print('No logical volumes present!')
print 'No logical volumes present!'
vg.close()
@@ -75,14 +75,14 @@ def find_vg_with_free_space():
def create_delete_logical_volume():
vg_name = find_vg_with_free_space()
print('Using volume group ', vg_name, ' for example')
print 'Using volume group ', vg_name, ' for example'
if vg_name:
vg = lvm.vgOpen(vg_name, 'w')
lv = vg.createLvLinear('python_lvm_ok_to_delete', vg.getFreeSize())
if lv:
print('New lv, id= ', lv.getUuid())
print 'New lv, id= ', lv.getUuid()
#Create a tag
lv.addTag('Demo_tag')
@@ -97,16 +97,16 @@ def create_delete_logical_volume():
#Try to rename
lv.rename("python_lvm_renamed")
print('LV name= ', lv.getName())
print 'LV name= ', lv.getName()
lv.remove()
vg.close()
else:
print('No free space available to create demo lv!')
print 'No free space available to create demo lv!'
if __name__ == '__main__':
#What version
print('lvm version=', lvm.getVersion())
print 'lvm version=', lvm.getVersion()
#Get a list of volume group names
vg_names = lvm.listVgNames()

View File

@@ -25,23 +25,6 @@
#include "lvm2app.h"
#include "defaults.h"
#if PY_MAJOR_VERSION >= 3
#define IS_PY3K
#define PYINTTYPE_CHECK PyLong_Check
#define PYINTTYPE_ASLONG PyLong_AsLong
#define PYINTTYPE_FROMLONG PyLong_FromLong
#define PYSTRYPE_CHECK PyUnicode_Check
#define PYSTRTYPE_ASSTRING PyUnicode_AsUTF8
#define PYSTRTYPE_FROMSTRING PyUnicode_FromString
#else
#define PYINTTYPE_CHECK PyInt_Check
#define PYINTTYPE_ASLONG PyInt_AsLong
#define PYINTTYPE_FROMLONG PyInt_FromLong
#define PYSTRYPE_CHECK PyString_Check
#define PYSTRTYPE_ASSTRING PyString_AsString
#define PYSTRTYPE_FROMSTRING PyString_FromString
#endif
static lvm_t _libh;
@@ -165,10 +148,10 @@ static PyObject *_liblvm_get_last_error(void)
if (!(info = PyTuple_New(2)))
return NULL;
PyTuple_SetItem(info, 0, PYINTTYPE_FROMLONG((long) lvm_errno(_libh)));
PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(_libh)));
msg = lvm_errmsg(_libh);
PyTuple_SetItem(info, 1, ((msg) ? PYSTRTYPE_FROMSTRING(msg) :
PYSTRTYPE_FROMSTRING("Memory error while retrieving error message")));
PyTuple_SetItem(info, 1, ((msg) ? PyString_FromString(msg) :
PyString_FromString("Memory error while retrieving error message")));
return info;
}
@@ -216,7 +199,7 @@ static PyObject *_liblvm_lvm_list_vg_names(void)
return NULL;
dm_list_iterate_items(strl, vgnames) {
PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
i++;
}
@@ -241,7 +224,7 @@ static PyObject *_liblvm_lvm_list_vg_uuids(void)
return NULL;
dm_list_iterate_items(strl, uuids) {
PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
i++;
}
@@ -870,19 +853,10 @@ static PyObject *get_property(struct lvm_property_value *prop)
if (!(pytuple = PyTuple_New(2)))
return NULL;
if (prop->is_integer) {
if (prop->is_signed) {
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("L", prop->value.signed_integer));
} else {
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("K", prop->value.integer));
}
} else {
if ( prop->value.string ) {
PyTuple_SET_ITEM(pytuple, 0, PYSTRTYPE_FROMSTRING(prop->value.string));
} else {
PyTuple_SET_ITEM(pytuple, 0, Py_None);
}
}
if (prop->is_integer)
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("K", prop->value.integer));
else
PyTuple_SET_ITEM(pytuple, 0, PyString_FromString(prop->value.string));
if (prop->is_settable)
setable = Py_True;
@@ -930,14 +904,14 @@ static PyObject *_liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
if (!lvm_property.is_valid)
goto lvmerror;
if (PYSTRYPE_CHECK(variant_type_arg)) {
if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
if (!lvm_property.is_string) {
PyErr_Format(PyExc_ValueError, "Property requires string value");
goto bail;
}
if (!(string_value = PYSTRTYPE_ASSTRING(variant_type_arg))) {
if (!(string_value = PyString_AsString(variant_type_arg))) {
PyErr_NoMemory();
goto bail;
}
@@ -950,8 +924,8 @@ static PyObject *_liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
goto bail;
}
if (PYINTTYPE_CHECK(variant_type_arg)) {
temp_py_int = PYINTTYPE_ASLONG(variant_type_arg);
if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
temp_py_int = PyInt_AsLong(variant_type_arg);
/* -1 could be valid, need to see if an exception was gen. */
if (temp_py_int == -1 && PyErr_Occurred())
@@ -1082,7 +1056,7 @@ static PyObject *_liblvm_lvm_vg_get_tags(vgobject *self)
return NULL;
dm_list_iterate_items(strl, tagsl) {
PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
i++;
}
@@ -1525,7 +1499,7 @@ static PyObject *_liblvm_lvm_lv_get_tags(lvobject *self)
return NULL;
dm_list_iterate_items(strl, tagsl) {
PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
i++;
}
@@ -1949,7 +1923,7 @@ static PyMethodDef _liblvm_pvseg_methods[] = {
};
static PyTypeObject _LibLVMvgType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_vg",
.tp_basicsize = sizeof(vgobject),
.tp_new = PyType_GenericNew,
@@ -1960,7 +1934,7 @@ static PyTypeObject _LibLVMvgType = {
};
static PyTypeObject _LibLVMlvType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_lv",
.tp_basicsize = sizeof(lvobject),
.tp_new = PyType_GenericNew,
@@ -1971,7 +1945,7 @@ static PyTypeObject _LibLVMlvType = {
};
static PyTypeObject _LibLVMpvlistType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_pvlist",
.tp_basicsize = sizeof(pvslistobject),
.tp_new = PyType_GenericNew,
@@ -1982,7 +1956,7 @@ static PyTypeObject _LibLVMpvlistType = {
};
static PyTypeObject _LibLVMpvType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_pv",
.tp_basicsize = sizeof(pvobject),
.tp_new = PyType_GenericNew,
@@ -1993,7 +1967,7 @@ static PyTypeObject _LibLVMpvType = {
};
static PyTypeObject _LibLVMlvsegType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_lvseg",
.tp_basicsize = sizeof(lvsegobject),
.tp_new = PyType_GenericNew,
@@ -2004,7 +1978,7 @@ static PyTypeObject _LibLVMlvsegType = {
};
static PyTypeObject _LibLVMpvsegType = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyObject_HEAD_INIT(&PyType_Type)
.tp_name = "lvm.Liblvm_pvseg",
.tp_basicsize = sizeof(pvsegobject),
.tp_new = PyType_GenericNew,
@@ -2022,65 +1996,40 @@ static void _liblvm_cleanup(void)
}
}
#ifdef IS_PY3K
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"lvm",
"Liblvm module",
-1,
_Liblvm_methods,
NULL,
NULL,
NULL,
NULL
};
#define MODINITERROR return NULL
PyObject *
PyInit_lvm(void)
#else
#define MODINITERROR return
PyMODINIT_FUNC initlvm(void);
PyMODINIT_FUNC initlvm(void)
#endif
{
PyObject *m;
_libh = lvm_init(NULL);
if (PyType_Ready(&_LibLVMvgType) < 0)
MODINITERROR;
return;
if (PyType_Ready(&_LibLVMlvType) < 0)
MODINITERROR;
return;
if (PyType_Ready(&_LibLVMpvType) < 0)
MODINITERROR;
return;
if (PyType_Ready(&_LibLVMlvsegType) < 0)
MODINITERROR;
return;
if (PyType_Ready(&_LibLVMpvsegType) < 0)
MODINITERROR;
return;
if (PyType_Ready(&_LibLVMpvlistType) < 0)
MODINITERROR;
return;
#ifdef IS_PY3K
m = PyModule_Create(&moduledef);
#else
m = Py_InitModule3("lvm", _Liblvm_methods, "Liblvm module");
#endif
if (m == NULL)
MODINITERROR;
if (!(m = Py_InitModule3("lvm", _Liblvm_methods, "Liblvm module")))
return;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_IGNORE",
LVM_THIN_DISCARDS_IGNORE) < 0)
MODINITERROR;
return;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_NO_PASSDOWN",
LVM_THIN_DISCARDS_NO_PASSDOWN) < 0)
MODINITERROR;
return;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_PASSDOWN",
LVM_THIN_DISCARDS_PASSDOWN) < 0)
MODINITERROR;
return;
if ((_LibLVMError = PyErr_NewException((char*)"lvm.LibLVMError", NULL, NULL))) {
/* Each call to PyModule_AddObject decrefs it; compensate: */
@@ -2091,7 +2040,4 @@ PyMODINIT_FUNC initlvm(void)
}
Py_AtExit(_liblvm_cleanup);
#ifdef IS_PY3K
return m;
#endif
}

3
scripts/.gitignore vendored
View File

@@ -4,9 +4,6 @@ dm_event_systemd_red_hat.service
lvm2_lvmetad_init_red_hat
lvm2_lvmetad_systemd_red_hat.service
lvm2_lvmetad_systemd_red_hat.socket
lvm2_lvmpolld_init_red_hat
lvm2_lvmpolld_systemd_red_hat.service
lvm2_lvmpolld_systemd_red_hat.socket
lvm2_monitoring_init_red_hat
lvm2_monitoring_systemd_red_hat.service
lvm2_tmpfiles_red_hat.conf

View File

@@ -75,9 +75,6 @@ endif
ifeq ("@BUILD_LVMETAD@", "yes")
$(INSTALL_SCRIPT) lvm2_lvmetad_init_red_hat $(initdir)/lvm2-lvmetad
endif
ifeq ("@BUILD_LVMPOLLD@", "yes")
$(INSTALL_SCRIPT) lvm2_lvmpolld_init_red_hat $(initdir)/lvm2-lvmpolld
endif
ifneq ("@CLVMD@", "none")
$(INSTALL_SCRIPT) clvmd_init_red_hat $(initdir)/clvmd
endif
@@ -117,10 +114,6 @@ ifeq ("@BUILD_LVMETAD@", "yes")
$(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
ifeq ("@BUILD_LVMPOLLD@", "yes")
$(INSTALL_DATA) lvm2_lvmpolld_systemd_red_hat.socket $(systemd_unit_dir)/lvm2-lvmpolld.socket
$(INSTALL_DATA) lvm2_lvmpolld_systemd_red_hat.service $(systemd_unit_dir)/lvm2-lvmpolld.service
endif
ifneq ("@CLVMD@", "none")
$(INSTALL_DATA) lvm2_clvmd_systemd_red_hat.service $(systemd_unit_dir)/lvm2-clvmd.service
$(INSTALL_DATA) lvm2_cluster_activation_systemd_red_hat.service $(systemd_unit_dir)/lvm2-cluster-activation.service
@@ -149,8 +142,6 @@ DISTCLEAN_TARGETS += \
lvm2_lvmetad_init_red_hat \
lvm2_lvmetad_systemd_red_hat.service \
lvm2_lvmetad_systemd_red_hat.socket \
lvm2_lvmpolld_systemd_red_hat.service \
lvm2_lvmpolld_systemd_red_hat.socket \
lvm2_monitoring_init_red_hat \
lvm2_monitoring_systemd_red_hat.service \
lvm2_pvscan_systemd_red_hat@.service \

View File

@@ -1,114 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# This file is part of LVM2.
# It is required for the proper handling of failures of LVM2 mirror
# devices that were created using the -m option of lvcreate.
#
#
# chkconfig: 12345 02 99
# description: Starts and stops LVM poll daemon
#
# For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
#
### BEGIN INIT INFO
# Provides: lvm2-lvmpolld
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 1 2 3 4 5
# Default-Stop: 0 6
# Short-Description: A daemon that is responsible for monitoring in-progress
# and possibly longer term operations on logical volumes.
# It helps to reduce the number of spawned processes if same
# logical volume is requested to get monitored multiple times.
# Also avoids unsolicited termination due to external factors.
### END INIT INFO
. /etc/init.d/functions
DAEMON=lvmpolld
exec_prefix=@exec_prefix@
sbindir=@sbindir@
LOCK_FILE="/var/lock/subsys/$DAEMON"
PID_FILE="@LVMPOLLD_PIDFILE@"
rh_status() {
status -p $PID_FILE $DAEMON
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
start()
{
ret=0
action "Starting LVM poll daemon:" $DAEMON || ret=$?
return $ret
}
stop()
{
ret=0
action "Signaling LVM poll daemon to exit:" killproc -p $PID_FILE $DAEMON -TERM || ret=$?
return $ret
}
rtrn=1
# See how we were called.
case "$1" in
start)
rh_status_q && exit 0
start
rtrn=$?
[ $rtrn = 0 ] && touch $LOCK_FILE
;;
stop|force-stop)
rh_status_q || exit 0
stop
rtrn=$?
[ $rtrn = 0 ] && rm -f $LOCK_FILE
;;
restart)
if stop
then
start
fi
rtrn=$?
;;
condrestart|try-restart)
rh_status_q || exit 0
if stop
then
start
fi
rtrn=$?
;;
status)
rh_status
rtrn=$?
;;
*)
echo $"Usage: $0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
;;
esac
exit $rtrn

View File

@@ -1,17 +0,0 @@
[Unit]
Description=LVM2 poll daemon
Documentation=man:lvmpolld(8)
Requires=lvm2-lvmpolld.socket
After=lvm2-lvmpolld.socket
DefaultDependencies=no
Conflicts=shutdown.target
[Service]
Type=simple
NonBlocking=true
ExecStart=@sbindir@/lvmpolld -t 60 -f
Environment=SD_ACTIVATION=1
PIDFile=@LVMPOLLD_PIDFILE@
[Install]
WantedBy=sysinit.target

View File

@@ -1,12 +0,0 @@
[Unit]
Description=LVM2 poll daemon socket
Documentation=man:lvmpolld(8)
DefaultDependencies=no
[Socket]
ListenStream=@DEFAULT_RUN_DIR@/lvmpolld.socket
SocketMode=0600
RemoveOnStop=true
[Install]
WantedBy=sysinit.target

Some files were not shown because too many files have changed in this diff Show More