]> sourceware.org Git - lvm2.git/log
lvm2.git
2 years agodev_manager: do not query for open_count
Zdenek Kabelac [Fri, 11 Feb 2022 22:55:08 +0000 (23:55 +0100)]
dev_manager: do not query for open_count

Oepn count is not used along this code path.

2 years agoclang: possible better compilation with musl c
Zdenek Kabelac [Tue, 15 Feb 2022 23:48:49 +0000 (00:48 +0100)]
clang: possible better compilation with musl c

Try to help resolving reported compilation problem with
clang & musl C.
https://github.com/lvmteam/lvm2/issues/61

2 years agoclang: add extra check
Zdenek Kabelac [Tue, 8 Feb 2022 18:17:30 +0000 (19:17 +0100)]
clang: add extra check

Make clang happier.

2 years agodev_manager: failing status is not internal error
Zdenek Kabelac [Tue, 15 Feb 2022 20:16:10 +0000 (21:16 +0100)]
dev_manager: failing status is not internal error

Different target type for LV it's not an internal error.
i.e.  when target type is replaced with 'error' type - it should be
reported as regular warning and not cause interruption of command with
internall error.

2 years agodev_manager: fix dm_task_get_device_list
Zdenek Kabelac [Tue, 15 Feb 2022 23:33:25 +0000 (00:33 +0100)]
dev_manager: fix dm_task_get_device_list

With very old version of DM target driver we have to avoid
trying to use newuuid setting - otherwise we get error
during ioctl preparation phase.

Patch is fixing regression from commit:
988ea0e94c79a496f2619eab878fd9db6168711d

2 years agotests: skip vgchange-pvs-online.sh on rhel5
David Teigland [Tue, 15 Feb 2022 21:56:01 +0000 (15:56 -0600)]
tests: skip vgchange-pvs-online.sh on rhel5

the /dev/mapper/ paths to test devices don't seem to work there

2 years agodevices file: do not clear PVID of unread devices
David Teigland [Thu, 10 Feb 2022 20:00:25 +0000 (14:00 -0600)]
devices file: do not clear PVID of unread devices

In a certain disconnected state, a block device is present on
the system, can be opened, reports a valid size, reports the
correct device id (wwid), and matches a devices file entry.
But, reading the device can still fail.  In this case,
device_ids_validate() was misinterpreting the read error as
the device having no data/label on it (and no PVID).
The validate function would then clear the PVID from the
devices file entry for the device, thinking that it was
fixing the devices file (making it consistent with the on disk
state.)  Fix this by not attempting to check and correct a
devices file entry that cannot be read.  Also make this case
explicit in the hints validation code (which was doing the
right thing but indirectly.)

2 years agotests: udev-pvscan-vgchange fix service wait
David Teigland [Mon, 7 Feb 2022 22:44:57 +0000 (16:44 -0600)]
tests: udev-pvscan-vgchange fix service wait

As a result of removing -r from systemd-run in
commit fbd8b0cf43dc67f51f86f060dce748f446985855
this test needs to change how it handles the
transient services.

2 years agomake: generate
Zdenek Kabelac [Sun, 6 Feb 2022 19:05:54 +0000 (20:05 +0100)]
make: generate

2 years agoasan: fix some reports from libasan
Zdenek Kabelac [Mon, 7 Feb 2022 18:58:04 +0000 (19:58 +0100)]
asan: fix some reports from libasan

When compiled and used with:

CFLAGS="-fsanitize=address -g -O0"
ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1

we have few reported issue - they where not normally spotted, since
we were still accessing our own memory - but ouf of buffer-range.

TODO: there is still something to enhance with handling of #orphan vgids

2 years agopost-release
Marian Csontos [Mon, 7 Feb 2022 17:02:07 +0000 (18:02 +0100)]
post-release

2 years agopre-release v2_03_15
Marian Csontos [Mon, 7 Feb 2022 17:00:54 +0000 (18:00 +0100)]
pre-release

2 years agotests: devicesfile-edit
David Teigland [Thu, 3 Feb 2022 22:58:12 +0000 (16:58 -0600)]
tests: devicesfile-edit

test lvmdevices add/del

2 years agolvmdevices: make deldev work for missing device
David Teigland [Thu, 3 Feb 2022 22:56:03 +0000 (16:56 -0600)]
lvmdevices: make deldev work for missing device

2 years agowritecache: look for settings in lvm.conf
David Teigland [Mon, 31 Jan 2022 22:12:24 +0000 (16:12 -0600)]
writecache: look for settings in lvm.conf

Restore the lvm.conf cache_settings for writecache
added by c6639056e0bb2fc5f072b2c0d6bb629ad17eee6e.
Shorter method reduces and isolates the complexity
of config trees.

2 years agoRevert "writecache: handle options from lvm.conf"
David Teigland [Mon, 31 Jan 2022 21:18:46 +0000 (15:18 -0600)]
Revert "writecache: handle options from lvm.conf"

This reverts commit c6639056e0bb2fc5f072b2c0d6bb629ad17eee6e.

Next commit restores this feature.

2 years agotests: skip test part when missed in kernel
Zdenek Kabelac [Mon, 31 Jan 2022 14:11:47 +0000 (15:11 +0100)]
tests: skip test part when missed in kernel

2 years agoactivation: use lv_is_active
Zdenek Kabelac [Sun, 30 Jan 2022 14:30:48 +0000 (15:30 +0100)]
activation: use lv_is_active

Use existing lv_is_active

2 years agotools: missing sync after deactivation
Zdenek Kabelac [Fri, 28 Jan 2022 16:42:04 +0000 (17:42 +0100)]
tools: missing sync after deactivation

Caching of DM states optimisation revealed some missing
synchronisation points.

2 years agoudev: create symlinks and watch even in suspended state
Martin Wilck [Fri, 28 Jan 2022 13:42:29 +0000 (14:42 +0100)]
udev: create symlinks and watch even in suspended state

If a dm device is suspended, we can't run blkid on it. But earlier
rules (e.g. 11-dm-parts.rules) might have imported previously scanned
properties from the udev db, in particular if the device had been correctly
set up beforehand (DM_UDEV_PRIMARY_SOURCE_FLAG==1). Symlinks for existing
ID_FS_xyz properties must be preserved in this case. Otherwise lower-priority
devices (such as multipath components) might take over the symlink
temporarily.

Likewise, we should't stop watching a temporarily suspended, but previously
correctly configured dm device.

Signed-off-by: Martin Wilck <mwilck@suse.com>
2 years agoremove static autoactivation
David Teigland [Tue, 25 Jan 2022 22:05:32 +0000 (16:05 -0600)]
remove static autoactivation

event based autoactivation is now the only method that lvm
provides for autoactivation.

Setting lvm.conf event_activation=0 can still be used to disable
event based autoactivation commands, but doing so will no longer
enable static autoactivation.

2 years agotest: remove leaked exit
Zdenek Kabelac [Wed, 26 Jan 2022 14:32:30 +0000 (15:32 +0100)]
test: remove leaked exit

2 years agogcc: increate buffer sizes
Zdenek Kabelac [Thu, 20 Jan 2022 14:27:29 +0000 (15:27 +0100)]
gcc: increate buffer sizes

Make all possible string buffers to fit so they are not shortened in the
middle.

2 years agogcc: snprintf may need here upto 18 bytes
Zdenek Kabelac [Thu, 20 Jan 2022 14:24:09 +0000 (15:24 +0100)]
gcc: snprintf may need here upto 18 bytes

Although hypothetical case....

2 years agolvcreate: code move
Zdenek Kabelac [Tue, 18 Jan 2022 16:33:53 +0000 (17:33 +0100)]
lvcreate: code move

2 years agotest: check writecache profile support
Zdenek Kabelac [Mon, 24 Jan 2022 13:49:53 +0000 (14:49 +0100)]
test: check writecache profile support

FIXME

2 years agoman: doc writecache profile support
Zdenek Kabelac [Mon, 24 Jan 2022 13:50:09 +0000 (14:50 +0100)]
man: doc writecache profile support

2 years agolvcreate: cachesettings works also with writecache
Zdenek Kabelac [Tue, 18 Jan 2022 18:06:21 +0000 (19:06 +0100)]
lvcreate: cachesettings works also with writecache

2 years agolvcreate: fix crash for unspecified LV name for writecache
Zdenek Kabelac [Thu, 20 Jan 2022 15:01:17 +0000 (16:01 +0100)]
lvcreate: fix crash for unspecified LV name for writecache

Fix aplication crash when creating writecached LV with 'automatic' name.

2 years agowritecache: handle options from lvm.conf
Zdenek Kabelac [Thu, 20 Jan 2022 14:36:14 +0000 (15:36 +0100)]
writecache: handle options from lvm.conf

User can place default settings into lvm.conf i.e.:

allocation {
cache_settings {
writecache {
block_size = 4096
}
}
}

2 years agolvmdevices: fix checks when adding entries
David Teigland [Tue, 25 Jan 2022 17:35:36 +0000 (11:35 -0600)]
lvmdevices: fix checks when adding entries

Removes some incorrect and unnecessary checks for other entries
when adding a new devices.  The removed checks and corrections were
mostly redundant with what is already done by device id matching.
Other checking is reworked so the warnings are a bit different.

2 years agodevice_id: fix search for renamed device when the wwid is ignored
David Teigland [Tue, 25 Jan 2022 16:47:50 +0000 (10:47 -0600)]
device_id: fix search for renamed device when the wwid is ignored

When a device has a wwid (from sysfs), but lvm ignores the wwid,
e.g. because it contains an unreliable "QEMU" value, then lvm
falls back to using IDTYPE=devname (the device name) as the
device id.  If the device name changes after reboot, then lvm
automatically searches for the PV on other devices to find the
new device name and correct system.devices.  When searching for
the PV, lvm skips looking at devices that would use other id types,
e.g. if a device would use a wwid and not a devname, then it
skips checking it.  However, it failed to account for the fact
that a device may have wwid that was ignored, in which case it
should be checked.

2 years agoRevert "pvcreate: overwrite partition header with -f"
David Teigland [Tue, 18 Jan 2022 18:15:03 +0000 (12:15 -0600)]
Revert "pvcreate: overwrite partition header with -f"

This reverts commit d5a950ca67c106403054ecb847e226e8b5a7c30e.

This commit did not properly recognize GPT cases.

2 years agolvmdevices check: error exit if update is needed
David Teigland [Thu, 13 Jan 2022 20:52:54 +0000 (14:52 -0600)]
lvmdevices check: error exit if update is needed

. error exit means that lvmdevices --update would make a change.

. remove check of PART field from --check because it isn't used.

. unlink searched_devnames file to ensure check|update will search

2 years agopvcreate: overwrite partition header with -f
David Teigland [Wed, 8 Sep 2021 21:30:11 +0000 (16:30 -0500)]
pvcreate: overwrite partition header with -f

$ pvcreate /dev/sdc
  Cannot use /dev/sdc: device is partitioned
$ pvcreate -f /dev/sdc
  Physical volume "/dev/sdc" successfully created.

2 years agoremove unused variable
David Teigland [Thu, 13 Jan 2022 17:41:09 +0000 (11:41 -0600)]
remove unused variable

resulting from commit cb798ee1c102aadde93965a894c5aa59d4e76e4a
  "lvmcache: remove lvmcache_update_vg_from_write"

2 years agohandle duplicate vgids
David Teigland [Thu, 6 Jan 2022 16:15:16 +0000 (10:15 -0600)]
handle duplicate vgids

The approach to duplicate VGIDs has been that it is not possible
or not allowed, so the behavior has been undefined.  The actual
result was unpredictable and/or broken, and generally unhelpful.

Improve this by recognizing the problem, displaying the VGs,
and printing a warning to fix the problem.  Beyond this,
using VGs with duplicate VGIDs remains undefined, but should
work well enough to correct the problem with vgchange -u.

It's possible to create this condition without too much difficulty
by cloning PVs, followed by an incomplete attempt at making the two
VGs unique (vgrename and pvchange -u, but missing vgchange -u.)

2 years agolvmcache: remove lvmcache_update_vg_from_write
David Teigland [Wed, 12 Jan 2022 22:46:26 +0000 (16:46 -0600)]
lvmcache: remove lvmcache_update_vg_from_write

After a vg_write, this function was used to attempt to
make lvmcache data match the new state written to disk.
It was not updated correctly in a many or most cases,
and the resulting lvmcache is not actually used after
vg_write, making the update unnecessary.

2 years agovgsplit: don't reread vg_to
David Teigland [Wed, 12 Jan 2022 22:42:01 +0000 (16:42 -0600)]
vgsplit: don't reread vg_to

The destination vg is first written with the EXPORTED flag,
then the source vg is written, then the destination vg is
written again without the EXPORTED flag.  Remove an unnecessary
vg_read of the destination vg just before the second write.

2 years agoRevert "handle duplicate vgids"
David Teigland [Tue, 11 Jan 2022 22:03:07 +0000 (16:03 -0600)]
Revert "handle duplicate vgids"

This reverts commit bd2baeaaa67da3885df9f06700565dc201c82861.

This commit broke vgrename because vgrename relies on old bugs
in lvmcache_update_vg_from_write and lvmcache_update_vgname
which need to be fixed first.

2 years agohandle duplicate vgids
David Teigland [Thu, 6 Jan 2022 16:15:16 +0000 (10:15 -0600)]
handle duplicate vgids

The approach to duplicate VGIDs has been that it is not possible
or not allowed, so the behavior has been undefined.  The actual
result was unpredictable and/or broken, and generally unhelpful.

Improve this by recognizing the problem, displaying the VGs,
and printing a warning to fix the problem.  Beyond this,
using VGs with duplicate VGIDs remains undefined, but should
work well enough to correct the problem with vgchange -u.

It's possible to create this condition without too much difficulty
by cloning PVs, followed by an incomplete attempt at making the two
VGs unique (vgrename and pvchange -u, but missing vgchange -u.)

2 years agolvmlockd: cleanup after sanlock_rem_lockspace error
David Teigland [Tue, 4 Jan 2022 20:47:31 +0000 (14:47 -0600)]
lvmlockd: cleanup after sanlock_rem_lockspace error

When storage is lost under a sanlock VG, and kill_vg/drop_vg
are used, sanlock_rem_lockspace() may return an error, but
the cleanup steps should still be performed.  Without the
cleanup, gl_lsname_sanlock was not cleared.  This caused
future lock requests to fail with ENOLS, but the NO_GL_LS
flag was not set due to gl_lsname_sanlock being set.
This caused lockd_global(sh) in lvm commands to fail when
they could succeed.

Fix from guozhonghua216

2 years agolabel: cache dm device list
Zdenek Kabelac [Wed, 15 Dec 2021 10:45:22 +0000 (11:45 +0100)]
label: cache dm device list

Since we check for present DM devices - cache result for
futher use of checking presence of such device.

lvm2 uses cache result for label scan, but also when
it tries to activate or deactivate LV - however only simple
target 'striped' is reasonably supported.

Use disable_dm_devs to be able to control when lv_info()
get cache or uncached results.

TODO: support more type, however this is getting very complicated.

2 years agoactivate: add get_device_list
Zdenek Kabelac [Wed, 15 Dec 2021 10:24:31 +0000 (11:24 +0100)]
activate: add get_device_list

Add funtion get_device_list() to get list of active DM devices.
Handled through new dm_task_get_device_list().

2 years agodevicemapper: add dm_task_get_device_list
Zdenek Kabelac [Wed, 15 Dec 2021 10:34:50 +0000 (11:34 +0100)]
devicemapper: add dm_task_get_device_list

New API extension (internal ATM) for getting a list
of active DM device with extra features like i.e. uuid.

To easily lookout for existing UUID in device list,
there is: dm_device_list_find_by_uuid()

Once the returned structure is no longer usable call:
dm_device_list_destroy()

Struct dm_active_device {} holds all the info,
but is always allocated and destroyed within library.

TODO: once it's stable, copy to libdm

2 years agolibdm: unmangling UUID for DM_DEVICE_LIST
Zdenek Kabelac [Wed, 8 Dec 2021 09:45:13 +0000 (10:45 +0100)]
libdm: unmangling UUID for DM_DEVICE_LIST

Properly unmangle UUID if they are provided as result
of DM_DEVICE_LIST ioctl on newer linux kernels.

2 years agoactivate: device_is_usable
Zdenek Kabelac [Wed, 15 Dec 2021 10:26:21 +0000 (11:26 +0100)]
activate: device_is_usable

Move checking of usable uuid into separate function
and pass in also cmd context.

2 years agolvmcmdline: comment reset of configuration settings
Zdenek Kabelac [Fri, 17 Dec 2021 15:41:54 +0000 (16:41 +0100)]
lvmcmdline: comment reset of configuration settings

We used to reset 'settings' to their defaults after command is finished.
This however has a drawback we lose all the logging after this point.

So this patch disables this 'reset' to observe for side-effects.

lvm shell should be getting reset when next command is run -
so this might or might not have some 'hidden' effects.

ATM it looks like nothing really bad should happen - we just should be
able to get more logs - at least from normal commands.

2 years agolibdm: correct version check
Zdenek Kabelac [Wed, 8 Dec 2021 09:56:21 +0000 (10:56 +0100)]
libdm: correct version check

If there ever would be API version 5,
these check would give incorrect results.

2 years agoactivate: cache driver_version result
Zdenek Kabelac [Wed, 8 Dec 2021 09:25:02 +0000 (10:25 +0100)]
activate: cache driver_version result

2 years agotoolcontext: reuse destroy_config_context
Zdenek Kabelac [Fri, 10 Dec 2021 19:51:46 +0000 (20:51 +0100)]
toolcontext: reuse destroy_config_context

Call existing destroy_config_context() to destroy
some parts of cmd_context.

2 years agohash: raise hash table size
Zdenek Kabelac [Fri, 17 Dec 2021 15:36:36 +0000 (16:36 +0100)]
hash: raise hash table size

With slightly bigger hash tables, there is considerable
less hash collisions.

2 years agotoollib: avoid repeated remove of online vg
Zdenek Kabelac [Fri, 17 Dec 2021 12:18:56 +0000 (13:18 +0100)]
toollib: avoid repeated remove of online vg

Call just once unlink after every deactivation of LV from VG.

2 years agovdo: ensure VDO config is removed
Andrew Walsh [Mon, 15 Nov 2021 15:49:06 +0000 (10:49 -0500)]
vdo: ensure VDO config is removed

Make sure to remove the VDO config after conversion
of LVM-backed VDO.

Addresses point 3 in rhbz#1987024#c5

2 years agoman lvmautoactivation: replace systemctl with journalctl
David Teigland [Tue, 14 Dec 2021 18:02:08 +0000 (12:02 -0600)]
man lvmautoactivation: replace systemctl with journalctl

2 years agoudev: remove -r from systemd-run
David Teigland [Tue, 14 Dec 2021 17:57:13 +0000 (11:57 -0600)]
udev: remove -r from systemd-run

If the transient service remains after it's done, then
it prevents the same transient service from being run
again later if the PVs are detached and reattached
(although the behavior of a second autoactivation is not
well defined and may only work in limited cases.)

2 years agodevices: recognise rbd (ceph rados block device)
наб [Mon, 13 Dec 2021 19:32:06 +0000 (13:32 -0600)]
devices: recognise rbd (ceph rados block device)

Description stolen from linux d/b/rbd.c L3:
  rbd.c -- Export ceph rados objects as a Linux block device

16 partitions seem to make sense according to L90:
  #define RBD_SINGLE_MAJOR_PART_SHIFT 4

Running *scan -vvvvvvdddddd yields
  #filters/filter-type.c:28            /dev/rbd1p5: Skipping: Unrecognised LVM device type 252
  #filters/filter-persistent.c:131           filter caching bad /dev/rbd1p5
right now, and adding
  types = ["rbd", 252]
to /e/l/lvm.conf (with the matching "252 rbd" in /p/devices) works as a
per-machine fix:
  rbd1               252:16   0      1T  1 disk
  |-rbd1p1           252:17   0    243M  1 part
  |-rbd1p2           252:18   0      1K  1 part
  `-rbd1p5           252:21   0 1023.8G  1 part
    `-dev01--vg-root 253:0    0 1023.8G  0 lvm
but rbd is supported by upstream so it'd be nice to have it work OOB

2 years agolvcreate: include recent options
David Teigland [Mon, 13 Dec 2021 14:59:31 +0000 (08:59 -0600)]
lvcreate: include recent options

The permitted option list in lvcreate has not kept
up with command-lines.in.

2 years agoman: add section about static autoactivation
David Teigland [Mon, 6 Dec 2021 19:20:32 +0000 (13:20 -0600)]
man: add section about static autoactivation

2 years agodevice_id: handle wwid with spaces or control characters
David Teigland [Thu, 2 Dec 2021 19:30:36 +0000 (13:30 -0600)]
device_id: handle wwid with spaces or control characters

non-standard wwid can be reported from sysfs with spaces/etc.
replace with "_"

2 years agoprint warning about unrecognized journal option value
David Teigland [Thu, 2 Dec 2021 18:40:52 +0000 (12:40 -0600)]
print warning about unrecognized journal option value

2 years agopvscan: fix error message for invalid devname
David Teigland [Wed, 1 Dec 2021 20:36:40 +0000 (14:36 -0600)]
pvscan: fix error message for invalid devname

uninitialized name buffer used in message.
fixes "pvs_online: include devname in pvid files"

2 years agopvscan: fix filter symlink checks
David Teigland [Wed, 1 Dec 2021 19:40:09 +0000 (13:40 -0600)]
pvscan: fix filter symlink checks

Fixes commit "pvscan: match device arg to filter symlink"
which failed to account for the fact that filter entries
are not just path names but include "a" or "r", etc.

2 years agodevices file: don't write in test mode
David Teigland [Wed, 1 Dec 2021 16:08:08 +0000 (10:08 -0600)]
devices file: don't write in test mode

2 years agotests devicesfile-devname.sh drop mdadm chunk
David Teigland [Wed, 1 Dec 2021 14:56:05 +0000 (08:56 -0600)]
tests devicesfile-devname.sh drop mdadm chunk

2 years agospec: Add lvmautoactivation man page
Marian Csontos [Wed, 1 Dec 2021 14:35:40 +0000 (15:35 +0100)]
spec: Add lvmautoactivation man page

2 years agopvscan: limit md device_hint for slow autoactivation
David Teigland [Tue, 30 Nov 2021 15:06:08 +0000 (09:06 -0600)]
pvscan: limit md device_hint for slow autoactivation

The device_hint name in the metadata was meant to prevent
autoactivation from md components, but the name checks were
more general and would catch unnecessary cases.

2 years agopvscan: match device arg to filter symlink
David Teigland [Mon, 29 Nov 2021 23:13:44 +0000 (17:13 -0600)]
pvscan: match device arg to filter symlink

This fixes an issue related to the optimization in
  "pvscan: only add device args to dev cache"

If the devices file is not used, and the lvm.conf filter
accepts devices via symlink names, then those devices won't
be accepted by pvscan for autoactivation.  To resolve this,
recognize when the filter contains symlinks and disable the
optimization.  When the optimization is disabled, a full
dev_cache_scan is performed, and symlinks are associated
with the device names passed to pvscan.  filter-regex
will accept a device if symlinks to that device are accepted.

2 years agoman: lvmautoactivation
David Teigland [Wed, 24 Nov 2021 22:03:39 +0000 (16:03 -0600)]
man: lvmautoactivation

new topical man page describing autoactivation

2 years agodevices: exclude md components when duplicate pvs are seen
David Teigland [Mon, 22 Nov 2021 21:10:43 +0000 (15:10 -0600)]
devices: exclude md components when duplicate pvs are seen

Improve handling of md components that get through the
filter, like the previous improvement for multipath.
If md components get through the filter and trigger
duplicate PV code, then eliminate any devs entirely
that are not an md device.

2 years agofix spelling of pruning
David Teigland [Fri, 19 Nov 2021 18:02:35 +0000 (12:02 -0600)]
fix spelling of pruning

2 years agodevices: exclude multipath components based on matching wwid
David Teigland [Wed, 17 Nov 2021 23:10:45 +0000 (17:10 -0600)]
devices: exclude multipath components based on matching wwid

If multipath component devices get through the filter and
cause lvm to see duplicate PVs, then check the wwid of the
devs and drop the component devices as if they had been
filtered.  If a dm mpath device was found among the duplicates
then use that as the PV, otherwise do not use any of the
components as the PV.

"duplicate PVs" associated with multipath configs will no
longer stop commands from working.

2 years agodisplay: ignore --reportformat
David Teigland [Wed, 17 Nov 2021 16:40:27 +0000 (10:40 -0600)]
display: ignore --reportformat

Using the option would do nothing useful but would
print extraneous braces.

2 years agoRevert "tests devicesfile-devname: remove searched_devnames"
David Teigland [Tue, 16 Nov 2021 20:30:09 +0000 (14:30 -0600)]
Revert "tests devicesfile-devname: remove searched_devnames"

This reverts commit 8e61c0ad6ecad5e0bcee09e44029e39396c1b59a.

The changes from "device_id: searched_devnames improvements"
allow this to work without the external removal.

2 years agotests pv-ext-flags: work with devices file
David Teigland [Tue, 16 Nov 2021 20:21:07 +0000 (14:21 -0600)]
tests pv-ext-flags: work with devices file

2 years agodevice_id: searched_devnames improvements
David Teigland [Tue, 16 Nov 2021 17:26:41 +0000 (11:26 -0600)]
device_id: searched_devnames improvements

Remove the searched_devnames file in a couple more places:
. When hints need refreshing it's possible that a missing
  devices file entry could be found by searching devices
  again.
. When a devices file entry devname is first found to be
  incorrect, a new search for missing entries may be
  useful.

2 years agodevice_id: fix search on filtered device
David Teigland [Tue, 16 Nov 2021 15:29:24 +0000 (09:29 -0600)]
device_id: fix search on filtered device

When devnames are used as device ids and devnames change,
then new devices need to be located for the PVs.  If the old
devname is now used by a filtered device, this was preventing
the code from searching for the new device, so the PV was
reported as missing.

2 years agotests devicesfile-devname: remove searched_devnames
David Teigland [Tue, 16 Nov 2021 00:04:10 +0000 (18:04 -0600)]
tests devicesfile-devname: remove searched_devnames

remove /run/lvm/searched_devnames when preparing each test
in case it has appeared on the system

2 years agovgchange autoactivation: error path cleanup
David Teigland [Fri, 12 Nov 2021 22:46:39 +0000 (16:46 -0600)]
vgchange autoactivation: error path cleanup

If the optimized label scan fails (using online files),
then clear the device state prior to falling back to the
standard label_scan.  This avoids printing output about
unexpected state.

2 years agodevice_id: match different dm device names
David Teigland [Fri, 12 Nov 2021 22:42:51 +0000 (16:42 -0600)]
device_id: match different dm device names

If a devices file entry for a dm device is using the devname
for the device id, then recognize different dm names as matching.

2 years agotests: udev-pvscan-vgchange clear services
David Teigland [Fri, 12 Nov 2021 18:10:26 +0000 (12:10 -0600)]
tests: udev-pvscan-vgchange clear services

2 years agoonline files: fix vgname check
David Teigland [Fri, 12 Nov 2021 17:52:36 +0000 (11:52 -0600)]
online files: fix vgname check

The pvs_online file for a PV will not contain a vgname
if the PV has no metadata, so don't require matching
vgname with the pvs_lookup file.

2 years agopvscan: consistent creation of pvs_lookup file
David Teigland [Fri, 12 Nov 2021 16:06:54 +0000 (10:06 -0600)]
pvscan: consistent creation of pvs_lookup file

Consistently create the pvs_lookup file for VGs with
more than one PV.  Previously the file create would be
skipped if all the PVs happened to already be online.
That led to unpredicatable results in an uncommon case
(when the last PV to come online is the only PV with
metadata.)

2 years agotests vgchange-pvs-online: clean up with devices file
David Teigland [Thu, 11 Nov 2021 22:38:10 +0000 (16:38 -0600)]
tests vgchange-pvs-online: clean up with devices file

changing the dev names resulted in stale devices file
entries that created noise in the output.

2 years agotests: udev-pvscan-vgchange fix wait
David Teigland [Thu, 11 Nov 2021 22:04:24 +0000 (16:04 -0600)]
tests: udev-pvscan-vgchange fix wait

the service now remains after completion

2 years agovgchange autoactivation: lock vg early to avoid second label scan
David Teigland [Wed, 10 Nov 2021 22:43:21 +0000 (16:43 -0600)]
vgchange autoactivation: lock vg early to avoid second label scan

Copy another optimization from pvscan -aay to vgchange -aay.
When using the optimized label scan for only one VG, acquire the
VG lock prior to the scan.  This allows vg_read to then skip the
repeated label scan that normally happens after locking the vg.

2 years agovgchange: move autoactivation setup code
David Teigland [Wed, 10 Nov 2021 20:44:11 +0000 (14:44 -0600)]
vgchange: move autoactivation setup code

into its own function, no functional change.

2 years agofilter-sysfs: support old kernels without sys/dev/block
David Teigland [Tue, 9 Nov 2021 17:54:48 +0000 (11:54 -0600)]
filter-sysfs: support old kernels without sys/dev/block

rhel5 for example doesn't have /sys/dev/block

2 years agopvs_online: include devname in pvid files
David Teigland [Mon, 8 Nov 2021 22:02:48 +0000 (16:02 -0600)]
pvs_online: include devname in pvid files

Include the device name in the /run/lvm/pvs_online/pvid files.
Commands using the pvid file can use the devname to more quickly
find the correct device, vs finding the device using the
major:minor number.  If the devname in the pvid file is missing
or incorrect, fall back to using the devno.

2 years agovgchange -aay: improve unexpected command variations
David Teigland [Mon, 8 Nov 2021 17:30:25 +0000 (11:30 -0600)]
vgchange -aay: improve unexpected command variations

For completeness and consistency, adjust the behavior
for some variations of:

  vgchange -aay --autoactivation event [vgname]

The current standard use is with a VG name arg, and the
command is only called when all pvs_online files exist.
This is the optimal case, in which only pvs_online devs
are read.  This remains the same.

Clean up behaviors for some other unexpected uses of the
command:

. With no VG name arg, the command activates any VGs
  that are complete according to pvs_online.  If no
  pvs_online files exist, it does nothing.

. If a VG name is used but no PVs online files exist for
  the VG, or the PVs online files are incomplete, then
  consider there could be a problem with the pvs_online
  files, and fall back to a full label scan prior to
  attempting the activation.

2 years agovgchange -aay: fall back to dev_cache_scan if optimization fails
David Teigland [Fri, 5 Nov 2021 22:01:34 +0000 (17:01 -0500)]
vgchange -aay: fall back to dev_cache_scan if optimization fails

Part of the optimization to avoid a full dev_cache_scan requires
translating major:minor numbers to a device name.  If this devno
translation fails, then fall back to doing a full dev_cache_scan
which is slower but certain to provide the info.  This preserves
the most important part of the label scanning optimization in the
vgchange aay (avoiding dev_cache_scan is a relatively small part
of the optimized activation compared to label scanning.)

2 years agofix device name from devno for partitions
David Teigland [Fri, 5 Nov 2021 21:21:23 +0000 (16:21 -0500)]
fix device name from devno for partitions

sysfs files for partitions are different from
whole devices and will require more work to translate
to device names.

2 years agovgchange -aay: optimize device list using pvs_online files
David Teigland [Fri, 5 Nov 2021 17:19:35 +0000 (12:19 -0500)]
vgchange -aay: optimize device list using pvs_online files

Port another optimization from pvscan -aay to vgchange -aay:
  "pvscan: only add device args to dev cache"

This optimization avoids doing a full dev_cache_scan, and
instead populates dev-cache with only the devices in the
VG being activated.

This involves shifting the use of pvs_online files from
the hints interface up to the higher level label_scan
interface.  This specialized label_scan is structured
around creating a list of devices from the pvs_online
files.  Previously, a list of all devices was created
first, and then reduced based on the pvs_online files.
The initial step of listing all devices was slow when
thousands of devices are present on the system.

This optimization extends the previous optimization that
used pvs_online files to limit the devices that were
actually scanned (i.e. reading to identify the device):
  "vgchange -aay: optimize device scan using pvs_online files"

2 years agolvm2-pvscan: include --autoactivation event
David Teigland [Thu, 4 Nov 2021 19:14:37 +0000 (14:14 -0500)]
lvm2-pvscan: include --autoactivation event

in the pvscan --cache -aay command so that the use
of the command for event activation is explicit.

2 years agomove code from pvscan.c to online.c
David Teigland [Wed, 3 Nov 2021 21:02:38 +0000 (16:02 -0500)]
move code from pvscan.c to online.c

related to managing files in /run/lvm/pvs_online
and /run/lvm/vgs_online

2 years agovgchange -aay: optimize device scan using pvs_online files
David Teigland [Wed, 3 Nov 2021 17:03:29 +0000 (12:03 -0500)]
vgchange -aay: optimize device scan using pvs_online files

Port the old pvscan -aay scanning optimization to vgchange -aay.
The optimization uses pvs_online files created by pvscan --cache
to derive a list of devices to use when activating a VG.  This
allows autoactivation of a VG to avoid scanning all devices, and
only scan the devices used by the VG itself.  The optimization is
applied internally using the device hints interface.

The new option "--autoactivation event" is given to pvscan and
vgchange commands that are called by event activation.  This
informs the command that it is being used for event activation,
so that it can apply checks and optimizations that are specific
to event activation.  Those include:

- skipping the command if lvm.conf event_activation=0
- checking that a VG is complete before activating it
- using pvs_online files to limit device scanning

2 years agorename pvscan_cache_single to expect_missing_vg_device in cmd
David Teigland [Wed, 3 Nov 2021 14:50:11 +0000 (09:50 -0500)]
rename pvscan_cache_single to expect_missing_vg_device in cmd

2 years agoadd hints interface to the pvs_online file information
David Teigland [Thu, 15 Jul 2021 21:33:50 +0000 (16:33 -0500)]
add hints interface to the pvs_online file information

The information in /run/lvm/pvs_online/<pvid> files can
be used to build a list of devices for a given VG.

The pvscan -aay command has long used this information to
activate a VG while scanning only devices in that VG, which
is an important optimization for autoactivation.

This patch implements the same thing through the existing
device hints interface, so that the optimization can be
applied elsewhere.  A future patch will take advantage of
this optimization in vgchange -aay, which is now used in
place of pvscan -aay for event activation.

2 years agolvmdevices: increase open file limit
David Teigland [Fri, 29 Oct 2021 19:49:36 +0000 (14:49 -0500)]
lvmdevices: increase open file limit

2 years agofilter-sysfs: skip when device id is set
David Teigland [Tue, 2 Nov 2021 20:42:26 +0000 (15:42 -0500)]
filter-sysfs: skip when device id is set

When a device id is set for a device, using an idtype other
than devname, it means that sysfs has been used with the device
to match the device id.  So, checking for a sysfs entry for the
device in filter-sysfs is redundant.  For any other cases not
covered by this (e.g. devname ids), have filter-sysfs simply
stat /sys/dev/block/major:minor to test if the device exists
in sysfs.

The extensive processing done by filter-sysfs init is removed.
It was taking an immense amount of time with many devices, e.g.
. 1024 PVs in 520 VGs
. 520 concurrent vgchange -ay <vgname> commands
. vgchange scans only PVs in the named VG (based on pvs_online
  files from a pending patch)

A large number of the vgchange commands were taking over 1 min,
and nearly half of that time was used by filter-sysfs init.
With this patch, the vgchange commands take about half the time.

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