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

17704 Commits

Author SHA1 Message Date
Zdenek Kabelac
3e2827f3b7 cov: add initilizer 2021-07-28 00:49:28 +02:00
Zdenek Kabelac
a4eb378fe4 cov: add explicit check for vg existence
Since we check !vg - add check before accessing ->status.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
f4b49dae1e cov: raid: no more checks with missing areas
Since ->areas is directly dereferenced we need to stop
validation right here.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
b2db01b530 cov: dev-mpath: check config_wwids_file
Since config_wwids_file is checked for NULL,
test is also before calling _read_wwid_file()
that is directly dereferencing it.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
b7edda8a98 cov: guard index
Analyzer wants explicit protect to not underflow index.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
d499491501 cov: ensure bufffe size is at least 5
Analyzer can now see, the buffer size will have at least 5 chars
on succefull path.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
046d85af3d cov: add internal error for missing arg
Analyzer is happier.
2021-07-28 00:49:28 +02:00
Zdenek Kabelac
69379df8f3 cov: remove unneeded includes 2021-07-28 00:49:28 +02:00
Zdenek Kabelac
ec9dd728aa cov: memleak dir descriptor
opendir() missed closedir().
2021-07-28 00:49:22 +02:00
Zdenek Kabelac
308c6f31c3 pvck: ensure buffer is 0 terminated
Since readed metadata buffer is passed to printf(),
ensure the buffer is '\0' terminated.
2021-07-28 00:49:22 +02:00
Zdenek Kabelac
01081b2100 cov: pvck fix memleak
Fix memory leaks on error paths for allocated
path and backup_file name by converting allocation to
dm_pool_alloc  and also change devicefile structure to contain
embeded  path as last struct member - so we could allocate
only needed string size  instead of PATH_MAX from pool.

TODO: still to be fixed 'mf' struct.
2021-07-28 00:49:22 +02:00
Zdenek Kabelac
8ebcbe9ace tests: extend vgmerge testing 2021-07-23 16:36:31 +02:00
Zdenek Kabelac
4b856476e9 vgmerge: support option --poolmetadataspare 2021-07-23 16:36:31 +02:00
Zdenek Kabelac
9cbc9e8296 vgmerge: remove one of merge pmspare LVs
When merging 2 VG, where both of them have pmspare volume,
select the bigger one and remove the other.
2021-07-23 16:35:47 +02:00
David Teigland
06602942a3 writecache: use block size 512 for thin pool data
Recent commit 84bd394cf9
  "writecache: use block size 4096 when no fs is found"

failed to account for the case where writecache is attached
to thin pool data.  Checking fs block size on the thin pool
data LV is wrong, and checking the fs block on each thin LV
would be impractical, so default to 512 which cannot break
any existing file systems, and require the user to specify
4k when appropriate.
2021-07-21 14:24:27 -05:00
David Teigland
d91c018732 writecache: fix missing sync_dev_names when attaching cache
When activating an LV to check the fs block size, wait for
the LV dev to be accessible before running blkid on it.
2021-07-21 13:16:21 -05:00
Marian Csontos
640fe5cf42 spec: Add vdoimport man page 2021-07-21 16:40:27 +02:00
Zdenek Kabelac
b70c341c9e test 2021-07-21 15:56:33 +02:00
Zdenek Kabelac
2132fdc11f vgsplit: add support for option --poolmetadataspare
When splitting VG with thin/cache pool volume, handle pmspare during
such split and allocate new pmspare in new VG or extend existing pmspare
there and eventually drop  pmspare in original VG if is no longer needed
there.
2021-07-21 15:56:33 +02:00
Zdenek Kabelac
5042463c50 vgremove: remove forgotten pmspare
As pmspare is an invisible LV it's not getting automatically removed
since vgremove removes only visible LVs and it depending LVs.
If there was no other thin/cache pool volume, such pmspare stayed
undeleted and caused command failure.

So handle explicitelly such forgotten pmspare and remove it.
2021-07-21 13:19:51 +02:00
Zdenek Kabelac
d38fdb25e4 thin: fix component detection of external origin
When check active componet of thinLV with external origin,
we need to check if the external origin isn't already active.
For this however we need to use layered check for -real device.
2021-07-14 12:56:08 +02:00
David Teigland
e33c2e032c pvscan: narrow the previous commit slightly
to avoid change to pvscan-autoactivate.sh
2021-07-13 16:38:04 -05:00
David Teigland
25f0f5daac pvscan: do nothing for device removal and event_activation=0
The lvm2-pvscan service runs pvscan --cache -aay <dev> for
device addition, and pvscan --cache <dev> on device removal.
For event_activation=0, the addition does nothing.  Fix
device removal to also do nothing for event_activation=0.
Device removal was previously doing some work to process
the removal which slowed down stopping lvm2-pvscan services.
2021-07-13 16:09:54 -05:00
David Teigland
f8b52f2763 fix multipath component detection for multiple holders
sysfs-based multipath component detection quit if a
device had multiple holders, and in this case would
fail to detect a device was an mpath component.
2021-07-13 11:11:23 -05:00
David Teigland
deaf43d6f0 filter-usable: remove udev dev size check
For the pv_min_size check, always use dev_get_size()
which is commonly used elsewhere, and don't bother
asking libudev for the device size when
external_device_info_source=udev.
2021-07-13 11:11:23 -05:00
David Teigland
9048565093 devices: rework libudev usage
related to config settings:
  obtain_device_info_from_udev (controls if lvm gets
    a list of devices from readdir /dev or from libudev)
  external_device_info_source (controls if lvm asks
    libudev for device information)

. Make the obtain_device_list_from_udev setting
  affect only the choice of readdir /dev vs libudev.
  The setting no longer controls if udev is used for
  device type checks.

. Change obtain_device_list_from_udev default to 0.
  This helps avoid boot timeouts due to slow libudev
  queries, avoids reported failures from
  udev_enumerate_scan_devices, and avoids delays from
  "device not initialized in udev database" errors.
  Even without errors, for a system booting with 1024 PVs,
  lvm2-pvscan times improve from about 100 sec to 15 sec,
  and the pvscan command from about 64 sec to about 4 sec.

. For external_device_info_source="none", remove all
  libudev device info queries, and use only lvm
  native device info.

. For external_device_info_source="udev", first check
  lvm native device info, then check libudev info.

. Remove sleep/retry loop when attempting libudev
  queries for device info.  udev info will simply
  be skipped if it's not immediately available.

. Only set up a libdev connection if it will be used by
  obtain_device_list_from_udev/external_device_info_source.

. For native multipath component detection, use
  /etc/multipath/wwids.  If a device has a wwid
  matching an entry in the wwids file, then it's
  considered a multipath component.  This is
  necessary to natively detect multipath
  components when the mpath device is not set up.
2021-07-13 11:11:23 -05:00
Heming Zhao
db22a389cf toolcontext: fix double free (core dumped) issue
How to trigger:

```
~ # export LVM_SYSTEM_DIR=_
~ # pvscan
  No matching physical volumes found
double free or corruption (!prev)
Aborted (core dumped)
```

when LVM_SYSTEM_DIR is empty, _load_config_file() won't be called.

when LVM_SYSTEM_DIR is not empty, cfl->cft links into cmd->config_files
by _load_config_file()@lib/commands/toolcontext.c

core dumped code: _destroy_config()@lib/commands/toolcontext.c

```
    /* CONFIG_FILE/CONFIG_MERGED_FILES */
    if ((cft = remove_config_tree_by_source(cmd, CONFIG_MERGED_FILES)))
        config_destroy(cft);
    else if ((cft = remove_config_tree_by_source(cmd, CONFIG_FILE)))
        config_destroy(cft); <=== first free the cft

    dm_list_iterate_items(cfl, &cmd->config_files)
        config_destroy(cfl->cft); <=== double free the cft
```

Fixes: c43f2f8ae0

Signed-off-by: Heming Zhao <heming.zhao@suse.com>
2021-07-12 14:10:21 -05:00
David Teigland
66daedc6d2 skip indexing devices used by LVs in more commands
expands commit d5a06f9a7d
  "pvscan: skip indexing devices used by LVs"

The dev cache index is expensive and slow, so limit it
to commands that are used to observe the state of lvm.
The index is only used to print warnings about incorrect
device use by active LVs, e.g. if an LV is using a
multipath component device instead of the multipath
device.  Commands that continue to use the index and
print the warnings:

  fullreport, lvmdiskscan, vgs, lvs, pvs,
  vgdisplay, lvdisplay, pvdisplay,
  vgscan, lvscan, pvscan (excluding --cache)

A couple other commands were borrowing the DEV_USED_FOR_LV
flag to just check if a device was actively in use by LVs.
These are converted to the new dev_is_used_by_active_lv().
2021-07-09 13:59:31 -05:00
Zdenek Kabelac
70c32d1e74 man: vdoimport page 2021-07-09 20:50:40 +02:00
Zdenek Kabelac
ed48cb26a3 vdo: add vdoimport support
Add tool 'vdoimport' to support easy conversion of an existing VDO manager managed
VDO volumes into lvm2 managed VDO LV.

When physical converted volume is already a logical volume, conversion
happens with the VG itself, just with validation for extent_size, so
the virtually sized logical VDO volume size can be expressed in extents.

Example of basic simple usage:

vdoimport --name vg/vdolv  /dev/mapper/vdophysicalvolume
2021-07-09 14:57:59 +02:00
Zdenek Kabelac
3a92d633a5 configure: updates 2021-07-09 14:57:59 +02:00
David Teigland
d5a06f9a7d pvscan: skip indexing devices used by LVs
dev_cache_index_devs() is taking a large amount of time
when there are many PVs.  The index keeps track of
devices that are currently in use by active LVs.  This
info is used to print warnings for users in some limited
cases.

The checks/warnings that are enabled by the index are not
needed by pvscan --cache, so disable it in this case.

This may be expanded to other cases in future commits.
dev_cache_index_devs should also be improved in another
commit to avoid the extreme delays with many devices.
2021-07-06 10:18:07 -05:00
David Teigland
b876dbfc24 scan: move metadata vgname check
There have been two separate checks for metadata
validity: first that the metadata text begins with
a valid VG name, and second the checksum of the
metadata text.  These happen in different places,
which means there have been two separate error paths
for invalid metadata.  This also causes large metadata
to be read in multiple parts, the first part is read
just to check the vgname, and then remaining parts are
read later when the full metadata is needed.

This patch moves the vg name verification so it's
done just before the checksum verification, which
results in a single error path for invalid metadata,
and causes the entire metadata to be read together
rather that in parts from different parts of the code.
2021-07-06 10:10:23 -05:00
David Teigland
e035e32350 scan: retry reading metadata on error
If label_scan encounters bad vg metadata, invalidate
bcache data for the device and reread the mda_header
and metadata text back to back.  With concurrent commands
modifying large metadata, it's possible that the entire
metadata area can be rewritten in the time between a
command reading the mda_header and reading the metadata
text that the header points to.  Since the label_scan
is just assembling an initial overview of devices, it
doesn't use locking to serialize with other commands
that may be modifying the vg metadata at the same time.
2021-07-06 10:10:23 -05:00
David Teigland
d89942d157 scan: don't hold bcache block during scan
This allows data from the bcache block to be
invalidated and reread if needed.
2021-07-06 10:10:23 -05:00
David Teigland
a47e20a092 tests: skip tests that require blkid BLOCK_SIZE
Recent commit 84bd394cf9
  "writecache: use block size 4096 when no fs is found"

changed the default writecache block size from 512 to 4096
when no file system is detected.  The fs block size detection
requires the libblkid BLOCK_SIZE feature, so skip tests on
systems without this.  Otherwise, 4096 writecache added to
512 xfs leads fs io or mount failures.
2021-06-30 11:56:42 -05:00
Zdenek Kabelac
39f497b9d8 WHATS_NEW: update 2021-06-28 20:41:07 +02:00
Zdenek Kabelac
580e64e93b make: generate 2021-06-28 20:41:07 +02:00
Zdenek Kabelac
2c6a2b6e86 vdo: support vdo_pool_header_size
Add profilable configurable setting for vdo pool header size, that is
used as 'extra' empty space at the front and end of vdo-pool device
to avoid having a disk in the system the may have same data is real
vdo LV.

For some conversion cases however we may need to allow using '0' header size.

TODO: in this case we may eventually avoid adding 'linear' mapping layer
in future - but this requires further modification over lvm code base.
2021-06-28 20:41:07 +02:00
Zdenek Kabelac
5fcbc3bd7d vdo: rename variable vdo_pool_zero
Match rest of code.
2021-06-28 20:41:07 +02:00
Zdenek Kabelac
6e773bb196 lvconvert: fix vdo virtual size when specified
Correctly use virtual size specified by:
lvconvert --type vdo-pool --virtualsize
2021-06-28 20:41:07 +02:00
Zdenek Kabelac
d9cb1d3983 config_settings: typo fix 2021-06-28 18:11:14 +02:00
David Teigland
73a05c8f02 device_id: handle qemu wwid
Ignore made-up wwid values reported for qemu devices
that contain the string "QEMU HARDDISK".  The devname
will be used as the device id.
2021-06-24 11:30:46 -05:00
David Teigland
84bd394cf9 writecache: use block size 4096 when no fs is found
When there is no block size constraint from a file system
or from a user setting, use 4096 rather than 512 because of
better performance.
2021-06-23 12:38:57 -05:00
David Teigland
1139a05939 device_id: handle scsi_debug wwid
Ignore the wwid value reported by scsi_debug devices
that begin "t10.Linux   scsi_debug".  The devname
will be used as the device id.
2021-06-22 13:36:10 -05:00
David Teigland
c35f7722d5 lvconvert: allow writecache with other thinpool command syntax
"lvconvert --thinpool LV" should allow LV to have a writecache,
but there was an extra type check preventing it.
2021-06-17 16:15:18 -05:00
Tony Asleson
f773040625 lvmdbusd: Wrap json.load in try/except
In testing where we inject large amounts of additional output in stderr
we can occassionally get truncated stdout from lvm.  Catching and dumping
the json for debug before we re-raise the exception.  As this doesn't
happen without the error injecting wrapper around lvm, the error seems to
be with the wrapper.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2021-06-17 09:14:29 -05:00
Tony Asleson
c474f174cc lvmdbusd: Handle arbitrary amounts stdout & stderr
When exec'ing lvm, it's possible to get large amounts of both stdout
and stderr depending on the state of lvm and the size of the lvm
configuration.  If we allow any of the buffers to fill we can end
up deadlocking the process.  Ensure we are handling stdout & stderr
during lvm execution.

Ref. https://bugzilla.redhat.com/show_bug.cgi?id=1966636

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2021-06-17 09:14:29 -05:00
David Teigland
71cb54d92f coverity cleanups 2021-06-16 13:42:51 -05:00
Tony Asleson
f70d97b916 lvmdbusd: Defer dbus object removal
When we are walking the new lvm state comparing it to the old state we can
run into an issue where we remove a VG that is no longer present from the
object manager, but is still needed by LVs that are left to be processed.
When we try to process existing LVs to see if their state needs to be
updated, or if they need to be removed, we need to be able to reference the
VG that was associated with it.  However, if it's been removed from the
object manager we fail to find it which results in:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/lvmdbusd/utils.py", line 666, in _run
  self.rc = self.f(*self.args)
File "/usr/lib/python3.6/site-packages/lvmdbusd/fetch.py", line 36, in _main_thread_load
  cache_refresh=False)[1]
File "/usr/lib/python3.6/site-packages/lvmdbusd/lv.py", line 146, in load_lvs
  lv_name, object_path, refresh, emit_signal, cache_refresh)
File "/usr/lib/python3.6/site-packages/lvmdbusd/loader.py", line 68, in common
  num_changes += dbus_object.refresh(object_state=o)
File "/usr/lib/python3.6/site-packages/lvmdbusd/automatedproperties.py", line 160, in refresh
  search = self.lvm_id
File "/usr/lib/python3.6/site-packages/lvmdbusd/lv.py", line 483, in lvm_id
  return self.state.lvm_id
File "/usr/lib/python3.6/site-packages/lvmdbusd/lv.py", line 173, in lvm_id
  return "%s/%s" % (self.vg_name_lookup(), self.Name)
File "/usr/lib/python3.6/site-packages/lvmdbusd/lv.py", line 169, in vg_name_lookup
  return cfg.om.get_object_by_path(self.Vg).Name

Instead of removing objects from the object manager immediately, we will
keep them in a list and remove them once we have processed all of the state.

Ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1968752
2021-06-16 12:19:02 -05:00