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

6054 Commits

Author SHA1 Message Date
Zdenek Kabelac
6481471c9d debug: update comment 2018-03-06 15:40:34 +01:00
Zdenek Kabelac
b6e7a0b490 cleanup: more usage of dm_strncpy
Use existing wrapper function arournd  strncpy + buf[] = 0;
2018-03-06 15:40:34 +01:00
Zdenek Kabelac
f04abd1f8a lvremove: drop duplicate check for active LV
Since this code branch already tested LV is active,
avoid repeating same query.
2018-03-06 15:40:31 +01:00
Zdenek Kabelac
b2f1254c14 raid: move VG update after archiving happened
Update of LV le_count needs to happen after archive().
2018-03-06 15:38:15 +01:00
Zdenek Kabelac
ce199db848 raid: fix error path for lv_raid_data_offset
Avoid using allocated status on error path.
2018-03-06 15:36:11 +01:00
Zdenek Kabelac
406d6de651 cleanup: indent 2018-02-28 21:15:55 +01:00
Zdenek Kabelac
16c209c613 cleanup: use lv_is_used_cache_pool
Use lv_is_used_cache_pool() to simplify the code.
Function was introduced later and this code missed to use it.
2018-02-28 21:15:55 +01:00
Zdenek Kabelac
e643de6e61 cleanup: explicitely ignore result code
ATM too long prefix is silently ignored.
2018-02-28 21:15:55 +01:00
Zdenek Kabelac
805bf6ec74 cleanup: unused header file 2018-02-28 21:15:55 +01:00
Zdenek Kabelac
6ba94fdd81 debug: change message severity
Although it's internal issue - in this case command continue without
any reported error - thus hide this internal error into debug.
2018-02-28 21:15:55 +01:00
Zdenek Kabelac
052f28746d lvresize: check external origin with new size
Instead of checking with existing size of external origin LV,
use correctly the new 'wanted' size of this LV whether it fits
the limitiation requirements for older thin-pool target.

Otherwise code started to the the resize, updates metadata and
just fails during 'resize' in case the LV was active. For
inactive LV operation could have actually passed.
2018-02-28 21:15:55 +01:00
Zdenek Kabelac
b09ea3b6f7 lvremove: drop unneded check
Checking here for cache_pool is not necessary and in effect
the check is not even right - since there are internal
states that do allow to active such LV.
2018-02-28 21:08:40 +01:00
Zdenek Kabelac
bc1adc32cb lv_manip: enhance for_each_sub_lv
Fix missing 'externalLV' traversing for thins with external origins.

Replace extra for_each_sub_lv_except_pools() with better
internal logic allowing selectively to cut of processed subLV tree.

Extend error code for function 'fn()' when it returns -1 it will
stop futher tree scan for given LV.

Also a bit simplify code to have only one place that
is calling 'fn()' and use level counter to know
depth of traversing.

Update renaming travering to skip trees for pools
and external origins.
2018-02-28 21:08:38 +01:00
Zdenek Kabelac
6b48868cf0 io: keep 64b arithmetic
Widen to 64b arithmetic from start.
2018-02-28 21:05:18 +01:00
Zdenek Kabelac
261e6c3df6 raid: add free for error path
Recent patch forget to release now allocated 'dso' on error path.
2018-02-28 21:05:18 +01:00
Zdenek Kabelac
e7f1329cae debug: capture internal error for too long resource name
Should never happen, so just put in internal error instead of silently
passing some shortened resource name.
2018-02-19 16:45:10 +01:00
Zdenek Kabelac
c3bb2b29d4 locking: move cache dropping to primary locking code
While 'file-locking' code always dropped cached VG before
lock was taken - other locking types actually missed this.

So while the cache dropping has been implement for i.e. clvmd,
actually running command in cluster keept using cache even
when the lock has been i.e. dropped and taken again.

This rather 'hard-to-hit' error was noticable in some
tests running in cluster where content of PV has been
changed (metadata-balance.sh)

Fix the code by moving cache dropping directly lock_vol() function.

TODO: it's kind of strange we should ever need drop_cached_metadata()
used in several places - this all should happen automatically
this some futher thinking here is likely needed.
2018-02-19 16:45:05 +01:00
Zdenek Kabelac
a2d2fe3a8c locking: exclusive can be either remote or local
When LOCK is exclusive and LV is already locally active,
it cannot be active remotely.
2018-02-15 13:54:55 +01:00
Zdenek Kabelac
a1195aaa66 cleanup: add missing WARNING
ATM log_warn() is supposed to be used with WARNING: prefix.
2018-02-15 13:52:02 +01:00
Marian Csontos
d67f160200 mirror: Add deprecation warning for mirrored log 2018-02-14 13:32:04 +01:00
Zdenek Kabelac
c3642957c5 gcc: remove warns about free of const 2018-02-13 19:56:02 +01:00
Zdenek Kabelac
0eb9daf602 segtype: no libmem pool usage for name allocation
Allocate name with plain malloc & free.
2018-02-13 19:11:28 +01:00
Zdenek Kabelac
32febed8d5 segtype: replace mempool allocation
So this is a bit more complex and possibly worth futher checking.

ATM  clvmd drops  cmd->mem  mempool AFTER refresh of cmd.
So anything allocating from cmd->mem during toolcontext init
will likely die at some point in time.

As a quick fix - just use regular malloc/free for 'dso' alloction.

It's worth to note -  cmd->libmem seems to be often misused
causing hidden memleaking for clvmd.
2018-02-13 19:11:28 +01:00
Zdenek Kabelac
e40768ac32 debug: add stack tracking 2018-02-12 22:15:03 +01:00
Zdenek Kabelac
27399755fd segtype: better get_monitor_dso_path api
Instead of allocating always 4K for dso path, use only real needed size.
Also simplify API call and move common functionality into function
itself.
2018-02-12 22:15:03 +01:00
Zdenek Kabelac
e113df129e cleanup: decode dso path just once
Build dso plugin name during  segtype initialisation and just
use the string during command life-time.

Also slightlt update message verbosity and make it very_verbose
when operation is going to be made and 'verbose' when it's done.
2018-02-12 22:15:03 +01:00
Zdenek Kabelac
6dff5dc653 activation: cleanup error to warning
Since for the code it's not fatal to fail on monitoring,
issue correct warning message instead of error.
2018-02-12 22:15:03 +01:00
Zdenek Kabelac
d90a647802 activation: separate reporting of error and monitoring status
Avoid using same return code for reporting 2 different things
and stricly report error code by return value and add new
parameter for reporting monitoring status.

This makes easier to recognize which error we got from dm_event
and continue only with  ENOENT.
2018-02-12 22:14:59 +01:00
Zdenek Kabelac
12fba201be cleanup: detect dmeventd_executable just once
Avoid repeating debug messages about dmeventd executable
and just remember it once for whole cmd lifetime.
2018-02-12 22:14:25 +01:00
Zdenek Kabelac
7239a45b79 clean: drop unneeded -1 for snprintf
man gives:
snprintf() and vsnprintf() write at most size bytes
(including the terminating null byte ('\0')) to str.
2018-02-12 22:14:25 +01:00
Zdenek Kabelac
afdbb28f72 toolcontext: light context missed to set-up mem mempool
If cmd->mem was null, then systemd generator was failing on:

(gdb) bt
dm_pool_alloc_aligned (p=0x0, s=96, alignment=8) at mm/pool-fast.c:95
dm_pool_alloc (p=0x0, s=96) at mm/pool-fast.c:90
dm_pool_zalloc (p=0x0, s=96) at mm/pool.c:74
config_file_read_fd (mem=0x0, cft=0x55f4339dbad0, dev=0x55f4339dfac0, reason=DEV_IO_MDA_CONTENT, offset=0, size=82293, offset2=0, size2=0,
    checksum_fn=0x0, checksum=0, checksum_only=0, no_dup_node_check=0, ioflags=0, config_file_read_fd_callback=0x0, config_file_read_fd_context=0x0) at config/config.c:567
config_file_read (mem=0x0, cft=0x55f4339dbad0) at config/config.c:658
config_file_open_and_read (config_file=0x7f49aef14540 <config_file> "/var/tmp/lvm/etc/lvm/lvm.conf", source=CONFIG_FILE, cmd=0x55f4339d6260)
    at config/config.c:282
_load_config_file (cmd=0x55f4339d6260, tag=0x7f49aeca15da "", local=0) at commands/toolcontext.c:824
_init_lvm_conf (cmd=0x55f4339d6260) at commands/toolcontext.c:853
create_config_context () at commands/toolcontext.c:1814
lvm_config_find_bool (libh=0x0, config_path=0x55f431a884ad "global/use_lvmetad", fail=0) at lvm_base.c:144
main ()
2018-02-12 22:13:53 +01:00
Zdenek Kabelac
83258e3385 toolcontext: do not change stream for pthreaded programs
With pthreaded daemons like 'dmeventd' using  liblvm via plugin,
lvm2 actually should not 'play' with streams at all - as there
could be parallel outputs running.

As a current quick workaround just disable change for pthreaded
program (gettid() != getpid()).

TODO: it's possible the change of buffering actually doesn't serve us
any measurable benefit and could be dropped as whole later...

Meanwhile this patch is fixing this occasional valgrind race report:

Invalid read of size 4
   at 0x571892C: vfprintf (in /usr/lib64/libc-2.26.9000.so)
   by 0x57216B3: fprintf (in /usr/lib64/libc-2.26.9000.so)
   by 0x5042886: dm_event_log (libdevmapper-event.c:925)
   by 0x10B015: _dmeventd_log (dmeventd.c:125)
   by 0x10D289: _unregister_for_event (dmeventd.c:1146)
   by 0x10E52E: _handle_request (dmeventd.c:1583)
   by 0x10E6D7: _do_process_request (dmeventd.c:1631)
   by 0x10E7C6: _process_request (dmeventd.c:1660)
   by 0x1101A4: main (dmeventd.c:2285)
 Address 0x6264d30 is 192 bytes inside a block of size 552 free'd
   at 0x4C2ED68: free (vg_replace_malloc.c:530)
   by 0x573907D: fclose@@GLIBC_2.2.5 (in /usr/lib64/libc-2.26.9000.so)
   by 0x6AC5C00: reopen_standard_stream (log.c:189)
   by 0x6A8E62C: destroy_toolcontext (toolcontext.c:2271)
   by 0x6BA5C22: lvm_fin (lvmcmdline.c:3339)
   by 0x6BD5EF3: lvm2_exit (lvmcmdlib.c:123)
   by 0x6856013: dmeventd_lvm2_exit (dmeventd_lvm.c:103)
   by 0x66535B8: unregister_device (dmeventd_thin.c:432)
   by 0x10CBBC: _do_unregister_device (dmeventd.c:926)
   by 0x10CD74: _monitor_unregister (dmeventd.c:979)
   by 0x10D094: _monitor_thread (dmeventd.c:1066)
   by 0x54B35E0: start_thread (in /usr/lib64/libpthread-2.26.9000.so)
   by 0x57C30EE: clone (in /usr/lib64/libc-2.26.9000.so)
 Block was alloc'd at
   at 0x4C2DBBB: malloc (vg_replace_malloc.c:299)
   by 0x573932B: fdopen@@GLIBC_2.2.5 (in /usr/lib64/libc-2.26.9000.so)
   by 0x6AC5DC2: reopen_standard_stream (log.c:200)
   by 0x6A8D11D: create_toolcontext (toolcontext.c:1898)
   by 0x6BA5B6B: init_lvm (lvmcmdline.c:3319)
   by 0x6BD5BC8: cmdlib_lvm2_init (lvmcmdlib.c:34)
   by 0x6BD5F04: lvm2_init (lvm2cmd.c:20)
   by 0x6855EA7: dmeventd_lvm2_init (dmeventd_lvm.c:67)
   by 0x665305F: register_device (dmeventd_thin.c:352)
   by 0x10CB7A: _do_register_device (dmeventd.c:916)
   by 0x10CEE4: _monitor_thread (dmeventd.c:1006)
   by 0x54B35E0: start_thread (in /usr/lib64/libpthread-2.26.9000.so)
   by 0x57C30EE: clone (in /usr/lib64/libc-2.26.9000.so)
....
Process terminating with default action of signal 6 (SIGABRT): dumping core
   at 0x570016B: raise (in /usr/lib64/libc-2.26.9000.so)
   by 0x5701520: abort (in /usr/lib64/libc-2.26.9000.so)
   by 0x57437D8: __libc_message (in /usr/lib64/libc-2.26.9000.so)
   by 0x5743831: __libc_fatal (in /usr/lib64/libc-2.26.9000.so)
   by 0x5744056: _IO_vtable_check (in /usr/lib64/libc-2.26.9000.so)
   by 0x574751C: __overflow (in /usr/lib64/libc-2.26.9000.so)
   by 0x574191A: fputc (in /usr/lib64/libc-2.26.9000.so)
   by 0x50428E3: dm_event_log (libdevmapper-event.c:934)
   by 0x10B015: _dmeventd_log (dmeventd.c:125)
   by 0x10D289: _unregister_for_event (dmeventd.c:1146)
   by 0x10E52E: _handle_request (dmeventd.c:1583)
   by 0x10E6D7: _do_process_request (dmeventd.c:1631)
   by 0x10E7C6: _process_request (dmeventd.c:1660)
   by 0x1101A4: main (dmeventd.c:2285)
2018-02-09 10:56:40 +01:00
Alasdair G Kergon
1b6d0346a3 format_text: Use versionsort to sort archive files
Ensure that vg_100000-* follows vg_99999-* so that the expiry logic
doesn't stop too early.

   https://bugzilla.redhat.com/1481085
2018-02-09 01:08:55 +00:00
Alasdair G Kergon
d6cabbbc53 device: Fix basic async I/O error handling 2018-02-08 20:19:21 +00:00
Alasdair G Kergon
3e29c80122 device: Queue any aio beyond defined limits. 2018-02-08 20:15:37 +00:00
Alasdair G Kergon
db41fe6c5d lvmcache: Use asynchronous I/O when scanning devices. 2018-02-08 20:15:29 +00:00
Alasdair G Kergon
8c7bbcfb0f device: Basic config and setup to support async I/O. 2018-02-08 20:15:14 +00:00
Alasdair G Kergon
7a9af3cd0e device: Add flag to indicate that a code path can support AIO
Until the whole source supports AIO, library code can check for
AIO_SUPPORTED_CODE_PATH to determine whether or not it is OK
to use AIO.
2018-02-06 01:11:00 +00:00
Alasdair G Kergon
e869a52cc4 callbacks: Miscellaneous fixes for recent changes 2018-02-06 01:09:39 +00:00
Zdenek Kabelac
083c221cbe pvmove: reinstantiate clustered pvmove
In fact  pvmove does support  'clustered-core' target for clustered
pvmove of LVs activated on multiple nodes.

This patch restores support for activation of pvmove on all nodes
for LVs that are also activate on all nodes.
2018-02-01 21:55:20 +01:00
Zdenek Kabelac
a1cfef9f26 dev_io: fix writes for unaligned buffers
Actually the removed code is necessary - since not all writes are
getting alligned buffer - older compilers seems to be not able
to create 4K aligned buffers on stack - this the aligning code still
need to be present for write path.
2018-01-23 13:36:12 +01:00
Zdenek Kabelac
6e9148e7ab debug: drop DEBUG_MEM path
Memory is not allocated so no DEBUG_MEM part is needed.
2018-01-23 11:45:18 +01:00
Alasdair G Kergon
9194610f42 device: Add ioflags parameter to transfer additional state.
Flags are set on the initial I/O and passed to any callbacks that
may in turn issue further I/O using the inherited flags.
2018-01-21 21:10:23 +00:00
Zdenek Kabelac
f3c75bb201 activation: move check later
Check for lv when it's known in all cases.
2018-01-17 15:15:43 +01:00
Zdenek Kabelac
38b81e6537 cleanup: enhance messages
Add extra info about failing local exlusive activation
(as in cluster the LV can be active on some other nodes).
2018-01-17 14:45:48 +01:00
Zdenek Kabelac
a8bcdef4fd activation: guard exclusive activation
Add protectional internall error whenever we spot activation
of 'exclusive' only segments in 'non-exclusive' mode.

TODO: possibly the activation locking could be enhanced to handle
this fully behind the scene - as for now this works purely for
lvchange/vgchange activation.
2018-01-17 14:45:47 +01:00
Zdenek Kabelac
e86910b052 lvconvert: use excl activation for conversion
Use properly exclusive activation when reactivating origin after
snapshot merge (since origin must have been previously also exlusively
activated).

Same applies when converting volumes to thin-pool or cache.

Previously used 'only' local activation incorrectly allowed local
activation of some targets (i.e. raid) - thus 'leaking' chance to
activate same device on another node - which can be a problem
for device types like raid.
2018-01-17 14:43:34 +01:00
Alasdair G Kergon
c26458339e device: Move buffer allocation nearer to the I/O.
Don't allocate memory until it's needed - later we'll add
some of the I/O to an internal queue instead of issuing it
immediately.
2018-01-16 01:12:08 +00:00
Alasdair G Kergon
081902b4c1 device: Merge _dev_read and dev_read_callback. 2018-01-16 00:41:42 +00:00
Alasdair G Kergon
0a3c6bf8c6 format_text: Refactor mda counting in label processing. 2018-01-15 23:47:44 +00:00
Alasdair G Kergon
73b5ee64e7 format_text: Change update_mda_baton to use label not labeller 2018-01-15 20:13:53 +00:00
Alasdair G Kergon
b825987b2f device: Rearrange _aligned_io(). 2018-01-15 20:10:54 +00:00
Alasdair G Kergon
c90582344d device: Add reason to devbuf. 2018-01-15 19:38:18 +00:00
Alasdair G Kergon
1f01eaa612 device: Store offset to data instead of pointer.
We want to save the relative offset before we've allocated the
buffer's memory.
2018-01-15 19:32:59 +00:00
Alasdair G Kergon
61d3296f2a device: Reorder device.h before change. 2018-01-15 19:24:01 +00:00
Alasdair G Kergon
35cdd9cf48 label: Clean up storing of device and label sector.
No longer use the external 'result' pointer internally to set up the
cached label.  The callback _set_label_read_result() is now given the
internal label pointer directly

Callers that don't need the result are no longer required to pass a
label pointer into label_read().
2018-01-11 02:54:00 +00:00
Alasdair G Kergon
f771d3f870 config: Move use_mmap to local variable. 2018-01-10 20:35:02 +00:00
Alasdair G Kergon
6210c1ec28 device: Mark read-only device buffers const. 2018-01-10 19:57:10 +00:00
Alasdair G Kergon
c350f96c09 device: Eliminate unnecessary buffer from dev_read. 2018-01-10 18:48:01 +00:00
Alasdair G Kergon
366493a1d1 device: Suppress repeated reads of the same data.
If the data being requested is present in last_[extra_]devbuf,
return that directly instead of reading it from disk again.

Typical LVM2 access patterns request data within two adjacent 4k blocks
so we eliminate some read() system calls by always reading at least 8k.
2018-01-10 15:52:03 +00:00
Alasdair G Kergon
dcb2a5a611 device: Remove some data copying between buffers.
Callers that read larger amounts of data now get a pointer to read-only
data directly without copying it through an intermediate buffer.  This
data is owned by the device layer so the callers no longer free it.
2018-01-10 15:48:03 +00:00
Alasdair G Kergon
4d568b709c device: Free cached device bufs when metadata invalid or dev closed. 2018-01-10 15:48:03 +00:00
Alasdair G Kergon
bd0967a4b1 device: Keep the last data buffer read off each device.
If there's a second metadata area on device, we record that separately.

Note that the memory requirements aren't restricted yet.
2018-01-10 15:48:03 +00:00
Alasdair G Kergon
bacc942333 allocation: Avoid exceeding array bounds in allocation tag code
If _limit_to_one_area_per_tag() changes nothing it writes beyond
the array.
2018-01-10 15:48:03 +00:00
Alasdair G Kergon
e2438b5b9f format_text: Use malloc aligned for export buffer 2018-01-10 15:48:03 +00:00
Alasdair G Kergon
b65246499b label: Rename a variable 2018-01-10 15:48:03 +00:00
Alasdair G Kergon
ea96381534 libdm: Introduce dm_malloc_aligned 2018-01-10 15:48:03 +00:00
Alasdair G Kergon
f4675af4cf format_text: Use vgsummary callbacks 2018-01-09 03:14:30 +00:00
Alasdair G Kergon
4b02d4e22e label: Add label_read callback. 2018-01-08 23:30:50 +00:00
Alasdair G Kergon
6d322e68f3 label: Add callback fns (partially) 2018-01-08 17:04:56 +00:00
Alasdair G Kergon
5e7d3ad749 device: Introduce dev_read_callback
If it obtains the data, it passes it into the supplied callback function
and returns 1.  Otherwise the callback receives failed = 1.

Updated config_file_read_fd to use this and similarly return the data
via a callback fn of its own.
2018-01-06 02:40:12 +00:00
Alasdair G Kergon
946f07af3e metadata: Use a consistent format for callback fn parameters 2018-01-05 14:24:56 +00:00
Alasdair G Kergon
a0ddfad94b metadata: Change the new data processing fns to void.
Move the existing fn return codes into the new structs.
2018-01-05 03:12:22 +00:00
Alasdair G Kergon
c70c9f6565 format_text: Split vgname_from_mda into three pieces. 2018-01-04 21:13:44 +00:00
Alasdair G Kergon
d61b1369d0 format_text: Split out raw_read_mda_header processing 2018-01-04 15:52:59 +00:00
Alasdair G Kergon
139209ef42 format_text: Split up _update_mda.
Dedicated functions are now used to process each piece of data obtained,
so the refactoring in this file gives us one for the vgsummary and one
for the metadata header.  This new type of function takes two parameters
(for now), the obtained data plus a single struct (that must not
reference any data on the stack) that wraps up the entire context needed
to process it.
2018-01-04 12:25:24 +00:00
Alasdair G Kergon
111a9fcff5 format_text: Allocate update_mda baton from mempool.
Also store return code.  Note that fatal and non-fatal errors while
handling the mda aren't currently distinguished.
2018-01-03 23:53:00 +00:00
Alasdair G Kergon
5a846e0929 format_text: Split the text import fns into two pieces. 2018-01-03 20:48:02 +00:00
Alasdair G Kergon
4b9806ab6f toolcontext: Add paired label_init to refresh_toolcontext.
label_init() and label_exit() should be paired.
2018-01-02 22:00:31 +00:00
Alasdair G Kergon
22b6c482ec config: Split config buffer processing into new fn.
Wrap its parameters into struct process_config_file_params allocated
from a mempool now passed into the config_file_read* fns.
2018-01-02 21:10:46 +00:00
Alasdair G Kergon
3db51e3f0e label: Wrap _find_labeller params into a struct.
Move the actual buffer reading up to _label_read() so _find_labeller()
just examines the buffer supplied.
2018-01-02 17:15:32 +00:00
Alasdair G Kergon
9b830791ea label: Move _set_label_read_result call into _find_labeller.
Move responsibility for setting the label_read() result parameter down
into _find_labeller().
2018-01-02 15:30:58 +00:00
Alasdair G Kergon
4f4ddb806d label: Move setting result of label_read into separate fn. 2018-01-02 14:19:20 +00:00
Alasdair G Kergon
e6b4b41881 label: Add mempool. 2018-01-02 13:37:12 +00:00
Zdenek Kabelac
3a841515af lvm-string: add function to detect component LV suffix
Add is_component_lvname() function to recognize component LV name.
2017-12-19 15:28:07 +01:00
Alasdair G Kergon
17649d4ac8 device: Move dev_read memory allocation into device layer.
Rename dev_read() to dev_read_buf() - the function that reads data
into a supplied buffer.

Introduce a new dev_read() that allocates the buffer it returns and
switch the important users over to this.  No caller may change the
returned data.  (For now, callers are responsible for freeing it after
use, but later the device layer will take full ownership.)

dev_read_buf() should only be used for tiny buffers or unimportant code
(such as the old disk formats).
2017-12-19 01:31:50 +00:00
David Teigland
3f9ae846b8 lvmlockd: clear coverity complaint
from previous coverity fix, it's never happy.
2017-12-18 15:19:17 -06:00
Alasdair G Kergon
5f45cb90a7 format_text: Transfer circular buf alloc to device layer.
Instead of the caller passing dev_read_circular() a buffer to fill with
data, the device layer itself now allocates it.
2017-12-15 22:34:26 +00:00
Alasdair G Kergon
beee9940a5 format_text: Separate out code paths for buffer wraparound
The creation of wrapped around metadata - where the start of metadata is
written up to the end of the buffer and the remainder follows back at
the start of the buffer - is now restricted to cases where writing the
metadata in one piece wouldn't fit.  This shouldn't happen in 'normal'
usage so let's begin treating the code for this as a special case that
can be ignored when optimising 'normal' cases.
2017-12-15 21:12:19 +00:00
Alasdair G Kergon
145ded10c2 format_text: Supply mempool directly to raw_read_mda_header. 2017-12-15 14:57:05 +00:00
Alasdair G Kergon
3edc25dbdf format_text: Round size written up to multiple of 4096.
Zero-fill metadata up to the next 4096 boundary then write out a
multiple of 4096 bytes to avoid triggering a read-modify-write.
2017-12-12 22:52:22 +00:00
Alasdair G Kergon
78ffa44fc5 format_text: Change metadata alignment from 512 to 4096.
If there is sufficient space in the metadata area, align the next
metadata to a disk offset that is a multiple of 4096 bytes and
don't write it circularly.  If it doesn't all fit at the end
of the metadata area, go back to the start and write it all there
contiguously.

If there is insufficient space to use the new stricter rules, revert to
the original behaviour, aligning on 512-byte boundaries wrapping around
the circular buffer as required.
2017-12-12 20:57:36 +00:00
Alasdair G Kergon
643df602c7 format_text: More refactoring of metadata offset calcs 2017-12-12 18:51:32 +00:00
Alasdair G Kergon
4002f5e206 format_text: Refactor and document metadata offset calculation. 2017-12-12 18:36:54 +00:00
Alasdair G Kergon
e932c5da50 device: Fix an unpaired device close.
dev_open_flags contains an unpaired dev_close_immediate so increment
open_count before calling it.
2017-12-12 17:56:58 +00:00
Alasdair G Kergon
b96862ee11 metadata: Consistently skip metadata areas that failed.
Even after writing some metadata encountered problems, some commands
continue (rightly or wrongly) and attempt to make further changes.

Once an mda is marked MDA_FAILED, don't try to use it again.
This also applies when reverting, where one loop already skips
failed mdas but the other doesn't.

This fixes some device open_count warnings on relevant failure paths.
2017-12-12 17:52:45 +00:00
Alasdair G Kergon
c5ef76bf27 device: Internal error if writing 0 bytes to dev. 2017-12-12 12:57:25 +00:00
Alasdair G Kergon
b76c6951aa format_text: Adjust metadata alignment calculation.
Use new ALIGN_ABSOLUTE macro when calculating the start location
of new metadata and adjust the end of buffer detection so that
there is no longer an imposed gap between old and new metadata.
2017-12-11 20:25:03 +00:00
Alasdair G Kergon
053d35de47 format_text: Use absolute alignment to calculate metadata usage
Currently both start and offset should always be divisible by alignment,
so this should have no effect, but a later patch will increase alignment
so these variables can no longer be optimised out.
2017-12-11 17:14:38 +00:00
Alasdair G Kergon
2db67a8ea0 format_text: Move metadata size checking into separate fn.
Move checks into _metadata_fits_into_buffer() and add macro for alignment.
2017-12-11 17:08:29 +00:00
Alasdair G Kergon
46393bfca0 format_text: Log additional circular buffer information. 2017-12-11 16:07:34 +00:00
Alasdair G Kergon
49d486319f format_text: Replace PRI with FMT. 2017-12-11 15:39:25 +00:00
Zdenek Kabelac
71485ebfc7 thin: regression fix for metadata checking
Fix regression from commit f173274fe4
and restore support for 'disabled' checking via lvm.conf.
2017-12-08 13:21:15 +01:00
Zdenek Kabelac
455b26b8db activation: keep priority till memlock_unlock
Although it doesn't look like it can be a measurable problem
and costs some time to flip priorities outside of activation window.

So just like with memory locking preserve priority until call
memlock_unlock() appears.

(addition to commit c086dfadc3).
2017-12-08 13:21:15 +01:00
Alasdair G Kergon
14b1e5270d format_text: Use explicit alignment in wrapping calc.
Expand out the metadata wrapping calculations to prepare
to support a larger alignment.

The current alignment is 512 bytes so
(mdac_area_start + rlocn->offset) % alignment is zero.
2017-12-08 01:18:46 +00:00
Zdenek Kabelac
f173274fe4 cleanup: reorder calling of pool checking tools
Test for zero header before even starting to create argument list for
execution of thin/cache_check tool.
2017-12-07 21:00:39 +01:00
Alasdair G Kergon
2166d7be72 lvmetad: drop stray underscore 2017-12-07 16:24:14 +00:00
Alasdair G Kergon
d591d04103 device: Tag I/O for each mda on a device separately in log messages.
Mark the first metadata area on each text format PV as MDA_PRIMARY.
Pass this information down to the device layer so that when
there are two metadata areas on a block device, we can easily
distinguish two independent streams of I/O.
2017-12-07 03:48:11 +00:00
David Teigland
54154dc6f1 lvmlockd: clear coverity complaint 2017-12-06 10:49:31 -06:00
David Teigland
b910c34f09 lvmlockd: use pool lock for tmeta access
When a command is run on a named tmeta LV, use
the lock on the pool.
2017-12-05 14:31:03 -06:00
David Teigland
b9e4198500 lvmlockd: fix log print
from previous commit
2017-12-05 13:48:30 -06:00
David Teigland
5d5807b238 lvmlockd: improve error message for VG lock conflict
When there is significant VG lock contention which retries
have not been able to mask, print a better error message.
2017-12-05 11:53:03 -06:00
Heinz Mauelshagen
94632eb155 deactivate_lvs: deactivate any missing RaidLV legs
In case of failed legs, raid replaces those with
e.g. "vg-lv_rimage_0-missing_0_0" mapped to an error target.

Those errouneously remain on deactivation.

Fix by removing them on deactivation/removal of the RaidLV.
2017-12-05 18:48:06 +01:00
Alasdair G Kergon
7195df5aca device: Skip read-modify-write if replacing whole block. 2017-12-05 01:00:38 +00:00
Alasdair G Kergon
e4805e4883 device: categorise block i/o
Introduce enum dev_io_reason to categorise block device I/O
in debug messages so it's obvious what it is for.

DEV_IO_SIGNATURES   /* Scanning device signatures */
DEV_IO_LABEL        /* LVM PV disk label */
DEV_IO_MDA_HEADER   /* Text format metadata area header */
DEV_IO_MDA_CONTENT  /* Text format metadata area content */
DEV_IO_FMT1         /* Original LVM1 metadata format */
DEV_IO_POOL         /* Pool metadata format */
DEV_IO_LV           /* Content written to an LV */
DEV_IO_LOG          /* Logging messages */
2017-12-04 23:45:26 +00:00
Zdenek Kabelac
698483b5a1 activation: also lock memory for clustered locking
Commit  c086dfadc3 missed to lock memory
for clustering suspend part since it's using differnt locking reason.
2017-12-04 23:33:02 +01:00
Zdenek Kabelac
110dac870c cleanup: use existing define with prefix 2017-12-04 15:38:50 +01:00
Zdenek Kabelac
2a22576b2d cleanup: drop unused header
DM_UUID_LEN is no longer needed.
2017-12-04 15:38:50 +01:00
Heinz Mauelshagen
4daad1cf11 lv_manip: allow extension on --nosync raid lv
If the recovery of the repleced leg(s) of a RaidLV created without
initial resynchronization (i.e. "lvcreate --nosync ...") got
interrupted, it can't be extended because of the < 100% sync rate.
2017-12-01 18:38:18 +01:00
Heinz Mauelshagen
d3d18e637c raid: ignore --stripesize on raid4/5 conversion to 1 stripe
In case caller passes in changed stripe size when reshaping raid4/5
to 1 stripe aiming to convert to raid1 and optionally to linear,
ignore it to prevent data corruption.
2017-12-01 15:00:09 +01:00
Zdenek Kabelac
a42c3a0e90 cleanup: remove debug code 2017-12-01 12:19:09 +01:00
Zdenek Kabelac
4dc8184803 suspend: optimize generated list
Avoid adding same LV multiple times into the list.
Just saves couple extra calls and ioctls and makes log shorter.
2017-12-01 12:19:09 +01:00
Zdenek Kabelac
7e794b7748 activation: avoid rechecking pvmove node
Use new 3rd. state of trace_pvmove_deps == 2.
In this state we know, we have already seen the node and can skip futher
testing.   Remainging value 1 signals we want to track, and value 0
is for ignoring tracking, but node is still checking in this case.

Reduces large amount of duplicate ioctl queries.
2017-12-01 12:19:09 +01:00
Zdenek Kabelac
e4db42e476 activation: extend resume validation
Check also all snapshosts when resume is requested,
the origin volume is already resume, but possibly
some subLV or snapshot LV could be suspended if
we are still in critical_section.
2017-12-01 12:19:09 +01:00
Zdenek Kabelac
c086dfadc3 activation: split priority from memory locking
When entering any critical section, lvm2 used to lock process memory
and raised task priority to avoid problem with page swapping and minimize
time of having non-resumed devices in table.

With this patch, memory locking which which is expensive is only used when
entering  'suspending' section as only in this section there is risk
lvm could be suspending a device which later can be needed for paging.

Raised priority is still kept for all section entrances as this is
low-cost operation and may accelerate table resumes - although the real
impact can be still considered later.
2017-12-01 12:19:09 +01:00
Zdenek Kabelac
c489dd2e17 pvmove: add missing segment merging
When pvmove is finished and metadata are updated, the code missed
to merge possible mergable segments - so add explicit merging
call after pvmoved volumes are unlocked.

This avoids weird results where i.e. lvs could have been reporting
non-matching segments as lvs upon metadata read is doing silent segment
merging while dm table left after pvmove was still preserving
non-merged segments.
2017-12-01 12:19:09 +01:00
Zdenek Kabelac
fbd8b456db pvmove: move code from tools to lib
Move code manipulating with locking flags into /lib part of lvm.
2017-12-01 12:18:32 +01:00
Alasdair G Kergon
a9812ec9d3 label: Remove unused verify functions.
label_verify has never been used so remove it.
2017-11-28 01:36:55 +00:00
Zdenek Kabelac
02e934c444 cleanup: reuse existing macro
Use existing macro to detect striped raid segment.
2017-11-27 10:34:30 +01:00
Zdenek Kabelac
f70404addb pvmove: enhance delayed_resume logic
ATM we want to support delayed resume purely in pvmove case.
So have libdm logic internal to recognize difference beween
pvmove and other targets that do use delayed resume.

This fixes problem introduced with commit aa68b898ff
for mirror-on-mirror or snapshot-on-mirror problem.

TODO: likely added new API call and let libdm user select
delayed nodes explicitely.
2017-11-26 00:36:48 +01:00
Zdenek Kabelac
8c6fd0933f activation: enhance holders detection
Use code which detectes handlers in a way, which is more
backward-compatible friendly.

Replace read of 'sysfs' uuid entry with dm ioctl call.

Use /sys/block/dm-X/holders path instead of
new path  /sys/dev/block/major:minor/holders.

TODO:
There are few more occurencies of this logic around the code
so some abstract interface should be considered.
2017-11-26 00:31:26 +01:00
Zdenek Kabelac
54741aeac5 cleanup: reduce couple debug lines 2017-11-24 16:09:59 +01:00
Zdenek Kabelac
5e88d3a89b cache: use conditional in warning message
In some cases the message could be slightly misleading so use
here rather conditional.

TODO:

In future we may possibly further tune the message in case we are
certain the level of redundancy protection has not been reduced.
2017-11-24 16:09:59 +01:00
Zdenek Kabelac
2a6981a697 activation: automaticaly discover pvmove holders
When pvmove is finished and does 'suspend/resume' on PVMOVE LV,
on resume path committed metadata are already showing 'standalone'
pvmove LV prepared just for removal.

However code should be able to 'resume' preloaded LV there were
participating in pvmove operation.

Previously this was all done in the 'tools' part of lvm2 code.
So the lvconvert upon pvmove finish had to explicitely call 'resume' on every such LV.
Now 'smarted' activation code is able to deduce and combine all information from
the active dm table and committed metadata so single  call resolves
it all in one go.

Internally holders are detected by reading sysfs directory to capture
all needed UUID which are then looked in lvm2 metadata and all such
LVs are automatically collected into dmtree.
2017-11-24 16:09:59 +01:00
Zdenek Kabelac
ddbe763eb8 mirror: use lv_update_and_reload_origin
Replace complex code with standard lv_update_and_reload_origin().
Extra suspend should not be necessary.
(If they would be - dependency tree would have bug for fixing).
2017-11-24 16:05:21 +01:00
Zdenek Kabelac
b5be7420d9 locking: pvmove is locking holding LV
As we do get lock for pvmove LV - it's lockholder ATM.
2017-11-24 16:05:21 +01:00
Zdenek Kabelac
8cf10948bd resume: secure critical section
Only  thin-pool with origin_only suspend is allowed to be not suspending anything.
In such case pairing resume will 'decrement' critical section counter.
2017-11-24 16:05:21 +01:00
Zdenek Kabelac
ae6beda12d suspend: handle start of pvmove
Just like suspend handles preload for pvmove finish,
in similar way handle suspend of starting pvmove.

In this case the  precommited metadata are checked for list of PVMOVEed
LVs and those are suspended in with committed metadata.
2017-11-24 16:05:21 +01:00
Alasdair G Kergon
115e66e9be device: log debug when I/O bounce buffer used 2017-11-16 19:16:10 +00:00
Heinz Mauelshagen
93c02e2532 raid: add validation checks for reshape flags
Enhance vg_validate() raid checking functions to check for
flags  LV_RESHAPE and LV_RESHAPE_DELTA_DISKS_(MINUS|PLUS).
2017-11-15 21:24:44 +01:00
Zdenek Kabelac
0f0dc1a2a5 pvmove: remove unusued code
Support for snapshot and cache LVs should now work.
Remove protection rejecting pvmove for them.
2017-11-15 21:00:29 +01:00
Zdenek Kabelac
b978f505ff pvmove: activation changes
Do not use precommitted LV for suspend of pvmoving LVs.
2017-11-15 21:00:26 +01:00
Zdenek Kabelac
9d04ecc7b3 cleanup: update log messages 2017-11-15 14:03:22 +01:00
Zdenek Kabelac
838592a171 activate_lvs: use exclusive activation
There is no need to differentiation between clustered VG and normal VG.
As the activation depends on locking type.

Use unconditionally locally exclusive activation for pvmove.
2017-11-15 14:03:22 +01:00
Zdenek Kabelac
8212e1047e pvmove: always flush when working with pvmove tree 2017-11-15 14:03:22 +01:00
Zdenek Kabelac
35b207946a activation: suspend pvmove using lv.
Whenever pvmove tree is going to be generated for suspend
and such LV has a user - use this 'using LV' to generate
correct dm tree  holding all components.
2017-11-15 14:03:22 +01:00
Zdenek Kabelac
9e2a68a981 activation: check subLV before skipping resume
LV is asked for resume, and its already resume and tool
is inside 'critical_section()' check if there is any suspended sub LV.
In that case 'resume' operation will not be skipped.
2017-11-15 14:03:22 +01:00
Zdenek Kabelac
c820b43fc0 activate_lvs: deactivate on uniterate
When activation of LVs fails prior pvmove start, try to deactivate
already activated LVs.

TODO: possibly remember which LVs where already activate and only those
take down - devices which are already in-use will stay active.
2017-11-15 12:11:33 +01:00
Zdenek Kabelac
eab9097b46 layers: collect only lock holding LVs 2017-11-15 12:11:33 +01:00
Zdenek Kabelac
cc854c0617 pvmove: return pvmove itself
When find_pvmove_lv_in_lv() get already a 'pvmoving' LV - return it.
2017-11-15 11:51:53 +01:00
Zdenek Kabelac
919744375e pvmove: snapshots need to go with origin device
Enable future support for pvmove for COW LVs.
2017-11-15 11:51:53 +01:00
Alasdair G Kergon
02e9876665 log: Add io debug class 2017-11-15 01:02:15 +00:00
Alasdair G Kergon
b5f62a143d metadata: Eliminate redundant nested VG metadata
Only lv_committed() now uses vg->vg_committed and it appears redundant
if its contents match the enclosing VG so don't waste cycles creating it
when that's known to be true when no write lock is held so the struct
won't get modified.
2017-11-14 15:38:55 +00:00
Heinz Mauelshagen
ebd0fed0ce raid: correct raid6_n_6 -> raid5 convenience type
Fix "lvconvert --type raid5 RaidLV" on a "raid6_n_6" LV offering
false "raid6_ls_6" instead of "raid5_n".
2017-11-14 14:41:06 +00:00
Alasdair G Kergon
00acae12a4 metadata: Remove unused vg.cft_precommitted
The precommitted metadata config_tree is now only referenced from a
single function so just use a local variable instead.
2017-11-14 01:22:09 +00:00
Alasdair G Kergon
6bf0f04ae2 log: Improve various device-related messages
- Use 'lvmcache' consistently instead of 'metadata cache'
- Always use 5 characters for source line number
- Remember to convert uuids into printable form
- Use <no name> rather than (null) when VG has no name.
2017-11-13 19:45:33 +00:00
Zdenek Kabelac
dd06a0a4a6 lv_lock_holder: unused cache-pool is not lock holder
Unused cache-pool is only a constainer for data and metadata,
and does not present localble entity.
2017-11-11 00:59:46 +01:00
Zdenek Kabelac
52cee9dd83 lvremove: for unused cache deactive sublv 2017-11-11 00:59:19 +01:00
Zdenek Kabelac
55b8204ca3 reload: do not take backup with suspended devices
If the suspend/resume sequence would leave some device in suspend
for possible later resume, backup cannot be takes (fs holding backups
could be still frozen in critical section())
2017-11-11 00:58:11 +01:00
Zdenek Kabelac
b9ac1c12d0 cleanup: constify lv parameter 2017-11-11 00:56:10 +01:00
Zdenek Kabelac
05f9acdc7f raid: protect raid4 activation
Move check for presence of raid4 into the right place
so there is no way how to hit activation of any LV
with raid4 on kernel which does not support it.
2017-11-11 00:56:10 +01:00
Heinz Mauelshagen
9958c41927 raid: reject message for 2-legged raid4/5 -> striped
Commit 763db8aab0 rejects 2-legged
conversions to striped/raid0 but different messages are displayed
for raid0 or striped. This commit provides the same rejection messages.
2017-11-08 18:17:26 +01:00
Heinz Mauelshagen
763db8aab0 raid: reject conversion request to striped/raid0 on 2-legged raid4/5
raid4/5 LVs may only be converted to striped or raid0/raid0_meta
in case they have at least 3 legs. 2-legged raid4/5 are a result
of either converting a raid1 to raid4/5 (takeover) or converting
a raid4/5 with more than 2 legs to raid1 with 2 legs (reshape).

The raid4/5 personalities map those as raid1,
thus reject conversion to striped/raid0.

Resolves: rhbz1511047
2017-11-08 17:49:04 +01:00
Zdenek Kabelac
0c9e3e8df2 coverity: add some initilizers
Coverity cannot do a deeper analyzis so let's make just reports
go away and initialize them to 0.
2017-11-07 21:26:11 +01:00
Zdenek Kabelac
3076a839a5 cleanup: drop unneeded headerfiles
Coverity reported these are no longer in use.
2017-11-07 21:26:11 +01:00
Zdenek Kabelac
2354fb3fe4 coverity: avoid overflow_before_widen
TODO: it likely should be checked value is >0...
2017-11-07 21:26:11 +01:00
Zdenek Kabelac
7a394575fb cleanup: use segtype_is_raid_with_meta
Replace with common macro.
2017-11-01 00:59:22 +01:00
Zdenek Kabelac
373372c8ab lv_manip: hide layered LV temporarily
Since vg_validate() now rejects LVs without segments and
insert_layer_for_segments_on_pv() gets just created
'layer_lv' without segment,  it needs to be hidden
from vg->lvs during processing of _align_segment_boundary_to_pe_range()
as this function calls  lv_validate() and now requires
vg to be consistent.  LV is then put back into vg->lvs.
2017-11-01 00:55:24 +01:00
Alasdair G Kergon
248144d066 liblvm: Fix segfault in lvm_pv_remove.
Since 4fa5add6b1 ("pvcreate: Wipe cached
bootloaderarea when wiping label.") label_remove is responsible
for the lvmcache_del.  (toollib and liblvm need fixing to share
the code.)
2017-10-30 22:03:35 +00:00
Zdenek Kabelac
2b6391538c raid: setup LV size earlier
New validation code which does require to not store LV with no size
(no segments) revealed this size setup code needs to happen
earlier.
2017-10-30 17:23:56 +01:00
Zdenek Kabelac
83d5db056b lvreduce: check LV has segment
Before accessing content make sure LV has segment.
This can be used in case code removes LV without segments
(i.e. on some error path)
2017-10-30 14:39:16 +01:00
Zdenek Kabelac
0424410773 validation: capture store of LV without segment 2017-10-30 14:39:16 +01:00
Zdenek Kabelac
e9206fb93d devcache: track more udev errors
Add a bit more details for failing udev function.
2017-10-30 13:16:50 +01:00
Alasdair G Kergon
52fd66210b metadata: Avoid accessing ignored metadata.
When an ignored metadata area gets flagged for use again, make sure the
code doesn't try to parse its old metadata.  Firstly by trying to detect
this situation and skipping the read (while still remembering the
position reached in the circular buffer), and secondly by clearing the
invalid live metadata location on disk as a precaution when subsequently
writing out the precommitted metadata.

Problems showed up when a metadata area in one VG got moved to
another VG in ignored state (still holding metadata for the original
VG) and then later got brought into use in the new VG - only the header
should be read in this case, not any of the metadata content.
2017-10-27 22:53:43 +01:00
Alasdair G Kergon
84aca4201e vgsplit: Fix detection of moved PVs.
vgsplit shares the vg_rename code so that must only set the PV_MOVED_VG
flag introduced in commit 486ed10848
("vgmerge: Fix intermediate metadata corruption") on PVs that moved.
2017-10-27 22:53:43 +01:00
Zdenek Kabelac
63c50ced89 snapshot: relocate common code validation for snapshot origin
Since both lvcreate and lvconvert needs to check for same
type of allowed origin for snapshot - move the code into
a single function.

This way we also fix several inconsitencies where snapshot
has been allowed by mistake either through lvcreate or
lvconvert path.
2017-10-27 17:07:42 +02:00
Heinz Mauelshagen
4a3884245d raid: ignore --stripes/--stripesize on takeover
Converting from one raid level to another, no changes
of stripes or stripesize can be requested because those
are subject to reshaping.  I.e. the process requires to
takeover first and secondly request raid algorithm,
stripe or stripesize changes.

Ignore any related changes display warninngs
and proceed with the takeover.

Without this patch, a takeover requesting
stripesize change causes data corruption!
2017-10-26 17:16:23 +02:00
Zdenek Kabelac
837bfab75c log: better message when reached log limit
Add explaining message, when command was aborted due to the reach
of configure line number count (LVM_LOG_FILE_MAX_LINES)
for logging (used mainly with testing).
2017-10-26 14:04:58 +02:00
Zdenek Kabelac
0e7edd1d24 snapshot: improve validation
Do not allow to take snapshot of mirror/raid leg or log or metadata LV.
This was actually never supported, but user was able to create it,
and this put device stack in hardly fixable state (needs manual work).

This prevents such creation to pass.

Also improve validation when recreating snapshot volume type
from origin and COW volume.
2017-10-25 21:58:01 +02:00
Zdenek Kabelac
d6fcab900b lvextend: detect stacked cache lv used for thinpool
Ensure, that cacheLV is not tried to be resize until full support is
added.
2017-10-23 12:00:43 +02:00
Alasdair G Kergon
f3ae99dcc0 liblvm: Move lib code used exclusively into metadata-liblvm.c
Also remove some redundant function definitions from metadata.h.
2017-10-18 19:29:32 +01:00
Alasdair G Kergon
f1cc5b12fd tidy: Add missing underscores to statics. 2017-10-18 15:58:13 +01:00
David Teigland
1b319f39d6 lvmlockd: check error for sanlock access to lvmlock LV
When the sanlock daemon does not have permission to access
the lvmlock LV, make the error messages more helpful.
2017-10-17 13:45:53 -05:00
Alasdair G Kergon
146745ad88 device: Separate errors for dev not found and filtered.
Replaced the confusing device error message "not found (or ignored by
filtering)" by either "not found" or "excluded by a filter".
(Later we should be able to say which filter.)

Left the the liblvm code paths alone.
2017-10-17 02:12:41 +01:00
Zdenek Kabelac
186a3da998 thin: monitor also external origin
Add missing monitoring for external origin LVs and add -real suffix
for UUID used for monitoring of external origin.
2017-10-16 15:47:46 +02:00
David Teigland
6ac1e04b3a replicator: remove the code
It has not been used in a long time and is not
expected to be used further.
2017-10-13 16:20:42 -05:00
Heinz Mauelshagen
cf13a30eaa lvcreate: allow 100%FREE creation of "--type mirror" to work
Fixes the following case with 3PVs and 3 legs "mirror" LV:

# lvcreate -l100%FREE --type mirror -m2 vg3
  Insufficient free space for log allocation for logical volume .
  Unable to allocate extents for mirror log.

Related: rhbz1269533
2017-10-12 17:43:24 +02:00
Zdenek Kabelac
e02e5b0c5b activation: fix activation lock
Activation lock has a primary purpose to serialize locking of individual
LV in case there is no other protecting mechanism for parallel
execution.

However in the case an activated LV is composed from several other LVs,
noone should be able to manipulate with those LVs as well.

This patch add a very 'naive' global VG activation locking in this case.
In the future we may introduce smarter function detecting minimal closed
graph components if this will appear as bottleneck

Patch checks if the  VG Write lock is held - in this case we do not
need any more locking - command has exclusive access to VG.

In case we have clustered VG and we are activating an LV which does not
need other LVs - we also do not need any more locks.

In all other cases take respective lock - for single LV - use lvid,
for complex LVs  use vgname.
2017-10-11 14:24:28 +02:00
Zdenek Kabelac
9bd7615fef activation: fix locking resource name for activation lock
Avoid cutting away 1st. character for activation lock.
Unlike with VG name locks like #orphan we should not cut-off 1st.
characted from resource name.
2017-10-11 14:24:28 +02:00
Alasdair G Kergon
22789563de thin: Improve overprovisioning and repair warnings. 2017-10-09 19:48:00 +01:00
Heinz Mauelshagen
3a639d8144 raid: cleanup raid4/5/6/10 validation check 2017-10-09 16:13:45 +02:00
Heinz Mauelshagen
44275c763c raid: fix validation check for raid0 segment data_offset member
Commit 2f754b73ff missed one.
2017-10-09 16:03:35 +02:00
Heinz Mauelshagen
5f13e33d54 lvcreate: fix region size on striped RaidLVs
Creating striped RaidLVs with lv size not divisible by region size
caused the region size to be adjusted:

# lvcreate   --type raid5 -n region_check.32.00m_3 -i 3 -L 1g --nosync -R 32.00m raid_sanity
  Using default stripesize 64.00 KiB.
  Rounding size 1.00 GiB (256 extents) up to stripe boundary size <1.01 GiB(258 extents).
  WARNING: New raid5 won't be synchronised. Don't read what you didn't write!
  Using reduced mirror region size of 8.00 MiB
  Logical volume region_check.32.00m_3 created.

Fix by not imposing "mirror" constraints on "raid".

Resolves: rhbz1404007
2017-10-09 14:35:06 +02:00
Heinz Mauelshagen
2f754b73ff raid: fix validation checks for segment data_offset member
Commit 222e1e3ace was not
valuing special case of data_ofset member equal to 1.
2017-10-09 14:01:23 +02:00
Heinz Mauelshagen
554a761db2 raid: return previous reshape space allocation properly
Fix returning previous allocation of reshape space.
2017-10-09 13:55:01 +02:00
Alasdair G Kergon
486ed10848 vgmerge: Fix intermediate metadata corruption
vgmerge suffers from a similar problem to the one fixed in commit
8146548d25 ("vgsplit: Fix intermediate
metadata corruption.")

When merging, splitting or renaming VGs, use a new PV status flag
PV_MOVED_VG to mark the PVs that hold metadata with the old VG name and
use this to provide PV-level granularity instead of incorrectly assuming
all PVs in the VG are the same.
2017-10-06 02:20:45 +01:00
Heinz Mauelshagen
a95f656d0d raid: enhance conversion rejection message
Related: rhbz1439399
2017-10-04 17:05:59 +02:00
Alasdair G Kergon
8146548d25 vgsplit: Fix intermediate metadata corruption.
Changing the VG of a PV uses the same on-disk mechanism as vgrename.
This relies on recognising both the old and new VG names.  Prior to this
patch the vgsplit code incorrectly provided the new VG name twice
instead of the old and new ones.  This lead the low-level mechanism not
to recognise the device as already belonging to a VG and so paying no
attention to the location of its existing metadata, sometimes partly
overwriting it and then later trying to read the corrupt metadata and
issuing a checksum error.
2017-09-22 18:34:34 +01:00
David Teigland
f2ee0e7aca pvmove: require LV name in a shared VG
In a shared VG, only allow pvmove with a named LV,
so that only PE's used by the LV will be moved.
The LV is then activated exclusively, ensuring that
the PE's being moved are not used from another host.

Previously, pvmove was mistakenly allowed on a full PV.
This won't work when LVs using that PV are active on
other hosts.
2017-09-20 09:56:51 -05:00
David Teigland
518a8e8cfb lvmlockd: activate mirror LVs in shared mode with cmirrord
Previously lvmlockd disallowed mirror LVs to be activated
in shared mode.
2017-09-20 09:55:34 -05:00