Zdenek Kabelac [Mon, 6 Mar 2023 13:52:59 +0000 (14:52 +0100)]
vdo: use fixed size vdopool wrapper
Instead of using size of 'empty header' in vdopool use fixed size 4K
for a 'wrappeing' vdo-pool device.
This fixes the issue when user tried to activate vdo-pool after
a conversion from vdo managed device with 'vgchange -ay' - where
this command activated all LVs with 'vdo-pool' wrapping device as well,
but this converted pool uses 0-length header.
This 4k size should usually prevent other tools like 'blkid' recognize
such device as anything - so it shouldn't cause any problems with
duplicate indentification of devices.
Tony Asleson [Thu, 30 Mar 2023 15:10:23 +0000 (10:10 -0500)]
lvmdbusd: Correct seg. fault on s390x ELN
syscall 186 is specific to x86 64bit. As this is different from arch
to arch and between same arch different arch size we will only grab
thread ID using built-in python support if it is supported.
Tony Asleson [Thu, 9 Mar 2023 17:29:58 +0000 (11:29 -0600)]
lvmdbusd: Add a retries during initial load
When the daemon is starting we do an initial fetch of lvm state. If we
happened to get some type of failure with lvm during this time we would
exit. During error injection testing this happened enough that
the unit tests were unable to finish. Add retries to ensure we can get
started during error injection testing.
Tony Asleson [Thu, 9 Mar 2023 17:25:58 +0000 (11:25 -0600)]
lvmdbustest: Only inject 1 missing key error
Previously we were injecting a missing key in the lv, vg, and pv.
Given the order of processing in lvmdbusd, this prevented us from
exercising all the error paths. Change to returning just 1 instead.
Tony Asleson [Thu, 9 Mar 2023 17:21:27 +0000 (11:21 -0600)]
lvmdbusd: Handle missing key in get_key
When we sort the LVs, we can stumble on a missing key, protect against
this as well.
Seen in error injection testing:
Traceback (most recent call last):
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 198, in update_thread
num_changes = load(*_load_args(queued_requests))
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 83, in load
rc = MThreadRunner(_main_thread_load, refresh, emit_signal).done()
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/utils.py", line 726, in done
raise self.exception
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/utils.py", line 732, in _run
self.rc = self.f(*self.args)
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 40, in _main_thread_load
(lv_changes, remove) = load_lvs(
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 148, in load_lvs
return common(
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/loader.py", line 37, in common
objects = retrieve(search_keys, cache_refresh=False)
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 72, in lvs_state_retrieve
lvs = sorted(cfg.db.fetch_lvs(selection), key=get_key)
File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 35, in get_key
pool = i['pool_lv']
KeyError: 'pool_lv'
David Teigland [Wed, 8 Feb 2023 19:34:35 +0000 (13:34 -0600)]
vg_read: keep MISSING_PV when device with no mda reappears
Remove old code that became incorrect at some point.
It's probably a fragment of an old condition that was left
behind because it wasn't understood. We don't want to drop
the MISSING_PV flag just because the PV has no mda in use.
The device that was missing may have stale data, so the user
needs to decide if the device should be removed or restored.
David Teigland [Tue, 7 Feb 2023 21:25:46 +0000 (15:25 -0600)]
tests: vg-raid-takeover
Different sequences of steps that could be used to handle raid LVs
after VG takeover (what would happen in cluster failover) combined
with the loss of a disk.
Peter Rajnoha [Tue, 7 Mar 2023 13:45:06 +0000 (14:45 +0100)]
toollib: fix segfault if using -S|--select with log/report_command_log=1 setting
When we are using -S|--select for non-reporting tools while using command log
reporting (log/report_command_log=1 setting), we need to create an internal
processing handle to handle the selection itself. In this case, the internal
processing handle to execute the selection (to process the -S|--select) has
a parent handle (that is processing the actual non-reporting command).
When this parent handle exists, we can't destroy the command log report
in destroy_processing_handle as there's still the parent processing to
finish. The parent processing may still generate logs which need to be
reported in the command log report. If the command log report was
destroyed prematurely together with destroying the internal processing
handle for -S|--select, then any subsequent log request from processing
the actual command (and hence an attermpt to access the command log report)
ended up with a segfault.
See also: https://bugzilla.redhat.com/show_bug.cgi?id=2175220
Tony Asleson [Mon, 27 Feb 2023 14:57:24 +0000 (08:57 -0600)]
lvmdbusd: Add lock to prevent concurrent lvm shell access
There is a window of time where the following can occur.
1. An API request is in process to the lvm shell, we have written some
command to the lvm shell and we are blocked on that thread waiting
2. A signal arrives to the daemon which causes us to exit. The signal
handling code path goes directly to the lvm shell and writes
"exit\n". This causes the lvm shell to simply exit.
3. The thread that was waiting for a response gets an EIO as the child
process has exited. This bubbles up a failure.
This is addressed by placing a lock in the lvm shell to prevent
concurrent access to the shell. We also gather additional debug data
when we get an error in the lvm shell read path. This should help if
the lvm shell exits/crashes on its own.
David Teigland [Thu, 23 Feb 2023 22:32:37 +0000 (16:32 -0600)]
lvresize: fix check for mounted and renamed LV to handle spaces
Replace spaces with \040 in directory paths from getmntent (mtab).
The recent commit 5374a44c5712 compares mount point directory paths
from /etc/mtab and /proc/mounts, in order to detect when a mounted
LV has been renamed. The directory path comparison does not work
correctly when the path contains spaces because getmntent uses
ascii space chars and proc replaces spaces with \040.
configure.ac: use pkg-config to detect static libs
Add some Gentoo based patches for better support of static linking.
This are not tested nor supported by upstream developers.
Usage requires presence of several libraries in their static form
which is however not commonly available.
Selinux modified by zkabelac to still work on older sofrware which
did not provided libselinux.pc at a time - see keep the old check
present and use pkg-config only when possible.
Zdenek Kabelac [Mon, 20 Feb 2023 22:57:56 +0000 (23:57 +0100)]
configure.ac: fail configure for missing libraries
When user enables lockd libraris, code needs to fail, when then are
missing. Also when notify-dbus support if enabled, and libsystemd is
missing, abort configuration.
Zdenek Kabelac [Mon, 20 Feb 2023 20:01:31 +0000 (21:01 +0100)]
configure.ac: update dlm check
Check for pkg-config --libs libdlm_lt and test if the returned value
contains word 'pthread' - if so, it's likely a buggy result from
incorrect config file and use directly -ldlm_lt for this case.
David Teigland [Wed, 22 Feb 2023 22:19:48 +0000 (16:19 -0600)]
vgimport: invalidate hints
There may be some unconventional methods of sharing disks with vgimport
where hints could cause confusion. Hints should be disabled when
sharing disks, or pvscan --cache used to regenerate hints as needed,
but invalidating hints from vgimport might help reduce confusion.
Zdenek Kabelac [Tue, 14 Feb 2023 19:59:56 +0000 (20:59 +0100)]
cov: avoid using strcpy
Coverity is complaining about unchecked strcpy here, which is
irelevant as we preallocate buffer to fit in copied string,
however we could actually reuse these size and use just memcpy().
So lets make some simple conversions.
David Teigland [Wed, 15 Feb 2023 16:21:13 +0000 (10:21 -0600)]
pvscan: remove warning about excluded root dev
This was trying to warn about a misconfig where the root PV
was excluded by the devices file, but it wasn't covering all
cases. Also, it's not very useful because the root LV is
usually activated directly in the initrd.
David Teigland [Wed, 15 Feb 2023 16:08:25 +0000 (10:08 -0600)]
pvscan: filter does not need to be checked for symlink names
With the recent use of DEVLINKS, there is no longer any real
point in checking the filter for symlink names. Removing
this check should not change behavior with or without symlinks
in the filter.
Zdenek Kabelac [Fri, 10 Feb 2023 21:53:43 +0000 (22:53 +0100)]
configure.ac: fix support for LOCKDIDM
Commit 7a8b7b4adde5c31c79aee8b0792cd8369652afc6 introducing lockidm
support missed to use AC_SUBST() for a variable and provide it only
in prebuilt configure, so with the next autoreconf this variable
was lost and IDM support was no longer compiled.
Fixes: https://github.com/lvmteam/lvm2/issues/98 Reported-by: Tom Prohofsky
Zdenek Kabelac [Sat, 11 Feb 2023 19:32:45 +0000 (20:32 +0100)]
man: update lvmcache cache setting
Correct setting of migration_threshold and add clarify
how the user can restore default cache settings for cache policies.
Also document mq aliasing with smq for newer kernels.
Zdenek Kabelac [Sun, 12 Feb 2023 22:44:43 +0000 (23:44 +0100)]
libdm: improve parallel create of control node
When two parallel commands would have tried to create our
/dev/mapper/control node at the same time, one of them could
actually fail even if the 2nd. command actually mknod()
this control node correctly.
So for EEXIST case add detection if the control node is ok.
This may possibly help with some race case in early boot.