1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
Commit Graph

1640 Commits

Author SHA1 Message Date
Zdenek Kabelac
6373f39092 tests: check event_activation can be disabled 2021-02-08 23:43:38 +01:00
Zdenek Kabelac
b86eb913c1 tests: support for resized cached LVs
Support for cached LVs is now enabled.
2021-02-08 23:43:38 +01:00
David Teigland
87ee401eea md component detection changes
Move extra md component detection into the label scan phase.
It had been in set_pv_devices which was deep within the vg_read
phase, which wasn't a good place (better to detect that earlier.)
Now that pv metadata info is available in the scan phase, the pv
details (size and device_hint) can be used for extra md checking.

Use the device_hint from the pv metadata to trigger a full md
component check if the device_hint begins with /dev/md.

Stop triggering full md component checks based on missing
udev info for a dev.

Changes to tests to reflect that the code is now detecting
md components in some test case that it wasn't before.
2021-02-05 16:23:51 -06:00
David Teigland
cb54d0801d cachevol: allow forced detaching of damaged or invalid cachevol
A cachevol can be forcibly detached when it's missing devices.
Also allow this if it's damaged/invalid and unrepairable.
This would be needed to recover data from the origin LV after
a cachevol is lost or damaged beyond repair.
2021-02-02 14:31:23 -06:00
Zdenek Kabelac
ae2af1d5ed test: check read_only_volume_list tagging works 2021-02-02 21:23:39 +01:00
David Teigland
8454ce66c5 writecache: let block_size setting override device block sizes
In cases where lvconvert does not detect a fs block size on the
device, it falls back to choosing a writecache block size based
on the device's LBS and PBS (tries to match those.)

If the user specifies a writecache block size on the command
line (--cachesettings block_size=4096|512), lvconvert currently
fails and reports an error if the user-specified value does not
match the value lvconvert would have chosen based on LBS and PBS.

The purpose of allowing a user-specified value on the command line
is to override what lvconvert would otherwise do, so change this
to just print a warning that the user value does not match the
value that would be chosen based on the LBS/PBS, and then take
the user-specified value as the writecache block size.
2021-02-02 13:52:31 -06:00
Zdenek Kabelac
48dfc388f7 tests: increase required target version
Require 1.7.0 for raid0.
2021-02-01 20:10:07 +01:00
Zdenek Kabelac
6e8a32e4fd tests: avoid killing test machines with kernel bug
Bug 1916891  still applies:

https://bugzilla.redhat.com/show_bug.cgi?id=1916891
2021-02-01 15:02:38 +01:00
Zdenek Kabelac
bfafd2b4e9 tests: check for raid target support 2021-02-01 15:01:04 +01:00
Zdenek Kabelac
b26e565ee5 tests: check for cache support presence 2021-02-01 12:13:49 +01:00
Zdenek Kabelac
19ddad12ca tests: update thin and cache checked messages
Slightly changed messages for allocation of pool metadata.
2021-02-01 12:13:49 +01:00
Zdenek Kabelac
b17b556e26 tests: check 16G thin pool metadata size 2021-02-01 12:13:49 +01:00
Heinz Mauelshagen
f08ef23856 lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.

Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.

Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss.  I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.

Add test/shell/lvdisplay-raid.sh.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
2021-01-27 16:56:22 +01:00
Zdenek Kabelac
cddeaed6e9 tests: check support for online vdo rename
kvdo 6.2.3 module version supports online rename.
Add cache and raid stacked renames.
2021-01-22 15:30:37 +01:00
David Teigland
37227b8ad6 devs: remove invalid path name aliases
Make dev_cache_get() verify aliases and drop any
that are invalid before returning a dev for a given
name.
2021-01-15 16:31:50 -06:00
Zdenek Kabelac
ff1324d595 tests: check full zeroing of thin-pool metadata
Check zeroing works on whole thin-pool metadata device.
2021-01-13 12:54:45 +01:00
Zdenek Kabelac
71162b2b4e tests: check thin-pool corner case allocs 2021-01-13 12:54:45 +01:00
David Teigland
e9503f257a lvconvert: chunksize option was missing with cachedevice 2021-01-07 13:30:48 -06:00
David Teigland
b84a9927b7 partial flag for writecache and integrity
When a writecache sublv or an integrity metadata sublv
are partial (missing a dev), set the partial flag on
the upper level LV also, as is done for other sublvs.
2020-12-11 16:25:25 -06:00
David Teigland
5dbe2fdd9d writecache: fix uncache for two step detach
Fix the two-step writecache detach in commit c32d7fed4f.
In the case of uncache, the cachevol is removed after
detaching the writecache.  When the detach is finished
in the second step, the remove must wait until then.
2020-12-10 15:42:01 -06:00
Zdenek Kabelac
57594fe673 tests: few more fsadm checks 2020-12-08 20:32:34 +01:00
David Teigland
1cc75317f9 tests: integrity mismatch checks for all raid levels
Verify that corruption is corrected for raid levels other
than raid1.  For other raid levels, attempt to corrupt the
given file pattern on each underlying device, since we don't
know which device contains the file being corrupted.
This ensures that corruption is actually be introduced
when testing the other raid levels.

Verify that corruption is being corrected by checking
the integritymismatches count is non-zero for the raid LV,
which includes the total from all images (since we don't
know which image will have the corruption.)
2020-11-11 15:13:46 -06:00
David Teigland
2317ba3934 tests: update integrity tests
simplified the method of corrupting data, the old method
was not working reliably.  moved syncation tests to a
different file
2020-11-10 17:41:04 -06:00
David Teigland
125da10d47 Revert "tests: revert lvm shell use in pvck-dump"
This reverts commit 05d23b2dd8.

this required enabling editline in configure
2020-10-28 16:45:04 -05:00
David Teigland
05d23b2dd8 tests: revert lvm shell use in pvck-dump
doesn't work on my machine
2020-10-27 15:44:56 -05:00
David Teigland
020d1edaa0 writecache: disallow partial or degraded activation
when either main or fast lvs are incomplete
2020-10-26 15:48:58 -05:00
David Teigland
830c20d33c lvchange: allow syncaction check with integrity
syncaction check will detect and correct integrity checksum mismatches.
2020-10-26 14:16:33 -05:00
Zdenek Kabelac
e793f34eb7 tests: minor update 2020-10-26 13:06:52 +01:00
Zdenek Kabelac
be94410446 tests: fsadm test continue after fs repair
Test case where filesystem has been corrected via fsck.
In such case fsck returns '1' as success and should be
handled in a same way as '0' since fs is correct.
2020-10-24 01:42:16 +02:00
David Teigland
f3b723cd8d pvscan: rework to improve PVs without metadata
Restructure the pvscan code, and add new temporary files
that list pvids in a VG, used for processing PVs that
have no metadata.

The new temp files, in /run/lvm/pvs_lookup/<vgname>, allow a
proper pvscan --cache to be done on PVs that have no metadata.
pvscan --cache <dev> is only supposed to read <dev>, but when
<dev> has no metadata, this had not been possible.  The
command had to fall back to scanning all devices to read all
VG metadata to get the list of all PVIDs needed to check for
a complete VG.  Now, the temp file can be used in place of
reading metadata from all PVs on the system.
2020-10-22 13:14:31 -05:00
David Teigland
83d0818523 tests: writecache-misc disable with lvmlockd
in a shared vg pvmove requires a named lv
2020-10-21 12:47:28 -05:00
Zdenek Kabelac
6be29e1179 tests: check dmevent with bigger reserved_stack
Check dmeventd remains working when reserved_stack
is above 300KiB.
2020-10-20 22:28:58 +02:00
Zdenek Kabelac
d2bdad28d1 tests: extend area covered by error target
Since 'BLKZEROOUT' streams out more block at once, at can easily
zero-out larger set of blocks after 1st. failing one.

So the test is adapted to fully 'hide' swap header under error target.
2020-10-19 16:53:18 +02:00
Marian Csontos
53db14171c Revert "tests: Adapt RAID test to changes"
The cpnversion of degraded RAID should still report a failure.

This reverts commit e12bdd591a.
2020-10-13 13:15:16 +02:00
Zdenek Kabelac
99b6173f10 tests: enable tests for lvmlockd 2020-10-02 22:27:00 +02:00
David Teigland
ff3945777b tests: enable writecache test that uses cleaner 2020-10-01 11:33:02 -05:00
Zdenek Kabelac
af8044da3a tests: thin-flags 2020-09-29 10:43:56 +02:00
David Teigland
fb96e9ab21 tests: add case for metadata checksum differences
Cover the case where two copies of metadata have the
same seqno but different checksums.  Also elaborate
on an existing fixme in the code for this case, since
we should be doing something better for this case.

This had been uncovering an issue with reopening
fds in readwrite mode.
2020-09-28 13:25:57 -05:00
Zdenek Kabelac
bbc164991a tests: add small delay
Prevent there is no i.e. udev trying to open our device.
2020-09-25 22:59:35 +02:00
Zdenek Kabelac
a89ac3bf6f tests: also add thick snap of thin volume 2020-09-25 22:59:35 +02:00
Zdenek Kabelac
ccb58c109f tests: check some common errors
Collect some cases users are hitting when working
with thin-pools which has mismatching kernel metadata content with
lvm2 metadata.
2020-09-25 22:59:35 +02:00
Zdenek Kabelac
3e003320a7 tests: vgsplit of vdo volumes 2020-09-25 22:59:35 +02:00
Zdenek Kabelac
502b895bb4 tests: basic test for vdo on raid LV
Check stacing of VDO on top of raid LV works.
2020-09-23 14:58:24 +02:00
Zdenek Kabelac
39cdc1469d tests: add check for rename of cached vdopool 2020-09-23 14:47:30 +02:00
Zdenek Kabelac
cfc4dd4c7c tests: a bit bigger mirrors
Seems even with throttling we occasinally need slightly more.
2020-09-23 14:47:30 +02:00
Zdenek Kabelac
3869c9c4f6 tests: use aux wrapper and add more notes
This test seems to be hitting some corner case in handling
out-of-metadata space condintion in thin-pool.

Add few more aid notes and functionality.

Also add missing '|| true' with now direct-IO dd command.
2020-09-22 23:43:26 +02:00
Zdenek Kabelac
e280f56dd3 tests: move function to aux for reuse 2020-09-22 23:43:26 +02:00
Zdenek Kabelac
adead83dc2 tests: update test
Shorten running time of the test.
Fix some issues in invoked resizing script to it returns
correct return code and dmeventd can be a little bit quicker
in this test.
2020-09-22 23:28:43 +02:00
Zdenek Kabelac
cbed63eeb9 tests: check vdopool policy extension
Check pool will grow even with small policy amount.
2020-09-22 23:28:43 +02:00
Zdenek Kabelac
bc9bb534ff tests: fix cleanup for unbound variables
When loop can't handle sector-size option - failure caused double fail
for access of unbound variable
Also fix expression for 'rm' and remove loops after loop release.
2020-09-20 00:37:21 +02:00
Zdenek Kabelac
f507a2564c tests: add FIXME case 2020-09-20 00:37:21 +02:00
Zdenek Kabelac
f2878a801c tests: use DIRECT io for zeroing whenver we can
Performance with direct I/O here is noticable better,
so use it instead of buffered write whenever we can.
2020-09-20 00:37:21 +02:00
Zdenek Kabelac
531a475afc tests: use 4K with mkfs.xfs
If the test runs of loop device backend with 512 sectors,
xfs selects this smaller sector size and then data do not fit
(we would need -l9 with most of 'raids').
With 4K sectors data always fits.
2020-09-20 00:37:21 +02:00
Zdenek Kabelac
a1074da20d tests: skip with fail of first prepare_scsi 2020-09-19 23:03:06 +02:00
Zdenek Kabelac
e556c7b7c6 tests: check for cvol
Check for cvol.
Add check for cmeta.
2020-09-19 23:02:17 +02:00
Zdenek Kabelac
6b168afcad tests: use parametrized function
Shorten and make the test easily readable by moving same code into
function and removed one duplicated test for 512,4096 combination.

Always use scsi_debug - since default ramdisk or loop device backend
is unpredictible.
2020-09-19 17:30:51 +02:00
Zdenek Kabelac
f63aac5309 tests: use zero backend
Since we are not reading read - just use zero device as backend for
test, so we do not eat real disk space.
2020-09-19 17:30:51 +02:00
Zdenek Kabelac
f7c58c636d tests: use faster awk generator
Shortens log length.
2020-09-19 17:30:51 +02:00
Zdenek Kabelac
8e3e2c74ed tests: ensure mnt is defined before trap install 2020-09-19 17:30:51 +02:00
Zdenek Kabelac
530fc17b38 tests: reduce disk usage 2020-09-19 17:30:51 +02:00
Zdenek Kabelac
4b07ae55f1 tests: printf to awk
Shorten trace logs.
2020-09-18 17:30:45 +02:00
Zdenek Kabelac
9fbcba1c40 tests: update integrity-dmeventd
Use tee.
Switch to more simple generator with awk
(which doesn't produce long debug trace)
Sync before sleep to provoke raid action.
2020-09-18 17:30:45 +02:00
Zdenek Kabelac
9448476202 tests: enhance low-disk-space behavior
Use new SKIP_WITH_LOW_SPACE and set higher requirement for free space.

But still this test can't run on system's tmpfs directories -
as they typically provide less then 2G of space and when the test
runs there it also provisioning for all READ pages!)
BRD (ramdisk) device should work.

Extend a _wait_recalc() loop for slower hw.
When creating large raid which do not need to be fully synchronized use
them on delay devices - so even less data needs read/write.
Remove unneeded lvchange as lvcreate is already leaving LV inactive.
Replace printf with awk as generator.

mm
2020-09-18 17:30:45 +02:00
Zdenek Kabelac
a4137412bf tests: also use sed to shorten log output 2020-09-18 00:31:59 +02:00
Zdenek Kabelac
8d40859e29 tests: resolve missing removal of loopdevice on error path
In case of test failure, loop device leaked and occupied space forever.
2020-09-18 00:31:11 +02:00
Zdenek Kabelac
a5e867139d tests: bigger data still needed for 0.7.0 2020-09-17 23:27:52 +02:00
Zdenek Kabelac
7f019f2580 tests: lower memory usage
Reduce memory needed by test at one time.
2020-09-17 23:27:45 +02:00
Zdenek Kabelac
52d3c4de6e tests: smaller delay and lowered version
See if this will still work. Some boxes are delayed too much.
Also try to check for raid extend progress from version 1.13.
2020-09-16 14:08:05 +02:00
Zdenek Kabelac
49292bccc3 tests: fix bash regex syntax
Typo before last commit.
2020-09-16 14:08:05 +02:00
Zdenek Kabelac
2c6bd480b2 tests: switch for checking version of installed tools
It looks like older tools were compacting metadata more.
2020-09-15 23:07:06 +02:00
Zdenek Kabelac
cf4fed3761 tests: skip kernel for this test
Kills this kernel ATM
2020-09-15 23:07:06 +02:00
Zdenek Kabelac
18a60c6340 tests: protect this test for another kernel
Thisi 3.10.0-862 kernel also dies with this test.
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
9c0d11ecc9 tests: tune usage of smaller metadata
While the previous commit c9b40083fc
decresed version to 1.19 for using bigger datasets,  it's not
been quite right - so from our bb machine it looks like
bigger metadata consumption started with 1.19 and kernel 4.18
(fc27)
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
1005fd7b06 tests: raise needed target version
Require higher version to avoid early bugs.
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
57e1e037b6 tests: improve cache abort test
Use bigger volume and slowdown writing to cache device.
This allows more simple to reach 'dirty' state.
Also document exactly 1 SIGINT has to fire aborting of flushing.
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
fe77d1a710 tests: avoid using string
String 'TEST WARNING' may not be present in the test script itself.
Add '\ ' to avoid 'grep' matching test as the test with warning.
2020-09-12 13:24:03 +02:00
Zdenek Kabelac
3008e1be08 tests: support for 16T is needed
Likely 32bit machines can't pass here.
2020-09-12 13:24:03 +02:00
Zdenek Kabelac
17dbb24f7c tests: change skip to die for upstream crash
So the failing test is not lost from sight.
2020-09-12 13:24:03 +02:00
Zdenek Kabelac
7bd015861d tests: skip test on failing kernel 2020-09-12 13:24:03 +02:00
Zdenek Kabelac
93e252c4a3 tests: check for boundary allocation sizes 2020-09-11 21:52:55 +02:00
Zdenek Kabelac
f84a7266bc tests: reduce disk space usage by pvck-dump
Lower disk usage for 'dd'.
2020-09-11 21:52:55 +02:00
Zdenek Kabelac
c9b40083fc tests: lower at_least to version 1.19
With this version already can be seen different metadata usage on
kernel side, so lower the target version.
2020-09-11 21:52:55 +02:00
Zdenek Kabelac
49d2b27a68 tests: adding "" around DM_DEV_DIR 2020-09-10 23:55:03 +02:00
Zdenek Kabelac
bb62af5b3d tests: tune extend test
For proper checking of extension progress require version 1.15

It looks with older versoin extension happens during very slow
resume within lvm command - although speed is still somewhat slow
with latest version.
2020-09-08 21:23:03 +02:00
Zdenek Kabelac
676ce47754 tests: check for writecache being compiled in 2020-09-08 21:23:03 +02:00
Zdenek Kabelac
8dea63d30f tests: check for cache_version that supports v2 2020-09-08 21:23:03 +02:00
David Teigland
dddf63ebc3 tests: fix pvck repair in hints.sh 2020-09-04 11:23:25 -05:00
Zdenek Kabelac
10fc3610c4 tests: use delayzero_dev
Speed-up a bit the first synchronization with just 50ms write delay,
but later set also delay on read to slowdown lvextend.

FIXME: there are still things to look at:

0 229376 raid raid1 2 AA 229376/229376 idle 0 0
0 229376 raid raid1 2 AA 0/229376 frozen 0 0 -
0 262144 raid raid1 2 AA 229376/262144 repair 0 0 -
0 262144 raid raid1 2 AA 229376/262144 repair 0 0 -
0 262144 raid raid1 2 AA 245888/262144 repair 0 0 -
2020-09-04 18:11:42 +02:00
David Teigland
d8bb85d963 writecache: allow pvmove on origin
The removed check didn't actually prevent pvmoving the origin,
which was possible by naming the wcorig lv, or naming no lv.
2020-09-02 14:45:52 -05:00
David Teigland
f5a669f314 pvck: repair should clear hints
repairing a pv can cause the hint file to become incorrect
2020-09-02 14:21:17 -05:00
David Teigland
739827ef1c tests: add new integrity reporting fields 2020-09-01 17:13:46 -05:00
Zdenek Kabelac
9a06700017 tests: skip this test for current 5.8 5.9 kernels
Kernel is hitting not yet fixed kernel bug.
Skip the test to avoid killing testing machine.
2020-09-01 23:40:24 +02:00
Zdenek Kabelac
fa1290f40e tests: slightly faster
Use lvm shell to agregrate lots of lvm commands
Reduce initial zeroing.
2020-09-01 23:40:24 +02:00
Zdenek Kabelac
38d460ed6e tests: set skipping autoactivation
On test system with 'default' filter  (aka accept all) test
after enabling device can suffer from automatic system
activation - so for created LVs setup skipping this automatic
activation. This should prevent getting LVs into table
with pvscan service.
2020-09-01 23:40:24 +02:00
Zdenek Kabelac
ada5728c72 tests: skip test when gcore cannot catch securetest 2020-09-01 23:40:24 +02:00
Zdenek Kabelac
2fbc578cfa tests: filefrag needs to support -e
Skip on systems with 'too old' filefrag without -e support
2020-09-01 17:57:48 +02:00
Zdenek Kabelac
ca54afd701 tests: check we detect lvm.conf read failure
No coredumps with unreadable lvm.conf.
2020-08-28 21:43:02 +02:00
Marian Csontos
e12bdd591a tests: Adapt RAID test to changes
Change 3c9177fdc0 causes a conversion of raid1 volume to a raid1 with
the same number of legs succeed with a warning.
2020-07-28 17:36:57 +02:00
David Teigland
085760992d cachevol: generate a unique name when creating
When a cachevol is automatically created, if the default name
conflicts with an existing name, generate a new unique name.
2020-07-23 13:18:22 -05:00
David Teigland
ad773511c5 integrity: add initial size to metadata size
The metadata device size needs to include space for
the dm-integrity "initial_sectors" which hold journals.
2020-06-30 16:43:05 -05:00
Zdenek Kabelac
3f32f9811e tests: check pool metadata are zeroed 2020-06-24 15:01:03 +02:00
Zdenek Kabelac
094d6f80dd tests: failure of zeroing fails command 2020-06-24 15:01:03 +02:00
David Teigland
ae5634a8be tests: cachevol-cachedevice 2020-06-22 11:23:58 -05:00
David Teigland
950d2d59c1 integrity: wait for raid sync to complete 2020-06-16 12:29:41 -05:00
David Teigland
48872b0369 integrity: avoid increasing logical block size of active LV
When adding integrity to an active LV, avoid choosing an
integrity block size that would result in increasing the
logical block size of the LV.
2020-06-16 12:27:22 -05:00
David Teigland
a014c4f341 tests: integrity and block size 2020-06-15 16:04:40 -05:00
David Teigland
9f38e95a2f tests: fix typo in writecache-blocksize 2020-06-11 13:15:38 -05:00
David Teigland
f32e85ae51 tests: expand integrity-blocksize 2020-06-11 12:46:47 -05:00
David Teigland
6ea3654868 tests: writecache tests
backport updates from later commits
2020-06-10 16:09:36 -05:00
David Teigland
48c1a295a2 tests: writecache-blocksize 2020-06-10 12:16:31 -05:00
David Teigland
240062a183 writecache: remove from an active lv 2020-06-10 12:13:31 -05:00
David Teigland
7b04ed07ba tests: integrity wait for sync
The test was using a raid+integrity LV without
first waiting for the integrity sync, which could
cause the test to fail (depending on init speed)
where it depends on integrity to work in uninitialized
areas.

Also use cmp instead of diff.
2020-05-29 10:57:56 -05:00
Marian Csontos
be61bd6ff5 test: Warn and exit on problematic integrity device behavior
The first leg of integrity enabled raid device sometimes does not get
recalculated.
2020-05-28 17:04:35 +02:00
David Teigland
74a211cfd3 lvconvert: error when using existing cachevol
Check if LV is an existing cachevol before attempting
to use it again as a cachevol or cachepool.
2020-05-22 14:12:34 -05:00
Zdenek Kabelac
bb41ca86fa tests: also udev wait on clean-up path 2020-05-21 16:03:41 +02:00
Marian Csontos
53803821de test: Use printf to generate data
...to avoid unnecessary dependency on python
2020-05-21 15:33:24 +02:00
Marian Csontos
b5811b7c9c tests: Use python single liner to generate data 2020-05-21 15:11:22 +02:00
Zdenek Kabelac
d3b515cea5 tests: add wait on udev processing
Trying to avoid collision with udev watch rule preventing to
succeed 'dmsetup remove' becuase it keeps device open.
2020-05-20 16:01:20 +02:00
David Teigland
d79afd4084 lvmcache: rework handling of VGs with duplicate vgnames
The previous method of managing duplicate vgnames prevented
vgreduce from working if a foreign vg with the same name
existed.
2020-04-21 14:40:34 -05:00
David Teigland
d9e8895a96 Allow dm-integrity to be used for raid images
dm-integrity stores checksums of the data written to an
LV, and returns an error if data read from the LV does
not match the previously saved checksum.  When used on
raid images, dm-raid will correct the error by reading
the block from another image, and the device user sees
no error.  The integrity metadata (checksums) are stored
on an internal LV allocated by lvm for each linear image.
The internal LV is allocated on the same PV as the image.

Create a raid LV with an integrity layer over each
raid image (for raid levels 1,4,5,6,10):

lvcreate --type raidN --raidintegrity y [options]

Add an integrity layer to images of an existing raid LV:

lvconvert --raidintegrity y LV

Remove the integrity layer from images of a raid LV:

lvconvert --raidintegrity n LV

Settings

Use --raidintegritymode journal|bitmap (journal is default)
to configure the method used by dm-integrity to ensure
crash consistency.

Initialization

When integrity is added to an LV, the kernel needs to
initialize the integrity metadata/checksums for all blocks
in the LV.  The data corruption checking performed by
dm-integrity will only operate on areas of the LV that
are already initialized.  The progress of integrity
initialization is reported by the "syncpercent" LV
reporting field (and under the Cpy%Sync lvs column.)

Example: create a raid1 LV with integrity:

$ lvcreate --type raid1 -m1 --raidintegrity y -n rr -L1G foo
  Creating integrity metadata LV rr_rimage_0_imeta with size 12.00 MiB.
  Logical volume "rr_rimage_0_imeta" created.
  Creating integrity metadata LV rr_rimage_1_imeta with size 12.00 MiB.
  Logical volume "rr_rimage_1_imeta" created.
  Logical volume "rr" created.
$ lvs -a foo
  LV                  VG  Attr       LSize  Origin              Cpy%Sync
  rr                  foo rwi-a-r---  1.00g                     4.93
  [rr_rimage_0]       foo gwi-aor---  1.00g [rr_rimage_0_iorig] 41.02
  [rr_rimage_0_imeta] foo ewi-ao---- 12.00m
  [rr_rimage_0_iorig] foo -wi-ao----  1.00g
  [rr_rimage_1]       foo gwi-aor---  1.00g [rr_rimage_1_iorig] 39.45
  [rr_rimage_1_imeta] foo ewi-ao---- 12.00m
  [rr_rimage_1_iorig] foo -wi-ao----  1.00g
  [rr_rmeta_0]        foo ewi-aor---  4.00m
  [rr_rmeta_1]        foo ewi-aor---  4.00m
2020-04-15 12:10:32 -05:00
Zdenek Kabelac
3dd11d9ea8 test: repair of thin-pool used by foreign apps 2020-04-08 15:37:24 +02:00
Marian Csontos
e6b93dc24e test: Fix previous commit 2020-03-18 18:03:12 +01:00
Marian Csontos
fc32787c1b test: Can not attach writecache to active volume 2020-03-18 14:35:58 +01:00
David Teigland
4b5bfa779a tests: reduce sizes in pvck-dump and improve checks
Smaller devs can be used so tests can be run on small vms.
Improve checks.
2020-03-04 11:30:50 -06:00
David Teigland
f6667f94cb tests: pvck dump from larger metadata areas 2020-03-03 13:47:07 -06:00
Zdenek Kabelac
9532bb577a tests: validate vdo slab_size
New vdoformat can print this size - so check we pass proper bit count
matching preset value.
2020-02-26 13:29:21 +01:00
David Teigland
4829f27b76 writecache: drop real dm suffix
fixes the problem of adding writecache to an active LV
2020-02-17 13:07:06 -06:00
David Teigland
2a6078f961 writecache: fix splitcache when origin is raid 2020-02-04 16:12:09 -06:00
Zdenek Kabelac
62ad12d0d0 tests: compatible with older kernels
Older kernels just show syscall stacktrace.
2020-02-04 17:22:06 +01:00
David Teigland
c0de37ab18 tests: move vgsplit writecache
to a different file
2020-02-04 10:20:19 -06:00
David Teigland
379a7e1288 vgsplit: handle cachevol
attached to a cache or writecache LV.
Ensure PVs in cachevol are moved with the main LV.
2020-02-03 15:33:58 -06:00
Zdenek Kabelac
bab3b70e3a tests: add corruption write on PV test
Test a case where PV is readable, but fails on write updating.
Check the failure is reported only for a single PV.
2020-01-23 10:32:15 +01:00
Zdenek Kabelac
30f4d0fcd4 tests: update for readahead 2020-01-13 17:42:31 +01:00
Zdenek Kabelac
4a52855899 tests: improve secure test
Validate we capture core while original task sleeps.
2019-12-10 15:44:16 +01:00
David Teigland
3145a85583 pvck: repair headers and metadata
To write a new/repaired pv_header and label_header:

  pvck --repairtype pv_header --file <file> <device>

This uses the metadata input file to find the PV UUID,
device size, and data offset.

To write new/repaired metadata text and mda_header:

  pvck --repairtype metadata --file <file> <device>

This requires a good pv_header which points to one or two
metadata areas.  Any metadata areas referenced by the
pv_header are updated with the specified metadata and
a new mda_header. "--settings mda_num=1|2" can be used
to select one mda to repair.

To combine all header and metadata repairs:

  pvck --repair --file <file> <device>

It's best to use a raw metadata file as input, that was
extracted from another PV in the same VG (or from another
metadata area on the same PV.)  pvck will also accept a
metadata backup file, but that will produce metadata that
is not identical to other metadata copies on other PVs
and other areas.  So, when using a backup file, consider
using it to update metadata on all PVs/areas.

To get a raw metadata file to use for the repair, see
pvck --dump metadata|metadata_search.

List all instances of metadata from the metadata area:
  pvck --dump metadata_search <device>

Save one instance of metadata at the given offset to
the specified file (this file can be used for repair):

  pvck --dump metadata_search --file <file>
    --settings "metadata_offset=<off>" <device>
2019-11-27 11:13:47 -06:00
David Teigland
b400353c71 tests hints: update check for io count
Running a reporting command on a VG now includes one
additional read to check the mda_header for any change
to the vg between scan and lock.
2019-11-26 16:52:28 -06:00
Marian Csontos
b690258518 tests: Find md name using lsblk
After stopping MD device and rescanning the leg, it is created with
different name.
2019-11-26 09:13:17 +01:00
Marian Csontos
4757ce4c2a Partial revert "tests: update to md dev name"
This partially reverts commit c2ff8876f9.

Not all MD devices are stopped. Something is missing there...
2019-11-25 09:23:02 +01:00
Zdenek Kabelac
f88f7c0fdc tests: add more tracing info 2019-11-15 12:37:44 +01:00
Zdenek Kabelac
496c368528 tests: reduce amount of written date
Since we reduced created LV to 4M - dd also just 4M.
2019-11-15 12:37:44 +01:00
Zdenek Kabelac
38617213f0 tests: add test of resize of different segtypes 2019-11-11 22:44:25 +01:00
Zdenek Kabelac
ba313ac84a tests: skip unneeded status check
If 'remove' was succesful - we can break loop immediatelly.
2019-11-11 22:44:25 +01:00
Marian Csontos
8263e62b00 test: Fix metadata-zero-space with long VG names 2019-11-06 16:20:27 +01:00
Zdenek Kabelac
c67a03727b tests: be happy with less then 90 percent
Thin metadata evolve between kernel version, so it's not always
precisely predictible its usage - so let's met test happy,
when it gets bellow 90%.
2019-11-01 16:31:12 +01:00
Zdenek Kabelac
dbaa4cdcdf tests: skip test if scsi_debug is not available 2019-11-01 16:31:12 +01:00
Zdenek Kabelac
5f064e2221 tests: slowdown delay of raid
Slowdown 'delay' more.
2019-11-01 16:31:12 +01:00
Zdenek Kabelac
c935f8a327 tests: conversion only of exclusive lv
We can 'cache' only exclusively active LV in cluster.
2019-11-01 16:27:21 +01:00
Zdenek Kabelac
d1c5b3ae74 tests: avoid checking command result in cluster
When running cluster test with clvmd, the actual 'monitoring'
happens in cluster - so the 'already monitored' message
is also logged within clvmd code and the command cannot
see such effect.

clvmd was incapable to report this information back to command
so it cannot be displayed this way.

Add 'lvs -o+seg_monitor' validation which also works in clustered mode.
2019-11-01 16:27:21 +01:00
Zdenek Kabelac
50b50039d9 tests: reduce space requirements
Test well runs on smaller test machines.
2019-10-31 15:31:30 +01:00
Zdenek Kabelac
e88fd2edfd tests: explicit testing of thin snapshot
Check merging of old snapshot of thin LV.
2019-10-26 00:49:16 +02:00
David Teigland
221edf4030 tests: lvmlockd-lv-types handle new cpool renaming 2019-10-24 13:26:33 -05:00
Zdenek Kabelac
b4e87e638e tests: enable with 6.2.1
Package vdo-6.2.2.18  goes with  kvdo version 6.2.1
Hopefully will get fixed soon.
Meanwhile to get test coverage...
2019-10-22 16:06:19 +02:00
Zdenek Kabelac
65efacd0e0 tests: more suffixes 2019-10-22 13:39:39 +02:00
Zdenek Kabelac
a0e40bad1d tests: used cache_pool adds _cpool 2019-10-21 15:32:35 +02:00
David Teigland
5714c8c9cc pvck: dump metadata search
Improve the implementation of extracting all text metadata
copies from the metadata area.  Use this for the existing
metadata_all dump option.

Add a new metadata_search dump option which does not use
lvm headers to find metadata, but looks in standard
locations.  This is useful if headers are damaged and
can't be used to locate metadata.

Adding '-v' to metadata_all or metadata_search will add
the description and creation_time to the printed list of
metadata instances that are found.
2019-10-18 12:26:29 -05:00
Zdenek Kabelac
4f860f79ff tests: cachevol needs FORMAT2
FORMAT2 is mandatory with cachevols...
2019-10-17 13:03:50 +02:00
Zdenek Kabelac
f07e5c1fe4 tests: skip when raid is not present 2019-10-17 13:03:50 +02:00
David Teigland
55bf692bff tests: metadata-zero-space long vgnames
In the hex dump output, grep for the vgname
followed by one space.  This allows for test pids
with up to seven digits, which are used to contruct
the variable vgname used by the test.  Otherwise
the long vgname wraps to the next line and fails to
match in grep.
2019-10-16 09:46:48 -05:00
David Teigland
998e7b1075 writecache: add cvol suffix to attached cachevol
When an LV is used as a writecache cachevol, give
it the LV name a _cvol suffix.  Remove the suffix
when the cachevol is detached, restoring the
original LV name.
2019-10-15 16:03:34 -05:00
Zdenek Kabelac
6666c39346 tests: cvol 2019-10-14 15:20:25 +02:00
Zdenek Kabelac
c70bab7531 tests: drop manipulation with 'internal' LV
Cachevol LV is 'internal' LV and should not be 'maintained'  this way
while it's being used as cachevol.
2019-10-14 15:20:25 +02:00
Zdenek Kabelac
e6691aa04b tests: disable caching of VDO
Disable until vdo gets fixed, then require fixed version.
Otherwise test kills kernel
2019-10-14 15:13:47 +02:00
Marian Csontos
df26b73b8e test: Minimize data written by metadata-zero-space
The test is checking only 2 megabytes, but is rewriting much more. Bad
for limited ramdisk.
2019-10-09 15:11:03 +02:00
David Teigland
d693041149 tests: add wipefs wrapper
which falls back to using dd on old systems without
the wipefs command
2019-10-02 14:11:08 -05:00
David Teigland
c2ff8876f9 tests: update to md dev name
Use /dev/md33 instead of /dev/md0 to reduce chances of
conflicting with an existing name.

Only call 'mdadm --stop /dev/md33' for cleanup and don't
use 'mdadm --stop --scan' to avoid stopping other md devs.
2019-10-02 14:09:51 -05:00
Heinz Mauelshagen
b138a87f43 test: increase size of raid10 LV allowing tests to succeed on fast storage
Also add health char check.
2019-10-02 15:25:43 +02:00
Heinz Mauelshagen
242e2dccc3 test: add RAID lvextend resynchronization test
Due to a dm-raid target flaw fixed in target version 1.15.0,
extents of raid sets don't get resynchronized when new MD bitmp
pages have to be allocated due to the extension.

Introduce lvextend-raid.sh to test this flaw.

Related: rhbz1671964
2019-10-02 15:25:41 +02:00
Heinz Mauelshagen
c4aba47dd0 test: add checks for not 100% sync ratio after initiation of check/repair
Related: rhbz1640630
2019-10-02 15:25:30 +02:00
David Teigland
7368cf8e7d pvck: handle PVs with zero metadata copies 2019-09-30 16:20:17 -05:00
David Teigland
1bfae5bf8e tests: update duplicate md tests
adjust to recent improvements in duplicate handling
2019-09-30 11:38:10 -05:00
David Teigland
9680fd6d78 tests: skip md tests if system not clean 2019-09-27 12:40:42 -05:00
David Teigland
0673d13518 tests: writecache-split check have_writecache 2019-09-26 10:45:53 -05:00
David Teigland
3b36de573e tests: update cache-single-split
add some uncache commands
2019-09-24 15:51:05 -05:00
David Teigland
e35cf0f623 tests: add writecache-split 2019-09-23 16:35:01 -05:00
David Teigland
a353bfdd9f tests: update cache-single-split
enable splitting while LV is active which works
again since the cvol suffix was dropped.
2019-09-23 14:21:09 -05:00
David Teigland
338a60bb41 tests: update cache-single-split
the new use of uuid suffixes on internal dm devs
has impacted splitting when an LV is active,
so temporarily disable that until fixed.
2019-09-20 16:36:14 -05:00
David Teigland
8d8b5e4f75 tests: add cache-single-split 2019-09-20 09:59:37 -05:00
Zdenek Kabelac
38a3da532f tests: check vdo 2019-09-17 13:17:21 +02:00
Zdenek Kabelac
ee6b9b78ec tests: pool conversion
Test conversion of cached LV.
2019-09-17 13:13:49 +02:00
David Teigland
196a9ed59f tests: metadata-zero-space more debugging 2019-09-12 14:38:20 -05:00
David Teigland
585db87274 tests: skip some without wipefs 2019-09-12 11:23:30 -05:00
David Teigland
82b887a4cf tests: more debug in metadata-zero-space 2019-09-12 11:19:44 -05:00
David Teigland
1fe04f89ef tests: use standard md devices 2019-09-12 10:11:27 -05:00
David Teigland
772dbb1e39 tests: metadata-zero-space add info for debugging 2019-09-11 14:20:59 -05:00
David Teigland
447ba5f1c2 tests: skip without xxd 2019-09-11 14:01:55 -05:00
David Teigland
31b6a04e4c tests: open-file-limit skip without prlimit 2019-09-11 14:01:55 -05:00
David Teigland
69b7c00a77 tests: allow-mixed-block-sizes skip with older losetup 2019-09-11 14:01:55 -05:00
David Teigland
715d2c778f tests: cache-single tests require version 1 10 2019-09-11 14:01:55 -05:00
David Teigland
acb8050a30 tests: metadata-bad-text.sh with lvmlockd
skip part of test that doesn't apply
2019-09-05 15:27:52 -05:00
David Teigland
25b58310e3 pvscan: avoid full scan for activation
When an online PV completed a VG, the standard
activation functions were used to activate the VG.
These functions use a full scan of all devs.
When many pvscans are run during startup and need
to activate many VGs, scanning all devs from all
the pvscans can take a long time.

Optimize VG activation in pvscan to scan only the
devs in the VG being activated.  This makes use of
the online file info that was used to determine
the VG was complete.

The downside of this approach is that pvscan activation
will not detect duplicate PVs and block activation,
where a normal activation command (which scans all
devices) would.
2019-09-03 10:11:16 -05:00
David Teigland
987f2733c7 tests: duplicate-pvs-md
Testing duplicate PV handling for various md device setups/states.
2019-08-16 13:26:12 -05:00
Zdenek Kabelac
e653f43732 tests: simplify some var settings
scan_lvs now automatically comes with extend_filter_LVMTEST
2019-08-09 12:57:21 +02:00
Zdenek Kabelac
05c7e09e71 tests: for cluster testing we always need exclusive mirrors
Cluster test would fail without exlusively activated mirror.
FIXME: test is still broken, since LV2 is not active after split.
2019-08-09 12:57:21 +02:00
Zdenek Kabelac
505c1d56e8 tests: accept also value 512
Older kernels provide fixed value 512 instead of 0.
2019-08-09 12:57:21 +02:00
Zdenek Kabelac
1e553159d5 tests: add settle wait before issue remove
Some older BB with older cryptsetup tool do not 'retry' on remove
and when  remove is issued right after 'fsck'  - it might be
rejected with:

Device @PREFIX@-tcrypt2 is busy.

Try to use udevadm settle.
2019-08-09 12:57:21 +02:00
Zdenek Kabelac
d3903d94e9 tests: fix ra checking
Since with some installed package like 'tuned' the value of 'RA' on
PV origin device can be different, adapting tests to count with this.
2019-08-09 12:57:21 +02:00
David Teigland
3fcb4697f6 tests: open-file-limit 2019-08-08 15:45:03 -05:00
David Teigland
cd8a0133fa tests: allow-mixed-block-sizes 2019-08-01 10:13:41 -05:00
David Teigland
e3ba8561fa tests: large-physical-sector-size 2019-07-30 15:59:11 -05:00
David Teigland
aa58f9bd9b tests: lvm-on-md use variable run dir
for hints file
2019-07-12 16:51:49 -05:00
David Teigland
bbca70a0b7 tests: metadata-zero-space
Test zero padding between copies of metadata.
2019-07-12 15:03:47 -05:00
David Teigland
7230aa891c tests: pvscan-autoactivate test unmatching dev and PV size 2019-07-11 11:38:12 -05:00
David Teigland
4eb0e65693 tests: extend lvm-on-md 2019-07-11 11:20:06 -05:00
David Teigland
f938545687 cache: warn and prompt for writeback with cachevol
The cache repair utility does not yet work with a cachevol
(where metadata and data exist on the same LV.)  So, warn
and prompt if writeback is specified with a cachevol.
2019-07-02 11:03:03 -05:00
Marian Csontos
ba9d152aa5 test: Remove now useless clvmd test 2019-06-27 11:14:00 +02:00
David Teigland
9ba45d824a tests: add exported.sh
to test how commands work with exported VGs/PVs.
2019-06-25 15:45:47 -05:00
David Teigland
8fecd9c14e metadata: include description with command in metadata areas
Previously the VG metadata description field (which contains
the command line) was only included in backup/archive copies
of the metadata.  Now also include it in the metadata written
to the metadata areas.
2019-06-20 16:09:05 -05:00
David Teigland
d7c1168c6a tests: add metadata-bad-mdaheader.sh
needs xxd command
2019-06-07 15:54:04 -05:00
David Teigland
878741502a tests: add metadata-bad-text.sh 2019-06-07 15:54:04 -05:00
David Teigland
4fa1638301 tests: add outdated-pv.sh 2019-06-07 15:54:04 -05:00
David Teigland
9156640b60 tests: add metadata-old.sh 2019-06-07 15:54:04 -05:00
David Teigland
d3636ff832 tests: add missing-pv missing-pv-unused 2019-06-07 15:54:04 -05:00
David Teigland
ba7ff96faf improve reading and repairing vg metadata
The fact that vg repair is implemented as a part of vg read
has led to a messy and complicated implementation of vg_read,
and limited and uncontrolled repair capability.  This splits
read and repair apart.

Summary
-------

- take all kinds of various repairs out of vg_read
- vg_read no longer writes anything
- vg_read now simply reads and returns vg metadata
- vg_read ignores bad or old copies of metadata
- vg_read proceeds with a single good copy of metadata
- improve error checks and handling when reading
- keep track of bad (corrupt) copies of metadata in lvmcache
- keep track of old (seqno) copies of metadata in lvmcache
- keep track of outdated PVs in lvmcache
- vg_write will do basic repairs
- new command vgck --updatemetdata will do all repairs

Details
-------

- In scan, do not delete dev from lvmcache if reading/processing fails;
  the dev is still present, and removing it makes it look like the dev
  is not there.  Records are now kept about the problems with each PV
  so they be fixed/repaired in the appropriate places.

- In scan, record a bad mda on failure, and delete the mda from
  mda in use list so it will not be used by vg_read or vg_write,
  only by repair.

- In scan, succeed if any good mda on a device is found, instead of
  failing if any is bad.  The bad/old copies of metadata should not
  interfere with normal usage while good copies can be used.

- In scan, add a record of old mdas in lvmcache for later, do not repair
  them while reading, and do not let them prevent us from finding and
  using a good copy of metadata from elsewhere.  One result is that
  "inconsistent metadata" is no longer a read error, but instead a
  record in lvmcache that can be addressed separate from the read.

- Treat a dev with no good mdas like a dev with no mdas, which is an
  existing case we already handle.

- Don't use a fake vg "handle" for returning an error from vg_read,
  or the vg_read_error function for getting that error number;
  just return null if the vg cannot be read or used, and an error_flags
  arg with flags set for the specific kind of error (which can be used
  later for determining the kind of repair.)

- Saving an original copy of the vg metadata, for purposes of reverting
  a write, is now done explicitly in vg_read instead of being hidden in
  the vg_make_handle function.

- When a vg is not accessible due to "access restrictions" but is
  otherwise fine, return the vg through the new error_vg arg so that
  process_each_pv can skip the PVs in the VG while processing.
  (This is a temporary accomodation for the way process_each_pv
  tracks which devs have been looked at, and can be dropped later
  when process_each_pv implementation dev tracking is changed.)

- vg_read does not try to fix or recover a vg, but now just reads the
  metadata, checks access restrictions and returns it.
  (Checking access restrictions might be better done outside of vg_read,
   but this is a later improvement.)

- _vg_read now simply makes one attempt to read metadata from
  each mda, and uses the most recent copy to return to the caller
  in the form of a 'vg' struct.
  (bad mdas were excluded during the scan and are not retried)
  (old mdas were not excluded during scan and are retried here)

- vg_read uses _vg_read to get the latest copy of metadata from mdas,
  and then makes various checks against it to produce warnings,
  and to check if VG access is allowed (access restrictions include:
  writable, foreign, shared, clustered, missing pvs).

- Things that were previously silently/automatically written by vg_read
  that are now done by vg_write, based on the records made in lvmcache
  during the scan and read:
  . clearing the missing flag
  . updating old copies of metadata
  . clearing outdated pvs
  . updating pv header flags

- Bad/corrupt metadata are now repaired; they were not before.

Test changes
------------

- A read command no longer writes the VG to repair it, so add a write
  command to do a repair.
  (inconsistent-metadata, unlost-pv)

- When a missing PV is removed from a VG, and then the device is
  enabled again, vgck --updatemetadata is needed to clear the
  outdated PV before it can be used again, where it wasn't before.
  (lvconvert-repair-policy, lvconvert-repair-raid, lvconvert-repair,
   mirror-vgreduce-removemissing, pv-ext-flags, unlost-pv)

Reading bad/old metadata
------------------------

- "bad metadata": the mda_header or metadata text has invalid fields
  or can't be parsed by lvm.  This is a form of corruption that would
  not be caused by known failure scenarios.  A checksum error is
  typically included among the errors reported.

- "old metadata": a valid copy of the metadata that has a smaller seqno
  than other copies of the metadata.  This can happen if the device
  failed, or io failed, or lvm failed while commiting new metadata
  to all the metadata areas.  Old metadata on a PV that has been
  removed from the VG is the "outdated" case below.

When a VG has some PVs with bad/old metadata, lvm can simply ignore
the bad/old copies, and use a good copy.  This is why there are
multiple copies of the metadata -- so it's available even when some
of the copies cannot be used.  The bad/old copies do not have to be
repaired before the VG can be used (the repair can happen later.)

A PV with no good copies of the metadata simply falls back to being
treated like a PV with no mdas; a common and harmless configuration.

When bad/old metadata exists, lvm warns the user about it, and
suggests repairing it using a new metadata repair command.
Bad metadata in particular is something that users will want to
investigate and repair themselves, since it should not happen and
may indicate some other problem that needs to be fixed.

PVs with bad/old metadata are not the same as missing devices.
Missing devices will block various kinds of VG modification or
activation, but bad/old metadata will not.

Previously, lvm would attempt to repair bad/old metadata whenever
it was read.  This was unnecessary since lvm does not require every
copy of the metadata to be used.  It would also hide potential
problems that should be investigated by the user.  It was also
dangerous in cases where the VG was on shared storage.  The user
is now allowed to investigate potential problems and decide how
and when to repair them.

Repairing bad/old metadata
--------------------------

When label scan sees bad metadata in an mda, that mda is removed
from the lvmcache info->mdas list.  This means that vg_read will
skip it, and not attempt to read/process it again.  If it was
the only in-use mda on a PV, that PV is treated like a PV with
no mdas.  It also means that vg_write will also skip the bad mda,
and not attempt to write new metadata to it.  The only way to
repair bad metadata is with the metadata repair command.

When label scan sees old metadata in an mda, that mda is kept
in the lvmcache info->mdas list.  This means that vg_read will
read/process it again, and likely see the same mismatch with
the other copies of the metadata.  Like the label_scan, the
vg_read will simply ignore the old copy of the metadata and
use the latest copy.  If the command is modifying the vg
(e.g. lvcreate), then vg_write, which writes new metadata to
every mda on info->mdas, will write the new metadata to the
mda that had the old version.  If successful, this will resolve
the old metadata problem (without needing to run a metadata
repair command.)

Outdated PVs
------------

An outdated PV is a PV that has an old copy of VG metadata
that shows it is a member of the VG, but the latest copy of
the VG metadata does not include this PV.  This happens if
the PV is disconnected, vgreduce --removemissing is run to
remove the PV from the VG, then the PV is reconnected.
In this case, the outdated PV needs have its outdated metadata
removed and the PV used flag needs to be cleared.  This repair
will be done by the subsequent repair command.  It is also done
if vgremove is run on the VG.

MISSING PVs
-----------

When a device is missing, most commands will refuse to modify
the VG.  This is the simple case.  More complicated is when
a command is allowed to modify the VG while it is missing a
device.

When a VG is written while a device is missing for one of it's PVs,
the VG metadata is written to disk with the MISSING flag on the PV
with the missing device.  When the VG is next used, it is treated
as if the PV with the MISSING flag still has a missing device, even
if that device has reappeared.

If all LVs that were using a PV with the MISSING flag are removed
or repaired so that the MISSING PV is no longer used, then the
next time the VG metadata is written, the MISSING flag will be
dropped.

Alternative methods of clearing the MISSING flag are:

vgreduce --removemissing will remove PVs with missing devices,
or PVs with the MISSING flag where the device has reappeared.

vgextend --restoremissing will clear the MISSING flag on PVs
where the device has reappeared, allowing the VG to be used
normally.  This must be done with caution since the reappeared
device may have old data that is inconsistent with data on other PVs.

Bad mda repair
--------------

The new command:
vgck --updatemetadata VG

first uses vg_write to repair old metadata, and other basic
issues mentioned above (old metadata, outdated PVs, pv_header
flags, MISSING_PV flags).  It will also go further and repair
bad metadata:

. text metadata that has a bad checksum
. text metadata that is not parsable
. corrupt mda_header checksum and version fields

(To keep a clean diff, #if 0 is added around functions that
are replaced by new code.  These commented functions are
removed by the following commit.)
2019-06-07 15:54:04 -05:00
David Teigland
db98a6e362 Additional MD component checking
If udev info is missing for a device, (which would indicate
if it's an MD component), then do an end-of-device read to
check if a PV is an MD component.  (This is skipped when
using hints since we already know devs in hints are good.)

A new config setting md_component_checks can be used to
disable the additional end-of-device MD checks, or to
always enable end-of-device MD checks.

When both hints and udev info are disabled/unavailable,
the end of PVs will now be scanned by default.  If md
devices with end-of-device superblocks are not being
used, the extra I/O overhead can be avoided by setting
md_component_checks="start".
2019-06-07 13:27:16 -05:00
David Teigland
c315112a3b tests: pvscan-autoactivate check for machine-id 2019-06-06 15:32:42 -05:00
David Teigland
356ea897cc tests: pvck-dump 2019-06-05 13:58:26 -05:00
Zdenek Kabelac
4d9f41b119 tests: check no_discard_passdown
Check reporting works
2019-06-05 15:48:44 +02:00
Marian Csontos
669a834981 test: Increase latency in pvmove-resume-multiseg
The test was failing consistently on some VMs (F25), and inconsistently
on Rawhide.

With increased latency these failures are no longer reproducible.

Reproducer:

    make check_lvmpolld T=pvmove-resume-multiseg.sh
2019-06-03 16:57:49 +02:00
David Teigland
eebb5e9fff tests: add debug to pvscan-cache deactivation 2019-05-23 15:32:46 -05:00
David Teigland
e055b89d28 tests: pvscan-cache more attempts to fix 2019-05-23 14:55:57 -05:00
David Teigland
1022b88a66 tests: change mkfs usage in lvconvert raid tests
The "echo y | mkfs" was failing at times from echo y.
Remove echo y and replace with wipefs -a prior to mkfs.
2019-05-23 11:45:26 -05:00
David Teigland
6169c0a51b tests: fix error detection in lvconvert-raid-takeover.sh 2019-05-23 10:29:52 -05:00
David Teigland
2036608423 tests: pvscan-cache try to fix teardown problems
teardown after the test was failing, probably because
of uncoordinated udev actions running on the test
system.  Try to avoid this by doing some work before
teardown.
2019-05-22 11:55:48 -05:00
David Teigland
78afe75b08 tests: fsadm-crypt.sh update mkfs parameter
mkfs.xfs was rejecting previously working value
2019-05-21 14:46:01 -05:00
David Teigland
cf3f463929 tests: pvscan-autoactivate.sh switch system_id_source
to machineid instead of uname which would break if
the test system had no proper uname set.
2019-05-21 14:37:55 -05:00
David Teigland
99ca06ca46 tests: hints check if strace exists
avoid test failure if test system does not
have strace
2019-05-21 14:24:57 -05:00
Zdenek Kabelac
0c26aa13ca tests: check accepting out-of-range creation_time 2019-05-10 15:00:21 +02:00
Zdenek Kabelac
1f7c9da554 tests: split args
Here we want args to be splited into individual strings.
2019-05-06 13:02:45 +02:00
Zdenek Kabelac
4ff472b907 tests: drop call of wipefs
wipefs might not be present on test system.
Devices are also already zeroed by cleanup_md_dev
(which 'fakes' missing wipefs eventually)
2019-05-04 19:11:00 +02:00
David Teigland
6ff1583c1b tests: expand lvm-on-md
test both md raid0 and raid1
2019-05-03 14:39:42 -05:00
Zdenek Kabelac
ac627fd1ce tests: use luks1 for test
Since we do not need anywhere luks2 - pick older format
which does not require password for resize to keep
the rest of test unmodified.
2019-05-03 13:17:22 +02:00
Zdenek Kabelac
8c56e31134 tests: update resize value
Since we now properly extend also _pmspare - there was not enough free
space to add 8extents to both volumes.
2019-05-03 13:17:22 +02:00
David Teigland
8c87dda195 locking: unify global lock for flock and lockd
There have been two file locks used to protect lvm
"global state": "ORPHANS" and "GLOBAL".

Commands that used the ORPHAN flock in exclusive mode:
  pvcreate, pvremove, vgcreate, vgextend, vgremove,
  vgcfgrestore

Commands that used the ORPHAN flock in shared mode:
  vgimportclone, pvs, pvscan, pvresize, pvmove,
  pvdisplay, pvchange, fullreport

Commands that used the GLOBAL flock in exclusive mode:
  pvchange, pvscan, vgimportclone, vgscan

Commands that used the GLOBAL flock in shared mode:
  pvscan --cache, pvs

The ORPHAN lock covers the important cases of serializing
the use of orphan PVs.  It also partially covers the
reporting of orphan PVs (although not correctly as
explained below.)

The GLOBAL lock doesn't seem to have a clear purpose
(it may have eroded over time.)

Neither lock correctly protects the VG namespace, or
orphan PV properties.

To simplify and correct these issues, the two separate
flocks are combined into the one GLOBAL flock, and this flock
is used from the locking sites that are in place for the
lvmlockd global lock.

The logic behind the lvmlockd (distributed) global lock is
that any command that changes "global state" needs to take
the global lock in ex mode.  Global state in lvm is: the list
of VG names, the set of orphan PVs, and any properties of
orphan PVs.  Reading this global state can use the global lock
in sh mode to ensure it doesn't change while being reported.

The locking of global state now looks like:

lockd_global()
  previously named lockd_gl(), acquires the distributed
  global lock through lvmlockd.  This is unchanged.
  It serializes distributed lvm commands that are changing
  global state.  This is a no-op when lvmlockd is not in use.

lockf_global()
  acquires an flock on a local file.  It serializes local lvm
  commands that are changing global state.

lock_global()
  first calls lockf_global() to acquire the local flock for
  global state, and if this succeeds, it calls lockd_global()
  to acquire the distributed lock for global state.

Replace instances of lockd_gl() with lock_global(), so that the
existing sites for lvmlockd global state locking are now also
used for local file locking of global state.  Remove the previous
file locking calls lock_vol(GLOBAL) and lock_vol(ORPHAN).

The following commands which change global state are now
serialized with the exclusive global flock:

pvchange (of orphan), pvresize (of orphan), pvcreate, pvremove,
vgcreate, vgextend, vgremove, vgreduce, vgrename,
vgcfgrestore, vgimportclone, vgmerge, vgsplit

Commands that use a shared flock to read global state (and will
be serialized against the prior list) are those that use
process_each functions that are based on processing a list of
all VG names, or all PVs.  The list of all VGs or all PVs is
global state and the shared lock prevents those lists from
changing while the command is processing them.

The ORPHAN lock previously attempted to produce an accurate
listing of orphan PVs, but it was only acquired at the end of
the command during the fake vg_read of the fake orphan vg.
This is not when orphan PVs were determined; they were
determined by elimination beforehand by processing all real
VGs, and subtracting the PVs in the real VGs from the list
of all PVs that had been identified during the initial scan.
This is fixed by holding the single global lock in shared mode
while processing all VGs to determine the list of orphan PVs.
2019-04-29 13:01:05 -05:00
David Teigland
aa75b31db5 pvscan: handle case of scanning PV without metadata last
Handle the case where pvscan --cache -aay (with no dev args)
gets to the final PV, completing the VG, but that final PV does not
have VG metadata.  In this case, we need to use VG metadata from a
previously scanned PV in the same VG, which we saved for this
possibility.  Using this saved metadata, we can find which VG
this PVID belongs to, and then check if that VG is now complete,
and if so add the VG name to the list of complete VGs to be
autoactivated.
2019-04-15 11:27:49 -05:00
David Teigland
41ba2b568b tests: disable unworking pvscan case
and add corresponding fixme in the code
2019-04-12 15:40:38 -05:00
David Teigland
48e9f116ae tests: update pvscan-autoactivate for init change 2019-04-05 14:04:42 -05:00
Zdenek Kabelac
5d6fe796bd tests: check auto-growth of thin-pool meta 2019-04-03 13:28:56 +02:00
Zdenek Kabelac
7f757ab616 tests: vdo caching tests 2019-03-20 14:39:11 +01:00
Zdenek Kabelac
5139e5f1b3 tests: vdo dmevent autoresize 2019-03-20 14:39:11 +01:00
Zdenek Kabelac
ac31bfd6fd tests: check vgsplit works with cache 2019-03-20 14:38:05 +01:00
David Teigland
d84134c75b pvscan: fix ignoring foreign PVs
Fix to previous commit
  "pvscan: ignore online for shared and foreign PVs"

which was incorrectly considering a PV foreign if its
VG had no system ID when the host did have a system ID.
2019-03-13 16:03:02 -05:00
David Teigland
98b7a3a42d tests: check that pvscan --cache ignores certain PVs 2019-03-06 12:17:47 -06:00
David Teigland
a9eaab6beb Use "cachevol" to refer to cache on a single LV
and "cachepool" to refer to a cache on a cache pool object.

The problem was that the --cachepool option was being used
to refer to both a cache pool object, and to a standard LV
used for caching.  This could be somewhat confusing, and it
made it less clear when each kind would be used.  By
separating them, it's clear when a cachepool or a cachevol
should be used.

Previously:

- lvm would use the cache pool approach when the user passed
  a cache-pool LV to the --cachepool option.

- lvm would use the cache vol approach when the user passed
  a standard LV in the --cachepool option.

Now:

- lvm will always use the cache pool approach when the user
  uses the --cachepool option.

- lvm will always use the cache vol approach when the user
  uses the --cachevol option.
2019-02-27 08:52:34 -06:00
David Teigland
74a388cca1 pvscan: autoactivate a VG once
When a VG has multiple PVs, and all those PVs come online
at the same time, concurrent pvscans for each PV will all
create the individual pvid files, and all will often see
the VG is now complete.  This causes each of the pvscan
commands to think it should activate the VG, so there
are multiple activations of the same VG.  The vg lock
serializes them, and only the first pvscan actually does
the activation, but there is still a lot of extra overhead
and time used by the other pvscans that attempt to
activate the already active VG.  This can lead to a backlog
of pvscans and timeouts.

To fix this, this adds a new /run/lvm/vgs_online/ dir that
works like the existing /run/lvm/pvs_online/ dir.  Each pvscan
that wants to activate a VG will first try to exlusively create
the file vgs_online/<vgname>.  Only the first pvscan will
succeed, and that one will do the VG activation. The other
pvscans will find the vgname file exists and will not do the
activation step.

When a PV goes offline, the vgs_online file for the corresponding
VG is removed.  This allows the VG to be autoactivated again
when the PV comes online again.  This requires that the vgname be
stored in the pvid files.
2019-02-21 15:17:41 -06:00
David Teigland
fedeab28c3 tests: set scan_lvs=1 in tests that stack PVs on LVs 2019-02-20 13:52:35 -06:00
Zdenek Kabelac
ab1fd0cb37 tests: rounding for pools changed to power of 2
Even with 64K chunk support, lvm2 will target power-of-2 chunks.
2019-01-28 22:17:27 +01:00
David Teigland
cbf62b9262 tests: use pvscan after enable_dev in process-each-duplicate-vgnames
instead of vgscan, so that new dev is recognized with hints
2019-01-28 11:38:05 -06:00
Zdenek Kabelac
fc02343eff tests: vdo dmeventd resize 2019-01-21 12:53:16 +01:00
Zdenek Kabelac
cbadf3d370 tests: initial test for vdo resize 2019-01-21 12:53:16 +01:00
Zdenek Kabelac
2cac4bfc15 tests: update cache test
Since migration_threshold is now protected to not be smaller
then 8*chunk_size - update tests to count with this modification.
2019-01-21 12:53:16 +01:00