master - bcache: support interrupts when waiting on IO
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b3c7a2b3f0bc761a14c...
Commit: b3c7a2b3f0bc761a14cfe1c8fc768e265a183204
Parent: 0fe58fc54fb17707ba5ff04bcf7c8a5174784bec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 17:16:14 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:57:50 2020 +0200
bcache: support interrupts when waiting on IO
Since lvm2 normally block signals during protected
phase where it does not want to be interrupted.
Support interruptible processing when allowed
in section between sigint_allow() ... sigint_restore())
and let the 'io_getenvents()' finish with EINTR.
---
WHATS_NEW | 1 +
lib/device/bcache.c | 4 +---
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1d38a7360..a93a61b32 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Support interruption for bcache waiting.
Fix bcache when device has too many failing writes.
Fix bcache waiting for IO completion with failing disks.
Configure use own python path name order to prefer using python3.
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 3fb6a0e80..d1749d9ab 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -325,9 +325,7 @@ static bool _async_wait(struct io_engine *ioe, io_complete_fn fn)
struct async_engine *e = _to_async(ioe);
memset(&event, 0, sizeof(event));
- do {
- r = io_getevents(e->aio_context, 1, MAX_EVENT, event, NULL);
- } while (r == -EINTR);
+ r = io_getevents(e->aio_context, 1, MAX_EVENT, event, NULL);
if (r < 0) {
log_sys_warn("io_getevents");
2 years, 5 months
master - bcache: fix busy loop with too many errors
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0fe58fc54fb17707ba5...
Commit: 0fe58fc54fb17707ba5ff04bcf7c8a5174784bec
Parent: 41f9e372c064c2c254dce0f3657bd1c36f950e7c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 17:42:50 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:56:55 2020 +0200
bcache: fix busy loop with too many errors
When bcache tries to write data to a faulty device,
it may get out of caching blocks and then just busy-loops
on a CPU - so this check protects this by checking
if there is already max_io (~64) errored blocks.
---
WHATS_NEW | 1 +
lib/device/bcache.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index bebd1f5cf..1d38a7360 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Fix bcache when device has too many failing writes.
Fix bcache waiting for IO completion with failing disks.
Configure use own python path name order to prefer using python3.
Add configure --enable-editline support as an alternative to readline.
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 33d124229..3fb6a0e80 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -964,6 +964,11 @@ static struct block *_new_block(struct bcache *cache, int di, block_address i, b
if (dm_list_empty(&cache->io_pending))
_writeback(cache, 16); // FIXME: magic number
_wait_all(cache);
+ if (dm_list_size(&cache->errored) >= cache->max_io) {
+ log_debug("bcache no new blocks for di %d index %u with >%d errors.",
+ di, (uint32_t) i, cache->max_io);
+ return NULL;
+ }
} else {
log_debug("bcache no new blocks for di %d index %u",
di, (uint32_t) i);
2 years, 5 months
master - bcache: fix waiting problem for completed IO
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=41f9e372c064c2c254d...
Commit: 41f9e372c064c2c254dce0f3657bd1c36f950e7c
Parent: 9885c9b43a6c72ea89852989f4fa4a9a4619014a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 17:18:12 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:53:41 2020 +0200
bcache: fix waiting problem for completed IO
Call _wait_all() which does check whether there is still
some pending IO before sleep. Otherwise it may happen
our submitted IO operations have been already dispatched
and this call then endlessly waits for IO which are all done.
This can be reproduced when device returns quickly errors
on write requests.
---
WHATS_NEW | 1 +
lib/device/bcache.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c7a3207f9..bebd1f5cf 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Fix bcache waiting for IO completion with failing disks.
Configure use own python path name order to prefer using python3.
Add configure --enable-editline support as an alternative to readline.
Enhance reporting and error handling when creating thin volumes.
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index fd18eef6e..33d124229 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -963,7 +963,7 @@ static struct block *_new_block(struct bcache *cache, int di, block_address i, b
if (can_wait) {
if (dm_list_empty(&cache->io_pending))
_writeback(cache, 16); // FIXME: magic number
- _wait_io(cache);
+ _wait_all(cache);
} else {
log_debug("bcache no new blocks for di %d index %u",
di, (uint32_t) i);
2 years, 5 months
master - configure: use our ordered list of python names
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9885c9b43a6c72ea898...
Commit: 9885c9b43a6c72ea89852989f4fa4a9a4619014a
Parent: 2df7ef58a547a62b83264d291295890ce72066d5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 20:40:52 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:52:38 2020 +0200
configure: use our ordered list of python names
Since it seems it's prefered now to use python3 in path name,
prefer this name as first in the list.
---
WHATS_NEW | 1 +
configure | 2 +-
configure.ac | 3 +++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a8639ff65..c7a3207f9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.11 -
==================================
+ Configure use own python path name order to prefer using python3.
Add configure --enable-editline support as an alternative to readline.
Enhance reporting and error handling when creating thin volumes.
Enable vgsplit for VDO volumes.
diff --git a/configure b/configure
index 4020eaa80..29d19f249 100755
--- a/configure
+++ b/configure
@@ -11881,7 +11881,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
diff --git a/configure.ac b/configure.ac
index 341591561..ee21b879d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1224,6 +1224,9 @@ if test "$BUILD_LVMDBUSD" = yes; then
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])
2 years, 5 months
master - configure: update with latest AM_PATH_PYTHON
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2df7ef58a547a62b832...
Commit: 2df7ef58a547a62b83264d291295890ce72066d5
Parent: ae96a43f05e7d5b9a420735bd4b652b275a3fe8f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 20:21:00 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:48:41 2020 +0200
configure: update with latest AM_PATH_PYTHON
World has moved towards python3.9.
Although we still don't like path ordering.
---
aclocal.m4 | 16 +++++++++-------
configure | 4 +++-
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index c57b12939..3e0fbd38d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.16.2 -*- Autoconf -*-
-# Copyright (C) 1996-2017 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -413,7 +413,7 @@ AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
])dnl PKG_HAVE_DEFINE_WITH_MODULES
-# Copyright (C) 1999-2017 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -446,10 +446,12 @@ AC_DEFUN([AM_PATH_PYTHON],
[
dnl Find a Python interpreter. Python versions prior to 2.0 are not
dnl supported. (2.0 was released on October 16, 2000).
- dnl FIXME: Remove the need to hard-code Python versions here.
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
-[python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
- python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
+[python python2 python3 dnl
+ python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
+ python3.2 python3.1 python3.0 dnl
+ python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
+ python2.0])
AC_ARG_VAR([PYTHON], [the Python interpreter])
@@ -649,7 +651,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
sys.exit(sys.hexversion < minverhex)"
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
-# Copyright (C) 2001-2017 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
diff --git a/configure b/configure
index 81f6d0875..4020eaa80 100755
--- a/configure
+++ b/configure
@@ -11845,6 +11845,7 @@ if test "$BUILD_LVMDBUSD" = yes; then
+
if test -n "$PYTHON"; then
# If the user set $PYTHON, use it and don't search something else.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 3" >&5
@@ -11880,7 +11881,7 @@ if ${am_cv_pathless_PYTHON+:} false; then :
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 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 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
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -14086,6 +14087,7 @@ _ACEOF
+
2 years, 5 months
master - configure: check for BLKZEROOUT support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ae96a43f05e7d5b9a42...
Commit: ae96a43f05e7d5b9a420735bd4b652b275a3fe8f
Parent: 91f869e43c8f3161d8bcc54477dfab4024a73a58
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 18:39:19 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 2 20:48:41 2020 +0200
configure: check for BLKZEROOUT support
---
configure | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 27 ++++++++++++++++++++++++
include/configure.h.in | 3 +++
3 files changed, 87 insertions(+)
diff --git a/configure b/configure
index c125aade1..81f6d0875 100755
--- a/configure
+++ b/configure
@@ -963,6 +963,7 @@ enable_fsadm
enable_blkdeactivate
enable_dmeventd
enable_selinux
+enable_blkzeroout
enable_nls
with_localedir
with_confdir
@@ -1684,6 +1685,7 @@ Optional Features:
--disable-blkdeactivate disable blkdeactivate
--enable-dmeventd enable the device-mapper event daemon
--disable-selinux disable selinux support
+ --disable-blkzeroout do not use BLKZEROOUT for device zeroing
--enable-nls enable Native Language Support
Optional Packages:
@@ -12707,6 +12709,61 @@ fi
fi
+################################################################################
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BLKZEROOUT in sys/ioctl.h." >&5
+$as_echo_n "checking for BLKZEROOUT in sys/ioctl.h.... " >&6; }
+if ${ac_cv_have_blkzeroout+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+int bar(void) { return ioctl(0, BLKZEROOUT, 0); }
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_have_blkzeroout=yes
+else
+ ac_cv_have_blkzeroout=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_blkzeroout" >&5
+$as_echo "$ac_cv_have_blkzeroout" >&6; }
+
+
+# Check whether --enable-blkzeroout was given.
+if test "${enable_blkzeroout+set}" = set; then :
+ enableval=$enable_blkzeroout; BLKZEROOUT=$enableval
+else
+ BLKZEROOUT=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use BLKZEROOUT for device zeroing" >&5
+$as_echo_n "checking whether to use BLKZEROOUT for device zeroing... " >&6; }
+if test "$BLKZEROOUT" = yes; then
+ if test $ac_cv_have_blkzeroout = yes; then :
+
+$as_echo "#define HAVE_BLKZEROOUT 1" >>confdefs.h
+
+else
+ BLKZEROOUT=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BLKZEROOUT" >&5
+$as_echo "$BLKZEROOUT" >&6; }
+
+
################################################################################
RT_LIBS=
HAVE_REALTIME=no
diff --git a/configure.ac b/configure.ac
index 148bde426..341591561 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1351,6 +1351,33 @@ if test "$SELINUX" = yes; then
HAVE_SELINUX=no ])
fi
+################################################################################
+dnl -- Check BLKZEROOUT support
+
+AC_CACHE_CHECK([for BLKZEROOUT in sys/ioctl.h.],
+ [ac_cv_have_blkzeroout],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[#include <sys/ioctl.h>
+#include <linux/fs.h>
+int bar(void) { return ioctl(0, BLKZEROOUT, 0); }]
+ )], [ac_cv_have_blkzeroout=yes], [ac_cv_have_blkzeroout=no])])
+
+
+AC_ARG_ENABLE(blkzeroout,
+ AC_HELP_STRING([--disable-blkzeroout],
+ [do not use BLKZEROOUT for device zeroing]),
+ BLKZEROOUT=$enableval, BLKZEROOUT=yes)
+
+AC_MSG_CHECKING(whether to use BLKZEROOUT for device zeroing)
+if test "$BLKZEROOUT" = yes; then
+ AC_IF_YES(ac_cv_have_blkzeroout,
+ AC_DEFINE(HAVE_BLKZEROOUT, 1,
+ [Define if ioctl BLKZEROOUT can be used for device zeroing.]),
+ BLKZEROOUT=no)
+fi
+AC_MSG_RESULT($BLKZEROOUT)
+
+
################################################################################
dnl -- Check for realtime clock support
RT_LIBS=
diff --git a/include/configure.h.in b/include/configure.h.in
index 46d5aef20..59b4da86f 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -154,6 +154,9 @@
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
+/* Define if ioctl BLKZEROOUT can be used for device zeroing. */
+#undef HAVE_BLKZEROOUT
+
/* Define to 1 if canonicalize_file_name is available. */
#undef HAVE_CANONICALIZE_FILE_NAME
2 years, 5 months
master - lvconvert: move log message to fix segfault
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=91f869e43c8f3161d8b...
Commit: 91f869e43c8f3161d8bcc54477dfab4024a73a58
Parent: 0143c7aebe2389ceada6ca0a314a3ff0fd9cdfef
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 2 09:23:25 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 2 09:23:25 2020 -0500
lvconvert: move log message to fix segfault
log message was printing lv name from released vg
---
tools/lvconvert.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a4ec48ede..7d5a541d0 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5774,14 +5774,15 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
backup(vg);
out_release:
+ if (ret)
+ log_print_unless_silent("Logical volume %s write cache has been detached.", display_lvname(lv));
+
unlock_and_release_vg(cmd, vg, vg->name);
out_lockd:
if (!lockd_vg(cmd, id->vg_name, "un", 0, &lockd_state))
stack;
- if (ret)
- log_print_unless_silent("Logical volume %s write cache has been detached.", display_lvname(lv));
return ret;
}
2 years, 5 months
master - improve message for invalid device arg in process_each_pv
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0143c7aebe2389ceada...
Commit: 0143c7aebe2389ceada6ca0a314a3ff0fd9cdfef
Parent: 74ed6e8a9969bb7d20c21f88b53e6134d81eab1d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 1 12:34:36 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 1 12:34:36 2020 -0500
improve message for invalid device arg in process_each_pv
Multiple commands process pvs by name using process_each_pv()
and will now have an improved error message for a device
that's excluded by filters.
---
tools/toollib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index f6879745b..f2372e095 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3839,7 +3839,7 @@ static int _get_arg_devices(struct cmd_context *cmd,
}
if (!(dil->dev = dev_cache_get(cmd, sl->str, cmd->filter))) {
- log_error("Failed to find device for physical volume \"%s\".", sl->str);
+ log_error("Cannot use %s: %s", sl->str, devname_error_reason(sl->str));
ret_max = ECMD_FAILED;
} else {
strncpy(dil->pvid, dil->dev->pvid, ID_LEN);
2 years, 5 months
master - improve message for invalid device arg
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=74ed6e8a9969bb7d20c...
Commit: 74ed6e8a9969bb7d20c21f88b53e6134d81eab1d
Parent: 450f272b31ef95bd7cb61812d9ef0525c7c1c341
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Oct 1 12:19:27 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 1 12:20:16 2020 -0500
improve message for invalid device arg
for pvcreate, pvremove, vgcreate, vgextend.
---
tools/toollib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 1814399b9..f6879745b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5248,7 +5248,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
dm_list_iterate_items_safe(pd, pd2, &pp->arg_devices) {
pd->dev = dev_cache_get(cmd, pd->name, cmd->filter);
if (!pd->dev) {
- log_error("Device %s not found.", pd->name);
+ log_error("Cannot use %s: %s", pd->name, devname_error_reason(pd->name));
dm_list_del(&pd->list);
dm_list_add(&pp->arg_fail, &pd->list);
}
2 years, 5 months
master - devices: support printing the filter that rejects a device
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=450f272b31ef95bd7cb...
Commit: 450f272b31ef95bd7cb61812d9ef0525c7c1c341
Parent: ff3945777ba6cb093174b99a9870df2494f4c29b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jul 20 12:48:36 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Oct 1 12:00:09 2020 -0500
devices: support printing the filter that rejects a device
Use of this new message function needs to be added
to various commands to improve the output.
---
lib/cache/lvmcache.c | 48 ++++++++++++++++++++++++++++++++++++++++
lib/cache/lvmcache.h | 3 +++
lib/device/dev-cache.c | 13 ++---------
lib/device/dev-cache.h | 3 ++-
lib/device/device.h | 1 +
lib/filters/filter-fwraid.c | 4 ++++
lib/filters/filter-internal.c | 3 +++
lib/filters/filter-md.c | 4 ++++
lib/filters/filter-mpath.c | 3 +++
lib/filters/filter-partitioned.c | 3 +++
lib/filters/filter-regex.c | 6 ++++-
lib/filters/filter-signature.c | 5 +++++
lib/filters/filter-sysfs.c | 3 +++
lib/filters/filter-type.c | 3 +++
lib/filters/filter-usable.c | 9 +++++++-
lib/filters/filter.h | 12 ++++++++++
tools/pvck.c | 6 ++---
17 files changed, 112 insertions(+), 17 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 9716eccaf..a2fa0e3fb 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -23,6 +23,7 @@
#include "lib/mm/memlock.h"
#include "lib/format_text/format-text.h"
#include "lib/config/config.h"
+#include "lib/filters/filter.h"
/* One per device */
struct lvmcache_info {
@@ -2683,3 +2684,50 @@ bool lvmcache_is_outdated_dev(struct cmd_context *cmd,
return false;
}
+
+const char *dev_filtered_reason(struct device *dev)
+{
+ if (dev->filtered_flags & DEV_FILTERED_REGEX)
+ return "device is rejected by filter config";
+ if (dev->filtered_flags & DEV_FILTERED_INTERNAL)
+ return "device is restricted internally";
+ if (dev->filtered_flags & DEV_FILTERED_MD_COMPONENT)
+ return "device is an md component";
+ if (dev->filtered_flags & DEV_FILTERED_MPATH_COMPONENT)
+ return "device is a multipath component";
+ if (dev->filtered_flags & DEV_FILTERED_PARTITIONED)
+ return "device is partitioned";
+ if (dev->filtered_flags & DEV_FILTERED_SIGNATURE)
+ return "device has a signature";
+ if (dev->filtered_flags & DEV_FILTERED_SYSFS)
+ return "device is missing sysfs info";
+ if (dev->filtered_flags & DEV_FILTERED_DEVTYPE)
+ return "device type is unknown";
+ if (dev->filtered_flags & DEV_FILTERED_MINSIZE)
+ return "device is too small (pv_min_size)";
+ if (dev->filtered_flags & DEV_FILTERED_UNUSABLE)
+ return "device is not in a usable state";
+
+ /* flag has not been added here */
+ if (dev->filtered_flags)
+ return "device is filtered";
+
+ return "device cannot be used";
+}
+
+const char *devname_error_reason(const char *devname)
+{
+ struct device *dev;
+
+ if ((dev = dev_hash_get(devname))) {
+ if (dev->filtered_flags)
+ return dev_filtered_reason(dev);
+ if (lvmcache_dev_is_unused_duplicate(dev))
+ return "device is a duplicate";
+ /* Avoid this case by adding by adding other more descriptive checks above. */
+ return "device cannot be used";
+ }
+
+ return "device not found";
+}
+
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 1ee99b534..7a718cad8 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -217,4 +217,7 @@ void lvmcache_get_mdas(struct cmd_context *cmd,
const char *vgname, const char *vgid,
struct dm_list *mda_list);
+const char *dev_filtered_reason(struct device *dev);
+const char *devname_error_reason(const char *devname);
+
#endif
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 84d65c4db..d5f18ff45 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1423,17 +1423,9 @@ const char *dev_name_confirmed(struct device *dev, int quiet)
return dev_name(dev);
}
-/* Provide a custom reason when a device is ignored */
-const char *dev_cache_filtered_reason(const char *name)
+struct device *dev_hash_get(const char *name)
{
- const char *reason = "not found";
- struct device *d = (struct device *) dm_hash_lookup(_cache.names, name);
-
- if (d)
- /* FIXME Record which filter caused the exclusion */
- reason = "excluded by a filter";
-
- return reason;
+ return (struct device *) dm_hash_lookup(_cache.names, name);
}
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f)
@@ -1657,4 +1649,3 @@ bool dev_cache_has_md_with_end_superblock(struct dev_types *dt)
return false;
}
-
diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h
index 46c86c27a..533e4561d 100644
--- a/lib/device/dev-cache.h
+++ b/lib/device/dev-cache.h
@@ -54,10 +54,11 @@ int dev_cache_has_scanned(void);
int dev_cache_add_dir(const char *path);
struct device *dev_cache_get(struct cmd_context *cmd, const char *name, struct dev_filter *f);
-const char *dev_cache_filtered_reason(const char *name);
struct device *dev_cache_get_by_devt(struct cmd_context *cmd, dev_t device, struct dev_filter *f, int *filtered);
+struct device *dev_hash_get(const char *name);
+
void dev_set_preferred_name(struct dm_str_list *sl, struct device *dev);
/*
diff --git a/lib/device/device.h b/lib/device/device.h
index 2706f28e1..a58bff8e3 100644
--- a/lib/device/device.h
+++ b/lib/device/device.h
@@ -73,6 +73,7 @@ struct device {
int bcache_fd;
int bcache_di;
uint32_t flags;
+ uint32_t filtered_flags;
unsigned size_seqno;
uint64_t size;
uint64_t end;
diff --git a/lib/filters/filter-fwraid.c b/lib/filters/filter-fwraid.c
index 992eba8b8..f82f87397 100644
--- a/lib/filters/filter-fwraid.c
+++ b/lib/filters/filter-fwraid.c
@@ -69,6 +69,8 @@ static int _ignore_fwraid(struct cmd_context *cmd, struct dev_filter *f __attrib
{
int ret;
+ dev->filtered_flags &= ~DEV_FILTERED_FWRAID;
+
if (!fwraid_filtering())
return 1;
@@ -80,12 +82,14 @@ static int _ignore_fwraid(struct cmd_context *cmd, struct dev_filter *f __attrib
else
log_debug_devs(MSG_SKIPPING " [%s:%p]", dev_name(dev),
dev_ext_name(dev), dev->ext.handle);
+ dev->filtered_flags |= DEV_FILTERED_FWRAID;
return 0;
}
if (ret < 0) {
log_debug_devs("%s: Skipping: error in firmware RAID component detection",
dev_name(dev));
+ dev->filtered_flags |= DEV_FILTERED_FWRAID;
return 0;
}
diff --git a/lib/filters/filter-internal.c b/lib/filters/filter-internal.c
index c10e8105f..a49c07e53 100644
--- a/lib/filters/filter-internal.c
+++ b/lib/filters/filter-internal.c
@@ -42,6 +42,8 @@ static int _passes_internal(struct cmd_context *cmd, struct dev_filter *f __attr
{
struct device_list *devl;
+ dev->filtered_flags &= ~DEV_FILTERED_INTERNAL;
+
if (!internal_filtering())
return 1;
@@ -50,6 +52,7 @@ static int _passes_internal(struct cmd_context *cmd, struct dev_filter *f __attr
return 1;
}
+ dev->filtered_flags |= DEV_FILTERED_INTERNAL;
log_debug_devs("%s: Skipping for internal filtering.", dev_name(dev));
return 0;
}
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
index 28903be3f..b530e407d 100644
--- a/lib/filters/filter-md.c
+++ b/lib/filters/filter-md.c
@@ -86,6 +86,8 @@ static int _passes_md_filter(struct cmd_context *cmd, struct dev_filter *f __att
{
int ret;
+ dev->filtered_flags &= ~DEV_FILTERED_MD_COMPONENT;
+
/*
* When md_component_dectection=0, don't even try to skip md
* components.
@@ -112,12 +114,14 @@ static int _passes_md_filter(struct cmd_context *cmd, struct dev_filter *f __att
else
log_debug_devs(MSG_SKIPPING " [%s:%p]", dev_name(dev),
dev_ext_name(dev), dev->ext.handle);
+ dev->filtered_flags |= DEV_FILTERED_MD_COMPONENT;
return 0;
}
if (ret < 0) {
log_debug_devs("%s: Skipping: error in md component detection",
dev_name(dev));
+ dev->filtered_flags |= DEV_FILTERED_MD_COMPONENT;
return 0;
}
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index 53a767c5e..85d1625f6 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -274,12 +274,15 @@ static int _dev_is_mpath(struct dev_filter *f, struct device *dev)
static int _ignore_mpath(struct cmd_context *cmd, struct dev_filter *f, struct device *dev, const char *use_filter_name)
{
+ dev->filtered_flags &= ~DEV_FILTERED_MPATH_COMPONENT;
+
if (_dev_is_mpath(f, dev) == 1) {
if (dev->ext.src == DEV_EXT_NONE)
log_debug_devs(MSG_SKIPPING, dev_name(dev));
else
log_debug_devs(MSG_SKIPPING " [%s:%p]", dev_name(dev),
dev_ext_name(dev), dev->ext.handle);
+ dev->filtered_flags |= DEV_FILTERED_MPATH_COMPONENT;
return 0;
}
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
index 1a700543c..22194f81c 100644
--- a/lib/filters/filter-partitioned.c
+++ b/lib/filters/filter-partitioned.c
@@ -24,6 +24,8 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
struct dev_types *dt = (struct dev_types *) f->private;
int ret;
+ dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
+
ret = dev_is_partitioned(dt, dev);
if (ret == -EAGAIN) {
@@ -39,6 +41,7 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
else
log_debug_devs(MSG_SKIPPING " [%s:%p]", dev_name(dev),
dev_ext_name(dev), dev->ext.handle);
+ dev->filtered_flags |= DEV_FILTERED_PARTITIONED;
return 0;
}
diff --git a/lib/filters/filter-regex.c b/lib/filters/filter-regex.c
index e439b36b5..7575981af 100644
--- a/lib/filters/filter-regex.c
+++ b/lib/filters/filter-regex.c
@@ -151,6 +151,8 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
struct rfilter *rf = (struct rfilter *) f->private;
struct dm_str_list *sl;
+ dev->filtered_flags &= ~DEV_FILTERED_REGEX;
+
dm_list_iterate_items(sl, &dev->aliases) {
m = dm_regex_match(rf->engine, sl->str);
@@ -168,8 +170,10 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
first = 0;
}
- if (rejected)
+ if (rejected) {
+ dev->filtered_flags |= DEV_FILTERED_REGEX;
log_debug_devs("%s: Skipping (regex)", dev_name(dev));
+ }
/*
* pass everything that doesn't match
diff --git a/lib/filters/filter-signature.c b/lib/filters/filter-signature.c
index 6a81203a9..f32bb2450 100644
--- a/lib/filters/filter-signature.c
+++ b/lib/filters/filter-signature.c
@@ -27,6 +27,8 @@ static int _ignore_signature(struct cmd_context *cmd, struct dev_filter *f __att
char buf[BUFSIZE];
int ret = 0;
+ dev->filtered_flags &= ~DEV_FILTERED_SIGNATURE;
+
if (!scan_bcache) {
/* let pass, call again after scan */
log_debug_devs("filter signature deferred %s", dev_name(dev));
@@ -40,18 +42,21 @@ static int _ignore_signature(struct cmd_context *cmd, struct dev_filter *f __att
log_debug_devs("%s: Skipping: error in signature detection",
dev_name(dev));
ret = 0;
+ dev->filtered_flags |= DEV_FILTERED_SIGNATURE;
goto out;
}
if (dev_is_lvm1(dev, buf, BUFSIZE)) {
log_debug_devs("%s: Skipping lvm1 device", dev_name(dev));
ret = 0;
+ dev->filtered_flags |= DEV_FILTERED_SIGNATURE;
goto out;
}
if (dev_is_pool(dev, buf, BUFSIZE)) {
log_debug_devs("%s: Skipping gfs-pool device", dev_name(dev));
ret = 0;
+ dev->filtered_flags |= DEV_FILTERED_SIGNATURE;
goto out;
}
ret = 1;
diff --git a/lib/filters/filter-sysfs.c b/lib/filters/filter-sysfs.c
index ebca8087c..b2ac63d7b 100644
--- a/lib/filters/filter-sysfs.c
+++ b/lib/filters/filter-sysfs.c
@@ -264,6 +264,8 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
{
struct dev_set *ds = (struct dev_set *) f->private;
+ dev->filtered_flags &= ~DEV_FILTERED_SYSFS;
+
if (!ds->initialised)
_init_devs(ds);
@@ -273,6 +275,7 @@ static int _accept_p(struct cmd_context *cmd, struct dev_filter *f, struct devic
if (!_set_lookup(ds, dev->dev)) {
log_debug_devs("%s: Skipping (sysfs)", dev_name(dev));
+ dev->filtered_flags |= DEV_FILTERED_SYSFS;
return 0;
}
diff --git a/lib/filters/filter-type.c b/lib/filters/filter-type.c
index 1d083707f..bfb8edd34 100644
--- a/lib/filters/filter-type.c
+++ b/lib/filters/filter-type.c
@@ -22,10 +22,13 @@ static int _passes_lvm_type_device_filter(struct cmd_context *cmd, struct dev_fi
struct dev_types *dt = (struct dev_types *) f->private;
const char *name = dev_name(dev);
+ dev->filtered_flags &= ~DEV_FILTERED_DEVTYPE;
+
/* Is this a recognised device type? */
if (!dt->dev_type_array[MAJOR(dev->dev)].max_partitions) {
log_debug_devs("%s: Skipping: Unrecognised LVM device type %"
PRIu64, name, (uint64_t) MAJOR(dev->dev));
+ dev->filtered_flags |= DEV_FILTERED_DEVTYPE;
return 0;
}
diff --git a/lib/filters/filter-usable.c b/lib/filters/filter-usable.c
index b3ff65075..8a5b0d828 100644
--- a/lib/filters/filter-usable.c
+++ b/lib/filters/filter-usable.c
@@ -113,6 +113,9 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
struct dev_usable_check_params ucp = {0};
int r = 1;
+ dev->filtered_flags &= ~DEV_FILTERED_MINSIZE;
+ dev->filtered_flags &= ~DEV_FILTERED_UNUSABLE;
+
/* further checks are done on dm devices only */
if (dm_is_dm_major(MAJOR(dev->dev))) {
switch (mode) {
@@ -142,8 +145,10 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
break;
}
- if (!(r = device_is_usable(dev, ucp)))
+ if (!(r = device_is_usable(dev, ucp))) {
+ dev->filtered_flags |= DEV_FILTERED_UNUSABLE;
log_debug_devs("%s: Skipping unusable device.", dev_name(dev));
+ }
}
if (r) {
@@ -153,6 +158,8 @@ static int _passes_usable_filter(struct cmd_context *cmd, struct dev_filter *f,
/* fall through */
case FILTER_MODE_PRE_LVMETAD:
r = _check_pv_min_size(dev);
+ if (!r)
+ dev->filtered_flags |= DEV_FILTERED_MINSIZE;
break;
case FILTER_MODE_POST_LVMETAD:
/* nothing to do here */
diff --git a/lib/filters/filter.h b/lib/filters/filter.h
index 7333cfe3c..bfd045be5 100644
--- a/lib/filters/filter.h
+++ b/lib/filters/filter.h
@@ -52,4 +52,16 @@ typedef enum {
} filter_mode_t;
struct dev_filter *usable_filter_create(struct cmd_context *cmd, struct dev_types *dt, filter_mode_t mode);
+#define DEV_FILTERED_FWRAID 0x00000001
+#define DEV_FILTERED_INTERNAL 0x00000002
+#define DEV_FILTERED_MD_COMPONENT 0x00000004
+#define DEV_FILTERED_MPATH_COMPONENT 0x00000008
+#define DEV_FILTERED_PARTITIONED 0x00000010
+#define DEV_FILTERED_REGEX 0x00000020
+#define DEV_FILTERED_SIGNATURE 0x00000040
+#define DEV_FILTERED_SYSFS 0x00000080
+#define DEV_FILTERED_DEVTYPE 0x00000100
+#define DEV_FILTERED_MINSIZE 0x00000200
+#define DEV_FILTERED_UNUSABLE 0x00000400
+
#endif /* _LVM_FILTER_H */
diff --git a/tools/pvck.c b/tools/pvck.c
index 39449af68..7ae4976e5 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -3040,7 +3040,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
if (!(dev = dev_cache_get(cmd, pv_name, cmd->filter))) {
- log_error("No device found for %s %s.", pv_name, dev_cache_filtered_reason(pv_name));
+ log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
return ECMD_FAILED;
}
}
@@ -3054,7 +3054,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
def = get_devicefile(pv_name);
if (!dev && !def) {
- log_error("No device found for %s %s.", pv_name, dev_cache_filtered_reason(pv_name));
+ log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
return ECMD_FAILED;
}
}
@@ -3143,7 +3143,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
pv_name = argv[i];
if (!(dev = dev_cache_get(cmd, argv[i], cmd->filter))) {
- log_error("Device %s %s.", pv_name, dev_cache_filtered_reason(pv_name));
+ log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
continue;
}
2 years, 5 months