main - lvmdbusd: Add command_log_selection to command line
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e63b0c7262f50ab43fc...
Commit: e63b0c7262f50ab43fcde1c50b6d880acab68407
Parent: 8f60c494515ddccb20e4afb804edb6b9599e65c0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Nov 29 10:04:17 2022 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 29 12:56:55 2022 -0600
lvmdbusd: Add command_log_selection to command line
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2145114
---
daemons/lvmdbusd/cmdhandler.py | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 0c7bd8528..9a76db4c9 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -17,7 +17,7 @@ import os
from lvmdbusd import cfg
from lvmdbusd.utils import pv_dest_ranges, log_debug, log_error, add_no_notify,\
- make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option
+ make_non_block, read_decoded, extract_stack_trace, LvmBug, add_config_option, get_error_msg
from lvmdbusd.lvm_shell_proxy import LVMShellProxy
try:
@@ -121,6 +121,9 @@ def call_lvm(command, debug=False, line_cb=None,
command.insert(0, cfg.LVM_CMD)
command = add_no_notify(command)
+ # Ensure we get an error message when we fork & exec the lvm command line
+ command = add_config_option(command, "--config", 'log/command_log_selection="log_context!=''"')
+
process = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True,
env=os.environ)
@@ -167,7 +170,17 @@ def call_lvm(command, debug=False, line_cb=None,
if debug or (process.returncode != 0 and (process.returncode != 5 and "fullreport" in command)):
_debug_c(command, process.returncode, (stdout_text, stderr_text))
- return process.returncode, stdout_text, stderr_text
+ try:
+ report_json = json.loads(stdout_text)
+ except json.decoder.JSONDecodeError:
+ # Some lvm commands don't return json even though we are asking for it to do so.
+ return process.returncode, stdout_text, stderr_text
+
+ error_msg = get_error_msg(report_json)
+ if error_msg:
+ stderr_text += error_msg
+
+ return process.returncode, report_json, stderr_text
else:
if cfg.run.value == 0:
raise SystemExit
@@ -619,20 +632,8 @@ def lvm_full_report_json():
rc, out, err = call(cmd)
# When we have an exported vg the exit code of lvs or fullreport will be 5
if rc == 0 or rc == 5:
- # If the 'call' implementation is lvmshell, the out is a dictionary as lvmshell has to
- # parse the output to get the exit value. When doing fork & exec, out is a string
- # representing the JSON. TODO: Make this consistent between implementations.
- if cfg.SHELL_IN_USE:
- assert(type(out) == dict)
- return out
- else:
- try:
- return json.loads(out)
- except json.decoder.JSONDecodeError as joe:
- log_error("JSONDecodeError %s, \n JSON=\n%s\n" %
- (str(joe), out))
- raise LvmBug("'fullreport' returned invalid JSON")
-
+ assert(type(out) == dict)
+ return out
raise LvmBug("'fullreport' exited with code '%d'" % rc)
1 year, 3 months
main - lvmdbusd: Move get_error_msg to utils
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f60c494515ddccb20e...
Commit: 8f60c494515ddccb20e4afb804edb6b9599e65c0
Parent: 61917fbac2302e1f0c56aa75437e6ea72834b30d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Nov 29 10:00:39 2022 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 29 12:56:55 2022 -0600
lvmdbusd: Move get_error_msg to utils
Moving this so we can re-use outside of lvm_shell_proxy.
---
daemons/lvmdbusd/lvm_shell_proxy.py.in | 23 +++--------------------
daemons/lvmdbusd/utils.py | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index ac6d51e65..37d73218b 100755
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -28,7 +28,7 @@ except ImportError:
import lvmdbusd.cfg as cfg
from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\
- read_decoded, extract_stack_trace, LvmBug
+ read_decoded, extract_stack_trace, LvmBug, get_error_msg
SHELL_PROMPT = "lvm> "
@@ -191,24 +191,7 @@ class LVMShellProxy(object):
def get_last_log(self):
self._write_cmd('lastlog\n')
report_json = self._read_response()[1]
- return LVMShellProxy.get_error_msg(report_json)
-
- @staticmethod
- def get_error_msg(report_json):
- # Get the error message from the returned JSON
- if 'log' in report_json:
- error_msg = ""
- # Walk the entire log array and build an error string
- for log_entry in report_json['log']:
- if log_entry['log_type'] == "error":
- if error_msg:
- error_msg += ', ' + log_entry['log_message']
- else:
- error_msg = log_entry['log_message']
-
- return error_msg
-
- return None
+ return get_error_msg(report_json)
def call_lvm(self, argv, debug=False):
rc = 1
@@ -245,7 +228,7 @@ class LVMShellProxy(object):
# report json too.
error_msg = self.get_last_log()
if error_msg is None:
- error_msg = LVMShellProxy.get_error_msg(report_json)
+ error_msg = get_error_msg(report_json)
if error_msg is None:
error_msg = 'No error reason provided! (missing "log" section)'
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 5aecb1fff..0b81591b2 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -859,3 +859,20 @@ class LvmDebugData:
self._close_fd()
# In case lvm_complete doesn't get called.
self._remove_file()
+
+
+def get_error_msg(report_json):
+ # Get the error message from the returned JSON
+ if 'log' in report_json:
+ error_msg = ""
+ # Walk the entire log array and build an error string
+ for log_entry in report_json['log']:
+ if log_entry['log_type'] == "error":
+ if error_msg:
+ error_msg += ', ' + log_entry['log_message']
+ else:
+ error_msg = log_entry['log_message']
+
+ return error_msg
+
+ return None
1 year, 3 months
main - lvmdbustest: Add test to ensure error collection
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=61917fbac2302e1f0c5...
Commit: 61917fbac2302e1f0c56aa75437e6ea72834b30d
Parent: a02268e93800c0390650cbf12061b705acfc2196
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Nov 29 09:57:20 2022 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Nov 29 12:56:55 2022 -0600
lvmdbustest: Add test to ensure error collection
Recreates https://bugzilla.redhat.com/show_bug.cgi?id=2145114
---
test/dbus/lvmdbustest.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 9582fe674..c07963525 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2468,6 +2468,27 @@ class TestDbusService(unittest.TestCase):
if rc == "/":
self._pv_create(pv_device_path)
+ def test_stderr_collection(self):
+ lv_name = lv_n()
+ vg = self._vg_create().Vg
+ (object_path, job_path) = vg.LvCreate(
+ dbus.String(lv_name), dbus.UInt64(vg.SizeBytes * 2),
+ dbus.Array([], signature='(ott)'), dbus.Int32(0),
+ EOD)
+
+ self.assertTrue(object_path == '/')
+ self.assertTrue(job_path != '/')
+
+ j = ClientProxy(self.bus, job_path, interfaces=(JOB_INT,)).Job
+ while True:
+ j.update()
+ if j.Complete:
+ (ec, error_msg) = j.GetError
+ self.assertTrue("insufficient free space" in error_msg, error_msg)
+ break
+ else:
+ time.sleep(0.1)
+
class AggregateResults(object):
1 year, 3 months
main - man: dmsetup concise format consitency
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a02268e93800c039065...
Commit: a02268e93800c0390650cbf12061b705acfc2196
Parent: a5042375de3fd7146906614bffbcc960349c2b20
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 25 14:19:57 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 25 16:41:53 2022 +0100
man: dmsetup concise format consitency
Use <name> consistenly.
---
man/dmsetup.8_main | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/man/dmsetup.8_main b/man/dmsetup.8_main
index 7576b54bc..6260396e6 100644
--- a/man/dmsetup.8_main
+++ b/man/dmsetup.8_main
@@ -1020,7 +1020,7 @@ A concise representation of one of more devices.
The representation of a device takes the form:
.ad l
.nh
-<name>,<uuid>,\:<minor>,<flags>,\:<table>\:[,<table>+]\:[;<dev_name>,<uuid>,\:<minor>,<flags>,<table>\:[,<table>+]]
+<name>,<uuid>,\:<minor>,<flags>,\:<table>\:[,<table>+]\:[;<name>,<uuid>,\:<minor>,<flags>,<table>\:[,<table>+]]
.hy
.ad b
.TP
1 year, 3 months
main - dmsetup: fix udev event handling for create
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a5042375de3fd714690...
Commit: a5042375de3fd7146906614bffbcc960349c2b20
Parent: ae916f77c92c1765c76fbb849a2eaeb5e0724768
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 25 15:45:47 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 25 16:41:53 2022 +0100
dmsetup: fix udev event handling for create
With newer kernels (>5.13) DM_CREATE no longer generates
uevent for DM devices without table.
There are even no sysfs block device entries in such case,
although device has asigned major:minor and it is being listed
by 'dmsetup info'.
So this patch calculates amount of 'table' lines and in case
no table line comes from cmdline or stdin - waiting on cookie
is avoided generically instead of disabling just case with
option --notable - which then also skipped handling of an
option --addnodeoncreate (which is however historical and
should be avoided)
As a result there should be no leaking udev cookies and endlessly
waiting commands like this:
dmsetup create mytestdev </dev/null
---
WHATS_NEW_DM | 1 +
libdm/dm-tools/dmsetup.c | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 1067312d3..71eee439f 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.189 -
=====================================
+ Improve 'dmsetup create' without given table line with new kernels.
Version 1.02.187 - 10th November 2022
=====================================
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 42eeead68..ea03d66c8 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -274,6 +274,7 @@ static char _disp_units = 's';
const char *_program_id = DM_STATS_PROGRAM_ID; /* program_id used for reports. */
static uint64_t _statstype = 0; /* stats objects to report */
static int _concise_output_produced = 0; /* Was any concise output already printed? */
+static int _added_target = 0; /* Count added target (no target -> no event) */
struct command;
static const struct command *_selection_cmd = NULL; /* Command to run against each device select with -S */
@@ -357,6 +358,8 @@ static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
if (!dm_task_add_target(dmt, start, size, ttype, ptr))
return_0;
+ _added_target++;
+
return 1;
}
@@ -1175,9 +1178,6 @@ static int _create_one_device(const char *name, const char *file)
_read_ahead_flags))
goto_out;
- if (_switches[NOTABLE_ARG])
- dm_udev_set_sync_support(0);
-
if (_switches[NOUDEVRULES_ARG])
udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
@@ -1194,8 +1194,12 @@ static int _create_one_device(const char *name, const char *file)
if (_udev_only)
udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
- if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
- !_task_run(dmt))
+ if (_switches[NOTABLE_ARG] || !_added_target)
+ cookie = 0; // ADD event -> no udev event handling
+ else if (!dm_task_set_cookie(dmt, &cookie, udev_flags))
+ goto_out;
+
+ if (!_task_run(dmt))
goto_out;
r = 1;
1 year, 3 months
main - configure: update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ae916f77c92c1765c76...
Commit: ae916f77c92c1765c76fbb849a2eaeb5e0724768
Parent: fdd8feb60e7a7757aaa12d9df357cadeb1c31044
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 23 13:18:07 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 25 15:55:56 2022 +0100
configure: update
---
configure | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 107 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index ccd5a5938..718f281bc 100755
--- a/configure
+++ b/configure
@@ -850,6 +850,7 @@ CHMOD
CSCOPE_CMD
CFLOW_CMD
AR
+READELF
RANLIB
MKDIR_P
SET_MAKE
@@ -5162,11 +5163,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_11+y}
+if test ${ac_cv_prog_cxx_cxx11+y}
then :
printf %s "(cached) " >&6
else $as_nop
- ac_cv_prog_cxx_11=no
+ ac_cv_prog_cxx_cxx11=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -5208,11 +5209,11 @@ if test x$ac_prog_cxx_stdcxx = xno
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_98+y}
+if test ${ac_cv_prog_cxx_cxx98+y}
then :
printf %s "(cached) " >&6
else $as_nop
- ac_cv_prog_cxx_98=no
+ ac_cv_prog_cxx_cxx98=no
ac_save_CXX=$CXX
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -5874,6 +5875,108 @@ else
RANLIB="$ac_cv_prog_RANLIB"
fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}readelf", so it can be a program name with args.
+set dummy ${ac_tool_prefix}readelf; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_READELF+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ if test -n "$READELF"; then
+ ac_cv_prog_READELF="$READELF" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ case $as_dir in #(((
+ '') as_dir=./ ;;
+ */) ;;
+ *) as_dir=$as_dir/ ;;
+ esac
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+ ac_cv_prog_READELF="${ac_tool_prefix}readelf"
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+READELF=$ac_cv_prog_READELF
+if test -n "$READELF"; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5
+printf "%s\n" "$READELF" >&6; }
+else
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_READELF"; then
+ ac_ct_READELF=$READELF
+ # Extract the first word of "readelf", so it can be a program name with args.
+set dummy readelf; ac_word=$2
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_READELF+y}
+then :
+ printf %s "(cached) " >&6
+else $as_nop
+ if test -n "$ac_ct_READELF"; then
+ ac_cv_prog_ac_ct_READELF="$ac_ct_READELF" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ case $as_dir in #(((
+ '') as_dir=./ ;;
+ */) ;;
+ *) as_dir=$as_dir/ ;;
+ esac
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_READELF="readelf"
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_READELF=$ac_cv_prog_ac_ct_READELF
+if test -n "$ac_ct_READELF"; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_READELF" >&5
+printf "%s\n" "$ac_ct_READELF" >&6; }
+else
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+fi
+
+ if test "x$ac_ct_READELF" = x; then
+ READELF=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ READELF=$ac_ct_READELF
+ fi
+else
+ READELF="$ac_cv_prog_READELF"
+fi
+
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
1 year, 3 months
main - lvmpolld: fix `strerror_r` check for musl
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fdd8feb60e7a7757aaa...
Commit: fdd8feb60e7a7757aaa12d9df357cadeb1c31044
Parent: 3dee7b7266f79aba12805dfbfcd770dac3171051
Author: Sam James <sam(a)gentoo.org>
AuthorDate: Sat Nov 19 17:51:09 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 25 15:55:23 2022 +0100
lvmpolld: fix `strerror_r` check for musl
We can't assume that strerror_r returns char* just because _GNU_SOURCE is
defined. We already call the appropriate autoconf test, so let's use its
result (STRERROR_R_CHAR_P).
Note that in configure, _GNU_SOURCE is always set, but we add a defined
guard just in case for futureproofing.
Bug: https://bugs.gentoo.org/869404
---
daemons/lvmpolld/lvmpolld-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index 47c9376b4..a75f71e2f 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -52,7 +52,7 @@ static pthread_key_t key;
static const char *_strerror_r(int errnum, struct lvmpolld_thread_data *data)
{
-#ifdef _GNU_SOURCE
+#if defined(_GNU_SOURCE) && defined(STRERROR_R_CHAR_P)
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;
1 year, 3 months
main - configure: allow for overriding of `readelf`
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3dee7b7266f79aba128...
Commit: 3dee7b7266f79aba12805dfbfcd770dac3171051
Parent: 2da4ca7ce163fe89b3c79b1d6c55aa30eaa6307d
Author: David Seifert <soap(a)gentoo.org>
AuthorDate: Sat Nov 19 17:51:08 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 25 15:54:57 2022 +0100
configure: allow for overriding of `readelf`
This allows users to use e.g. `llvm-readelf`
on systems with binutils as default.
Bug: https://bugs.gentoo.org/840628
---
configure.ac | 1 +
libdm/Makefile.in | 4 ++--
libdm/make.tmpl.in | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 704772b62..f39c87d08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,6 +83,7 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
AC_PROG_RANLIB
+AC_CHECK_TOOL([READELF], [readelf])
AC_CHECK_TOOL(AR, ar)
AC_PATH_TOOL(CFLOW_CMD, cflow)
AC_PATH_TOOL(CSCOPE_CMD, cscope)
diff --git a/libdm/Makefile.in b/libdm/Makefile.in
index 35115d7f0..2758648e6 100644
--- a/libdm/Makefile.in
+++ b/libdm/Makefile.in
@@ -71,8 +71,8 @@ libdevmapper.$(LIB_SUFFIX) libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION): $(LIB_SHAR
# also the older symbol is built-in
.symver_check: $(LIB_SHARED)
@echo " [CHECK] $<"
- $(Q) if readelf -Ws $< | grep -q dm_stats_create_region@@; then \
- SYM=$$(readelf -Ws $< | grep dm_stats_create_region@DM_1_02_106); \
+ $(Q) if $(READELF) -Ws $< | grep -q dm_stats_create_region@@; then \
+ SYM=$$($(READELF) -Ws $< | grep dm_stats_create_region@DM_1_02_106); \
if test -n "$$SYM"; then touch $@; \
else echo >&2 "Missing versioned symbols in $<"; false; fi; \
else touch $@; fi
diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in
index f1c88fac0..095fb028a 100644
--- a/libdm/make.tmpl.in
+++ b/libdm/make.tmpl.in
@@ -34,6 +34,7 @@ ifeq ($(CC), cc)
endif
RANLIB = @RANLIB@
+READELF = @READELF@
INSTALL = @INSTALL@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
1 year, 3 months
main - tests: devicesfile-vpd-ids add nvme wwid
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2da4ca7ce163fe89b3c...
Commit: 2da4ca7ce163fe89b3c79b1d6c55aa30eaa6307d
Parent: e0ea0706dc884916c36b7fca285b621eafefc2bf
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Nov 21 10:57:30 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 21 10:57:30 2022 -0600
tests: devicesfile-vpd-ids add nvme wwid
---
test/shell/devicesfile-vpd-ids.sh | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/test/shell/devicesfile-vpd-ids.sh b/test/shell/devicesfile-vpd-ids.sh
index 0eca56935..2801310ef 100644
--- a/test/shell/devicesfile-vpd-ids.sh
+++ b/test/shell/devicesfile-vpd-ids.sh
@@ -62,8 +62,8 @@ setup_sysfs() {
cleanup_sysfs() {
rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
rm -f $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/vpd_pg83
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device
- rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1
+ rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device || true
+ rmdir $SYS_DIR/dev/block/$MAJOR1:$MINOR1 || true
}
@@ -193,9 +193,34 @@ rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/device/wwid
pvs "$DEV1"
cleanup_sysfs
+# Test nvme wwid that starts with "nvme" instead of naa/eui/t10
+rm $DF
+aux wipefs_a "$DEV1"
+mkdir -p $SYS_DIR/dev/block/$MAJOR1:$MINOR1/
+echo "nvme.111111111111111111122222222222333333333333333-44444444444444444445555555555556666666666666666662-00000001" > $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+lvmdevices --adddev "$DEV1"
+cat $DF
+vgcreate $vg "$DEV1"
+lvcreate -l1 -an $vg
+cat $DF
+pvs -o+deviceidtype,deviceid "$DEV1" |tee out
+grep sys_wwid out
+grep nvme.111 out
+grep sys_wwid $DF
+grep nvme.111 $DF
+lvmdevices --deldev "$DEV1"
+not lvmdevices --adddev "$DEV1" --deviceidtype wwid_eui
+lvmdevices --adddev "$DEV1" --deviceidtype sys_wwid
+lvmdevices | grep nvme.111
+lvremove -y $vg
+sleep 1
+lvs $vg
+vgremove $vg
+rm $SYS_DIR/dev/block/$MAJOR1:$MINOR1/wwid
+cleanup_sysfs
# TODO: lvmdevices --adddev <dev> --deviceidtype <type> --deviceid <val>
# This would let the user specify the second naa wwid.
remove_base
-rmmod scsi_debug
+rmmod scsi_debug || true
1 year, 3 months
main - report: query lvmlockd for lv_active_exclusively
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e0ea0706dc884916c36...
Commit: e0ea0706dc884916c36b7fca285b621eafefc2bf
Parent: 779fc3c0453d4a1abdfc62db740517467dbaf0e3
Author: corubba <corubba(a)gmx.de>
AuthorDate: Tue Nov 1 22:23:47 2022 +0100
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Nov 11 13:30:25 2022 -0600
report: query lvmlockd for lv_active_exclusively
Query LV lock state in lvmlockd to report lv_active_exclusively
for active LVs in a shared VGs. As with all lvmlockd state,
it is from the perspective of the local node.
Signed-off-by: corubba <corubba(a)gmx.de>
---
lib/locking/lvmlockd.c | 14 ++++++++++----
lib/locking/lvmlockd.h | 9 +++++++++
lib/report/report.c | 10 +++++++++-
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 7f8150365..051aa817c 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2298,9 +2298,8 @@ int lockd_vg_update(struct volume_group *vg)
return ret;
}
-static int _query_lock_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, char *lv_uuid,
- const char *lock_args, int *ex, int *sh)
+int lockd_query_lv(struct volume_group *vg, const char *lv_name, char *lv_uuid,
+ const char *lock_args, int *ex, int *sh)
{
daemon_reply reply;
const char *opts = NULL;
@@ -2308,6 +2307,13 @@ static int _query_lock_lv(struct cmd_context *cmd, struct volume_group *vg,
int result;
int ret;
+ if (!vg_is_shared(vg))
+ return 1;
+ if (!_use_lvmlockd)
+ return 0;
+ if (!_lvmlockd_connected)
+ return 0;
+
log_debug("lockd query LV %s/%s", vg->name, lv_name);
reply = _lockd_send("query_lock_lv",
@@ -2386,7 +2392,7 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
!strcmp(cmd->name, "lvchange") || !strcmp(cmd->name, "lvconvert")) {
int ex = 0, sh = 0;
- if (!_query_lock_lv(cmd, vg, lv_name, lv_uuid, lock_args, &ex, &sh))
+ if (!lockd_query_lv(vg, lv_name, lv_uuid, lock_args, &ex, &sh))
return 1;
if (sh) {
log_warn("WARNING: shared LV may require refresh on other hosts where it is active.");
diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h
index 43934202f..fcaa0a326 100644
--- a/lib/locking/lvmlockd.h
+++ b/lib/locking/lvmlockd.h
@@ -103,6 +103,9 @@ int lockd_lv_uses_lock(struct logical_volume *lv);
int lockd_lv_refresh(struct cmd_context *cmd, struct lvresize_params *lp);
+int lockd_query_lv(struct volume_group *vg, const char *lv_name, char *lv_uuid,
+ const char *lock_args, int *ex, int *sh);
+
#else /* LVMLOCKD_SUPPORT */
static inline void lvmlockd_set_socket(const char *sock)
@@ -258,6 +261,12 @@ static inline int lockd_lv_refresh(struct cmd_context *cmd, struct lvresize_para
return 0;
}
+static inline int lockd_query_lv(struct volume_group *vg, const char *lv_name,
+ char *lv_uuid, const char *lock_args, int *ex, int *sh)
+{
+ return 0;
+}
+
#endif /* LVMLOCKD_SUPPORT */
#endif /* _LVMLOCKD_H */
diff --git a/lib/report/report.c b/lib/report/report.c
index cb5fc93c8..26d35ba95 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -24,6 +24,7 @@
#include "lib/cache/lvmcache.h"
#include "lib/device/device-types.h"
#include "lib/datastruct/str_list.h"
+#include "lib/locking/lvmlockd.h"
#include <stddef.h> /* offsetof() */
#include <float.h> /* DBL_MAX */
@@ -3854,13 +3855,20 @@ static int _lvactiveexclusively_disp(struct dm_report *rh, struct dm_pool *mem,
const void *data, void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- int active_exclusively;
+ int active_exclusively, _sh = 0;
if (!activation())
return _binary_undef_disp(rh, mem, field, private);
active_exclusively = lv_is_active(lv);
+ if (active_exclusively && vg_is_shared(lv->vg)) {
+ active_exclusively = 0;
+ if (!lockd_query_lv(lv->vg, lv->name, lv_uuid_dup(NULL, lv),
+ lv->lock_args, &active_exclusively, &_sh))
+ return _binary_undef_disp(rh, mem, field, private);
+ }
+
return _binary_disp(rh, mem, field, active_exclusively, GET_FIRST_RESERVED_NAME(lv_active_exclusively_y), private);
}
1 year, 4 months