1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

6684 Commits

Author SHA1 Message Date
Zdenek Kabelac
41f9e372c0 bcache: fix waiting problem for completed IO
Call _wait_all() which does check whether there is still
some pending IO before sleep. Otherwise it may happen
our submitted IO operations have been already dispatched
and this call then endlessly waits for IO which are all done.
This can be reproduced when device returns quickly errors
on write requests.
2020-10-02 20:53:41 +02:00
David Teigland
450f272b31 devices: support printing the filter that rejects a device
Use of this new message function needs to be added
to various commands to improve the output.
2020-10-01 12:00:09 -05:00
David Teigland
c32d7fed4f writecache: use two step detach
When detaching a writecache, use the cleaner setting
by default to writeback data prior to suspending the
lv to detach the writecache.  This avoids potentially
blocking for a long period with the device suspended.

Detaching a writecache first sets the cleaner option, waits
for a short period of time (less than a second), and checks
if the writecache has quickly become clean.  If so, the
writecache is detached immediately.  This optimizes the case
where little writeback is needed.

If the writecache does not quickly become clean, then the
detach command leaves the writecache attached with the
cleaner option set.  This leaves the LV in the same state
as if the user had set the cleaner option directly with
lvchange --cachesettings cleaner=1 LV.

After leaving the LV with the cleaner option set, the
detach command will wait and watch the writeback progress,
and will finally detach the writecache when the writeback
is finished.  The detach command does not need to wait
during the writeback phase, and can be canceled, in which
case the LV will remain with the writecache attached and
the cleaner option set.  When the user runs the detach
command again it will complete the detach.

To detach a writecache directly, without using the cleaner
step (which has been the approach previously), add the
option --cachesettings cleaner=0 to the detach command.
2020-10-01 11:33:02 -05:00
David Teigland
2272a32e6f lvmlockd vdo: add support
lvmlockd handling for vdo lv and vdo pool is like
thin lv and thin pool.
2020-09-29 14:43:27 -05:00
David Teigland
82e270c18a lvmlockd vdo: disallow use of shared lock on LV
vdo cannot be active on multiple hosts concurrently
2020-09-29 14:43:26 -05:00
Zdenek Kabelac
6728788bf5 debug: remove stacktrace on regular path
Here _insert is expected to also fail, so just regular 'return 0'.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
0c89c5a40f debug: update debug message 2020-09-29 10:43:56 +02:00
Zdenek Kabelac
bd0d4de4e2 active: fix compilation without devmapper
Better support for compilation without device-mapper.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
4cd356b26b thin: remove unneeded code test
Since we detect already transaction if before starting
to build dm tree - this extra check is a duplicate
that would only capture very tiny 'race' and we later
validate transaction_id with suspended snapshot origin.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
4de6f58085 thin: use lv_status_thin and lv_status_thin_pool
Introduce structures lv_status_thin_pool and
lv_status_thin  (pair to lv_status_cache, lv_status_vdo)

Convert lv_thin_percent() -> lv_thin_status()
and  lv_thin_pool_percent() + lv_thin_pool_transaction_id() ->
lv_thin_pool_status().

This way a function user can see not only percentages, but also
other important status info about thin-pool.

TODO:
This patch tries to not change too many other things,
but pool_below_threshold() now uses new thin-pool info to return
failure if thin-pool cannot be actually modified.
This should be handle separately in a better way.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
92c0e8c17f writecache: archive before modification of metadata
Archive before we start to modify metadata.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
08e838f488 cleanup: avoid unneeded check
Since creation of thin snapshot already makes sure,
the message list is empty, there is no need to check
this again.
2020-09-29 10:43:56 +02:00
Zdenek Kabelac
af5f29c7e2 activation: move locking of critical section
Move begining of 'suspending' critical section closer to _lv_suspend_lv()
for better correctness of error paths.
2020-09-29 10:43:56 +02:00
Bastian Germann
168e2ffbcd lvm: add readline alternative editline
LVM2 is distributed under GPLv2 only. The readline library changed its
license long ago to GPLv3. Given that those licenses are incompatible
and you follow the FSF in their interpretation that dynamically linking
creates a derivative work, distributing LVM2 linked against a current
readline version might be legally problematic.

Add support for the BSD licensed editline library as an alternative for
readline.

Link: https://thrysoee.dk/editline
2020-09-29 10:13:24 +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
David Teigland
da14cf68cb scanning: keep open an lvm device with scanning problem
The command may want to update it.
2020-09-28 13:25:57 -05:00
David Teigland
890c7ef451 devices: fix reopen for unopened device
If there's a request to reopen rw a device that's not
open, then just call the normal open function.
2020-09-28 13:25:57 -05:00
Heinz Mauelshagen
8952dcbff0 Revert "lvconvert: display warning if raid1 LV image count does not change"
This reverts superfluous commit 3c9177fdc0 as
_lv_raid_change_image_count() already checks for non-changed image count.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872130
2020-09-28 17:14:03 +02:00
Zdenek Kabelac
e414ebef6e thin: pass through whole code
Instead of early 'return 0' let the whole code finish
in case of an error with syncing.
2020-09-25 22:59:35 +02:00
Zdenek Kabelac
8b22e38087 thin: improve error message
Add more info, explaing why the suspend of thin snapshot origin was omitted.
2020-09-25 22:59:35 +02:00
Zdenek Kabelac
ef59c83f2d thin: enhance lvcreate error paths
Improve error response and reporting, when creating thin snapshots.
If the thin pool kernel metadata already have device with ID lvm2
tries to create, give more meanigful error message and also properly
restore transaction id to the value known to thin-pool in this case.

Before it's been possible to divert by one from kernel TID value,
and lvm2 stacked delete message for such thin device.
2020-09-25 22:56:40 +02:00
Zdenek Kabelac
e2eb1dc501 thin: no delete message for device_id 0
Since we always use device_id > 0, we could use
device_id == 0 to actually mark thinLV as an
LV we want to remove without delete message.
2020-09-25 22:54:07 +02:00
Zdenek Kabelac
50a37948b5 vdo: allow passing renamed vdopool name to kernel
Although kernel does not allow to load a new dm table
with renamed vdopool, at least make lvm2 code ready
it it every will get supported.
2020-09-23 13:20:28 +02:00
Zdenek Kabelac
7c19186271 vdo: disable support for online rename of vdopool LV
Since ATM kernel does not support this operation,
disable 'lvrename' of an active vdopool.

As a workaround, user may simply deactivate, rename and activate.
2020-09-23 13:18:23 +02:00
Zdenek Kabelac
3a3307c0d8 vdo: enhance vdo pool extension
When user tries to extend vdo pool - he needs to go always
at least by 1 full VDO slab  (defined as  vdo_slab_size_mb).

To avoid all trouble around find 'workable' size - lvm2 automatically
increases the passed (or by --use-policies calculated) extension size
(and informs a user about sometimes possibly large increase as slab
size can go upto 32GiB)

With VDO users need to always 'think-big' anyway and expect such
operation to be in GiB domain range.
2020-09-22 23:28:43 +02:00
Zdenek Kabelac
f38b7afd62 vdo: extend vdo segment validation
Try to catch all suspicious VDO segments in metadata early.
2020-09-22 23:25:16 +02:00
Zdenek Kabelac
642ef54399 vdo: correct message about policy extend support
Policy extend is already supported for vdo pools as well,
so correct the error message.
2020-09-22 23:25:16 +02:00
Zdenek Kabelac
e08a0421a3 vdo: drop unnecessary tabulator from metadata output 2020-09-22 23:25:16 +02:00
Zdenek Kabelac
5bc66532c7 activation: use revert_lv on tree suspend failure
When thetable reload fails during suspend() - we were only calling
plain resume() - and this will reload only those devices,
which were left suspend, but will not try to restore
metadata state according to lvm2 reverted metadata.
So if we were reloading device tree - we have restored
only top-level LV and rest of reverted device manipulation
were left alone and possibly mismatched what is in committed
metadata.

FIXME: There are several cases were such revert will likely not work
properly anyway as some operation are currenly handled in single commit,
while they need multiple commits, but it's step towards better correctness.
At least we catch there errors now earlier.
2020-09-22 21:02:14 +02:00
Zdenek Kabelac
6c769eb460 bache: fix error return value
Return 0 as failure (as checked for).
Also add INTERNAL_ERROR if  'DI' would be -1.
2020-09-19 23:00:50 +02:00
David Teigland
1404e5ee61 metadata: open rw fd before closing ro fd
lvm opens devices readonly to scan them, but
needs to open then readwrite to update the metadata.
Previously, the ro fd was closed before the rw fd
was opened, leaving a small gap where the dev was
not held open, and during which the dev could
possibly change which storage it referred to.

With the bcache_change_fd() interface, lvm opens a
rw fd on a device to be written, tells bcache to
change to the new rw fd, and closes the ro fd.

. open dev ro
. read dev with the ro fd (label_scan)
. lock vg (ex for writing)
. open dev rw
. close ro fd
. rescan dev to check if the metadata changed
  between the scan and the lock
. if the metadata did change, reread in full
. write the metadata
2020-09-18 15:10:11 -05:00
David Teigland
1570e76233 bcache: use indirection table for fd
Add a "device index" (di) for each device, and use this
in the bcache api to the rest of lvm.  This replaces the
file descriptor (fd) in the api.  The rest of lvm uses
new functions bcache_set_fd(), bcache_clear_fd(), and
bcache_change_fd() to control which fd bcache uses for
io to a particular device.

. lvm opens a dev and gets and fd.
  fd = open(dev);

. lvm passes fd to the bcache layer and gets a di
  to use in the bcache api for the dev.
  di = bcache_set_fd(fd);

. lvm uses bcache functions, passing di for the dev.
  bcache_write_bytes(di, ...), etc.

. bcache translates di to fd to do io.

. lvm closes the device and clears the di/fd bcache state.
  close(fd);
  bcache_clear_fd(di);

In the bcache layer, a di-to-fd translation table
(int *_fd_table) is added.  When bcache needs to
perform io on a di, it uses _fd_table[di].

In the following commit, lvm will make use of the new
bcache_change_fd() function to change the fd that
bcache uses for the dev, without dropping cached blocks.
2020-09-18 15:10:11 -05:00
David Teigland
46f43589d0 hints: enhance debug messages 2020-09-16 15:01:10 -05:00
David Teigland
491eb25832 label: cleanup set_byte error exit 2020-09-16 13:54:16 -05:00
David Teigland
37bcd7ce84 Revert "label: use formaters FMTu64 and FMTsize_t"
This reverts commit d0ccb2521b.
2020-09-16 13:47:06 -05:00
Zdenek Kabelac
d0ccb2521b label: use formaters FMTu64 and FMTsize_t
Produces code without casts to differntly signed types
and also shortens and enhances readbility.
2020-09-15 23:07:06 +02:00
Zdenek Kabelac
2b36542f41 wipe: dev_set_bytes resolves zeroing
Since dev_write_zeros() is just subset of dev_set_bytes()
use it directly and simplify code.
2020-09-15 23:07:06 +02:00
Zdenek Kabelac
d588de77aa wipe: convert zero_value to uint8_t
We always write this value as byte.
2020-09-15 22:52:25 +02:00
Zdenek Kabelac
ec4e8b5c0e wipe: zeroing of 8 sectors is granted
With do_zero min is always 8 sectors, so use 0 as default.
2020-09-15 22:52:25 +02:00
Zdenek Kabelac
7bcc994776 label: deduplicate dev_set_bytes
As dev_write_zeros() is same as dev_set_bytes() reused the code
directly.
2020-09-15 22:52:25 +02:00
Zdenek Kabelac
7b08133844 label: code deduplication 2020-09-15 22:52:25 +02:00
Zdenek Kabelac
6d344b4ac0 hints: enhance debug with log_sys_debug 2020-09-15 22:52:25 +02:00
Zdenek Kabelac
187cc8d344 lvcreate: change error message
Provide more useful error message.
2020-09-15 22:52:25 +02:00
Zdenek Kabelac
39198eb2ce lvcreate: add extra synchronization at error path
Put explict udev synchronization before we try to deactive devices.
2020-09-15 22:52:25 +02:00
Zdenek Kabelac
b2978efbff cache: simplier signal handling
Use just single sigint_allow()/restore() within flushing loop
and void one extra signal manipulation.
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
2101e324f9 locking: restore blocking signal for VG_GLOBAL lck
During removal of a lot of locking code the signal blocking got lost
and signal processing got broken leading to unpredictable
behavior of i.e. activation code the can get interrupted in the
middle of DM table processing.

lvm2 code always expects signals are blocked while lock is held
unless it is explictelly placed into section of:
sigint_allow();....;sigint_restore();
For checking catched interrupt there is sigint_catched();
2020-09-14 00:15:14 +02:00
Zdenek Kabelac
77fdc17d70 alloc: improve estimation of sufficient_pes_free
Metadata size was calculated correctly only for raids.

Fixes problem for crash during lvcreate when thin-pool was created
on a VG where remaining free space had the size to only fit a single
metadata LV and not also its _pmspare.

Lvcreate crashed with this assert message:

lvcreate: metadata/pv_map.c:198: consume_pv_area: Assertion `to_go <= pva->count' failed.
Aborted (core dumped)

TODO: there is probably to large overload of several alloc_handle
variables.

Reported-by: Wu Guanghao<wuguanghao3@huawei.com>
Reported-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
2020-09-11 21:51:24 +02:00
Zdenek Kabelac
9f78acfee9 thin: compensate metadata size by extra percent
When using --use-policy for automatic extension of thin-pool,
the extension of thin-pool's metadata itself can actually take
some extra space.
Since I'm not aware of exact compensation formula, add just
1% extra to calculated amount and hope it fits.

Wanted target is to always have usable thin-pool that fits
bellow pool_metadata_min_threshold().
2020-09-11 21:42:37 +02:00
Zdenek Kabelac
b798554a20 lv_manip: even better rounding 2020-09-11 13:37:04 +02:00
Zdenek Kabelac
678951f635 cleanup: comment typo 2020-09-10 23:55:03 +02:00