stable-2.02 - label: cleanup set_byte error exit
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e94e0cd0206044780bd...
Commit: e94e0cd0206044780bdde19b833d818da8f3f651
Parent: 35104f7ba5c5318b059ed0fd76f47fdd1c04285b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 16 13:54:16 2020 -0500
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
label: cleanup set_byte error exit
---
lib/label/label.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 065da1282..e05b18a9e 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1414,6 +1414,8 @@ bool dev_write_zeros(struct device *dev, uint64_t start, size_t len)
bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
{
+ bool rv;
+
if (test_mode())
return true;
@@ -1444,25 +1446,30 @@ bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
dev_set_last_byte(dev, start + len);
- if ((!val && !bcache_zero_bytes(scan_bcache, dev->bcache_fd, start, len)) ||
- !bcache_set_bytes(scan_bcache, dev->bcache_fd, start, len, val)) {
- log_error("Error writing device %s at %llu length %u.",
+ if (!val)
+ rv = bcache_zero_bytes(scan_bcache, dev->bcache_fd, start, len);
+ else
+ rv = bcache_set_bytes(scan_bcache, dev->bcache_fd, start, len, val);
+
+ if (!rv) {
+ log_error("Error writing device value %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
- dev_unset_last_byte(dev);
- label_scan_invalidate(dev);
- return false;
+ goto fail;
}
if (!bcache_flush(scan_bcache)) {
log_error("Error writing device %s at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
- dev_unset_last_byte(dev);
- label_scan_invalidate(dev);
- return false;
+ goto fail;
}
dev_unset_last_byte(dev);
return true;
+
+fail:
+ dev_unset_last_byte(dev);
+ label_scan_invalidate(dev);
+ return false;
}
void dev_set_last_byte(struct device *dev, uint64_t offset)
3 years, 6 months
stable-2.02 - wipe: dev_set_bytes resolves zeroing
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=35104f7ba5c5318b059...
Commit: 35104f7ba5c5318b059ed0fd76f47fdd1c04285b
Parent: 0559ce6be098253fecb8d2cc42d391b270e75894
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 15 20:35:48 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
wipe: dev_set_bytes resolves zeroing
Since dev_write_zeros() is just subset of dev_set_bytes()
use it directly and simplify code.
---
lib/metadata/lv_manip.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 660e742dd..7576eaeba 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7244,6 +7244,7 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
log_debug("Metadata logical volume %s will be fully zeroed.",
display_lvname(lv));
zero_sectors = lv->size;
+ wp.zero_value = 0;
} else {
if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
@@ -7260,11 +7261,7 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
- if ((!wp.is_metadata &&
- wp.zero_value && !dev_set_bytes(dev, UINT64_C(0),
- (size_t) zero_sectors << SECTOR_SHIFT,
- (uint8_t)wp.zero_value)) ||
- !dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT)) {
+ if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
log_error("Failed to initialize %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
3 years, 6 months
stable-2.02 - lvm: add readline alternative editline
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f0a2b6737a89996db3a...
Commit: f0a2b6737a89996db3a607f9e328a81cd1d85444
Parent: cc5eb1d70f2b910a0b45b27cb82fced77f0a4047
Author: Bastian Germann <bastiangermann(a)fishpost.de>
AuthorDate: Sat Sep 26 21:32:55 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
lvm: add readline alternative editline
LVM2 is distributed under GPLv2 only. The readline library changed its
license long ago to GPLv3. Given that those licenses are incompatible
and you follow the FSF in their interpretation that dynamically linking
creates a derivative work, distributing LVM2 linked against a current
readline version might be legally problematic.
Add support for the BSD licensed editline library as an alternative for
readline.
Link: https://thrysoee.dk/editline
---
configure.ac | 23 +++++++++++++++++++++++
include/configure.h.in | 9 +++++++++
lib/mm/memlock.c | 1 +
make.tmpl.in | 1 +
tools/Makefile.in | 4 ++--
tools/lvm.c | 21 +++++++++++++--------
tools/lvmcmdline.c | 2 +-
7 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4aee76542..41217c651 100644
--- a/configure.ac
+++ b/configure.ac
@@ -607,6 +607,12 @@ AC_ARG_ENABLE([readline],
AC_HELP_STRING([--disable-readline], [disable readline support]),
READLINE=$enableval, READLINE=maybe)
+################################################################################
+dnl -- Disable editline
+AC_ARG_ENABLE([editline],
+ AC_HELP_STRING([--enable-editline], [enable editline support]),
+ EDITLINE=$enableval, EDITLINE=no)
+
################################################################################
dnl -- Disable realtime clock support
AC_MSG_CHECKING(whether to enable realtime support)
@@ -1615,6 +1621,16 @@ AC_IF_YES(ac_cv_stat_st_ctim,
dnl -- Check for getopt
AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.]))
+################################################################################
+dnl -- Check for editline
+if test "$EDITLINE" == yes; then
+ PKG_CHECK_MODULES([EDITLINE], [libedit], [
+ AC_DEFINE([EDITLINE_SUPPORT], 1,
+ [Define to 1 to include the LVM editline shell.])], AC_MSG_ERROR(
+[libedit could not be found which is required for the --enable-readline option.])
+ )
+fi
+
################################################################################
dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
if test "$READLINE" != no; then
@@ -1747,6 +1763,12 @@ fi
AC_MSG_CHECKING(whether to enable readline)
AC_MSG_RESULT($READLINE)
+if test "$EDITLINE" = yes; then
+ AC_CHECK_HEADERS(editline/readline.h editline/history.h,,hard_bailout)
+fi
+AC_MSG_CHECKING(whether to enable editline)
+AC_MSG_RESULT($EDITLINE)
+
if test "$BUILD_CMIRRORD" = yes; then
AC_CHECK_FUNCS(atexit,,hard_bailout)
fi
@@ -2033,6 +2055,7 @@ AC_SUBST(QUORUM_CFLAGS)
AC_SUBST(QUORUM_LIBS)
AC_SUBST(RT_LIBS)
AC_SUBST(READLINE_LIBS)
+AC_SUBST(EDITLINE_LIBS)
AC_SUBST(REPLICATORS)
AC_SUBST(SACKPT_CFLAGS)
AC_SUBST(SACKPT_LIBS)
diff --git a/include/configure.h.in b/include/configure.h.in
index 812cacc8b..94f755c82 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -144,6 +144,9 @@
/* Library version */
#undef DM_LIB_VERSION
+/* Define to 1 to include the LVM editline shell. */
+#undef EDITLINE_SUPPORT
+
/* Path to fsadm binary. */
#undef FSADM_PATH
@@ -203,6 +206,12 @@
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
+/* Define to 1 if you have the <editline/history.h> header file. */
+#undef HAVE_EDITLINE_HISTORY_H
+
+/* Define to 1 if you have the <editline/readline.h> header file. */
+#undef HAVE_EDITLINE_READLINE_H
+
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c
index 6adc9e83c..7eee399b4 100644
--- a/lib/mm/memlock.c
+++ b/lib/mm/memlock.c
@@ -122,6 +122,7 @@ static const char * const _blacklist_maps[] = {
"/libpcre.so.", /* not using pcre during mlock (selinux) */
"/libpcre2-", /* not using pcre during mlock (selinux) */
"/libreadline.so.", /* not using readline during mlock */
+ "/libedit.so.", /* not using editline during mlock */
"/libresolv-", /* not using during mlock (udev) */
"/libselinux.so.", /* not using selinux during mlock */
"/libsepol.so.", /* not using sepol during mlock */
diff --git a/make.tmpl.in b/make.tmpl.in
index e7780e8d4..e4fcc9ab7 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -82,6 +82,7 @@ RT_LIBS = @RT_LIBS@
M_LIBS = @M_LIBS@
PTHREAD_LIBS = @PTHREAD_LIBS@
READLINE_LIBS = @READLINE_LIBS@
+EDITLINE_LIBS = @EDITLINE_LIBS@
SELINUX_LIBS = @SELINUX_LIBS@
UDEV_CFLAGS = @UDEV_CFLAGS@
UDEV_LIBS = @UDEV_LIBS@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 103b76732..ddc1ee630 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -140,8 +140,8 @@ INCLUDES += -I$(top_builddir)/tools
lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
@echo " [CC] $@"
- $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $(OBJECTS) lvm.o \
- $(LVMLIBS) $(READLINE_LIBS) $(LIBS)
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $+ \
+ $(DMEVENT_LIBS) $(LVMLIBS) $(READLINE_LIBS) $(EDITLINE_LIBS)
DEFS_man-generator.o += -DMAN_PAGE_GENERATOR
diff --git a/tools/lvm.c b/tools/lvm.c
index 4bfa6f5c2..79b1210af 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -22,13 +22,18 @@ int main(int argc, char **argv)
return lvm2_main(argc, argv);
}
-#ifdef READLINE_SUPPORT
-
-# include <readline/readline.h>
-# include <readline/history.h>
-# ifndef HAVE_RL_COMPLETION_MATCHES
-# define rl_completion_matches(a, b) completion_matches((char *)a, b)
-# define rl_completion_func_t CPPFunction
+#if defined(READLINE_SUPPORT) || defined(EDITLINE_SUPPORT)
+
+# ifdef READLINE_SUPPORT
+# include <readline/readline.h>
+# include <readline/history.h>
+# ifndef HAVE_RL_COMPLETION_MATCHES
+# define rl_completion_matches(a, b) completion_matches((char *)a, b)
+# define rl_completion_func_t CPPFunction
+# endif
+# elif defined(EDITLINE_SUPPORT)
+# include <editline/readline.h>
+# include <editline/history.h>
# endif
static struct cmdline_context *_cmdline;
@@ -348,4 +353,4 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
return 0;
}
-#endif /* READLINE_SUPPORT */
+#endif /* READLINE_SUPPORT || EDITLINE_SUPPORT */
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 9c39f48f6..0655a57a9 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3514,7 +3514,7 @@ int lvm2_main(int argc, char **argv)
}
if (run_shell) {
-#ifdef READLINE_SUPPORT
+#if defined(READLINE_SUPPORT) || defined(EDITLINE_SUPPORT)
_nonroot_warning();
if (!_prepare_profiles(cmd)) {
ret = ECMD_FAILED;
3 years, 6 months
stable-2.02 - configure: fix python paths
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0559ce6be098253fecb...
Commit: 0559ce6be098253fecb8d2cc42d391b270e75894
Parent: 789fc2a081545ff81c5cb11c3503e93701b96393
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Oct 17 22:26:50 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
configure: fix python paths
Stable branch supports also python2.
---
configure | 6 ++++--
configure.ac | 8 ++++----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/configure b/configure
index 3b52cf244..6859d51b1 100755
--- a/configure
+++ b/configure
@@ -12665,6 +12665,7 @@ if test "$PYTHON_BINDINGS" = yes; then
as_fn_error $? "--enable-python-bindings is replaced by --enable-python2-bindings and --enable-python3-bindings" "$LINENO" 5
fi
+
if test "$PYTHON2_BINDINGS" = yes; then
@@ -12707,7 +12708,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python3 python2 python python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -13275,7 +13276,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python3 python2 python python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python3 python2 python python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -15658,6 +15659,7 @@ _ACEOF
+
diff --git a/configure.ac b/configure.ac
index 41217c651..9d90ff062 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1433,6 +1433,9 @@ if test "$PYTHON_BINDINGS" = yes; then
AC_MSG_ERROR([--enable-python-bindings is replaced by --enable-python2-bindings and --enable-python3-bindings])
fi
+m4_define_default([_AM_PYTHON_INTERPRETER_LIST],[ python3 python2 python dnl
+python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 dnl
+python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 ])
if test "$PYTHON2_BINDINGS" = yes; then
AM_PATH_PYTHON([2])
AC_PATH_TOOL(PYTHON2, python2)
@@ -1445,15 +1448,12 @@ if test "$PYTHON2_BINDINGS" = yes; then
PYTHON2DIR=$pythondir
PYTHON_BINDINGS=yes
fi
-
+
if test "$PYTHON3_BINDINGS" = yes -o "$BUILD_LVMDBUSD" = yes; then
unset PYTHON PYTHON_CONFIG
unset am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_platform
unset am_cv_python_pythondir am_cv_python_version am_cv_python_pyexecdir
unset ac_cv_path_PYTHON_CONFIG ac_cv_path_ac_pt_PYTHON_CONFIG
- m4_define_default([_AM_PYTHON_INTERPRETER_LIST],[ python3 python2 python dnl
- python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 dnl
- python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 ])
AM_PATH_PYTHON([3])
PYTHON3=$PYTHON
test -z "$PYTHON3" && AC_MSG_ERROR([python3 is required for --enable-python3_bindings or --enable-dbus-service but cannot be found])
3 years, 6 months
stable-2.02 - configure: editline updates
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=789fc2a081545ff81c5...
Commit: 789fc2a081545ff81c5cb11c3503e93701b96393
Parent: f0a2b6737a89996db3a607f9e328a81cd1d85444
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 29 10:15:45 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
configure: editline updates
Update configure file.
---
WHATS_NEW | 1 +
configure | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 123 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9c2df1515..764af0da4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Add configure --enable-editline support as an alternative to readline.
Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
Failure in zeroing or wiping will fail command (bypass with -Zn, -Wn).
Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
diff --git a/configure b/configure
index b6658b908..3b52cf244 100755
--- a/configure
+++ b/configure
@@ -747,6 +747,8 @@ BLKID_PC
APPLIB
MODPROBE_CMD
MSGFMT
+EDITLINE_LIBS
+EDITLINE_CFLAGS
PYTHON3_CONFIG
PYTHON2_CONFIG
PYTHON2
@@ -927,6 +929,7 @@ with_cache_repair
with_cache_restore
enable_cache_check_needs_check
enable_readline
+enable_editline
enable_realtime
enable_ocf
with_ocfdir
@@ -1045,7 +1048,9 @@ SYSTEMD_CFLAGS
SYSTEMD_LIBS
UDEV_CFLAGS
UDEV_LIBS
-PYTHON'
+PYTHON
+EDITLINE_CFLAGS
+EDITLINE_LIBS'
# Initialize some variables set by options.
@@ -1678,6 +1683,7 @@ Optional Features:
--disable-cache_check_needs_check
required if cache_check version is < 0.5
--disable-readline disable readline support
+ --enable-editline enable editline support
--disable-realtime disable realtime clock support
--enable-ocf enable Open Cluster Framework (OCF) compliant
resource agents
@@ -1893,6 +1899,10 @@ Some influential environment variables:
UDEV_CFLAGS C compiler flags for UDEV, overriding pkg-config
UDEV_LIBS linker flags for UDEV, overriding pkg-config
PYTHON the Python interpreter
+ EDITLINE_CFLAGS
+ C compiler flags for EDITLINE, overriding pkg-config
+ EDITLINE_LIBS
+ linker flags for EDITLINE, overriding pkg-config
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -9606,6 +9616,15 @@ else
fi
+################################################################################
+# Check whether --enable-editline was given.
+if test "${enable_editline+set}" = set; then :
+ enableval=$enable_editline; EDITLINE=$enableval
+else
+ EDITLINE=no
+fi
+
+
################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable realtime support" >&5
$as_echo_n "checking whether to enable realtime support... " >&6; }
@@ -14213,6 +14232,86 @@ fi
done
+################################################################################
+if test "$EDITLINE" == yes; then
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EDITLINE" >&5
+$as_echo_n "checking for EDITLINE... " >&6; }
+
+if test -n "$EDITLINE_CFLAGS"; then
+ pkg_cv_EDITLINE_CFLAGS="$EDITLINE_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libedit\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libedit") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_EDITLINE_CFLAGS=`$PKG_CONFIG --cflags "libedit" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$EDITLINE_LIBS"; then
+ pkg_cv_EDITLINE_LIBS="$EDITLINE_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libedit\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libedit") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_EDITLINE_LIBS=`$PKG_CONFIG --libs "libedit" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ EDITLINE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libedit" 2>&1`
+ else
+ EDITLINE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libedit" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$EDITLINE_PKG_ERRORS" >&5
+
+ as_fn_error $? "libedit could not be found which is required for the --enable-readline option." "$LINENO" 5
+
+elif test $pkg_failed = untried; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "libedit could not be found which is required for the --enable-readline option." "$LINENO" 5
+
+else
+ EDITLINE_CFLAGS=$pkg_cv_EDITLINE_CFLAGS
+ EDITLINE_LIBS=$pkg_cv_EDITLINE_LIBS
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+
+$as_echo "#define EDITLINE_SUPPORT 1" >>confdefs.h
+
+fi
+fi
+
################################################################################
if test "$READLINE" != no; then
lvm_saved_libs=$LIBS
@@ -14651,6 +14750,28 @@ $as_echo_n "checking whether to enable readline... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE" >&5
$as_echo "$READLINE" >&6; }
+if test "$EDITLINE" = yes; then
+ for ac_header in editline/readline.h editline/history.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ hard_bailout
+fi
+
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable editline" >&5
+$as_echo_n "checking whether to enable editline... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $EDITLINE" >&5
+$as_echo "$EDITLINE" >&6; }
+
if test "$BUILD_CMIRRORD" = yes; then
for ac_func in atexit
do :
3 years, 6 months
stable-2.02 - tests: check pool metadata are zeroed
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cc5eb1d70f2b910a0b4...
Commit: cc5eb1d70f2b910a0b45b27cb82fced77f0a4047
Parent: a46fdf5426596db41b08530ea2a0d4c8d8895ad8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 24 14:42:11 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
tests: check pool metadata are zeroed
---
test/lib/aux.sh | 1 +
test/shell/lvcreate-thin.sh | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 0ab4cabaf..728e6dc0e 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1303,6 +1303,7 @@ activation/udev_sync = 1
activation/verify_udev_operations = $LVM_VERIFY_UDEV
activation/raid_region_size = 512
allocation/wipe_signatures_when_zeroing_new_lvs = 0
+allocation/zero_metadata = 0
backup/archive = 0
backup/backup = 0
devices/cache_dir = "$TESTDIR/etc"
diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh
index 8e04c9e64..7c91b3413 100644
--- a/test/shell/lvcreate-thin.sh
+++ b/test/shell/lvcreate-thin.sh
@@ -237,4 +237,25 @@ not lvcreate -s $vg/lv1 -L4M -V2G --name $vg/lv4
not lvcreate -T mirpool -L4M --alloc anywhere -m1 $vg
not lvcreate --thinpool mirpool -L4M --alloc anywhere -m1 $vg
+
+# Check pool metadata volume is zeroed, when zero_metadata is enabled.
+# 1st. ensure 8megs of both PVs will have some non-0 data
+lvcreate -L8m -n $lv1 $vg "$dev1"
+lvextend -L+8m $vg/$lv1 "$dev2"
+dd if=/dev/urandom of="$DM_DEV_DIR/$vg/$lv1" bs=1M count=16 oflag=direct conv=fdatasync
+lvremove -ff $vg/$lv1
+
+lvcreate -l1 --poolmetadatasize 4m --conf 'allocation/zero_metadata=1' -vvvv -T $vg/pool
+lvchange -an $vg
+# component activation to check device was zeroed
+lvchange -y -ay $vg/pool_tmeta
+dd if="$DM_DEV_DIR/$vg/pool_tmeta" of=file bs=1M count=3 skip=1 iflag=direct conv=fdatasync
+
+md5sum -b file | tee out
+# md5sum of 3M of zeros
+grep d1dd210d6b1312cb342b56d02bd5e651 out
+lvchange -an $vg
+lvremove -ff $vg
+
+
vgremove -ff $vg
3 years, 6 months
stable-2.02 - tests: failure of zeroing fails command
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a46fdf5426596db41b0...
Commit: a46fdf5426596db41b08530ea2a0d4c8d8895ad8
Parent: e5010662a19502183fcbcc2a5e755c223ede2744
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 23 14:10:18 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
tests: failure of zeroing fails command
---
test/shell/lvcreate-signature-wiping.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 73fea54fd..18d7a2f7e 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -42,6 +42,13 @@ init_lv_
test_blkid_ || skip
lvremove -f $vg/$lv1
+# Zeroing stops the command when there is a failure (write error in this case)
+aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):2"
+not lvcreate -l1 -n $lv1 $vg 2>&1 | tee out
+grep "Failed to initialize" out
+aux enable_dev "$dev1"
+
+
aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 0"
lvcreate -y -Zn -l1 -n $lv1 $vg 2>&1 | tee out
3 years, 6 months
stable-2.02 - lvconvert: more support for yes conversion
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e5010662a19502183fc...
Commit: e5010662a19502183fcbcc2a5e755c223ede2744
Parent: 9c746f153e351a806592554cf1d90ddb03879933
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 10:57:52 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:27:51 2020 +0200
lvconvert: more support for yes conversion
When converting volume to pool LV use also wiping of other signatures.
For pool conversion support --yet and --force
to bypass prompting for signature wiping.
Note: currently we have lvconvert doing convertion and prompting
for confirmation of conversion - and then again wipe_lv() prompts
for removing i.e. filesystem signature - we should unify this
prompting into 1 message - althought the 'filesystem' discovery
needs active volume - while the 1st. conversion prompt can
work without active converted volume.
---
tools/lvconvert.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4dc2eed59..fb33cc4e8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3195,7 +3195,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
}
metadata_lv->status &= ~LV_ACTIVATION_SKIP;
- if (!wipe_lv(metadata_lv, (struct wipe_params) { .do_zero = 1 })) {
+ if (!wipe_lv(metadata_lv, (struct wipe_params) {
+ .do_wipe_signatures = 1,
+ .is_metadata = 1,
+ .yes = arg_count(cmd, yes_ARG),
+ .force = arg_count(cmd, force_ARG) } )) {
log_error("Aborting. Failed to wipe metadata lv.");
goto bad;
}
3 years, 6 months
stable-2.02 - wipe_lv: always zero at least 4K
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9c746f153e351a80659...
Commit: 9c746f153e351a806592554cf1d90ddb03879933
Parent: 8ee2479dd0547ee6451da5b3e2ffca2f808c09a9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 8 10:38:36 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:27:51 2020 +0200
wipe_lv: always zero at least 4K
When zero_sectors passed value like 1 - we could zero only 1 sector.
Reinstantiate we always zero at least 4K block.
---
lib/metadata/lv_manip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 0e58d4fa9..660e742dd 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7248,7 +7248,9 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
display_lvname(lv));
- zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
+ zero_sectors = UINT64_C(4096) >> SECTOR_SHIFT;
+ if (wp.zero_sectors > zero_sectors)
+ zero_sectors = wp.zero_sectors;
if (zero_sectors > lv->size)
zero_sectors = lv->size;
3 years, 6 months
stable-2.02 - pool: zero metadata
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8ee2479dd0547ee6451...
Commit: 8ee2479dd0547ee6451da5b3e2ffca2f808c09a9
Parent: 7a06bc240001a18db8da8a9befa5b6e9ddbcdcb5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 24 12:11:21 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:27:51 2020 +0200
pool: zero metadata
To avoid polution of metadata with some 'garbage' content or eventualy
some leak of stale data in case user want to upload metadata somewhere,
ensure upon allocation the metadata device is fully zeroed.
Behaviour may slow down allocation of thin-pool or cache-pool a bit
so the old behaviour can be restored with lvm.conf setting:
allocation/zero_metadata=0
TODO: add zeroing for extension of metadata volume.
---
WHATS_NEW | 1 +
conf/example.conf.in | 6 +++++-
lib/config/config_settings.h | 5 ++++-
lib/config/defaults.h | 1 +
lib/metadata/lv_manip.c | 28 +++++++++++++++++++++-------
lib/metadata/metadata-exported.h | 2 ++
lib/metadata/pool_manip.c | 6 ++++--
7 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e7245447b..9c2df1515 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
Failure in zeroing or wiping will fail command (bypass with -Zn, -Wn).
Fix support for lvconvert --repair used by foreign apps (i.e. Docker).
Support interruption for bcache waiting.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 29b0df497..a57c66e40 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -467,7 +467,7 @@ allocation {
# This configuration option does not have a default value defined.
# Configuration option allocation/thin_pool_metadata_require_separate_pvs.
- # Thin pool metdata and data will always use different PVs.
+ # Thin pool metadata and data will always use different PVs.
thin_pool_metadata_require_separate_pvs = 0
# Configuration option allocation/thin_pool_zero.
@@ -505,6 +505,10 @@ allocation {
# This configuration option has an automatic default value.
# thin_pool_chunk_size_policy = "generic"
+ # Configuration option allocation/zero_metadata.
+ # Zero whole metadata area before use with thin or cache pool.
+ zero_metadata = 1
+
# Configuration option allocation/thin_pool_chunk_size.
# The minimal chunk size in KiB for thin pool volumes.
# Larger chunk sizes may improve performance for plain thin volumes,
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 429bff14e..d23ae49ff 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -594,7 +594,7 @@ cfg(allocation_cache_pool_max_chunks_CFG, "cache_pool_max_chunks", allocation_CF
"Using cache pool with more chunks may degrade cache performance.\n")
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL, 0, NULL,
- "Thin pool metdata and data will always use different PVs.\n")
+ "Thin pool metadata and data will always use different PVs.\n")
cfg(allocation_thin_pool_zero_CFG, "thin_pool_zero", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_ZERO, vsn(2, 2, 99), NULL, 0, NULL,
"Thin pool data chunks are zeroed before they are first used.\n"
@@ -625,6 +625,9 @@ cfg(allocation_thin_pool_chunk_size_policy_CFG, "thin_pool_chunk_size_policy", a
" 512KiB.\n"
"#\n")
+cfg(allocation_zero_metadata_CFG, "zero_metadata", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ZERO_METADATA, vsn(2, 2, 188), NULL, 0, NULL,
+ "Zero whole metadata area before use with thin or cache pool.\n")
+
cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99), 0, NULL,
"The minimal chunk size in KiB for thin pool volumes.\n"
"Larger chunk sizes may improve performance for plain thin volumes,\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 6d3c37c81..2ffad243e 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -116,6 +116,7 @@
#define DEFAULT_THIN_POOL_DISCARDS "passdown"
#define DEFAULT_THIN_POOL_ZERO 1
#define DEFAULT_POOL_METADATA_SPARE 1 /* thin + cache */
+#define DEFAULT_ZERO_METADATA 1 /* thin + cache */
#ifdef CACHE_CHECK_NEEDS_CHECK
# define DEFAULT_CACHE_CHECK_OPTION1 "-q"
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index c4fabf5a0..0e58d4fa9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7183,8 +7183,9 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
struct device *dev;
char name[PATH_MAX];
uint64_t zero_sectors;
+ int zero_metadata;
- if (!wp.do_zero && !wp.do_wipe_signatures)
+ if (!wp.do_zero && !wp.do_wipe_signatures && !wp.is_metadata)
/* nothing to do */
return 1;
@@ -7236,17 +7237,29 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
}
}
- if (wp.do_zero) {
- zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
-
- if (zero_sectors > lv->size)
+ if (wp.do_zero || wp.is_metadata) {
+ zero_metadata = !wp.is_metadata ? 0 :
+ find_config_tree_bool(lv->vg->cmd, allocation_zero_metadata_CFG, NULL);
+ if (zero_metadata) {
+ log_debug("Metadata logical volume %s will be fully zeroed.",
+ display_lvname(lv));
zero_sectors = lv->size;
+ } else {
+ if (wp.is_metadata) /* Verbosely notify metadata will not be fully zeroed */
+ log_verbose("Metadata logical volume %s not fully zeroed and may contain stale data.",
+ display_lvname(lv));
+ zero_sectors = wp.zero_sectors ? : UINT64_C(4096) >> SECTOR_SHIFT;
+
+ if (zero_sectors > lv->size)
+ zero_sectors = lv->size;
+ }
log_verbose("Initializing %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
- if ((wp.zero_value && !dev_set_bytes(dev, UINT64_C(0),
+ if ((!wp.is_metadata &&
+ wp.zero_value && !dev_set_bytes(dev, UINT64_C(0),
(size_t) zero_sectors << SECTOR_SHIFT,
(uint8_t)wp.zero_value)) ||
!dev_write_zeros(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT)) {
@@ -8088,7 +8101,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
.do_zero = lp->zero,
.do_wipe_signatures = lp->wipe_signatures,
.yes = lp->yes,
- .force = lp->force
+ .force = lp->force,
+ .is_metadata = lp->is_metadata,
})) {
log_error("Aborting. Failed to wipe %s.", lp->snapshot
? "snapshot exception store" : "start of new LV");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f64f53f86..8f173059b 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -780,6 +780,7 @@ struct wipe_params {
int do_wipe_signatures; /* should we wipe known signatures found on LV? */
int yes; /* answer yes automatically to all questions */
force_t force; /* force mode */
+ int is_metadata; /* wipe volume is metadata LV */
};
/* Zero out LV and/or wipe signatures */
@@ -943,6 +944,7 @@ struct lvcreate_params {
int thin_chunk_size_calc_policy;
unsigned suppress_zero_warn : 1;
unsigned needs_lockd_init : 1;
+ unsigned is_metadata : 1; /* created LV will be used as metadata LV (and can be zeroed) */
const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; /* all */
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index 1381f29bf..a93e230be 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -532,8 +532,8 @@ int create_pool(struct logical_volume *pool_lv,
display_lvname(pool_lv));
goto bad;
}
- /* Clear 4KB of pool metadata device. */
- if (!(r = wipe_lv(pool_lv, (struct wipe_params) { .do_zero = 1 }))) {
+ /* Clear pool metadata device. */
+ if (!(r = wipe_lv(pool_lv, (struct wipe_params) { .is_metadata = 1 }))) {
log_error("Aborting. Failed to wipe pool metadata %s.",
display_lvname(pool_lv));
}
@@ -614,6 +614,7 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
.tags = DM_LIST_HEAD_INIT(lvc.tags),
.temporary = 1,
.zero = 1,
+ .is_metadata = 1,
};
if (!(lvc.segtype = get_segtype_from_string(pool_lv->vg->cmd, SEG_TYPE_NAME_STRIPED)))
@@ -650,6 +651,7 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
.tags = DM_LIST_HEAD_INIT(lp.tags),
.temporary = 1,
.zero = 1,
+ .is_metadata = 1,
};
if (!(lp.segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_STRIPED)))
3 years, 6 months