]> sourceware.org Git - lvm2.git/log
lvm2.git
3 years agoclang: avoid double free on error path
Zdenek Kabelac [Tue, 14 Sep 2021 16:00:22 +0000 (18:00 +0200)]
clang: avoid double free on error path

Error path in _lockd_retrive_vg_pv_list() has not zeroed released path
caussing possible double-free later in the code.

Fix it by using one single function freeing lock_pvs structure.

3 years agolvmdevices: allow deviceidtype with addpvid
David Teigland [Mon, 13 Sep 2021 19:11:07 +0000 (14:11 -0500)]
lvmdevices: allow deviceidtype with addpvid

in addition to using with adddev

3 years agoadd --nohints option
David Teigland [Fri, 10 Sep 2021 20:57:19 +0000 (15:57 -0500)]
add --nohints option

The command will not use the hints file to locate devices for PVs.
It will still do standard hint file invalidation where appropriate.

3 years agocmdlib_lvm2_init: release cmd on failure path
Wu Guanghao [Mon, 30 Aug 2021 07:13:00 +0000 (15:13 +0800)]
cmdlib_lvm2_init: release cmd on failure path

The cmd memory space is allocated by zalloc, and the registration
fails and is not released.

Although this code would be ever triggered just in the case
of some internal (likely compilation) bug.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
3 years agoman-generator: initialize struct stat to avoid MSAN error
Adrian Ratiu [Thu, 9 Sep 2021 14:51:47 +0000 (17:51 +0300)]
man-generator: initialize struct stat to avoid MSAN error

When building lvm2 in Gentoo/ChromeOS with the ASAN memory
sanitizer enabled, man-generator fails with the following
error. Initializing makes the error go away.

* SUMMARY: MemorySanitizer: use-of-uninitialized-value /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3316:6 in _include_description_file
* Exiting
* ASAN error detected:
* ==2548047==WARNING: MemorySanitizer: use-of-uninitialized-value
*     #0 0x558b00ab4730 in _include_description_file /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3316:6
*     #1 0x558b00ab4730 in _print_man /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3426:21
*     #2 0x558b00ab4730 in main /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3570:7
*     #0 0x7fa9b2cbb807 in find_derivation /var/tmp/portage/cross-x86_64-cros-linux-gnu/glibc-2.33-r8/work/glibc-2.33/iconv/gconv_db.c:583:15
*     #1 0x558b00a29559 in ?? ??:0
*
*   Uninitialized value was created by an allocation of 'statbuf.i.i' in the stack frame of function 'main'
*     #0 0x558b00ab1d4d in main /build/amd64-generic/tmp/portage/sys-fs/lvm2-2.02.187-r3/work/LVM2.2.02.187/tools/man-generator.c:3505

3 years agogcc: remove unused vg setting
Zdenek Kabelac [Fri, 10 Sep 2021 21:34:58 +0000 (23:34 +0200)]
gcc: remove unused vg setting

3 years agogcc: remove invalid attribute
Zdenek Kabelac [Thu, 9 Sep 2021 21:17:29 +0000 (23:17 +0200)]
gcc: remove invalid attribute

In this function parameter 'attribute' is used.

3 years agocov: remove unused variable setting
Zdenek Kabelac [Sat, 11 Sep 2021 20:40:31 +0000 (22:40 +0200)]
cov: remove unused variable setting

Since there is no use for &end after strtol, remove it.

3 years agocov: make it aware we need these headers for muslC
Zdenek Kabelac [Thu, 9 Sep 2021 21:06:45 +0000 (23:06 +0200)]
cov: make it aware we need these headers for muslC

3 years agocov: hide false positive warning
Zdenek Kabelac [Fri, 10 Sep 2021 07:58:26 +0000 (09:58 +0200)]
cov: hide false positive warning

Here we have valid use case of strncpy() which just need
to fill precise buffer size - so no explicit \0 on buffer
end is needed.

3 years agocov: add some initializers
Zdenek Kabelac [Fri, 10 Sep 2021 20:32:44 +0000 (22:32 +0200)]
cov: add some initializers

3 years agocov: initilized more struct members
Zdenek Kabelac [Thu, 9 Sep 2021 21:07:40 +0000 (23:07 +0200)]
cov: initilized more struct members

For some hypothetical path, make these vars defined.

3 years agocov: initialize attr
Zdenek Kabelac [Fri, 10 Sep 2021 20:32:26 +0000 (22:32 +0200)]
cov: initialize attr

3 years agocov: keep time calculation ready for 2038
Zdenek Kabelac [Thu, 9 Sep 2021 20:37:36 +0000 (22:37 +0200)]
cov: keep time calculation ready for 2038

Be prepared ;) and keep arithmetic 64bit ready.

3 years agocov: keep 64bit arithmetic
Zdenek Kabelac [Thu, 9 Sep 2021 20:35:11 +0000 (22:35 +0200)]
cov: keep 64bit arithmetic

Highly unlikely this case will ever need 64bit math, but just in case,
keep the expression as 64bit.

3 years agocov: do not try to change passed in argv
Zdenek Kabelac [Fri, 10 Sep 2021 14:04:43 +0000 (16:04 +0200)]
cov: do not try to change passed in argv

It's not a good idea to change passed 'argv[]' and replace it with
pointers to local stack - although in this case we are not using
this argv[] after return from this function.

3 years agocov: fix copy from tmp_name buffer
Zdenek Kabelac [Thu, 9 Sep 2021 20:32:09 +0000 (22:32 +0200)]
cov: fix copy from tmp_name buffer

Mask for strncpy() Coverity report warning would
actually need to copy buffer from 'tmp_name' instead of 'str'.

But replace it directly with single 'strncpy()' again for better readbility,
just mask out the warning reported for this strncpy instance
(so we do not need to put comment fro every call of strcpy_name_len).

3 years agotests: increase size of thin-pool for newer mkfs
Zdenek Kabelac [Sun, 12 Sep 2021 19:20:38 +0000 (21:20 +0200)]
tests: increase size of thin-pool for newer mkfs

Looks like newer version of mkfs.ext4 consumes more 'real' disk space,
when formating virtual volumes - so double the size of thin-pool to
have enough backend chunks for provisioning.

3 years agotests: add test for handling unknown cache settings
Zdenek Kabelac [Mon, 13 Sep 2021 09:57:06 +0000 (11:57 +0200)]
tests: add test for handling unknown cache settings

3 years agolibdm: enhance tracking of activated LVs
Zdenek Kabelac [Sun, 12 Sep 2021 19:15:31 +0000 (21:15 +0200)]
libdm: enhance tracking of activated LVs

Existing mechanism was not able to trace root volume issue.
Simplify the functionality by using simply using activated flag
and trace the dtree in reverse order.

3 years agocache: implement better revert path
Zdenek Kabelac [Sun, 12 Sep 2021 15:44:38 +0000 (17:44 +0200)]
cache: implement better revert path

When cache creation fails on table reload path, implemen more
advanced revert solution, that tries to restore state of LVM
metadata into is look before actual caching started.

3 years agocache: filter out unsupported policy settings
Zdenek Kabelac [Sun, 12 Sep 2021 15:41:53 +0000 (17:41 +0200)]
cache: filter out unsupported policy settings

Loading invalid MQ/SMQ policy settings table line cause immediate
rejection - to prevent such failure, automatically filter valid
settins before it is being uploaded by lvm2.

For invalid setting issue a warnning informing user how to remove
them.

This solution is used to keep running cached LVs that might had
been created in the past with invalid settings that have been actually
unused due to another code bug.

3 years agocache: fix parentheses for migration_threshold
Zdenek Kabelac [Fri, 10 Sep 2021 21:02:09 +0000 (23:02 +0200)]
cache: fix parentheses for migration_threshold

When generating table line for cache target line,
the estimation of added arguments was incorrectly
calculated as the evaluation order of "?" is
made after "+".

However the result was 'masked' by the

Reported-by: Jian Cai jcai19
3 years agofilters: fix memleak on mpath filter destroy
Zdenek Kabelac [Sun, 12 Sep 2021 14:13:27 +0000 (16:13 +0200)]
filters: fix memleak on mpath filter destroy

Missing free() leaks filter structure.

3 years agovdo: prompt with no return failure
Zdenek Kabelac [Fri, 10 Sep 2021 20:39:23 +0000 (22:39 +0200)]
vdo: prompt with no return failure

Exit 1  (failure) when prompt for conversion is answered as 'No'.

3 years agovdo: man page updates
Zdenek Kabelac [Thu, 9 Sep 2021 23:15:01 +0000 (01:15 +0200)]
vdo: man page updates

3 years agovdo: lvm_import_vdo script needs to continue when vgname does not exist
Zdenek Kabelac [Thu, 9 Sep 2021 16:10:13 +0000 (18:10 +0200)]
vdo: lvm_import_vdo script needs to continue when vgname does not exist

When the script cannot find vgname - it needs to continue to run.

3 years agotests: check lvm2 parses vdo statistics
Zdenek Kabelac [Thu, 9 Sep 2021 13:22:20 +0000 (15:22 +0200)]
tests: check lvm2 parses vdo statistics

3 years agovdo: read new sysfs path
Zdenek Kabelac [Thu, 9 Sep 2021 12:59:38 +0000 (14:59 +0200)]
vdo: read new sysfs path

New versions of kvdo module exposes statistics at new location:
/sys/block/dm-XXX/vdo/statistics/...

Enhance lvm2 to access this location first.
Also if the statistic info is missing - make it 'debug' level info,
so it is not failing 'lvs' command.

3 years agovdo: more lvm_import_vdo fixes
Zdenek Kabelac [Mon, 6 Sep 2021 13:06:32 +0000 (15:06 +0200)]
vdo: more lvm_import_vdo fixes

Do not call 'dmsetup info' for non-dm devices.

Better handling for VGNAME and LVNAME - so when convering LV as
backend device automatically recognize it and reuse LV name for VDOLV.

Add prompt for final confirmation before actual conversion is started
(once confirmed, lvm2 commands no longer prompts to avoid leaving
conversion in the middle of its process.)

3 years agovdo: better message for missing device
Zdenek Kabelac [Wed, 1 Sep 2021 13:46:04 +0000 (15:46 +0200)]
vdo: better message for missing device

Show readable message when passed device cannot be accessed.
And use STAT shell var wrapper to call 'stat' command.

3 years agovdo: lvm_import_vdo fix max_discard size
Zdenek Kabelac [Mon, 6 Sep 2021 12:57:43 +0000 (14:57 +0200)]
vdo: lvm_import_vdo fix max_discard size

Use correct 4K units in lvm2 for max_discard VDO option.

3 years agovdo: add support for auto-unsafe writePolicy
Zdenek Kabelac [Mon, 6 Sep 2021 11:56:40 +0000 (13:56 +0200)]
vdo: add support for auto-unsafe writePolicy

This vdoWritePolicy policy missed matching support in lvm2.

3 years agotests: remove all debug logs when using die
Zdenek Kabelac [Mon, 6 Sep 2021 12:59:10 +0000 (14:59 +0200)]
tests: remove all debug logs when using die

Since die is called from a shell script, there is no need
to report any recent lvm2 command debug traces.

3 years agomakefiles: sanitize environment
Zdenek Kabelac [Fri, 3 Sep 2021 17:31:44 +0000 (19:31 +0200)]
makefiles: sanitize environment

Compilation needs to generate 'C' locale sorted command file
definitions. To always enforce 'C' sorting rules user LC_ALL
instead of LANG, as  LANG settings can be overuled by
other LC settings like LC_COLLATE and may result into miscompiled
lvm2 binary if locales ordering differs from 'C'.

Reported-by: jmp-lvm2@ookaze.fr
3 years agovdo: fixes
Zdenek Kabelac [Tue, 31 Aug 2021 18:52:26 +0000 (20:52 +0200)]
vdo: fixes

Better identify VDO device with major:minor.
Handle different LV name from originally converted origin LV.
Improve --dry-run handling.

3 years agovdo: support lvcreate with skipped activation
Zdenek Kabelac [Tue, 31 Aug 2021 19:34:06 +0000 (21:34 +0200)]
vdo: support lvcreate with skipped activation

Support creation of VDO LV for 'lvcreate -ky...'.

3 years agovdo: fix conversion of large virtual sizes
Zdenek Kabelac [Mon, 30 Aug 2021 16:12:59 +0000 (18:12 +0200)]
vdo: fix conversion of large virtual sizes

Properly accept virtual sizes above 2TiB.

3 years agovdo: skip zeroing for VDO LV
Zdenek Kabelac [Thu, 26 Aug 2021 21:04:56 +0000 (23:04 +0200)]
vdo: skip zeroing for VDO LV

Since VDO is always returns 'zero' on unprovisioned read
and every provisioned block is always 'zeroed' on partial writes,
we can avoid 'zeroing' of such LVs.

3 years agocov: lvmlockd read_adopt_file free structs on error path
David Teigland [Mon, 30 Aug 2021 18:48:42 +0000 (13:48 -0500)]
cov: lvmlockd read_adopt_file free structs on error path

3 years agopvremove: apply devices file
David Teigland [Fri, 27 Aug 2021 19:48:33 +0000 (14:48 -0500)]
pvremove: apply devices file

pvremove was wrongly allowed to operate on a device
not listed in the devices file.

3 years agovdo: rename vdoimport to lvm_import_vdo
Zdenek Kabelac [Mon, 23 Aug 2021 12:02:42 +0000 (14:02 +0200)]
vdo: rename vdoimport to lvm_import_vdo

Missed bits in previous rename commits.

3 years agospec: Rename vdoimport to lvm_import_vdo. dev-mcsontos-rename-vdoimport
Marian Csontos [Thu, 26 Aug 2021 14:54:26 +0000 (16:54 +0200)]
spec: Rename vdoimport to lvm_import_vdo.

3 years agovdo: Rename vdoimport to lvm_import_vdo.
Marian Csontos [Thu, 26 Aug 2021 14:53:33 +0000 (16:53 +0200)]
vdo: Rename vdoimport to lvm_import_vdo.

3 years agodevices: restrict device id types to specific major numbers
David Teigland [Mon, 23 Aug 2021 20:01:26 +0000 (15:01 -0500)]
devices: restrict device id types to specific major numbers

Some device id types can only be used with specific device major
numbers, so use this restriction to avoid some comparisions.
This is more efficient, and can avoid some incorrect matches.

3 years agoadd missing sys/file.h include
Alex Xu (Hello71) [Mon, 23 Aug 2021 14:24:45 +0000 (09:24 -0500)]
add missing sys/file.h include

required for LOCK_EX etc on musl

3 years agovgimportclone: fix when duplicates are both in the devices file
David Teigland [Fri, 20 Aug 2021 20:06:33 +0000 (15:06 -0500)]
vgimportclone: fix when duplicates are both in the devices file

Fix case where duplicate PVs are created (e.g. with dd) from
devices that are both already in the devices file.

3 years agodevices file: recognize old locking_type 0
David Teigland [Fri, 20 Aug 2021 15:32:16 +0000 (10:32 -0500)]
devices file: recognize old locking_type 0

if the old locking_type is 0, set cmd->nolocking so that
it will be applied to the devices file lock.

3 years agologging: messages for found metadata
David Teigland [Thu, 19 Aug 2021 20:07:05 +0000 (15:07 -0500)]
logging: messages for found metadata

3 years agodevices: apply ignorelockingfailure to devices file lock
David Teigland [Thu, 19 Aug 2021 17:57:31 +0000 (12:57 -0500)]
devices: apply ignorelockingfailure to devices file lock

3 years agotests: adjust for check_devicesfile
David Teigland [Wed, 18 Aug 2021 21:23:48 +0000 (16:23 -0500)]
tests: adjust for check_devicesfile

3 years agolvmdevices: check yes option for adding duplicate
David Teigland [Wed, 18 Aug 2021 21:26:11 +0000 (16:26 -0500)]
lvmdevices: check yes option for adding duplicate

3 years agocov: clean up pvid and vgid usage
David Teigland [Tue, 3 Aug 2021 20:32:33 +0000 (15:32 -0500)]
cov: clean up pvid and vgid usage

pvid and vgid are sometimes a null-terminated string, and
other times a 'struct id', and the two types were often
cast between each other.  When a struct id was cast to a char
pointer, the resulting string would not necessarily be null
terminated.  Casting a null-terminated string id to a
struct id is fine, but is still avoided when possible.

A struct id is:  int8_t uuid[ID_LEN]
A string id is:  char pvid[ID_LEN + 1]

A convention is introduced to help distinguish them:

- variables and struct fields named "pvid" or "vgid"
  should be null-terminated strings.

- variables and struct fields named "pv_id" or "vg_id"
  should be struct id's.

- examples:
  char pvid[ID_LEN + 1];
  char vgid[ID_LEN + 1];
  struct id pv_id;
  struct id vg_id;

Function names also attempt to follow this convention.

Avoid casting between the two types as much as possible,
with limited exceptions when known to be safe and clearly
commented.

Avoid using variations of strcpy and strcmp, and instead
use memcpy/memcmp with ID_LEN (with similar limited
exceptions possible.)

3 years agocov: lvmlockd: rewrite string copies to avoid warnings
David Teigland [Mon, 2 Aug 2021 22:22:45 +0000 (17:22 -0500)]
cov: lvmlockd: rewrite string copies to avoid warnings

- Use a new function for all instances of copying
  a null-terminated string into a fixed size struct
  field that is not null-terminated.

- use memcpy when copying between struct fields of
  the same size

3 years agolvchange: fix lvchange refresh failed for dm suspend or resume failed
Yi Wang [Fri, 13 Aug 2021 05:49:13 +0000 (13:49 +0800)]
lvchange: fix lvchange refresh failed for dm suspend or resume failed

When multiple lvchange refresh processes executed at the same time,
suspend/resume ioctl on the same dm, some of these commands will be failed
for dm aready change status, and ioctl will return EINVAL in _do_dm_ioctl function.
to avoid this problem, add READ_FOR_ACTIVATE flags in lvchange refresh process,
it will hold LCK_WRITE lock and avoid suspend/resume dm at the same time.

Signed-off-by: Long YunJian <long.yunjian@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
3 years agotoolcontext.h: use bit field in struct
David Teigland [Thu, 12 Aug 2021 20:51:43 +0000 (15:51 -0500)]
toolcontext.h: use bit field in struct

Two recent additions should have used a bit instead
of an entire int.

3 years agopost-release
Marian Csontos [Wed, 11 Aug 2021 15:15:51 +0000 (17:15 +0200)]
post-release

3 years agopre-release v2_03_13
Marian Csontos [Wed, 11 Aug 2021 15:14:26 +0000 (17:14 +0200)]
pre-release

3 years agoWHATS_NEW: update
Marian Csontos [Tue, 10 Aug 2021 12:19:24 +0000 (14:19 +0200)]
WHATS_NEW: update

3 years agomake: generate
root [Thu, 5 Aug 2021 19:38:43 +0000 (21:38 +0200)]
make: generate

3 years agopvscan: only match devices file for command args
David Teigland [Wed, 4 Aug 2021 17:04:03 +0000 (12:04 -0500)]
pvscan: only match devices file for command args

Avoid matching all devices with the devices file to
avoid delays during startup.

3 years agodevices file: avoid updating entry dev names in some cases
David Teigland [Tue, 27 Jul 2021 21:56:20 +0000 (16:56 -0500)]
devices file: avoid updating entry dev names in some cases

Avoid thrashing changes to devices file device names by
some commands that are run during startup when devnames
are still being set up.

3 years agodevices file: limit warnings about devices file entries not found
David Teigland [Tue, 27 Jul 2021 20:28:34 +0000 (15:28 -0500)]
devices file: limit warnings about devices file entries not found

All commands were printing a warning if a devices file
entry was not found.  Limit this to commands that report/display
lvm state.

3 years agocov: lvmlockd path copy
David Teigland [Mon, 2 Aug 2021 20:49:39 +0000 (15:49 -0500)]
cov: lvmlockd path copy

3 years agodebug: stack tracing on error path
Zdenek Kabelac [Tue, 27 Jul 2021 20:52:23 +0000 (22:52 +0200)]
debug: stack tracing on error path

3 years agocov: add initilizer
Zdenek Kabelac [Tue, 27 Jul 2021 20:39:16 +0000 (22:39 +0200)]
cov: add initilizer

3 years agocov: add explicit check for vg existence
Zdenek Kabelac [Tue, 27 Jul 2021 15:03:38 +0000 (17:03 +0200)]
cov: add explicit check for vg existence

Since we check !vg - add check before accessing ->status.

3 years agocov: raid: no more checks with missing areas
Zdenek Kabelac [Tue, 27 Jul 2021 15:01:17 +0000 (17:01 +0200)]
cov: raid: no more checks with missing areas

Since ->areas is directly dereferenced we need to stop
validation right here.

3 years agocov: dev-mpath: check config_wwids_file
Zdenek Kabelac [Tue, 27 Jul 2021 14:57:39 +0000 (16:57 +0200)]
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.

3 years agocov: guard index
Zdenek Kabelac [Tue, 27 Jul 2021 13:53:48 +0000 (15:53 +0200)]
cov: guard index

Analyzer wants explicit protect to not underflow index.

3 years agocov: ensure bufffe size is at least 5
Zdenek Kabelac [Tue, 27 Jul 2021 13:43:23 +0000 (15:43 +0200)]
cov: ensure bufffe size is at least 5

Analyzer can now see, the buffer size will have at least 5 chars
on succefull path.

3 years agocov: add internal error for missing arg
Zdenek Kabelac [Tue, 27 Jul 2021 13:40:26 +0000 (15:40 +0200)]
cov: add internal error for missing arg

Analyzer is happier.

3 years agocov: remove unneeded includes
Zdenek Kabelac [Tue, 27 Jul 2021 13:04:09 +0000 (15:04 +0200)]
cov: remove unneeded includes

3 years agocov: memleak dir descriptor
Zdenek Kabelac [Tue, 27 Jul 2021 13:36:48 +0000 (15:36 +0200)]
cov: memleak dir descriptor

opendir() missed closedir().

3 years agopvck: ensure buffer is 0 terminated
Zdenek Kabelac [Tue, 27 Jul 2021 13:12:56 +0000 (15:12 +0200)]
pvck: ensure buffer is 0 terminated

Since readed metadata buffer is passed to printf(),
ensure the buffer is '\0' terminated.

3 years agocov: pvck fix memleak
Zdenek Kabelac [Tue, 27 Jul 2021 20:52:08 +0000 (22:52 +0200)]
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.

3 years agotests: extend vgmerge testing
Zdenek Kabelac [Fri, 23 Jul 2021 14:34:50 +0000 (16:34 +0200)]
tests: extend vgmerge testing

3 years agovgmerge: support option --poolmetadataspare
Zdenek Kabelac [Fri, 23 Jul 2021 14:32:35 +0000 (16:32 +0200)]
vgmerge: support option --poolmetadataspare

3 years agovgmerge: remove one of merge pmspare LVs
Zdenek Kabelac [Fri, 23 Jul 2021 14:31:11 +0000 (16:31 +0200)]
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.

3 years agowritecache: use block size 512 for thin pool data
David Teigland [Wed, 21 Jul 2021 19:10:38 +0000 (14:10 -0500)]
writecache: use block size 512 for thin pool data

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

3 years agowritecache: fix missing sync_dev_names when attaching cache
David Teigland [Wed, 21 Jul 2021 18:16:21 +0000 (13:16 -0500)]
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.

3 years agospec: Add vdoimport man page
Marian Csontos [Wed, 21 Jul 2021 14:40:27 +0000 (16:40 +0200)]
spec: Add vdoimport man page

3 years agotest
Zdenek Kabelac [Tue, 20 Jul 2021 20:37:54 +0000 (22:37 +0200)]
test

3 years agovgsplit: add support for option --poolmetadataspare
Zdenek Kabelac [Tue, 20 Jul 2021 20:33:05 +0000 (22:33 +0200)]
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.

3 years agovgremove: remove forgotten pmspare
Zdenek Kabelac [Tue, 20 Jul 2021 20:28:13 +0000 (22:28 +0200)]
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.

3 years agothin: fix component detection of external origin
Zdenek Kabelac [Wed, 14 Jul 2021 10:53:47 +0000 (12:53 +0200)]
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.

3 years agopvscan: narrow the previous commit slightly
David Teigland [Tue, 13 Jul 2021 21:26:36 +0000 (16:26 -0500)]
pvscan: narrow the previous commit slightly

to avoid change to pvscan-autoactivate.sh

3 years agopvscan: do nothing for device removal and event_activation=0
David Teigland [Tue, 13 Jul 2021 20:34:05 +0000 (15:34 -0500)]
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.

3 years agofix multipath component detection for multiple holders
David Teigland [Fri, 9 Jul 2021 20:05:11 +0000 (15:05 -0500)]
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.

3 years agofilter-usable: remove udev dev size check
David Teigland [Tue, 15 Jun 2021 16:22:32 +0000 (11:22 -0500)]
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.

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.

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