]> sourceware.org Git - lvm2.git/log
lvm2.git
3 years agodevices: rework libudev usage
David Teigland [Tue, 8 Jun 2021 22:12:09 +0000 (17:12 -0500)]
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.

3 years agotoolcontext: fix double free (core dumped) issue
Heming Zhao [Mon, 12 Jul 2021 19:01:00 +0000 (03:01 +0800)]
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: c43f2f8ae08ed0555a300764c8644ea56f4f41e2
Signed-off-by: Heming Zhao <heming.zhao@suse.com>
3 years agoskip indexing devices used by LVs in more commands
David Teigland [Wed, 7 Jul 2021 21:59:56 +0000 (16:59 -0500)]
skip indexing devices used by LVs in more commands

expands commit d5a06f9a7df5a43b2e2311db62ff8d3011217d74
  "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().

3 years agoman: vdoimport page
Zdenek Kabelac [Fri, 9 Jul 2021 18:50:40 +0000 (20:50 +0200)]
man: vdoimport page

3 years agovdo: add vdoimport support
Zdenek Kabelac [Fri, 9 Jul 2021 12:44:07 +0000 (14:44 +0200)]
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

3 years agoconfigure: updates
Zdenek Kabelac [Fri, 9 Jul 2021 12:42:26 +0000 (14:42 +0200)]
configure: updates

3 years agopvscan: skip indexing devices used by LVs
David Teigland [Thu, 1 Jul 2021 22:25:43 +0000 (17:25 -0500)]
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.

3 years agoscan: move metadata vgname check
David Teigland [Tue, 29 Jun 2021 17:40:03 +0000 (12:40 -0500)]
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.

3 years agoscan: retry reading metadata on error
David Teigland [Mon, 28 Jun 2021 23:10:47 +0000 (18:10 -0500)]
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.

3 years agoscan: don't hold bcache block during scan
David Teigland [Mon, 28 Jun 2021 22:09:09 +0000 (17:09 -0500)]
scan: don't hold bcache block during scan

This allows data from the bcache block to be
invalidated and reread if needed.

3 years agotests: skip tests that require blkid BLOCK_SIZE
David Teigland [Wed, 30 Jun 2021 16:56:42 +0000 (11:56 -0500)]
tests: skip tests that require blkid BLOCK_SIZE

Recent commit 84bd394cf9aaa581b4bf980f764544dda26a0305
  "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.

3 years agoWHATS_NEW: update
Zdenek Kabelac [Mon, 28 Jun 2021 18:38:54 +0000 (20:38 +0200)]
WHATS_NEW: update

3 years agomake: generate
Zdenek Kabelac [Mon, 28 Jun 2021 16:10:41 +0000 (18:10 +0200)]
make: generate

3 years agovdo: support vdo_pool_header_size
Zdenek Kabelac [Mon, 28 Jun 2021 15:53:08 +0000 (17:53 +0200)]
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.

3 years agovdo: rename variable vdo_pool_zero
Zdenek Kabelac [Mon, 28 Jun 2021 15:54:55 +0000 (17:54 +0200)]
vdo: rename variable vdo_pool_zero

Match rest of code.

3 years agolvconvert: fix vdo virtual size when specified
Zdenek Kabelac [Mon, 28 Jun 2021 16:12:19 +0000 (18:12 +0200)]
lvconvert: fix vdo virtual size when specified

Correctly use virtual size specified by:
lvconvert --type vdo-pool --virtualsize

3 years agoconfig_settings: typo fix
Zdenek Kabelac [Mon, 28 Jun 2021 15:48:01 +0000 (17:48 +0200)]
config_settings: typo fix

3 years agodevice_id: handle qemu wwid
David Teigland [Thu, 24 Jun 2021 16:30:46 +0000 (11:30 -0500)]
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.

3 years agowritecache: use block size 4096 when no fs is found
David Teigland [Wed, 23 Jun 2021 17:38:57 +0000 (12:38 -0500)]
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.

3 years agodevice_id: handle scsi_debug wwid
David Teigland [Tue, 22 Jun 2021 18:36:10 +0000 (13:36 -0500)]
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.

3 years agolvconvert: allow writecache with other thinpool command syntax
David Teigland [Thu, 17 Jun 2021 21:15:18 +0000 (16:15 -0500)]
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.

3 years agolvmdbusd: Wrap json.load in try/except
Tony Asleson [Tue, 15 Jun 2021 03:04:09 +0000 (22:04 -0500)]
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>
3 years agolvmdbusd: Handle arbitrary amounts stdout & stderr
Tony Asleson [Fri, 11 Jun 2021 15:35:31 +0000 (10:35 -0500)]
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>
3 years agocoverity cleanups
David Teigland [Wed, 16 Jun 2021 18:22:54 +0000 (13:22 -0500)]
coverity cleanups

3 years agolvmdbusd: Defer dbus object removal
Tony Asleson [Thu, 10 Jun 2021 18:38:38 +0000 (13:38 -0500)]
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

3 years agolvmdbusd: Don't setup search key unless needed
Tony Asleson [Thu, 10 Jun 2021 18:26:15 +0000 (13:26 -0500)]
lvmdbusd: Don't setup search key unless needed

self.lvm_id is a property which actually executes some code which doesn't
need to be executed everytime.

3 years agotests: Fix building for IDM program
Leo Yan [Wed, 16 Jun 2021 13:44:27 +0000 (21:44 +0800)]
tests: Fix building for IDM program

When execute IDM testing, the command reports error:

  /usr/bin/install: cannot stat ‘lib/idm_inject_failure’: No such file
  or directory

Since there have a stale program in my local environment, thus Makefile
always uses the stale program and doesn't report any issue.  In the
brand new repository, it doesn't contain an idm_inject_failure program,
and Makefile doesn't build it without specifying the dependency, thus
the test command complaints the file 'idm_inject_failure' is not found.

This patch adds the dependency 'lib/idm_inject_failure' for IDM testing,
so it can firstly build the injection program and dismiss the error.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: stress: Change to use $SHARED for vgcreate
Leo Yan [Wed, 16 Jun 2021 13:43:54 +0000 (21:43 +0800)]
tests: stress: Change to use $SHARED for vgcreate

Use the variable $SHARED to replace "--shared" for vgcreate commands.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: fix skip in stress_single_thread.sh
David Teigland [Wed, 16 Jun 2021 14:37:04 +0000 (09:37 -0500)]
tests: fix skip in stress_single_thread.sh

3 years agotests: add some LVM_TEST_LOCK_TYPE_IDM
David Teigland [Tue, 15 Jun 2021 19:02:18 +0000 (14:02 -0500)]
tests: add some LVM_TEST_LOCK_TYPE_IDM

3 years agolvmdevices: add deviceidtype option
David Teigland [Tue, 8 Jun 2021 19:49:34 +0000 (14:49 -0500)]
lvmdevices: add deviceidtype option

When adding a device to the devices file with --adddev, lvm
by default chooses the best device ID type for the new device.
The new --deviceidtype option allows the user to override the
built in preference.  This is useful if there's a problem with
the default type, or if a secondary type is preferrable.

If the specified deviceidtype does not produce a device ID,
then lvm falls back to the preference it would otherwise use.

3 years agopvck: add lock_global() before clean_hint_file()
Wu Guanghao [Fri, 11 Jun 2021 15:18:56 +0000 (10:18 -0500)]
pvck: add lock_global() before clean_hint_file()

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
3 years agoarchive: avoid abuse of internal flag
Zdenek Kabelac [Wed, 9 Jun 2021 14:16:26 +0000 (16:16 +0200)]
archive: avoid abuse of internal flag

Since archive is now postponned we use internal variable 'changed'
to mark we need to commit new metadata.

3 years agobackup: automatically store data on vg_unlock
Zdenek Kabelac [Tue, 8 Jun 2021 17:39:15 +0000 (19:39 +0200)]
backup: automatically store data on vg_unlock

Previously there have been necessary explicit call of backup (often
either forgotten or over-used). With this patch the necessity to
store backup is remember at vg_commit and once the VG is unlocked,
the committed metadata are automatically store in backup file.

This may possibly alter some printed messages from command when the
backup is now taken later.

3 years agoarchiving: take archive automatically
Zdenek Kabelac [Tue, 8 Jun 2021 17:02:07 +0000 (19:02 +0200)]
archiving: take archive automatically

Instead of calling explicit archive with command processing logic,
move this step towards 1st. vg_write() call, which will automatically
store archive of committed metadata.

This slightly changes some error path where the error in archiving
was detected earlier in the command, while now some on going command
'actions' might have been, but will be simply scratched in case
of error (since even new metadata would not have been even written).

So general effect should be only some command message ordering.

3 years agoman/help: fix common option listing
David Teigland [Tue, 8 Jun 2021 19:07:39 +0000 (14:07 -0500)]
man/help: fix common option listing

3 years agodevices: don't use deleted loop backing file for device id
David Teigland [Tue, 8 Jun 2021 17:16:06 +0000 (12:16 -0500)]
devices: don't use deleted loop backing file for device id

check for "(deleted)" in the backing_file string and
fall back to devname for id.

$ cat /sys/block/loop0/loop/backing_file
/root/looptmp (deleted)

3 years agolvmlockd: Fix the compilation warning
Leo Yan [Tue, 8 Jun 2021 06:45:09 +0000 (14:45 +0800)]
lvmlockd: Fix the compilation warning

As SUSE build tool reports the warning:

lvmlockd-core.c: In function 'client_thread_main':
lvmlockd-core.c:4959:37: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
    snprintf(buf, sizeof(buf), "path[%d]", i);
                                     ^~
lvmlockd-core.c:4959:31: note: directive argument in the range [0, 2147483647]
    snprintf(buf, sizeof(buf), "path[%d]", i);
                               ^~~~~~~~~~

To dismiss the compilation warning, enlarge the array "buf" to 17
bytes to support the max signed integer: string format 6 bytes + signed
integer 10 bytes + terminal char "\0".

Reported-by: Heming Zhao <heming.zhao@suse.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: add writecache-cache-blocksize-2
David Teigland [Mon, 7 Jun 2021 20:40:40 +0000 (15:40 -0500)]
tests: add writecache-cache-blocksize-2

inconsistent physical block size of devs used
for main LV and cache

3 years agotests: rename test
David Teigland [Mon, 7 Jun 2021 17:12:33 +0000 (12:12 -0500)]
tests: rename test

3 years agotests: writecache-blocksize add dm-cache tests
David Teigland [Mon, 7 Jun 2021 17:11:12 +0000 (12:11 -0500)]
tests: writecache-blocksize add dm-cache tests

Add the same tests for dm-cache as exist for dm-writecache,
dm-cache uses a different blocksize in a couple cases.

3 years agofix empty mem pool leak
David Teigland [Thu, 3 Jun 2021 19:44:55 +0000 (14:44 -0500)]
fix empty mem pool leak

of "config" when LVM_SYSTEM_DIR=""

3 years agotests: multi-hosts: Test lease timeout with LV shareable mode
Leo Yan [Thu, 3 Jun 2021 09:59:25 +0000 (17:59 +0800)]
tests: multi-hosts: Test lease timeout with LV shareable mode

This patch is to test timeout handling after activate LV with shareable
mode.  It has the same logic with the testing for LV exclusive mode,
except it verifies the locking with shareable mode.

  On the host A:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hosta.sh

  On the host B:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_sh_timeout_hostb.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: multi-hosts: Test lease timeout with LV exclusive mode
Leo Yan [Thu, 3 Jun 2021 09:59:24 +0000 (17:59 +0800)]
tests: multi-hosts: Test lease timeout with LV exclusive mode

This patch is to test timeout handling after activate LV with exclusive
mode.  It contains two scripts for host A and host B separately.

The script on host A firstly creates VGs and LVs based on the passed
back devices, every back device is for a dedicated VG and a LV is
created as well in the VG.  Afterwards, all LVs are activated by host A,
so host A acquires the lease for these LVs.  Then the test is designed
to fail on host A.

After the host A fails, host B starts to run the paired testing script,
it firstly fails to activate the LVs since the locks are leased by
host A; after lease expiration (after 70s), host B can achieve the lease
for LVs and it can operate LVs and VGs.

  On the host A:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hosta.sh

  On the host B:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_ex_timeout_hostb.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: multi-hosts: Add LV testing
Leo Yan [Thu, 3 Jun 2021 09:59:23 +0000 (17:59 +0800)]
tests: multi-hosts: Add LV testing

This patch is to add LV testing on multi hosts.  There have two scripts,
the script multi_hosts_lv_hosta.sh is used to create LVs on one host,
and the second script multi_hosts_lv_hostb.sh will acquire
global lock and VG lock, and remove VGs.  The testing flow verifies the
locking operations between two hosts with lvmlockd and the backend
locking manager.

  On the host A:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hosta.sh

  On the host B:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_lv_hostb.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: multi-hosts: Add VG testing
Leo Yan [Thu, 3 Jun 2021 09:59:22 +0000 (17:59 +0800)]
tests: multi-hosts: Add VG testing

This patch is to add VG testing on multi hosts.  There have two scripts,
the script multi_hosts_vg_hosta.sh is used to create VGs on one host,
and the second script multi_hosts_vg_hostb.sh afterwards will acquire
global lock and VG lock, and remove VGs.  The testing flow verifies the
locking operations between two hosts with lvmlockd and the backend
locking manager.

  On the host A:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hosta.sh

  On the host B:
    make check_lvmlockd_idm \
      LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3,/dev/sdl3 \
      LVM_TEST_MULTI_HOST=1 T=multi_hosts_vg_hostb.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: idm: Add testing for IDM lock manager failure
Leo Yan [Thu, 3 Jun 2021 09:59:21 +0000 (17:59 +0800)]
tests: idm: Add testing for IDM lock manager failure

If the IDM lock manager fails to access drives, might partially fail to
access drives (e.g. it fails to access one of three drives), or totally
fail to access drives, the lock manager should handle properly for these
cases.  When the drives are partially failure, if the lock manager still
can renew the lease for the locking, then it doesn't need to take any
action for the drive failure; otherwise, if it detects it cannot renew
the locking majority, it needs ti immediately kill the VG from the
lvmlockd.

This patch adds the test for verification the IDM lock manager failure;
the command can be used as below:

  # make check_lvmlockd_idm \
    LVM_TEST_BACKING_DEVICE=/dev/sdp3,/dev/sdl3,/dev/sdq3 \
    LVM_TEST_FAILURE=1 T=idm_ilm_failure.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: idm: Add testing for the fabric's half brain failure
Leo Yan [Thu, 3 Jun 2021 09:59:20 +0000 (17:59 +0800)]
tests: idm: Add testing for the fabric's half brain failure

If the fabric is broken instantly and the partial drives connected on
the fabric disappear from the system.  For this case, according to the
locking algorithm in idm, the lease will not lose since the half drives
are still alive so can renew the lease for the half drives.  On the
other hand, since the VG lock requires to acquire the majority of drive
number, but half drives failure cannot achieve the majority, so it
cannot acquire the lock for VG and thus cannot change metadata for VG.

This patch is to add half brain failure for idm; the test command is as
below:

  # make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdp3,/dev/sdo3 LVM_TEST_FAILURE=1 \
T=idm_fabric_failure_half_brain.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: idm: Add testing for the fabric failure and timeout
Leo Yan [Thu, 3 Jun 2021 09:59:19 +0000 (17:59 +0800)]
tests: idm: Add testing for the fabric failure and timeout

If the fabric is broken instantly, the drives connected on the fabric
will disappear from the system.  For worst case, the lease is timeout
and the drives cannot recovery back.  So a new test is added to emulate
this scenario, it uses a drive for LVM operations and this drive is also
used for locking scheme; if the drive and all its associated paths (if
the drive supports multiple paths) are disconnected, the lock manager
should stop the lockspace for the VG/LVs.

And afterwards, if the drive recovers back, the VG/LV resident in the
drive should be operated properly.  The test command is as below:

  # make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdp3 LVM_TEST_FAILURE=1 \
T=idm_fabric_failure_timeout.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: idm: Add testing for the fabric failure
Leo Yan [Thu, 3 Jun 2021 09:59:18 +0000 (17:59 +0800)]
tests: idm: Add testing for the fabric failure

When the fabric failure occurs, it will lose the connection with hosts
instantly, and after a while it can recovery back so that the hosts can
continue to access the drives.

For this case, the locking manager should be reliable for this case and
can dynamically handle this case and allows user to continue to use the
VG/LV with associated locking scheme.

This patch adds a testing to emulate the fabric faliure, verify LVM
commands for this case.  The testing usage is:

  # make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdo3,/dev/sdp3,/dev/sdp4 \
LVM_TEST_FAILURE=1 T=idm_fabric_failure.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Add testing for lvmlockd failure
Leo Yan [Thu, 3 Jun 2021 09:59:17 +0000 (17:59 +0800)]
tests: Add testing for lvmlockd failure

After the lvmlockd abnormally exits and relaunch the daemon, if LVM
commands continue to run, lvmlockd and the backend lock manager (e.g.
sanlock lock manager or IDM lock manager) should can continue to serve
the requests from LVM commands.

This patch adds a test to emulate lvmlockd failure, and verify the LVM
commands after lvmlockd recovers back.  Below is an example for testing
the case:

  # make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdo3,/dev/sdp3,/dev/sdp4 \
LVM_TEST_FAILURE=1 T=lvmlockd_failure.sh

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Support idm failure injection
Leo Yan [Thu, 3 Jun 2021 09:59:16 +0000 (17:59 +0800)]
tests: Support idm failure injection

When the drive failure occurs, the IDM lock manager and lvmlockd should
handle this case properly.  E.g. when the IDM lock manager detects the
lease renewal failure caused by I/O errors, it should invoke the kill
path which is predefined by lvmlockd, so that the kill path program
(like lvmlockctl) can send requests to lvmlockd to stop and drop lock
for the relevant VG/LVs.

To verify the failure handling flow, this patch introduces an idm
failure injection program, it can input the "percentage" for drive
failures so that can emulate different failure cases.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: stress: Add multi-threads stress testing for PV/VG/LV
Leo Yan [Thu, 3 Jun 2021 09:59:15 +0000 (17:59 +0800)]
tests: stress: Add multi-threads stress testing for PV/VG/LV

This patch is to add the stress testing, which launches three threads,
one thread is for creating/removing PV, one thread is for
creating/removing VG, and the last one thread is for LV operations.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: stress: Add multi-threads stress testing for VG/LV
Leo Yan [Thu, 3 Jun 2021 09:59:14 +0000 (17:59 +0800)]
tests: stress: Add multi-threads stress testing for VG/LV

This patch is to add the stress testing, which launches two threads,
each thread creates LV, activate and deactivate LV in the loop; so this
can test for multi-threading in lvmlockd and its backend lock manager.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: stress: Add single thread stress testing
Leo Yan [Thu, 3 Jun 2021 09:59:13 +0000 (17:59 +0800)]
tests: stress: Add single thread stress testing

This patch is to add the stress testing, which loops to create LV,
activate and deactivate LV in the single thread.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Add checking for lvmlockd log
Leo Yan [Thu, 3 Jun 2021 09:59:12 +0000 (17:59 +0800)]
tests: Add checking for lvmlockd log

Add checking for lvmlockd log, this can be used for the test cases which
are interested in the interaction with lvmlockd.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Cleanup idm context when prepare devices
Leo Yan [Thu, 3 Jun 2021 09:59:11 +0000 (17:59 +0800)]
tests: Cleanup idm context when prepare devices

For testing idm locking scheme, it's good to cleanup the idm context
before run the test cases.  This can give a clean environment for the
testing.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Support multiple backing devices
Leo Yan [Thu, 3 Jun 2021 09:59:10 +0000 (17:59 +0800)]
tests: Support multiple backing devices

In current implementation, the option "LVM_TEST_BACKING_DEVICE" only
supports to specify one backing device; this patch is to extend the
option to support multiple backing devices by using comma as separator,
e.g. below command specifies two backing devices:

  make check_lvmlockd_idm LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3

This can allow the testing works on multiple drives and verify the
locking scheme if can work as expected for multiple drives case.  For
example, for Seagate IDM locking scheme, if a VG uses two PVs, every PV
is resident on a drive, thus the locking operations will be sent to two
drives respectively; so the extension for "LVM_TEST_BACKING_DEVICE" can
help to verify different drive configurations for locking.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotests: Enable the testing for IDM locking scheme
Leo Yan [Thu, 3 Jun 2021 09:59:09 +0000 (17:59 +0800)]
tests: Enable the testing for IDM locking scheme

This patch is to introduce testing option LVM_TEST_LOCK_TYPE_IDM, with
specifying this option, the Seagate IDM lock manager will be launched as
backend for testing.  Also add the prepare and remove shell scripts for
IDM.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agopvchange: fix file locking deadlock
David Teigland [Wed, 2 Jun 2021 21:29:54 +0000 (16:29 -0500)]
pvchange: fix file locking deadlock

Calling clear_hint_file() to invalidate hints would acquire
the hints flock before the global flock which could cause deadlock.
The lock order requires the global lock to be taken first.

pvchange was always invalidating hints, which was unnecessary;
only invalidate hints when changing a PV uuid.  Because of the
lock ordering, take the global lock before clear_hint_file which
locks the hints file.

3 years agowritecache: don't pvmove device used by writecache
David Teigland [Wed, 2 Jun 2021 16:12:20 +0000 (11:12 -0500)]
writecache: don't pvmove device used by writecache

The existing check didn't cover the unusual case where the
cachevol exists on the same device as the origin LV.

3 years agowritecache: fix lv_on_pmem
David Teigland [Wed, 2 Jun 2021 15:51:12 +0000 (10:51 -0500)]
writecache: fix lv_on_pmem

dev_is_pmem on pv->dev requires a pv segment or it could segfault.

3 years agovdo: fix preload of kvdo
Zdenek Kabelac [Tue, 25 May 2021 22:19:28 +0000 (00:19 +0200)]
vdo: fix preload of kvdo

Commit 5bf1dba9eb8a8b77410e386e59dadeb27801b14e broke load of kvdo
kernel module - correct it by loading kvdo instead of trying dm-vdo.

3 years agolvremove: fix removing thin pool with writecache on data
David Teigland [Mon, 24 May 2021 21:08:27 +0000 (16:08 -0500)]
lvremove: fix removing thin pool with writecache on data

3 years agoenable command syntax for thin and writecache
David Teigland [Wed, 19 May 2021 19:36:40 +0000 (14:36 -0500)]
enable command syntax for thin and writecache

converting an LV with a writecache to thin pool data in
addition to previous attaching writecache to thin pool data

3 years agoconfigure: Add macro LOCKDIDM_SUPPORT
Leo Yan [Fri, 21 May 2021 02:56:37 +0000 (10:56 +0800)]
configure: Add macro LOCKDIDM_SUPPORT

The macro LOCKDIDM_SUPPORT is missed in configure.h.in file, thus when
execute "configure" command, it has no chance to add this macro in the
automatic generated header include/configure.h.

This patch adds macro LOCKDIDM_SUPPORT into configure.h.in.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agotools: Add support for "idm" lock type
Leo Yan [Fri, 7 May 2021 02:25:16 +0000 (10:25 +0800)]
tools: Add support for "idm" lock type

This patch is to update the comment and code to support "idm" lock type
which is used for LVM toolkit.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agolib: locking: Parse PV list for IDM locking
Leo Yan [Fri, 7 May 2021 02:25:15 +0000 (10:25 +0800)]
lib: locking: Parse PV list for IDM locking

For shared VG or LV locking, IDM locking scheme needs to use the PV
list assocated with VG or LV for sending SCSI commands, thus it requires
to use some places to generate PV list.

In reviewing the flow for LVM commands, the best place to generate PV
list is in the locking lib.  So this is why this patch parses PV list as
shown.  It iterates over all the PV nodes one by one, and compare with
the VG name or LV prefix string.  If any PV matches, then the PV is
added into the PV list.  Finally the PV list is sent to lvmlockd daemon.

Here as mentioned, it compares LV prefix string with the format
"lv_name_", the reason is it needs to find out all relevant PVs, e.g.
for the thin pool, it has LVs for metadata, pool, error, and raw LV, so
we can use the prefix string to find out all PVs belonging to the thin
pool.

For the global lock, it's not covered in this patch.  To avoid the egg
and chicken issue, we need to prepare the global lock ahead before any
locking can be used.  So the global lock's PV list is established in
lvmlockd daemon by iterating all drives with partition labeled with
"propeller".

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agolib: locking: Add new type "idm"
Leo Yan [Fri, 7 May 2021 02:25:14 +0000 (10:25 +0800)]
lib: locking: Add new type "idm"

We can consider the drive firmware a server to handle the locking
request from nodes, this essentially is a client-server model.
DLM uses the kernel as a central place to manage locks, so it also
complies with client-server model for locking operations.  This is
why IDM and DLM are similar with each other for their wrappers.

This patch largely works by generalizing the DLM code paths and then
providing degeneralized functions as wrappers for both IDM and DLM.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agolvmlockd: idm: Hook Seagate IDM wrapper APIs
Leo Yan [Fri, 7 May 2021 02:25:13 +0000 (10:25 +0800)]
lvmlockd: idm: Hook Seagate IDM wrapper APIs

To allow the IDM locking scheme be used by users, this patch hooks the
IDM wrapper; it also introducs a new locking type "idm" and we can use
it for global lock with option '-g idm'.

To support IDM locking type, the main change in the data structure is to
add pvs path arrary.  The pvs list is transferred from the lvm commands,
when lvmlockd core layer receives message, it extracts the message with
the keyword "path[idx]".  Finally, the pv list will pass to IDM lock
manager as the target drives for sending IDM SCSI commands.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agolvmlockd: idm: Introduce new locking scheme
Leo Yan [Fri, 7 May 2021 02:25:12 +0000 (10:25 +0800)]
lvmlockd: idm: Introduce new locking scheme

Alongside the existed locking schemes of DLM and sanlock, this patch is
to introduce new locking scheme: In-Drive-Mutex (IDM).

With the IDM support in the drive, the locks are resident in the drive,
thus, the locking lease is maintained in a central place: the drive
firmware.  We can consider this is a typical client-server model,
every host (or node) in the server cluster launches the request for
leasing mutex to a drive firmware, the drive firmware works as an
arbitrator to grant the mutex to a requester and it can reject other
applicants if the mutex has been acquired.  To satisfy the LVM
activation for different modes, IDM supports two locking modes:
exclusive and shareable.

Every IDM is identified with two IDs, one is the host ID and another is
the resource ID.  The resource ID is a unique identifier for what the
resource it's protected, in the integration with lvmlockd, the resource
ID is combined with VG's UUID and LV's UUID; for the global locking,
the bytes in resource ID are all zeros, and for the VG locking, the
LV's UUID is set as zero.   Every host can generate a random UUID and
use it as the host ID for the SCSI command, this ID is used to clarify
the ownership for mutex.

For easily invoking the IDM commands to drive, like other locking
scheme (e.g. sanlock), a daemon program named IDM lock manager is
created, so the detailed IDM SCSI commands are encapsulated in the
daemon, and lvmlockd uses the wrapper APIs to communicate with the
daemon program.

This patch introduces the IDM locking wrapper layer, it forwards the
locking requests from lvmlockd to the IDM lock manager, and returns the
result from drives' responding.

One thing should be mentioned is the IDM's LVB.  IDM supports LVB to max
7 bytes when stores into the drive, the most significant byte of 8 bytes
is reserved for control bits.  For this reason, the patch maps the
timestamp in macrosecond unit with its cached LVB, essentially, if any
timestamp was updated by other nodes, that means the local LVB is
invalidate.  When the timestamp is stored into drive's LVB, it's
possbile to cause time-going-backwards issue, which is introduced by the
time precision or missing synchronization acrossing over multiple nodes.
So the IDM wrapper fixes up the timestamp by increment 1 to the latest
value and write back into drive.

Currently LVB is used to track VG changes and its purpose is to notify
lvmetad cache invalidation when detects any metadata has been altered;
but lvmetad is not used anymore for caching metadata, LVB doesn't
really work.  It's possible that the LVB functionality could be useful
again in the future, so let's enable it for IDM in the first place.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
3 years agopost-release
Marian Csontos [Fri, 7 May 2021 20:36:56 +0000 (22:36 +0200)]
post-release

3 years agopre-release v2_03_12
Marian Csontos [Fri, 7 May 2021 20:34:45 +0000 (22:34 +0200)]
pre-release

3 years agomake: generate
Marian Csontos [Fri, 7 May 2021 15:44:43 +0000 (17:44 +0200)]
make: generate

3 years agotests: add lvextend-caches-on-thindata
David Teigland [Thu, 6 May 2021 20:59:37 +0000 (15:59 -0500)]
tests: add lvextend-caches-on-thindata

to test lvextend of thin pool data while it has
cache|writecache attached

3 years agowritecache: allow attaching to thin pool data
David Teigland [Thu, 6 May 2021 21:18:50 +0000 (16:18 -0500)]
writecache: allow attaching to thin pool data

3 years agotests: new lvextend-caches
David Teigland [Thu, 6 May 2021 19:43:10 +0000 (14:43 -0500)]
tests: new lvextend-caches

to test lvextend of LVs with attached cache|writecache

3 years agoblkid: simplify fs block size check
David Teigland [Wed, 5 May 2021 21:15:10 +0000 (16:15 -0500)]
blkid: simplify fs block size check

Only the LV path name is needed for blkid query,
the step of getting a dev struct is not needed.

3 years agodevices file: recommend removing filter
David Teigland [Wed, 5 May 2021 18:59:42 +0000 (13:59 -0500)]
devices file: recommend removing filter

When the devices file is enabled and the filter is set,
recommand that the user remove the filter from lvm.conf
since it's ignored.

3 years agopvremove: use consistent error message
David Teigland [Tue, 4 May 2021 18:03:25 +0000 (13:03 -0500)]
pvremove: use consistent error message

When the device is not a PV print
  "No PV found on device ..."

instead of
  "Failed to read lvm info for ... PVID ."

an earlier check had been added with a different
message for the same condition.

3 years agolabel_read_pvid: separate error and no-pvid
David Teigland [Fri, 23 Apr 2021 22:32:37 +0000 (17:32 -0500)]
label_read_pvid: separate error and no-pvid

error reading dev and no pvid on dev were both
returning 0.  make it easier for callers to
know which, if they care.

return 1 if the device could be read, regardless
of whether a pvid was found or not.
set has_pvid=1 if a pvid is found and 0 if no
pvid is found.

3 years agoRevert "cov: check label_read_pvid return value"
David Teigland [Fri, 23 Apr 2021 22:12:24 +0000 (17:12 -0500)]
Revert "cov: check label_read_pvid return value"

This reverts commit bf461b99c6d26e550835b77eaffe2204cbc9bed3.

label_read_pvid returns 0 for non-PVs and these callers want
to handle non-PVs.

3 years agomake: generate
Zdenek Kabelac [Thu, 22 Apr 2021 09:28:56 +0000 (11:28 +0200)]
make: generate

3 years agotests: use should for expected state
Zdenek Kabelac [Thu, 22 Apr 2021 16:28:50 +0000 (18:28 +0200)]
tests: use should for expected state

While we heavily try to spot arrays that are not yet in-sync,
some kernels tends to block our lvm2 command in kernel,
while we resume these smaller raid arrays even for 5 seconds.

But since the result is not really wrong - report these
check failures only as TEST WARNING.

3 years agocleanup: indent
Zdenek Kabelac [Fri, 23 Apr 2021 17:45:34 +0000 (19:45 +0200)]
cleanup: indent

3 years agomakefiles: add target for man-generator
Zdenek Kabelac [Fri, 23 Apr 2021 11:49:52 +0000 (13:49 +0200)]
makefiles: add target for man-generator

Add supporting target for recreating man-generator when dependencies needs it.

3 years agoman: add some resizing examples
Zdenek Kabelac [Fri, 23 Apr 2021 10:53:14 +0000 (12:53 +0200)]
man: add some resizing examples

Add some examples with -l% usage.

3 years agoman: add missing _iorig suffix
Zdenek Kabelac [Thu, 22 Apr 2021 10:37:18 +0000 (12:37 +0200)]
man: add missing _iorig suffix

3 years agoman: document fsadm -l option
Zdenek Kabelac [Thu, 22 Apr 2021 09:09:05 +0000 (11:09 +0200)]
man: document fsadm -l option

Missed -l option in man page, although users should prefer
lvresize -r when the also want to do a volume management,
as there they can specify i.e. extents for allocation.
Also mention dm-crypt support in command description.

3 years agoargs.h: bold command refference
Zdenek Kabelac [Fri, 23 Apr 2021 20:45:20 +0000 (22:45 +0200)]
args.h: bold command refference

3 years agoshellcheck: updates
Zdenek Kabelac [Thu, 22 Apr 2021 21:22:01 +0000 (23:22 +0200)]
shellcheck: updates

Ehance some shellcheck reported issues.

3 years agoclang: remove unused assignment
Zdenek Kabelac [Fri, 23 Apr 2021 15:27:44 +0000 (17:27 +0200)]
clang: remove unused assignment

3 years agoclang: ensure vg is defined
Zdenek Kabelac [Thu, 22 Apr 2021 20:42:54 +0000 (22:42 +0200)]
clang: ensure vg is defined

3 years agoclang: avoid possible use-after-free
Zdenek Kabelac [Thu, 22 Apr 2021 20:08:57 +0000 (22:08 +0200)]
clang: avoid possible use-after-free

If the 'act' has been already processed by add_client_result()
it could have been possibly release - so avoid accessin 'act->'
afterward and go for next item directly.

3 years agoclang: always initialized values
Zdenek Kabelac [Thu, 22 Apr 2021 19:49:30 +0000 (21:49 +0200)]
clang: always initialized values

3 years agocov: convert to code that analyzer may better understand
Zdenek Kabelac [Thu, 22 Apr 2021 13:06:48 +0000 (15:06 +0200)]
cov: convert to code that analyzer may better understand

Switch to code that is problematic to analyzer

3 years agocov: use correct enum type
Zdenek Kabelac [Thu, 22 Apr 2021 15:31:17 +0000 (17:31 +0200)]
cov: use correct enum type

Correct function declaration.

3 years agocov: explicitely ignore return value
Zdenek Kabelac [Thu, 22 Apr 2021 14:49:34 +0000 (16:49 +0200)]
cov: explicitely ignore return value

3 years agocov: check return value
Zdenek Kabelac [Thu, 22 Apr 2021 15:00:45 +0000 (17:00 +0200)]
cov: check return value

Log problems on fail path.

3 years agocov: fix typo and reduce stack usage
Zdenek Kabelac [Thu, 22 Apr 2021 13:27:58 +0000 (15:27 +0200)]
cov: fix typo and reduce stack usage

Buffer on stack was for single LV name plus some  short text around.
Use of 50* was a typo so use correly 50+.

This page took 0.087564 seconds and 5 git commands to generate.