1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

18309 Commits

Author SHA1 Message Date
Tony Asleson
0f56c1ad12 lvmnotify.c: Check to see if dbus daemon is running
The lvm dbus daemon will auto activate on dbus API calls.  To
prevent the dbus daemon starting when lvm command line tools are
being used we will check to see if the daemon is running first.
If the daemon is not running, we will not notify the daemon.

For this check to work it requires the changes done previously
with commit: 3fdf449348

Reviewed-by: David Teigland <teigland@redhat.com>
2022-10-19 14:22:12 -05:00
David Teigland
04097d9f62 lvreduce: change error message about --fs options 2022-10-12 10:05:14 -05:00
corubba
4f4554164b lvmlockd: Fix sanlock lvmlock lv size calculation
The number of extents for the sanlock lvmlock lv is calculated using
integer division, which rounds towards zero. With a physical extent size
of 129M, instead of the requested 256M the lv is only 129M (1 extent).
With any physical extent size greater than 256M the lv creation fails
because the number of extents is zero.

This is fixed by replacing the integer division with a division macro
that rounds up and thus guarantees that the size of the lv will always
be equal or greater than the requested size. Using the examples above, a
pes of 129M will result in a 258M lv (2 extents), pes of 300M in a 300M
lv (1 extent).

The re-calculation of the lv size in bytes and megabytes is only so the
debug output shows the correct values. The size in mb there is still
not byte-perfect-accurate, but good enough for a human-readable estimate;
and the exact size in bytes and extents is right next to it.

Signed-off-by: corubba <corubba@gmx.de>
2022-10-12 09:19:01 -05:00
Peter Rajnoha
908555459f toollib: do not process just created historical LV
When executing process_each_lv_in_vg, we process live LVs first and
after that, we process any historical LVs. In case we have just removed
an LV, which also means we have just made it "historical" and so it
appears as fresh item in vg->historical_lvs list, we have to skip it
when we get to processing historical LVs inside the same process_each_lv_in_vg
call.

The simplest approach here, without introducing another LV list, is to
simply mark such historical LVs as "fresh" directly in struct
historical_logical_volume when we have just removed the original LV
and created the historical LV for it. Then, we just need to check the
flag when processing historical LVs and skip it if it is "fresh".

When we read historical LVs out of metadata, they are marked as
"not fresh" and so they can be processed as usual.

This was mainly an issue in conjuction with -S|--select use:

	#  lvmconfig --type diff
	metadata {
		record_lvs_history=1
	}

(In this example, a thin pool with lvol1 thin LV and lvol2 and lvol3 snapshots.)

	#  lvs -H vg -o name,pool_lv,full_ancestors,full_descendants
	  LV    Pool FAncestors  FDescendants
	  lvol1 pool             lvol2,lvol3
	  lvol2 pool lvol1       lvol3
	  lvol3 pool lvol2,lvol1
	  pool

	#  lvremove -S 'name=lvol2'
	  Logical volume "lvol2" successfully removed.
	  Historical logical volume "lvol2" successfully removed.

...here, the historical LV lvol2 should not have been removed because
we have just removed its original non-historical lvol2 and the fresh
historical lvol2 must not be included in the same processing spree.
2022-10-12 15:14:59 +02:00
David Teigland
f6f2737015 lvreduce: require active LV when no fs option is used
Without an --fs option set, make lvreduce of an inactive LV
fail and report that the LV must be active.
2022-10-11 12:48:31 -05:00
David Teigland
fc52e87f06 tests: add comments to fsadm-renamed
to explain the what and why of the steps that are
not obvious
2022-10-11 12:48:31 -05:00
David Teigland
657df00c96 lvmlockd: fix warning 2022-10-11 12:35:38 -05:00
David Teigland
fc01dd8900 tests: skip lvresize tests without mkfs.xfs 2022-10-10 13:25:50 -05:00
David Teigland
13c63f0cfa lvmdevices: use deviceidtype option strictly
Only use the device id type specified by --deviceidtype,
and fail if that type is not available for the device.
2022-10-10 11:47:29 -05:00
David Teigland
c4e6d675de tests: device ids using vpd data 2022-10-10 11:47:29 -05:00
David Teigland
79e67fc5e4 device id: add new types using values from vpd_pg83
The new device_id types are: wwid_naa, wwid_eui, wwid_t10.
The new types use the specific wwid type in their name.
lvm currently gets the values for these types by reading
the device's vpd_pg83 sysfs file (this could change in the
future if better methods become available for reading the
values.)

If a device is added to the devices file using one of these
types, prior versions of lvm will not recognize the types
and will be unable to use the devices.

When adding a new device, lvm continues to first use sys_wwid
from the sysfs wwid file.  If the device has no sysfs wwid file,
lvm now attempts to use one of the new types from vpd_pg83.

If a devices file entry with type sys_wwid does not match a
given device's sysfs wwid file, the sys_wwid value will also
be compared to that device's other wwids from its vpd_pg83 file.
If the kernel changes the wwid type reported from the sysfs
wwid file, e.g. from a device's t10 id to its naa id, then lvm
should still be able to match it correctly using the vpd_pg83
data which will include both ids.
2022-10-10 11:47:29 -05:00
David Teigland
8de87e0207 device id: change space handling in t10 wwid
t10 wwids are now edited in the same way that multipath does,
which is replacing a series of spaces with one _.  Previously
lvm replaced every space with one _.  Devices file entries
with the old form will be converted to the new shorter form.
2022-10-10 11:47:29 -05:00
David Teigland
380ab3f45c device id wwid adjustments
Move the functions handling dev wwids.

Add dev flags indicating that wwids have been read from
sysfs wwid file or sysfs vpd_pg83 file.  This can be
used to avoid rereading these.

Improve filter-mpath search for a device's wwid in
/etc/multipath/wwids, to avoid unnecessary rereading
of wwids from sysfs files.

Type 8 wwids from vpd_pg83 with naa or eui names should be
saved as those types.
2022-10-10 11:47:29 -05:00
Lidong Zhong
39e6c4f749 lvmlockd: purge the lock resources left in previous lockspace
If lvmlockd in cluster is killed accidently or any other reason, the
lock resources will become orphaned in the VG lockspace. When the
cluster manager tries to restart this daemon, the LVs will probably
become inactive because of resource schedule policy and thus the lock
resouce will be omited during the adoption process. This patch will
try to purge the lock resources left in previous lockspace, so the
following actions can work again.
2022-10-07 09:45:57 -05:00
David Teigland
a23588d77c lvresize: move the lockd_lv earlier
the lock should cover any potential activation,
not just the resizing changes
2022-10-03 12:42:02 -05:00
Tony Asleson
599cbd7dd3 lvmdbusd: Correct env. variable
Make this match the unit test expectation and the form we use for
other env. variables.
2022-09-30 11:51:23 -05:00
David Teigland
b09de683c7 blkid: fix BLKID_SUBLKS_FSINFO usage
Use this flag for all fs info lookups, including BLOCK_SIZE,
if it is defined in blkid.h.
2022-09-29 15:25:32 -05:00
David Teigland
5a0052a1d3 lvresize: give special advice to reiserfs users 2022-09-28 11:54:13 -05:00
David Teigland
1924fed308 lvresize: exclude new fs handling at build time
Exclude the new fs resizing capabilities at build time
(rather than run time) if the necessary libblkid features
are not available.  When excluded, all fs resizing options
are translated to resize_fsadm.  Accessing the new
features now requires rebuilding lvm if libblkid is
upgraded.
2022-09-28 11:16:43 -05:00
David Teigland
b39ad99325 lvresize: let env var set lvresize_fs_helper_path 2022-09-27 15:42:18 -05:00
David Teigland
7f1ef25b46 remove unused variables 2022-09-27 15:42:18 -05:00
David Teigland
50281e5710 change messages about libblkid features
remove message about missing libblkid features

change message recommending resize_fsadm when libblkid
features are not available.
2022-09-27 15:13:31 -05:00
David Teigland
3ca44e13be lvreduce: use temporary flag when activating lv to check for fs
This flag is meant to suppress udev processing of the LV.
2022-09-27 12:59:17 -05:00
David Teigland
c1ab9fb37f make: move cmds.h
generate the header in the include dir so it
can be easily used from both lib and tools dirs.
2022-09-27 09:06:06 -05:00
Tony Asleson
fd05b79aad lvmdbustest: Add test to stress mode changing
Add a test to toggle from fork & exec to lvm shell repeatedly, to stress
test it.
2022-09-22 17:14:10 -05:00
Tony Asleson
897b326ccc lvmdbustest: Re-work setUp
Place the addCleanup at the end as we don't want to go through clean up
if we don't make it through setUp.  If we don't do this we can remove VGs
that we didn't create in the unit test.
2022-09-22 17:10:13 -05:00
Tony Asleson
7966f1dd18 lvmdbustest: Refuse to remove a VG we didn't create
One of our previous commits introduced the side effect that we could
inadvertently remove a VG we didn't create, and lose data.
2022-09-22 16:19:16 -05:00
Tony Asleson
40018cbf53 lvmdbustest: Make vg name suffix more unique 2022-09-22 16:17:20 -05:00
Tony Asleson
36a8fb20bf lvmdbusd: Correct lvm shell signal & child process handling
Previously when the __del__ method ran on LVMShellProxy we would blindly
call terminate().  This was a race condition as the underlying process
may/maynot be present.  When the process is still present the SIGTERM will
end up being seen by lvmdbusd too.  Re-work the code so that we
first try to wait for the child process to exit and only then if it hasn't
exited will we send it a SIGTERM.  We also ensure that when this is
executed we will briefly ignore a SIGTERM that arrives for the daemon.
2022-09-22 08:33:06 -05:00
David Teigland
c21783d492 covscan: free wwid strings in lvmcache 2022-09-21 12:15:13 -05:00
Zdenek Kabelac
e97cf8552c make: generate 2022-09-21 14:58:34 +02:00
Zdenek Kabelac
3a7aeebf7d tests: validate CONFIG_HZ_1000
If we plan to use dm throttling for mirror targets - we actually
have to check whether kernel runs with CONFIG_HZ_1000 - if it does
not the whole idea of throttling is actually not working in the
testsuite as within a single 'tick' with HZ 100 way too much date
is being moved on any modern hardware - and since there is no plan
to change this in kernel - we simply avoid using throttling on such
kernel and test needs to work differently - either ignore results
or use much larger mirror sizes...
2022-09-21 14:58:34 +02:00
Zdenek Kabelac
96f303eb08 tests: discard update 2022-09-21 14:58:34 +02:00
Zdenek Kabelac
cbfdb87358 makefiles: use single libs definition 2022-09-21 14:58:34 +02:00
Zdenek Kabelac
1bf1aca544 tests: integrity switch to ext4
Since we would need to create a lot of 300M filesystem,
switch this test suite to ext4.
2022-09-21 14:58:34 +02:00
Tony Asleson
9c2ed74221 lvmdbusd: Register for SIGTERM
Ensure we log that we are exiting on this signal too.
2022-09-20 16:37:01 -05:00
Tony Asleson
d88998f516 lvmdbusd: Correct get_object_path_by_uuid_lvm_id
When checking to see if the PV is missing we incorrectly checked that the
path_create was equal to PV creation.  However, there are cases where we
are doing a lookup where the path_create == None.  In this case, we would
fail to set lvm_id == None which caused a problem as we had more than 1
PV that was missing.  When this occurred, the second lookup matched the
first missing PV that was added to the object manager.  This resulted in
the following:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lvmdbusd/utils.py", line 667, in _run
    self.rc = self.f(*self.args)
  File "/usr/lib/python3.9/site-packages/lvmdbusd/fetch.py", line 25, in _main_thread_load
    (changes, remove) = load_pvs(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/pv.py", line 46, in load_pvs
    return common(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/loader.py", line 55, in common
    del existing_paths[dbus_object.dbus_object_path()]

Because we expect to find the object in existing_paths if we found it in
the lookup.

resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2085078
2022-09-20 16:36:53 -05:00
Marian Csontos
a0fc61177e make: Fix build in chroot
When building in a buildroot, must create libexec directory explicitly.
2022-09-20 15:56:13 +02:00
Marian Csontos
178564317a spec: Workaround for failing build
Commit 18722dfdf4 introduced a dependency
on file from tools/ into lib/.

TODO: revert this once the issue is resolved.
2022-09-20 15:12:44 +02:00
Tony Asleson
8686657664 lvmdbusd: Remove --reportformat
Latest upstream build of lvm results in the following error when
trying to use lvmshell.

"Argument --reportformat cannot be used in interactive mode.,
Error during parsing of command line."
2022-09-16 10:49:37 -05:00
Tony Asleson
3d3c517b0b lvmdbustest: Add wrapper for injecting errors
Useful for forcing lvmdbusd down error paths.
2022-09-16 10:49:37 -05:00
Tony Asleson
11c033c222 lvmdbusd: Include lvm debug output for lvmshell
Move the option to add the debug file into lvm_full_report_json so that
we collect the debug data when we fork & exec lvm and when we use lvm
shell.
2022-09-16 10:49:37 -05:00
Tony Asleson
a4b7f988d8 lvmdbusd: Call readlines instead of readline
Better to drain everything we have now that our IO is line orientated
when using a ptty.
2022-09-16 10:49:37 -05:00
Tony Asleson
8e1e40c499 lvmdbusd: Raise IOError instead of ignoring
We end up in a bad state if we simply eat IOErrors here.  Exit the lvmshell
process and raise the IOError.
2022-09-16 10:49:37 -05:00
Tony Asleson
2c5762038a lvmdbusd: Correct log_error for shell proxy 2022-09-16 10:49:37 -05:00
Tony Asleson
d51fb57f1a lvmdbusd: Check for KeyError in refresh
Bubble up a LvmBug if we get a KeyError on a lvm column name.
2022-09-16 10:49:37 -05:00
Tony Asleson
feaf46863b lvmdbusd: Use common func. for checking missing LV keys 2022-09-16 10:49:37 -05:00
Tony Asleson
ed9072dad8 lvmdbusd: Correct undefined var 2022-09-16 10:49:37 -05:00
Tony Asleson
a326e35cda lvmdbustest: Check for self.pvs
If we don't make it through setUp, self.pvs will not exist.
2022-09-16 10:49:37 -05:00
Tony Asleson
ead80d134d lvmdbustest: Move signals to last
When we do the signal testing we default back to fork & exec.  Put these
on the end to maximize our lvm shell testing until we fix this proper.
2022-09-16 10:49:37 -05:00