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

5416 Commits

Author SHA1 Message Date
Zdenek Kabelac
ec93f37b86 toolcontext: action for LVM_RUN_BY_DMEVENTD env var
When LVM_RUN_BY_DMEVENTD is set to 1, ensure there will
be no interaction with dmeventd.
2017-01-23 14:55:47 +01:00
Zdenek Kabelac
4a7f2155c1 clean: move code to lib part
Move actual processing part of the lvm2_disable_dmeventd_monitoring()
into a /lib part so we can reuse the code later for other cases.
2017-01-23 14:55:28 +01:00
Zdenek Kabelac
04a9cad499 config: new option dmeventd/thin_command
This setting will allowing configuring which command gets executed
when thin-pool fullness goes from 50%..100%
2017-01-20 23:53:26 +01:00
Zdenek Kabelac
f8234d6e5f libdm: add human R|readable units
When showing sizes with 'H|human' units we do use standard rounding.
This however is confusing users from time to time,
when the printed number uses some biger units i.e. GiB and there is just
tiny fraction of space missing.

So here is some real-life example with new 'r' unit.

$lvs

  LV    VG Attr       LSize  Pool Origin
  lvol0 vg -wi-a-----  1.99g
  lvol1 vg -wi-a----- <2.00g
  lvol2 vg -wi-a----- <2.01g

Meaning is - lvol1 has 'slightly' less then 2.00g - from sign '<' user
can be aware the LV doesn't have full 2.00GiB in size so he
will be less surpriced allocation of 2G volume will not succeed.

$ vgs
  VG #PV #LV #SN Attr   VSize  VFree
  vg   2   2   0 wz--n- <6,00g <2,01g

For uses needing  'old'  undecorated human unit simply will continue
to use 'H|h' units.

The new R|r  may further change when we would recongnize some
other way how to improve readability.
2017-01-20 23:52:17 +01:00
Alasdair G Kergon
6a20b22151 devices: Recognise Veritas Dynamic Multipathing
VxDMP doesn't interact very well with udev so always set
  devices/obtain_device_list_from_udev = 0
in lvm.conf on these systems.
2017-01-10 22:23:23 +00:00
Zdenek Kabelac
a4be2be5a4 raid: postpone archiving until metadata are changed
Avoid archiving of lvm2 metadata when there is call of 'lvconvert --repair'
on healthy raid LV.
2017-01-06 23:39:04 +01:00
Zdenek Kabelac
8a93cde75e mirror: relax internal error for a while
With recent commit d6a74025df using
INTERNAL_ERROR while cheking layer LV - it's been noticed mirror
logic currently doesn't do a correct thing during upconversion and
does a full-try instead of checking only allocator capabilities.
This leads to invalid usage of layer.

To keep existing code running before providing a fix, relax
INTERNAL_ERROR just an error and keep the 'code' running.

Once mirror code is fixed, these all check should be switched
to internal errors.
2017-01-06 12:45:07 +01:00
Zdenek Kabelac
d6a74025df debug: show proper error message for layer mismatch
Show proper internal error for failing command when there are some
inconsitencies in sizes of LV and its layer instead of rather
meaningless error code 5.

(Could be hit i.e. if user tried to 'resize' cached LV and then
uncache such LV.)
2017-01-05 15:54:14 +01:00
Zdenek Kabelac
3e9c03cbbc cache: resize is still unsupported
During rework of resize code this validation check
has been lost (in my resize branch). Upstream
is still not supporting resize of any cache type LV
so needs to be prevented.
2017-01-05 15:34:22 +01:00
Zdenek Kabelac
1f5dde38a7 cleanup: more use of lvseg_name
Use existing function lvseg_name().
2017-01-03 14:55:16 +01:00
Zdenek Kabelac
dc5bb12956 cleanup: use macros 2017-01-03 14:55:16 +01:00
Zdenek Kabelac
ee784fd28f cleanup: defines 2017-01-03 14:55:16 +01:00
Zdenek Kabelac
377288fe03 cleanup: reuse existing code 2017-01-03 14:55:16 +01:00
Zdenek Kabelac
95d5877f7a cache: add missing udev wait
When we need to clear dirty cache content of cached LV, there
is table reload which usually is shortly followed by next metadata
change.  However  udev  can't (as of now)  process   udev event
while device is 'suspended'.

So whenever sequence of  'suspend/resume/suspend' is needed,
we need to wait first for finishing of 'resume' processing before
starting next 'suspend'. Otherwise there is  'race' danger of triggering
unwantend umount by systemd as  such event will trigger
SYSTEMD_READY=0 state for a moment for such changed device.

Such race is pretty ugly to trace so we may need to review more
sequencies for missing 'sync'.

(Other option is to enhnace 'udev' rules processing to avoid
such dramatic actions to be happening for suspended devices).
2017-01-03 14:55:16 +01:00
Zdenek Kabelac
14902d1739 validation: temporarily let pass linear with chunk_size
Old pool format seems to be setting chunk_size.
For now let validation pass with this.
2016-12-23 13:16:06 +01:00
Heinz Mauelshagen
95d68f1d0e lvchange: allow a transiently failed RaidLV to be refreshed
Add to commits 87117c2b25 and 0b8bf73a63 to avoid refreshing two
times altogether, thus avoiding issues related to clustered, remotely
activated RaidLV.  Avoid need to repeat "lvchange --refresh RaidLV"
two times as a workaround to refresh a RaidLV.  Fix handles removal
of temporary *-missing-* devices created for any missing segments
in RAID SubLVs during activation.

Because the kernel dm-raid target isn't able to handle transiently
failing devices properly we need
"[dm-devel][PATCH] dm raid: fix transient device failure processing"
as well.

test: add lvchange-raid-transient-failures.sh
      and enhance lvconvert-raid.sh

Resolves: rhbz1025322
Related:  rhbz1265191
Related:  rhbz1399844
Related:  rhbz1404425
2016-12-23 03:41:32 +01:00
Zdenek Kabelac
95e3dd5fb1 lv: more exact check for merging origin
Merging origin has 'MERGE_LV' and should also have its merging snapshot.
2016-12-22 23:37:07 +01:00
Zdenek Kabelac
9491ab41cd validation: rework segment validation
Move individual segment validation to a separate function
executed for 'complete_vg'.

Move some 'extra' validation bits from 'raid' validation to global
segtype validation (so extending existing normal validation)

TODO: still some test are left to be moved.
Reduce some duplication in validation process - there are still
some left thought so still room for improving overal speed.
2016-12-22 23:37:07 +01:00
Zdenek Kabelac
0c56eb8f43 cache: support cached origin for snapshot
Enable  'lvcreate/lvconvert -s' for cached LV.
and supported operations:

Create a snapshot of cached LV

Split/Join snapshot LV to cached origin LV.
2016-12-19 14:41:42 +01:00
Zdenek Kabelac
8c17233af5 debug: add debug message showing new lv
Make trace easier to follow knowing which LV was added to dtree.
2016-12-18 19:38:51 +01:00
Zdenek Kabelac
034931f68d activate: further _info API refinement
Another cleanup of internal _info() API simplifying code.
Also make sure 'error' on _info() call is properly passed upward
(return 0 is error path).
2016-12-18 19:38:51 +01:00
Zdenek Kabelac
79121416df thin: add comment with future extension
It could be actually better to use even cache origin in
read-only mode so there could no be some 'acidental'
change being done on this volume.

This however need further tools enhancment - where we would need
to handle whole subtree on 'lvchange -pr/-prw'.
2016-12-18 19:38:51 +01:00
Zdenek Kabelac
75f2388093 backup: show warning once per command
When command calls backup() more then once (which is actually not
wanted) this warning message is shown repeatedly:

"WARNING: This metadata update is NOT backed up."

Instead now print message just once and less confuse user.
2016-12-18 19:38:30 +01:00
Zdenek Kabelac
5bb6266046 lvconvert: support cache to external origin conversion
Add this functionality to lvconvert:

'lvconvert --thin cachedLV --thinpool vg/poll'

Converts cachedLV to external origin (which will be read-only).
New thin volume is created in thinpool LV and it's using external
origin as source for unprovisioned chunks.
This conversion happens  online (while volume is in use).
Thin LV remains fully writable.
Cached external origin no longer could be written so cache will be used
ONLY for read operations. For this limitation we require cache mode
to be writethrough (as writeback cannot write to read-only volumes).

When  thinLV is later removed  cached external origin is again
fully usable, just note, LV remain in 'read-only' mode.
When read-write is needed,  'lvchange -prw' has to be used.

Single external origin could be user by multiple thinLV in
multiple differen thin pool.
2016-12-18 19:35:27 +01:00
Zdenek Kabelac
69434c2eca cache: improve activation with -real
When cache volume may be converted from normal to -real layer LV
we need to improve logic for call cache_check.

With this patch, we register call for cache_check only when metadata LV
is not yet present in active table slot (should match initial table
load).
This avoids unwanted checking when cache would become layer device
online.
2016-12-18 19:30:50 +01:00
Zdenek Kabelac
29b0e42be3 lv: fix lock holder for external origin
External origin could be reloaded via more locks.
It's actually even more complex then thin-pool,
as it may be active on more nodes for linear LVs
(and maybe even more types).

External origin is always read-only thus unmodifiable
device so there should not be a problem accesing it
through multiple nodes.

Also for thin-pool check first presence of active thin-pool.

FIXME:
It's not easy to detect on which nodes this device is active
Thus manipulation with such device may require checking every
node and it active state and refresh.

But since such setup is quite complex to prepare and use,
hopefully there are not user trying to 'explore' this usage yet.
2016-12-18 19:25:25 +01:00
Zdenek Kabelac
a24eae6e82 cache: prepare status checking for layer
To be ready to show status of cache volume, call the status
with layer.  Layer is automatically detected in this case when
cache volume is used in 'layered' form (needs -real suffix).
2016-12-18 19:23:13 +01:00
Zdenek Kabelac
bf157ed833 cache: improve wait for cache clear
Avoid printing misleading message about single dirty block.
Instead properly detect condition where the 'cleaner' policy
needs to be installed without 'overloading' dirty variable.

Also print warning if we would be clearing read-only volume.
(it really shouldn't happen).
2016-12-18 19:22:11 +01:00
Zdenek Kabelac
36f609e513 validation: check external property is matching
Detect if number of external_count is matching
referencing devices for  external_origin LV.
2016-12-18 19:17:59 +01:00
Zdenek Kabelac
7db46c4a39 thin: reload external origin with last thin
External origin could be activated as stand-alone device.
When the last thin LV is removed, external origin is no longer
the external origin and it's layer property was dropped.

Ensure dm table is correct by reloading external origin
(when it's active).
2016-12-18 19:13:34 +01:00
Zdenek Kabelac
c71fefad8d lvs: show status for layer
When LV is external origin, show info for LV but
status for -layer.  So we expose more info to a user
as otherwise active external origin is only linear
mapping of -real layer.

We do the same for i.e. old snaphost origin.
2016-12-18 19:12:12 +01:00
Zdenek Kabelac
bdfc96cb08 raid: fix activation of tracked image
Activation of raid has brough up also splitted image with tracing
(without taking lock for this).

So when raid is now activate - such image is not put into
table (with _rmeta).  When user needs such device, just active it.
2016-12-18 19:10:38 +01:00
Zdenek Kabelac
0f98d5c2e6 cleanup: use exiting function
Reuse existing code and some indent change.
2016-12-14 11:41:42 +01:00
Zdenek Kabelac
fecd043cca raid: split preserves local exlusive activation 2016-12-14 11:40:01 +01:00
Zdenek Kabelac
77e09c3fb4 raid: activation with list
Commit 0690392040 revealed a problem
in raid metadata manipulation.

We do two operations in one table reload:
- raid leg/image extraction
- rename remaining raid legs

This should be made in separate steps. Otherwise we do an
uncorrectable table change on error path (leaving tables
for admin and dmsetup).

As a hotfix - restore the previous logic and use a single
new function _lv_update_and_reload_list which activates exclusively
extracted LVs on the list before resuming suspended raid LV.
This restore 'rename' functionality upon resume.

Also still preserve the 'origin_only' logic - although we know
it's not working properly for cluster and LV stacking.

Further fixes are needed.
2016-12-14 11:37:02 +01:00
Zdenek Kabelac
fce7449d73 cleanup: remove wrapping function
backup is not 'tested' for success and also it should
actually happen just when command is finished.
We do not target to make backups with each inter-step
metadata change.
2016-12-13 22:07:52 +01:00
Zdenek Kabelac
c7da16e5f1 cleanup: log message updates 2016-12-13 22:07:52 +01:00
Zdenek Kabelac
a8f5e1f274 cleanup: more lv_is_ usage 2016-12-13 22:07:52 +01:00
Zdenek Kabelac
47b96c3537 cleanup: allocate NAME_LEN size for lv name 2016-12-13 22:07:52 +01:00
Zdenek Kabelac
d0fe3ec0c5 raid: avoid manipulation of segment status
RAID is LV property

TODO: only 2 flags are seg->status: PVMOVE & MERGING
At least the second one should be soon elimanted as again
we merge LV not a segment.
2016-12-13 22:07:52 +01:00
Zdenek Kabelac
d1e398c474 segtype: check for seg type instead of status
RAID is LV property - which has single segment of raid type.
2016-12-13 22:07:52 +01:00
Zdenek Kabelac
0690392040 raid: improve table reload sequence
This is another place for 'common' use pattern or
reload and activation of deleted devices.
(Moving the exclusive activation to _deactivate_and_remove_lvs()).

TODO: looks like halve of raid function is reloading
just 'origin' - and the other full LV.
2016-12-13 22:07:52 +01:00
Bryn M. Reeves
107bc13db3 util: add clz() and use __builtin_clz() if available
Add a macro for the clz (count leading zeros) operation.

Use the GCC __builtin_clz() for clz() if it is available and fall
back to a shift based implementation on systems that do not set
HAVE___BUILTIN_CLZ.
2016-12-13 20:41:29 +00:00
Heinz Mauelshagen
87117c2b25 lvchange: allow a transiently failed RaidLV to be refreshed
Enhance commit 0b8bf73a63 to refresh the top-level LV correctly
in case of a clustered, remotely activated RaidLV.

Related: rhbz1399844
2016-12-12 22:08:47 +01:00
Zdenek Kabelac
4a33e4c509 cov: declaration matching 2016-12-11 23:24:19 +01:00
Zdenek Kabelac
794093722c debug: missing stack traces 2016-12-11 23:24:19 +01:00
Zdenek Kabelac
dc7d3dd5ed cleanup: use NAME_LEN stack buffer
Using NAME_LEN we get at least easy max LV name size validation.
Also code gets more simple.
2016-12-11 23:24:19 +01:00
Zdenek Kabelac
67f9e6b175 raid: avoid _ at end of name of extracted metadata LV
Do not generate @PREFIX@vg/LV1_rmeta_1_extracted_.
2016-12-11 23:20:51 +01:00
Zdenek Kabelac
55ca8043d4 raid: optimize clearing of lvs
Activate whole list of metadata lvs first before clearing them.
(Similar to commit ada5733c56)

TODO: make this clearing in a single common function.
2016-12-11 23:19:41 +01:00
Zdenek Kabelac
8831a541a8 raid: fix delete on clustered vg
For clustered VG ensure lock is grabbed first,
so later deactivation works.

TODO: fix tree to solve device removal automatically.
2016-12-11 23:18:22 +01:00