]> sourceware.org Git - lvm2.git/log
lvm2.git
6 years agomirror: improve table update
Zdenek Kabelac [Sat, 28 Apr 2018 20:14:47 +0000 (22:14 +0200)]
mirror: improve table update

Shift refresh of mirror table right into monitor_dev_for_events().
Use  !vg_write_lock_held() to recognize use of lvchange/vgchange.
(this shall change if this would no longer work, but requires
futher some API changes).

With this patch  dm mirror table is only refreshed when necassary.

Also update WARNING message about mirror usage without monitoring
and display LV name.

6 years agoaux: enhance teardown to better handle weird names
Zdenek Kabelac [Fri, 27 Apr 2018 21:23:45 +0000 (23:23 +0200)]
aux: enhance teardown to better handle weird names

When 'dmsetup' reports result with --nameprefixes it currently
incorrectly 'escapes' problematic characters.

Letting pass such string though shell 'eval' function is hard task.
So instead cut away substring.

Once dmsetup will start to properly escape backslash and apostrophe
this function may need further tuning.

6 years agoMerge branch 'master' of git+ssh://sourceware.org/git/lvm2 into merge
Joe Thornber [Mon, 30 Apr 2018 08:34:12 +0000 (09:34 +0100)]
Merge branch 'master' of git+ssh://sourceware.org/git/lvm2 into merge

6 years agobuild: Calculate dependencies at same time as compiling.
Joe Thornber [Mon, 30 Apr 2018 08:32:14 +0000 (09:32 +0100)]
build: Calculate dependencies at same time as compiling.

Speeds up the build slightly.

6 years agotest: remove pv-duplicate
David Teigland [Fri, 27 Apr 2018 16:42:58 +0000 (11:42 -0500)]
test: remove pv-duplicate

This wasn't testing duplicate PVs, which are tested by
process-each-duplicate-pvs.sh.

6 years agounit-tests: Move to test/unit
Joe Thornber [Fri, 27 Apr 2018 15:55:07 +0000 (16:55 +0100)]
unit-tests: Move to test/unit

6 years agobuild: Stop creating the symlinks in include/ on the fly.
Joe Thornber [Fri, 27 Apr 2018 15:06:59 +0000 (16:06 +0100)]
build: Stop creating the symlinks in include/ on the fly.

Git handles symlinks, tar handles symlinks.  So I've just put the
links themselves into git.

This simplifies dependencies a little, and stop some build loops I was
hitting.

External build dir now works too.

6 years agoRevert "build: Stop creating the symlinks in include/ on the fly."
Joe Thornber [Fri, 27 Apr 2018 14:30:08 +0000 (15:30 +0100)]
Revert "build: Stop creating the symlinks in include/ on the fly."

This reverts commit f8f621951315087c4e7720682be495941dc3cf37.

It wasn't taking builds outside the src dir into account.

6 years agobuild: Stop creating the symlinks in include/ on the fly.
Joe Thornber [Fri, 27 Apr 2018 14:12:15 +0000 (15:12 +0100)]
build: Stop creating the symlinks in include/ on the fly.

Git handles symlinks, tar handles symlinks.  So I've just put the
links themselves into git.

This simplifies dependencies a little, and stop some build loops I was
hitting.

6 years agobcache: write some sanity checks for the asyn io engine
Joe Thornber [Fri, 27 Apr 2018 13:24:05 +0000 (14:24 +0100)]
bcache: write some sanity checks for the asyn io engine

Mainly checks aio is installed properly.

6 years ago[bcache] Some work on bcache_invalidate()
Joe Thornber [Fri, 27 Apr 2018 09:56:13 +0000 (10:56 +0100)]
[bcache] Some work on bcache_invalidate()

bcache_invalidate() now returns a bool to indicate success.  If fails
if the block is currently held, or the block is dirty and writeback
fails.

Added a bunch of unit tests for the invalidate functions.

Fixed some bugs to do with invalidating errored blocks.

6 years ago[bcache] Add some unit tests for invalidate block.
Joe Thornber [Fri, 27 Apr 2018 08:12:57 +0000 (09:12 +0100)]
[bcache] Add some unit tests for invalidate block.

Trying to identify dct's lockup.

6 years agoclvmd: drop old saved_vg when returning new saved_vg
David Teigland [Thu, 26 Apr 2018 19:41:57 +0000 (14:41 -0500)]
clvmd: drop old saved_vg when returning new saved_vg

In some pvmove tests, clvmd uses the new (precommitted)
saved_vg, but then requests the old saved_vg, and
expects that the new saved_vg be returned instead of
the old.  So, when returning the new saved_vg, forget
the old one so we don't return it again.

6 years agoscan: refresh filters before scan
David Teigland [Thu, 26 Apr 2018 19:48:13 +0000 (14:48 -0500)]
scan: refresh filters before scan

The filters save information about devices that should
be ignored, so if we need to repeat a scan  (unusual,
but happens in clvmd), we need to update the filters.

6 years ago[bcache] get all unit tests passing again
Joe Thornber [Thu, 26 Apr 2018 12:13:27 +0000 (13:13 +0100)]
[bcache] get all unit tests passing again

6 years ago[unit-test] Push the new unit test framwork.
Joe Thornber [Thu, 26 Apr 2018 10:59:39 +0000 (11:59 +0100)]
[unit-test] Push the new unit test framwork.

See doc/unit-test.txt for details.

Some bcache tests failing.  Probably due to dct changing semantics, will
fix in follow up patch.

6 years agopvmove: in fork mode destroy bcache in child
David Teigland [Wed, 25 Apr 2018 21:23:55 +0000 (16:23 -0500)]
pvmove: in fork mode destroy bcache in child

When pvmove was run in background mode and forks
instead of using lvmpolld, the child pvmove process
was not clearing the bcache from the parent, so all
the aio ops in the child were failing.

6 years agoscan: don't use cmd mem pool in scan
David Teigland [Wed, 25 Apr 2018 20:48:19 +0000 (15:48 -0500)]
scan: don't use cmd mem pool in scan

Make it consistent with all the other allocations
in scanning.

6 years agoskip some clvmd-specific code in common cases
David Teigland [Wed, 25 Apr 2018 20:08:54 +0000 (15:08 -0500)]
skip some clvmd-specific code in common cases

This, or something like it, can probably be done
in many other places.

6 years agoclvmd: skip dev rescan after full scan
David Teigland [Tue, 24 Apr 2018 19:48:30 +0000 (14:48 -0500)]
clvmd: skip dev rescan after full scan

When clvmd does a full label scan just prior to
calling _vg_read(), pass a new flag into _vg_read
to indicate that the normal rescan of VG devs is
not needed.

6 years agoclvmd: reuse a vg struct for sequential LV operations
David Teigland [Tue, 24 Apr 2018 18:19:48 +0000 (13:19 -0500)]
clvmd: reuse a vg struct for sequential LV operations

After reading a VG, stash it in lvmcache as "saved_vg".
Before reading the VG again, try to use the saved_vg.
The saved_vg is dropped on VG lock operations.

6 years agolvmcache: rename suspended_vg to saved_vg
David Teigland [Tue, 24 Apr 2018 17:18:22 +0000 (12:18 -0500)]
lvmcache: rename suspended_vg to saved_vg

The copy of the VG which clvmd stashes in lvmcache should
not only be used between suspend and resume, but between
sequential LV operations in clvmd, so that clvmd does not
need to reread the VG for each one.  Prepare for that by
renaming the stashed VG as "saved_vg".

6 years agoMerge remote-tracking branch 'sourceware/master' into upstream
Joe Thornber [Wed, 25 Apr 2018 08:18:42 +0000 (09:18 +0100)]
Merge remote-tracking branch 'sourceware/master' into upstream

6 years agotests: more zero usage
Zdenek Kabelac [Wed, 21 Mar 2018 10:21:38 +0000 (11:21 +0100)]
tests: more zero usage

Another case where usage of zero backend for mirror legs is more
effective then using delayed_dev.

6 years agotests: update testing to not use delay dev
Zdenek Kabelac [Mon, 23 Apr 2018 19:26:05 +0000 (21:26 +0200)]
tests: update testing to not use delay dev

Instead of using delayer device user 'zero' device and let mirror
do some real work which takes some time.

In case the test machine is too fast - mirror might need to be made bigger
to meet needed criteria.

Also move all test needed this 'zero' PV trick to the end of test
so  $dev2  and $dev4 are covered with 'zero' and can take any amount of
write without consuming any real space.

6 years agodebug: more explanatory error message
Zdenek Kabelac [Mon, 23 Apr 2018 20:11:38 +0000 (22:11 +0200)]
debug: more explanatory error message

6 years agolvconvert: preserve regionsize from existing mirror
Zdenek Kabelac [Mon, 23 Apr 2018 20:13:03 +0000 (22:13 +0200)]
lvconvert: preserve regionsize from existing mirror

When adding leg to existing mirror - preserve its regionsize.

6 years agolvchange: update mirror table when changing monitoring
Zdenek Kabelac [Mon, 23 Apr 2018 19:28:35 +0000 (21:28 +0200)]
lvchange: update mirror table when changing monitoring

Since for non-monitored mirrors we let mirror running without
error handling - when monitoring changes for mirror, updated
table (refresh) is needed.

6 years agogcc: remove duplicate typedef
Zdenek Kabelac [Mon, 23 Apr 2018 20:28:47 +0000 (22:28 +0200)]
gcc: remove duplicate typedef

6 years ago[git] Update .gitignore
Joe Thornber [Mon, 29 Jan 2018 09:40:21 +0000 (09:40 +0000)]
[git] Update .gitignore

6 years agoclvm: rescan when VG or PV not found
David Teigland [Fri, 20 Apr 2018 21:09:49 +0000 (16:09 -0500)]
clvm: rescan when VG or PV not found

Rescan devices to update lvmcache content when
clvmd vg_read doesn't find a VG or PV.

6 years agoliblvm2app: missed the addition of lvmcache_label_scan
David Teigland [Fri, 20 Apr 2018 17:00:49 +0000 (12:00 -0500)]
liblvm2app: missed the addition of lvmcache_label_scan

6 years agoscan: skip device rescan in vg_read
David Teigland [Wed, 18 Apr 2018 21:29:42 +0000 (16:29 -0500)]
scan: skip device rescan in vg_read

For reporting commands (pvs,vgs,lvs,pvdisplay,vgdisplay,lvdisplay)
we do not need to repeat the label scan of devices in vg_read if
they all had matching metadata in the initial label scan.  The
data read by label scan can just be reused for the vg_read.
This cuts the amount of device i/o in half, from two reads of
each device to one.  We have to be careful to avoid repairing
the VG if we've skipped rescanning.  (The VG repair code is very
poor, and will be redone soon.)

6 years agolvmpolld: update to use new scanning correctly
David Teigland [Fri, 13 Apr 2018 19:40:00 +0000 (14:40 -0500)]
lvmpolld: update to use new scanning correctly

6 years agobcache: intercept test mode before write
David Teigland [Mon, 9 Apr 2018 18:57:44 +0000 (13:57 -0500)]
bcache: intercept test mode before write

Don't allow writes in test mode.  test mode should be
more sophisticated than just faking writes, and this
should be a last defense for cases where test mode is
not being checked correctly.

6 years agolvmcache: simplify
David Teigland [Mon, 9 Apr 2018 18:40:49 +0000 (13:40 -0500)]
lvmcache: simplify

Recent changes allow some major simplification of the way
lvmcache works and is used.  lvmcache_label_scan is now
called in a controlled fashion at the start of commands,
and not via various unpredictable side effects.  Remove
various calls to it from other places.  lvmcache_label_scan
should not be called from anywhere during a command, because
it produces an incorrect representation of PVs with no MDAs,
and misclassifies them as orphans.  This has been a long
standing problem.  The invalid flag and rescanning based on
that is no longer used and removed.  The 'force' variation is
no longer needed and removed.

6 years agodev_cache: clean up scan
David Teigland [Mon, 9 Apr 2018 16:13:43 +0000 (11:13 -0500)]
dev_cache: clean up scan

Pull out all of the twisted logic and simply call dev_cache_scan
at the start of the command prior to label scan.

6 years agoremove unnecessary REQUIRES_FULL_LABEL_SCAN
David Teigland [Fri, 6 Apr 2018 18:18:03 +0000 (13:18 -0500)]
remove unnecessary REQUIRES_FULL_LABEL_SCAN

we always scan all devices

6 years agoscan: improve io error checking and reporting
David Teigland [Fri, 6 Apr 2018 18:12:26 +0000 (13:12 -0500)]
scan: improve io error checking and reporting

6 years agobcache: let caller see an error
David Teigland [Fri, 6 Apr 2018 18:11:39 +0000 (13:11 -0500)]
bcache: let caller see an error

6 years agoscan: drop bcache between lvm shell commands
David Teigland [Fri, 6 Apr 2018 18:05:17 +0000 (13:05 -0500)]
scan: drop bcache between lvm shell commands

A running lvm shell keeps all lvm devices open
unless the bcache is dropped.

6 years agotests: vgck now exits with error for bad vg
David Teigland [Fri, 9 Mar 2018 19:18:38 +0000 (13:18 -0600)]
tests: vgck now exits with error for bad vg

6 years agolvmetad: more fixes related to bcache
David Teigland [Fri, 9 Mar 2018 17:39:12 +0000 (11:39 -0600)]
lvmetad: more fixes related to bcache

Need to open devs prior to bcache io.

6 years agolvmetad: need to set up bcache in another place
David Teigland [Tue, 6 Mar 2018 21:05:27 +0000 (15:05 -0600)]
lvmetad: need to set up bcache in another place

We need to find one common place to set up bcache
for the lvmetad case, instead of adding calls in
various places.

6 years agolvmetad: fix process_each_label
David Teigland [Tue, 6 Mar 2018 17:22:18 +0000 (11:22 -0600)]
lvmetad: fix process_each_label

Was missing the call to populate lvmcache info from lvmetad
at the start of process_each_label.

6 years agoclvm: fix bcache scan handling
David Teigland [Thu, 1 Mar 2018 18:43:29 +0000 (12:43 -0600)]
clvm: fix bcache scan handling

We can't let clvmd keep all scanned devs open,
which prevents them from being removed.  So
drop the bcache data (and close fds) affter
doing a label scan.

Also set up bcache before the clvm-specific
vg_read (which needs to rescan the vg's devs
using bcache) and destroy the bcache after.

6 years agoscan: check for errors in text layer
David Teigland [Thu, 1 Mar 2018 18:42:18 +0000 (12:42 -0600)]
scan: check for errors in text layer

The scanning code in the format_text layer
has previously ignored errors.  Start checking
for and returning them.

6 years agoscan: remove lvmcache info for failed devs
David Teigland [Thu, 1 Mar 2018 18:40:37 +0000 (12:40 -0600)]
scan: remove lvmcache info for failed devs

When scanning a device fails, drop an lvmcache
info struct for it.

6 years agolvmcache: add shorter way to delete dev info
David Teigland [Thu, 1 Mar 2018 16:20:34 +0000 (10:20 -0600)]
lvmcache: add shorter way to delete dev info

Don't make the caller look up the info first.

6 years agobcache: fix error handling
David Teigland [Thu, 1 Mar 2018 16:17:32 +0000 (10:17 -0600)]
bcache: fix error handling

The error handling code wasn't working, but it
appears that just removing it is what we need.
The doesn't really need any different behavior
related to bcache blocks on an io error, it just
wants to know if there was an error.

6 years agoscan: add function to drop bcache blocks
David Teigland [Tue, 27 Feb 2018 22:35:47 +0000 (16:35 -0600)]
scan: add function to drop bcache blocks

which can be a little more efficient that destroy.

6 years agoscan: invalidate bcache for dev after errors
David Teigland [Tue, 27 Feb 2018 21:03:56 +0000 (15:03 -0600)]
scan: invalidate bcache for dev after errors

If there are errors reading or writing dev,
invalidate bcache for it.

6 years agobcache: add some error messages for debugging
David Teigland [Tue, 27 Feb 2018 18:37:25 +0000 (12:37 -0600)]
bcache: add some error messages for debugging

6 years agoscan: create bcache with minimum number of blocks
David Teigland [Tue, 27 Feb 2018 18:35:45 +0000 (12:35 -0600)]
scan: create bcache with minimum number of blocks

In some odd cases (e.g. tests) there are very few devices
which results in creating too few blocks in bcache, so
create bcache with a minimum number of blocks.

6 years agobcache: use wrappers for bcache read write in lvm
David Teigland [Tue, 27 Feb 2018 17:26:04 +0000 (11:26 -0600)]
bcache: use wrappers for bcache read write in lvm

Using a wrapper makes it easier to disable bcache if needed.

6 years agobcache: do all writes through bcache
David Teigland [Mon, 19 Feb 2018 21:40:44 +0000 (15:40 -0600)]
bcache: do all writes through bcache

6 years agomisc bcache fixes from ejt
David Teigland [Tue, 20 Feb 2018 15:33:27 +0000 (09:33 -0600)]
misc bcache fixes from ejt

6 years agovgchange: invalidate bcache for stacked LVs when deactivating
David Teigland [Fri, 16 Feb 2018 20:18:55 +0000 (14:18 -0600)]
vgchange: invalidate bcache for stacked LVs when deactivating

An LV with a stacked PV will be open in bcache and needs to be
invalidated to close the fd before attempting to deactivate.

6 years agoscan: drop bcache and close fd for LV with stacked PV
David Teigland [Fri, 16 Feb 2018 16:37:09 +0000 (10:37 -0600)]
scan: drop bcache and close fd for LV with stacked PV

When a PV is stacked on an LV, the LV will be kept in
bcache, and the open fd on the LV may interfere with
processing the LV.  So, drop/close a bcache fd for
an LV before processing the LV.

6 years agoscan: put dev back on caller's list
David Teigland [Thu, 15 Feb 2018 20:17:51 +0000 (14:17 -0600)]
scan: put dev back on caller's list

Commit 6e442875613915e506440e59a290b56756df2521 missed
adding devs back to caller's list.

6 years agopvck: use bcache
David Teigland [Thu, 15 Feb 2018 17:06:50 +0000 (11:06 -0600)]
pvck: use bcache

6 years agoscan: use 128K bcache block size
David Teigland [Thu, 15 Feb 2018 16:27:43 +0000 (10:27 -0600)]
scan: use 128K bcache block size

6 years agotest: vgsplit-usage if LVM1 tests
David Teigland [Thu, 15 Feb 2018 16:00:07 +0000 (10:00 -0600)]
test: vgsplit-usage if LVM1 tests

6 years agodisable LVM1 tests
David Teigland [Thu, 15 Feb 2018 15:54:12 +0000 (09:54 -0600)]
disable LVM1 tests

6 years agolvmdiskscan: use the new label_scan
David Teigland [Wed, 14 Feb 2018 22:43:26 +0000 (16:43 -0600)]
lvmdiskscan: use the new label_scan

instead of doing it's own.

6 years agoscan: always setup bcache for commands using lvmetad
David Teigland [Wed, 14 Feb 2018 22:21:27 +0000 (16:21 -0600)]
scan: always setup bcache for commands using lvmetad

Do this at the start of the command so that it doesn't
need to be checked and set up in every function that
could need it.

6 years agoscan: leave the caller's dev list unchanged
David Teigland [Wed, 14 Feb 2018 22:15:30 +0000 (16:15 -0600)]
scan: leave the caller's dev list unchanged

When scanning the list of devs from the caller
they are moved to another temporary list, but
were never returned to the original list.

6 years agoscan: setup bcache for commands using lvmetad
David Teigland [Wed, 14 Feb 2018 21:45:31 +0000 (15:45 -0600)]
scan: setup bcache for commands using lvmetad

Commands using lvmetad will not begin with a proper
label_scan which initializes bcache, but may later
decide they need to scan a set of devs, in which case
they'll need bcache set up at that point.

6 years agovgremove: fix force remove on devs with damaged metadata
David Teigland [Wed, 14 Feb 2018 20:47:28 +0000 (14:47 -0600)]
vgremove: fix force remove on devs with damaged metadata

The improved detection of bad metadata when scanning
(where errors were ignored before) means we now have to
override some errors when forcibly erasing damaged metadata.

6 years agoscan: skip extra scan in vg_read
David Teigland [Wed, 14 Feb 2018 19:49:56 +0000 (13:49 -0600)]
scan: skip extra scan in vg_read

Drop an extra label scan in the recovery part
of vg_read.  This is a temporary improvement
until the pending replacement for the broken
recovery code burried in vg_read.

6 years agoscan: handle request to scan missing dev
David Teigland [Tue, 13 Feb 2018 22:17:02 +0000 (16:17 -0600)]
scan: handle request to scan missing dev

6 years agoremove debugging print
David Teigland [Tue, 13 Feb 2018 21:53:59 +0000 (15:53 -0600)]
remove debugging print

6 years agoremove unused variable in _pvremove_check_single
David Teigland [Tue, 13 Feb 2018 20:28:24 +0000 (14:28 -0600)]
remove unused variable in _pvremove_check_single

6 years agoscan: handle no devices
David Teigland [Tue, 13 Feb 2018 19:37:10 +0000 (13:37 -0600)]
scan: handle no devices

Still create bcache.

6 years agoscan: add a dev to bcache before each read to handle write path
David Teigland [Tue, 13 Feb 2018 18:50:44 +0000 (12:50 -0600)]
scan: add a dev to bcache before each read to handle write path

This is a temporary hacky workaround to the problem of
reads going through bcache and writes not using bcache.
The write path wants to read parts of data that it is
incrementally writing to disk, but the reads (using
bcache) don't work because the writes are not in the
bcache.  For now, add a dev to bcache before each attempt
to read it in case it's being used on the write path.

6 years agoscan: use separate fd for bcache
David Teigland [Tue, 13 Feb 2018 14:58:35 +0000 (08:58 -0600)]
scan: use separate fd for bcache

Create a new dev->bcache_fd that the scanning code owns
and is in charge of opening/closing.  This prevents other
parts of lvm code (which do various open/close) from
interfering with the bcache fd.  A number of dev_open
and dev_close are removed from the reading path since
the read path now uses the bcache.

With that in place, open(O_EXCL) for pvcreate/pvremove
can then be fixed.  That wouldn't work previously because
of other open fds.

6 years agoprocess_each_label: use lvmcache
David Teigland [Fri, 9 Feb 2018 17:24:40 +0000 (11:24 -0600)]
process_each_label: use lvmcache

In the same way as the other process_each functions.
In the common case all the info that's needed can be
used from lvmcache after a label scan.  But this means
that unchosen devs for duplicate PVs need to be handled
explicitly.

6 years agopvremove: device check doesn't require label_read
David Teigland [Fri, 9 Feb 2018 18:43:12 +0000 (12:43 -0600)]
pvremove: device check doesn't require label_read

It just needs to check if the device was found during
the scan, which means checking if it exists in lvmcache.

6 years agoformat-text.c log message fixes
David Teigland [Wed, 7 Feb 2018 21:20:39 +0000 (15:20 -0600)]
format-text.c log message fixes

6 years agolvmcache: simplify metadata cache
David Teigland [Wed, 1 Nov 2017 14:35:40 +0000 (09:35 -0500)]
lvmcache: simplify metadata cache

The copy of VG metadata stored in lvmcache was not being used
in general.  It pretended to be a generic VG metadata cache,
but was not being used except for clvmd activation.  There
it was used to avoid reading from disk while devices were
suspended, i.e. in resume.

This removes the code that attempted to make this look
like a generic metadata cache, and replaces with with
something narrowly targetted to what it's actually used for.

This is a way of passing the VG from suspend to resume in
clvmd.  Since in the case of clvmd one caller can't simply
pass the same VG to both suspend and resume, suspend needs
to stash the VG somewhere that resume can grab it from.
(resume doesn't want to read it from disk since devices
are suspended.)  The lvmcache vginfo struct is used as a
convenient place to stash the VG to pass it from suspend
to resume, even though it isn't related to the lvmcache
or vginfo.  These suspended_vg* vginfo fields should
not be used or touched anywhere else, they are only to
be used for passing the VG data from suspend to resume
in clvmd.  The VG data being passed between suspend and
resume is never modified, and will only exist in the
brief period between suspend and resume in clvmd.

suspend has both old (current) and new (precommitted)
copies of the VG metadata.  It stashes both of these in
the vginfo prior to suspending devices.  When vg_commit
is successful, it sets a flag in vginfo as before,
signaling the transition from old to new metadata.

resume grabs the VG stashed by suspend.  If the vg_commit
happened, it grabs the new VG, and if the vg_commit didn't
happen it grabs the old VG.  The VG is then used to resume
LVs.

This isolates clvmd-specific code and usage from the
normal lvm vg_read code, making the code simpler and
the behavior easier to verify.

Sequence of operations:

- lv_suspend() has both vg_old and vg_new
  and stashes a copy of each onto the vginfo:
  lvmcache_save_suspended_vg(vg_old);
  lvmcache_save_suspended_vg(vg_new);

- vg_commit() happens, which causes all clvmd
  instances to call lvmcache_commit_metadata(vg).
  A flag is set in the vginfo indicating the
  transition from the old to new VG:
  vginfo->suspended_vg_committed = 1;

- lv_resume() needs either vg_old or vg_new
  to use in resuming LVs.  It doesn't want to
  read the VG from disk since devices are
  suspended, so it gets the VG stashed by
  lv_suspend:
  vg = lvmcache_get_suspended_vg(vgid);

If the vg_commit did not happen, suspended_vg_committed
will not be set, and in this case, lvmcache_get_suspended_vg()
will return the old VG instead of the new VG, and it will
resume LVs based on the old metadata.

6 years agolabel_scan: remove extra label scan and read for orphan PVs
David Teigland [Mon, 6 Nov 2017 18:09:52 +0000 (12:09 -0600)]
label_scan: remove extra label scan and read for orphan PVs

When process_each_pv() calls vg_read() on the orphan VG, the
internal implementation was doing an unnecessary
lvmcache_label_scan() and two unnecessary label_read() calls
on each orphan.  Some of those unnecessary label scans/reads
would sometimes be skipped due to caching, but the code was
always doing at least one unnecessary read on each orphan.

The common format_text case was also unecessarily calling into
the format-specific pv_read() function which actually did nothing.

By analyzing each case in which vg_read() was being called on
the orphan VG, we can say that all of the label scans/reads
in vg_read_orphans are unnecessary:

1. reporting commands: the information saved in lvmcache by
the original label scan can be reported.  There is no advantage
to repeating the label scan on the orphans a second time before
reporting it.

2. pvcreate/vgcreate/vgextend: these all share a common
implementation in pvcreate_each_device().  That function
already rescans labels after acquiring the orphan VG lock,
which ensures that the command is using valid lvmcache
information.

6 years agovgcreate: improve the use of label_scan
David Teigland [Thu, 26 Oct 2017 19:32:30 +0000 (14:32 -0500)]
vgcreate: improve the use of label_scan

The old code was doing unnecessary label scans when
checking to see if the new VG name exists.  A single
label_scan is sufficient if it is done after the
new VG lock is held.

6 years agolvmetad: use new label_scan for update from pvscan
David Teigland [Wed, 7 Feb 2018 19:58:40 +0000 (13:58 -0600)]
lvmetad: use new label_scan for update from pvscan

Take advantage of the common implementation with aio
and reduced disk reads.

6 years agolvmetad: use new label_scan for update from lvmlockd
David Teigland [Thu, 26 Oct 2017 15:58:23 +0000 (10:58 -0500)]
lvmetad: use new label_scan for update from lvmlockd

When lvmlockd indicates that the lvmetad cache is out of
date because of changes by another node, lvmetad_pvscan_vg()
rescans the devices in the VG to update lvmetad.  Use the
new label_scan in this function to use the common code and
take advantage of the new aio and reduced reads.

6 years agoindependent metadata areas: fix bogus code
David Teigland [Wed, 25 Oct 2017 18:55:22 +0000 (13:55 -0500)]
independent metadata areas: fix bogus code

Fix mixing bitwise & and logical && which was
always 1 in any case.

6 years agolabel_scan: fix independent metadata areas
David Teigland [Wed, 25 Oct 2017 18:39:46 +0000 (13:39 -0500)]
label_scan: fix independent metadata areas

This fixes the use of lvmcache_label_rescan_vg() in the previous
commit for the special case of independent metadata areas.

label scan is about discovering VG name to device associations
using information from disks, but devices in VGs with
independent metadata areas have no information on disk, so
the label scan does nothing for these VGs/devices.
With independent metadata areas, only the VG metadata found
in files is used.  This metadata is found and read in
vg_read in the processing phase.

lvmcache_label_rescan_vg() drops lvmcache info for the VG devices
before repeating the label scan on them.  In the case of
independent metadata areas, there is no metadata on devices, so the
label scan of the devices will find nothing, so will not recreate
the necessary vginfo/info data in lvmcache for the VG.  Fix this
by setting a flag in the lvmcache vginfo struct indicating that
the VG uses independent metadata areas, and label rescanning should
be skipped.

In the case of independent metadata areas, it is the metadata
processing in the vg_read phase that sets up the lvmcache
vginfo/info information, and label scan has no role.

6 years agoscan: do scanning at the start of a command
David Teigland [Wed, 7 Feb 2018 19:26:37 +0000 (13:26 -0600)]
scan: do scanning at the start of a command

Move the location of scans to make it clearer and avoid
unnecessary repeated scanning.  There should be one scan
at the start of a command which is then used through the
rest of command processing.

Previously, the initial label scan was called as a side effect
from various utility functions.  This would lead to it being called
unnecessarily.  It is an expensive operation, and should only be
called when necessary.  Also, this is a primary step in the
function of the command, and as such it should be called prominently
at the top level of command processing, not as a hidden side effect
of a utility function.  lvm knows exactly where and when the
label scan needs to be done.  Because of this, move the label scan
calls from the internal functions to the top level of processing.

Other specific instances of lvmcache_label_scan() are still called
unnecessarily or unclearly by specific commands that do not use
the common process_each functions.  These will be improved in
future commits.

During the processing phase, rescanning labels for devices in a VG
needs to be done after the VG lock is acquired in case things have
changed since the initial label scan.  This was being done by way
of rescanning devices that had the INVALID flag set in lvmcache.
This usually approximated the right set of devices, but it was not
exact, and obfuscated the real requirement.  Correct this by using
a new function that rescans the devices in the VG:
lvmcache_label_rescan_vg().

Apart from being inexact, the rescanning was extremely well hidden.
_vg_read() would call ->create_instance(), _text_create_text_instance(),
_create_vg_text_instance() which would call lvmcache_label_scan()
which would call _scan_invalid() which repeats the label scan on
devices flagged INVALID.  lvmcache_label_rescan_vg() is now called
prominently by _vg_read() directly.

6 years agoscan: use new label_scan for lvmcache_label_scan
David Teigland [Wed, 7 Feb 2018 19:14:08 +0000 (13:14 -0600)]
scan: use new label_scan for lvmcache_label_scan

To do label scanning, lvm code calls lvmcache_label_scan().
Change lvmcache_label_scan() to use the new label_scan()
based on bcache.

Also add lvmcache_label_rescan_vg() which calls the new
label_scan_devs() which does label scanning on only the
specified devices.  This is for a subsequent commit and
is not yet used.

6 years agoscan: use bcache for label scan and vg read
David Teigland [Tue, 6 Feb 2018 21:18:11 +0000 (15:18 -0600)]
scan: use bcache for label scan and vg read

New label_scan function populates bcache for each device
on the system.

The two read paths are updated to get data from bcache.

The bcache is not yet used for writing.  bcache blocks
for a device are invalidated when the device is written.

6 years ago[makefile] add -laio to makefiles
David Teigland [Thu, 8 Feb 2018 15:32:19 +0000 (09:32 -0600)]
[makefile] add -laio to makefiles

6 years ago[device/bcache] bcache_read_bytes should put blocks
David Teigland [Thu, 8 Feb 2018 19:44:54 +0000 (13:44 -0600)]
[device/bcache] bcache_read_bytes should put blocks

6 years ago[device/bcache] fix min() function
David Teigland [Thu, 8 Feb 2018 17:16:19 +0000 (11:16 -0600)]
[device/bcache] fix min() function

6 years ago[device/bcache] fix missing max_io fn in bcache async engine
David Teigland [Thu, 8 Feb 2018 16:10:31 +0000 (10:10 -0600)]
[device/bcache] fix missing max_io fn in bcache async engine

6 years ago[device/bcache] more work on bcache
Joe Thornber [Tue, 6 Feb 2018 15:10:44 +0000 (15:10 +0000)]
[device/bcache] more work on bcache

6 years ago[device/bcache] More fiddling with tests
Joe Thornber [Tue, 6 Feb 2018 13:06:15 +0000 (13:06 +0000)]
[device/bcache] More fiddling with tests

6 years ago[device/bcache] add bcache_prefetch_bytes() and bcache_read_bytes()
Joe Thornber [Mon, 5 Feb 2018 16:56:56 +0000 (16:56 +0000)]
[device/bcache] add bcache_prefetch_bytes() and bcache_read_bytes()

Not tested yet.

6 years ago[device/bcache] More tests and some bug fixes
Joe Thornber [Mon, 5 Feb 2018 16:04:23 +0000 (16:04 +0000)]
[device/bcache] More tests and some bug fixes

6 years ago[build] include test/unit/Makefile rather than recursive build
Joe Thornber [Fri, 2 Feb 2018 15:39:17 +0000 (15:39 +0000)]
[build] include test/unit/Makefile rather than recursive build

FIXME: unit tests are not currently run as part of make check.

6 years ago[device/bcache] rename a unit test
Joe Thornber [Fri, 2 Feb 2018 15:38:46 +0000 (15:38 +0000)]
[device/bcache] rename a unit test

6 years ago[device/bcache] another unit test
Joe Thornber [Fri, 2 Feb 2018 14:35:11 +0000 (14:35 +0000)]
[device/bcache] another unit test

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