]> sourceware.org Git - lvm2.git/log
lvm2.git
7 years agotests: ignore racy test failure
Zdenek Kabelac [Fri, 6 Jan 2017 22:37:46 +0000 (23:37 +0100)]
tests: ignore racy test failure

When test fails here, make it just warning instead of failing whole
test.

7 years agotests: make test more race immune
Zdenek Kabelac [Fri, 6 Jan 2017 20:46:58 +0000 (21:46 +0100)]
tests: make test more race immune

Add more delay and increase raid size.
Speedup volume during wait for sync.
Drop --yes from lvcreate.

7 years agoraid: postpone archiving until metadata are changed
Zdenek Kabelac [Fri, 6 Jan 2017 22:36:31 +0000 (23:36 +0100)]
raid: postpone archiving until metadata are changed

Avoid archiving of lvm2 metadata when there is call of 'lvconvert --repair'
on healthy raid LV.

7 years agovgchange: also -l is uint32
Zdenek Kabelac [Fri, 6 Jan 2017 20:24:16 +0000 (21:24 +0100)]
vgchange: also -l is uint32

7 years agomirror: relax internal error for a while
Zdenek Kabelac [Fri, 6 Jan 2017 11:41:38 +0000 (12:41 +0100)]
mirror: relax internal error for a while

With recent commit d6a74025df1afb3d76bec435bc6a40d649217b42 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.

7 years agoblkdeactivate: also unmount mount point on top of MD device if using blkdeactivate -u
Peter Rajnoha [Fri, 6 Jan 2017 10:16:07 +0000 (11:16 +0100)]
blkdeactivate: also unmount mount point on top of MD device if using blkdeactivate -u

The blkdeactivate script processes MD devices too so we should unmount
any mount point on top of an MD device if blkdeactivate -u|--umount is
called.

Diagnosed and reported by: Rick Warner <rick@microway.com>
See also https://bugzilla.redhat.com/show_bug.cgi?id=1410585.

7 years agotests: slow down devs for raid more
Zdenek Kabelac [Wed, 4 Jan 2017 15:02:08 +0000 (16:02 +0100)]
tests: slow down devs for raid more

Since we still experience occasiaonal test failure - slow
things down even more to avoid race.

Add support for 'quick' table changes between normal & delayed tables.

7 years agotests: drop FIXME
Zdenek Kabelac [Wed, 4 Jan 2017 10:21:20 +0000 (11:21 +0100)]
tests: drop FIXME

Since we fixed core trouble with sequence of
suspend/resume/suspend without udev wait
we can drop 'should' and expect volume is still mounted.

7 years agoreport: report merged state for inactive LV
Zdenek Kabelac [Thu, 5 Jan 2017 14:52:00 +0000 (15:52 +0100)]
report: report merged state for inactive LV

This was missing piece in 77997c7673bfca56f51ae4eb55a50bc76e40fe79.
When merging origin is inactive (while driver is loaded) we
could already report merge in progress values as there is
no way to activate 'old state' now.

7 years agodebug: show proper error message for layer mismatch
Zdenek Kabelac [Thu, 5 Jan 2017 14:49:07 +0000 (15:49 +0100)]
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.)

7 years agocache: resize is still unsupported
Zdenek Kabelac [Thu, 5 Jan 2017 14:32:25 +0000 (15:32 +0100)]
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.

7 years agocleanup: more use of lvseg_name
Zdenek Kabelac [Sat, 24 Dec 2016 23:29:30 +0000 (00:29 +0100)]
cleanup: more use of lvseg_name

Use existing function lvseg_name().

7 years agocleanup: use macros
Zdenek Kabelac [Sat, 24 Dec 2016 22:46:47 +0000 (23:46 +0100)]
cleanup: use macros

7 years agocleanup: defines
Zdenek Kabelac [Sat, 24 Dec 2016 22:24:37 +0000 (23:24 +0100)]
cleanup: defines

7 years agocleanup: reuse existing code
Zdenek Kabelac [Sat, 24 Dec 2016 22:10:06 +0000 (23:10 +0100)]
cleanup: reuse existing code

7 years agocache: add missing udev wait
Zdenek Kabelac [Tue, 3 Jan 2017 13:47:46 +0000 (14:47 +0100)]
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).

7 years agovgchange: max_pv limited to uint32
Zdenek Kabelac [Tue, 3 Jan 2017 12:04:51 +0000 (13:04 +0100)]
vgchange: max_pv limited to uint32

Solves: https://bugzilla.redhat.com/1280496

The only reasonable behaviour here is to error on
any number out of accepted range (i.e. now numbers
wrapping around with some hidden logic).

As this is plain bug there is no support for
backward compatibility since noone should
set numbers >UINT32_MAX and expect 0 or error
depending on how big number was used....

TODO: more fields might need to be converted.

7 years agolvmcmdline: support uint32
Zdenek Kabelac [Tue, 3 Jan 2017 12:02:52 +0000 (13:02 +0100)]
lvmcmdline: support uint32

Add simple function to wrap usage for only uint32 numbers.
Unlike  'int_arg'  which accepts full range of 64bit number
this function will error on numbers out of this range:

   <0, UINT32_MAX>

7 years agoman: fix name of 'write_time' field in dmstats.8.in
Bryn M. Reeves [Sun, 25 Dec 2016 17:36:35 +0000 (17:36 +0000)]
man: fix name of 'write_time' field in dmstats.8.in

7 years agotests: update test
Zdenek Kabelac [Fri, 23 Dec 2016 11:52:45 +0000 (12:52 +0100)]
tests: update test

lvm2 now correctly reports thin_id  after action of merged thin,
but before physical metadata update as we know the merge has happened.

7 years agovalidation: temporarily let pass linear with chunk_size
Zdenek Kabelac [Fri, 23 Dec 2016 11:40:40 +0000 (12:40 +0100)]
validation: temporarily let pass linear with chunk_size

Old pool format seems to be setting chunk_size.
For now let validation pass with this.

7 years agolvchange: allow a transiently failed RaidLV to be refreshed
Heinz Mauelshagen [Fri, 23 Dec 2016 02:35:13 +0000 (03:35 +0100)]
lvchange: allow a transiently failed RaidLV to be refreshed

Add to commits 87117c2b2546 and 0b8bf73a63d8 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

7 years agotests: use hold_device_open
Zdenek Kabelac [Thu, 22 Dec 2016 22:31:22 +0000 (23:31 +0100)]
tests: use hold_device_open

7 years agotests: add device holding function
Zdenek Kabelac [Thu, 22 Dec 2016 21:21:09 +0000 (22:21 +0100)]
tests: add device holding function

Hold device open with sleep and wait till sleep really opens
given devices.

7 years agotests: workaround failure on fc23
Zdenek Kabelac [Tue, 20 Dec 2016 15:29:23 +0000 (16:29 +0100)]
tests: workaround failure on fc23

7 years agothin: refresh status when error processing fails
Zdenek Kabelac [Thu, 22 Dec 2016 22:28:04 +0000 (23:28 +0100)]
thin: refresh status when error processing fails

When thin-pool processes event and 'lvextend --use-policies' fails
rather capture up-to-date new info as the fullness percentage may
have jumped noticable. This way we could use 'more' correct numbers
when checking for thresholds.

7 years agoreport: show proper info for merging origin
Zdenek Kabelac [Thu, 22 Dec 2016 18:51:35 +0000 (19:51 +0100)]
report: show proper info for merging origin

When there is 'merging' of an origin in progress, but metadata stil
do provide both origin and snapshot, we should show data from merged
snapshot.  This is important mainly for thin case, where there was
a window, where i.e. 'lvs -o+device_id' would report information
about 'already gone' origin thin LV.

This race window is usually hard to trigger but can be ocasionally hit.
Usually shortly after activation, but before polling process manages
to update metadata after merge.

7 years agosnapshot: validate merge has started
Zdenek Kabelac [Thu, 22 Dec 2016 18:46:02 +0000 (19:46 +0100)]
snapshot: validate merge has started

Before starting polling process, validate the merge has actually started
so there is not pointless invoke of lvmpolld.

This also fixes reported message from command, so user has
correct info whether merging has already started or
if it's delayed for next activation.

7 years agolv: more exact check for merging origin
Zdenek Kabelac [Thu, 22 Dec 2016 20:15:31 +0000 (21:15 +0100)]
lv: more exact check for merging origin

Merging origin has 'MERGE_LV' and should also have its merging snapshot.

7 years agovalidation: rework segment validation
Zdenek Kabelac [Tue, 20 Dec 2016 14:59:11 +0000 (15:59 +0100)]
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.

7 years agolvmdbustest: Print messages if timeout value > 10%
Tony Asleson [Wed, 14 Dec 2016 21:32:08 +0000 (15:32 -0600)]
lvmdbustest: Print messages if timeout value > 10%

We will dump some informational messages if the time to return when we
specify a timeout exceeds 10% of requested.

7 years agolvmdbusd: Use timeout_add instead
Tony Asleson [Wed, 14 Dec 2016 21:30:01 +0000 (15:30 -0600)]
lvmdbusd: Use timeout_add instead

The function timeout_add_seconds has quite a bit of variability.  Using
timeout_add which specifies the timeout in ms instead of seconds.  Testing
shows that this is much more consistent which should improve clients that
are using shorter timeouts for the API and the connection.

7 years agolvmdbusd: Use cfg.reload() instead of dbo.refresh
Tony Asleson [Mon, 12 Dec 2016 22:15:12 +0000 (16:15 -0600)]
lvmdbusd: Use cfg.reload() instead of dbo.refresh

We want to update the data and send out any signals as needed, not just
update the in memory database.

7 years agolvmdbusd: Remove un-needed main thread execution
Tony Asleson [Mon, 12 Dec 2016 22:13:27 +0000 (16:13 -0600)]
lvmdbusd: Remove un-needed main thread execution

7 years agotests: usage of cached volume for snapshot
Zdenek Kabelac [Mon, 19 Dec 2016 13:05:16 +0000 (14:05 +0100)]
tests: usage of cached volume for snapshot

7 years agocache: support cached origin for snapshot
Zdenek Kabelac [Mon, 19 Dec 2016 13:08:56 +0000 (14:08 +0100)]
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.

7 years agolvconvert: fix shown lv name for snapshot split
Zdenek Kabelac [Mon, 19 Dec 2016 13:06:55 +0000 (14:06 +0100)]
lvconvert: fix shown lv name for snapshot split

We can't keep 'display_lvname' for too long - it's using
ringbuffer and keeps limited number of names. So it's
safe only per few simple tests,  but can't be used anymore
after some function calls..
(Fixes 00e641ef37a977129acc503f3fa1b67f556ac5eb)

7 years agolibdm: add dm_stats_bind_from_fd()
Bryn M. Reeves [Sun, 18 Dec 2016 14:40:57 +0000 (14:40 +0000)]
libdm: add dm_stats_bind_from_fd()

dmsetup already has a version of this function, and dmfilemapd will
need it too: move it to libdevmapper to avoid copying it around.

7 years agolibdm: clear region table in dm_stats_list()
Bryn M. Reeves [Thu, 15 Dec 2016 19:03:42 +0000 (19:03 +0000)]
libdm: clear region table in dm_stats_list()

Call _stats_regions_destroy() from dm_stats_list() if dms->regions
is non-NULL. This avoids leaking any pool allocations and ensures
the handle is in a known state: if an error occurs during the list,
dms->regions will be NULL and the handle will appear empty.

7 years agotests: using cached LV for external origin
Zdenek Kabelac [Sun, 18 Dec 2016 16:43:05 +0000 (17:43 +0100)]
tests: using cached LV for external origin

7 years agodebug: add debug message showing new lv
Zdenek Kabelac [Sun, 18 Dec 2016 14:05:18 +0000 (15:05 +0100)]
debug: add debug message showing new lv

Make trace easier to follow knowing which LV was added to dtree.

7 years agoactivate: further _info API refinement
Zdenek Kabelac [Sun, 18 Dec 2016 13:57:16 +0000 (14:57 +0100)]
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).

7 years agothin: add comment with future extension
Zdenek Kabelac [Sun, 18 Dec 2016 14:06:12 +0000 (15:06 +0100)]
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'.

7 years agobackup: show warning once per command
Zdenek Kabelac [Sun, 18 Dec 2016 15:36:33 +0000 (16:36 +0100)]
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.

7 years agolvconvert: support cache to external origin conversion
Zdenek Kabelac [Sat, 17 Dec 2016 21:41:27 +0000 (22:41 +0100)]
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.

7 years agocache: improve activation with -real
Zdenek Kabelac [Sun, 18 Dec 2016 14:05:31 +0000 (15:05 +0100)]
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.

7 years agolibdm: drop callback on revert path
Zdenek Kabelac [Sat, 17 Dec 2016 21:40:59 +0000 (22:40 +0100)]
libdm: drop callback on revert path

The system is likely in some very inconsisten state.
Do not try to make it even more problematic with trying
to invoke tools like thin_check via callback.

7 years agolv: fix lock holder for external origin
Zdenek Kabelac [Sat, 17 Dec 2016 21:40:14 +0000 (22:40 +0100)]
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.

7 years agocache: prepare status checking for layer
Zdenek Kabelac [Sat, 17 Dec 2016 20:52:27 +0000 (21:52 +0100)]
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).

7 years agocache: improve wait for cache clear
Zdenek Kabelac [Sun, 18 Dec 2016 14:05:57 +0000 (15:05 +0100)]
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).

7 years agovalidation: check external property is matching
Zdenek Kabelac [Sat, 17 Dec 2016 20:58:35 +0000 (21:58 +0100)]
validation: check external property is matching

Detect if number of external_count is matching
referencing devices for  external_origin LV.

7 years agothin: reload external origin with last thin
Zdenek Kabelac [Sat, 17 Dec 2016 20:55:02 +0000 (21:55 +0100)]
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).

7 years agolvs: show status for layer
Zdenek Kabelac [Sat, 17 Dec 2016 20:54:51 +0000 (21:54 +0100)]
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.

7 years agoraid: fix activation of tracked image
Zdenek Kabelac [Wed, 14 Dec 2016 20:47:38 +0000 (21:47 +0100)]
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.

7 years agodmstats: don't declare _start_timestamp if HAVE_SYS_TIMERFD_H
Bryn M. Reeves [Sun, 18 Dec 2016 14:08:11 +0000 (14:08 +0000)]
dmstats: don't declare _start_timestamp if HAVE_SYS_TIMERFD_H

The _start_timestamp is not used by the TIMERFD clock.

7 years agodmstats: fix TIMERFD _timer_running() test
Bryn M. Reeves [Sun, 18 Dec 2016 14:07:25 +0000 (14:07 +0000)]
dmstats: fix TIMERFD _timer_running() test

7 years agodmstats: fix interval number reporting with --count=0
Bryn M. Reeves [Sun, 18 Dec 2016 12:58:03 +0000 (12:58 +0000)]
dmstats: fix interval number reporting with --count=0

When --count=0 interval numbers are miscalculated:

Interval     #18446744069414584325     time delta:    999920887ns
Interval     #18446744069414584325   current err:       -79113ns
End interval #18446744069414584325  duration:    999920887ns

This is because the command line argument is cast through the
uint32_t type, and fixed to UINT32_MAX:

  _count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;

We also need to handle --count=0 specially when calculating the
interval number: since intervals count from #1, this must account
for the implicit "minus one" when converting from zero to the
UINT64_MAX value used (which is too large to store in _int_args).

7 years agodmstats: separate TIMERFD and useleep() exit conditions
Bryn M. Reeves [Sun, 18 Dec 2016 12:42:47 +0000 (12:42 +0000)]
dmstats: separate TIMERFD and useleep() exit conditions

The time management code mixes tests of the _timer_fd value with
code that should be timer agnostic: this causes problems for users
of the usleep() timer, since it cannot properly detect the start
of a new interval:

Beginning first interval
Interval     #18446744069414584348     time delta:   1000000000ns
Interval     #18446744069414584348   current err:            0ns
End interval #18446744069414584348  duration:   1000000000ns
Adjusted sample interval duration:   1000000000ns
[...]
Beginning first interval
Interval     #18446744069414584349     time delta:   1000000000ns
Interval     #18446744069414584349   current err:            0ns
End interval #18446744069414584349  duration:   1000000000ns
Adjusted sample interval duration:   1000000000ns

Separate these out, by defining a _timer_running() call that each
timer implements, and only define _timer_fd if we are compiling
with TIMERFD enabled.

7 years agodmstats: use better interval estimate for usleep() timer
Bryn M. Reeves [Sun, 18 Dec 2016 12:39:26 +0000 (12:39 +0000)]
dmstats: use better interval estimate for usleep() timer

Although the usleep() interval timer is not used if the Linux
TIMERFD interface is available it should still provide reasonably
good timing.

Instead of trying to estimate the error from the duration of the
last sleep, peg it to the start time of the program, and use the
value of  ((start_time - now) % interval) to correct the current
interval duration.

This always pulls us back into sync at the end of each interval,
rather than relying on trying to incrementally adjust the time
duration at each interval start.

This greatly reduces drift when the usleep() clock is used.

7 years agodmstats: improve tool help output and option coverage
Bryn M. Reeves [Sun, 18 Dec 2016 10:53:27 +0000 (10:53 +0000)]
dmstats: improve tool help output and option coverage

7 years agoman: fix 'dmstats create' formatting in dmstats.8.in
Bryn M. Reeves [Sun, 18 Dec 2016 10:23:12 +0000 (10:23 +0000)]
man: fix 'dmstats create' formatting in dmstats.8.in

7 years agoman: fix 'dmstats list' option formatting in dmstats.8.in
Bryn M. Reeves [Sun, 18 Dec 2016 10:12:56 +0000 (10:12 +0000)]
man: fix 'dmstats list' option formatting in dmstats.8.in

7 years agoman: fix 'dmstats <command>' formatting in dmstats.8.in
Bryn M. Reeves [Sun, 18 Dec 2016 10:11:02 +0000 (10:11 +0000)]
man: fix 'dmstats <command>' formatting in dmstats.8.in

7 years agolibdm: use destination size as limit in dm_bit_copy()
Bryn M. Reeves [Mon, 12 Dec 2016 20:28:29 +0000 (20:28 +0000)]
libdm: use destination size as limit in dm_bit_copy()

The dm_bit_copy() macro uses the source (bs1) bitset size as the
limit for memcpy:

    memcpy((bs1) + 1, (bs2) + 1, ((*(bs1) / DM_BITS_PER_INT) + 1)..)

This is safe if the destination bitset is smaller than the source,
or if the two bitsets are of the same size.

With a destination that is larger (e.g. when resizing a bitmap to
add more capacity), the memcpy will overrun the source bitset and
set garbage bits in the destination.

There are nine uses of the macro currently (8 in libdm/regex, and
1 in daemons/cmirrord): in each case the two bitsets are always of
equal size so the behaviour is unchanged.

Fix the macro to use bs2's size to simplify resizing bitsets and
avoid the need for another copy macro.

7 years agocleanup: use exiting function
Zdenek Kabelac [Wed, 14 Dec 2016 10:34:28 +0000 (11:34 +0100)]
cleanup: use exiting function

Reuse existing code and some indent change.

7 years agoraid: split preserves local exlusive activation
Zdenek Kabelac [Wed, 14 Dec 2016 09:19:25 +0000 (10:19 +0100)]
raid: split preserves local exlusive activation

7 years agoraid: activation with list
Zdenek Kabelac [Wed, 14 Dec 2016 10:16:47 +0000 (11:16 +0100)]
raid: activation with list

Commit 069039204002e5c8514050fe541bbd378c383a02 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.

7 years agoconfigure: just move new macro to right file
Zdenek Kabelac [Tue, 13 Dec 2016 21:48:56 +0000 (22:48 +0100)]
configure: just move new macro to right file

aclocal is regenerated while acinclude is permanent.
Move new macro to permanent file.

7 years agolibdm: ensure first extent is always counted
Bryn M. Reeves [Tue, 13 Dec 2016 21:36:11 +0000 (21:36 +0000)]
libdm: ensure first extent is always counted

If FIEMAP returns a single extent after the first call, no extent
boundary is detected and the first extent is not counted by the
normal mechanism.

In this case, increment nr_extents at the same time the extent is
added to the region table, before returning.

7 years agocleanup: remove wrapping function
Zdenek Kabelac [Tue, 13 Dec 2016 11:28:12 +0000 (12:28 +0100)]
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.

7 years agocleanup: log message updates
Zdenek Kabelac [Mon, 12 Dec 2016 23:10:01 +0000 (00:10 +0100)]
cleanup: log message updates

7 years agocleanup: more lv_is_ usage
Zdenek Kabelac [Mon, 12 Dec 2016 23:09:15 +0000 (00:09 +0100)]
cleanup: more  lv_is_  usage

7 years agocleanup: allocate NAME_LEN size for lv name
Zdenek Kabelac [Mon, 12 Dec 2016 23:09:38 +0000 (00:09 +0100)]
cleanup: allocate NAME_LEN size for lv name

7 years agoraid: avoid manipulation of segment status
Zdenek Kabelac [Tue, 13 Dec 2016 13:52:06 +0000 (14:52 +0100)]
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.

7 years agosegtype: check for seg type instead of status
Zdenek Kabelac [Tue, 13 Dec 2016 13:50:48 +0000 (14:50 +0100)]
segtype: check for seg type instead of status

RAID is LV property - which has single segment of raid type.

7 years agoraid: improve table reload sequence
Zdenek Kabelac [Tue, 13 Dec 2016 11:31:28 +0000 (12:31 +0100)]
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.

7 years agolibdm: add min_num_bits to dm_bitset_parse_list()
Bryn M. Reeves [Sun, 11 Dec 2016 22:41:45 +0000 (22:41 +0000)]
libdm: add min_num_bits to dm_bitset_parse_list()

It's useful to be able to specify a minimum number of bits for a
new bitmap parsed from a list, for e.g. to allow for expansing a
group without needing to copy/reallocate the bitmap.

Add a backwards compatible symbol for programs linked against old
versions of the library.

7 years agolibdm: use dm_bit_get_last() in _stats_group_tag_fill()
Bryn M. Reeves [Tue, 13 Dec 2016 10:32:29 +0000 (10:32 +0000)]
libdm: use dm_bit_get_last() in _stats_group_tag_fill()

Instead of iterating over all bits, use dm_bit_get_last() to find
the last set bit in the group bitmap.

7 years agolibdm: add dm_bit_get_last()/dm_bit_get_prev()
Bryn M. Reeves [Sun, 11 Dec 2016 12:44:45 +0000 (12:44 +0000)]
libdm: add dm_bit_get_last()/dm_bit_get_prev()

It is sometimes convenient to iterate over the set bits in a dm
bitset in reverse order (from the highest set bit toward zero), or
to quickly find the last set bit.

Add dm_bit_get_last() and dm_bit_get_prev(), mirroring the existing
dm_bit_get_first() and dm_bit_get_next().

dm_bit_get_prev() uses __builtin_clz when available to efficiently
test the bitset in reverse.

7 years agoutil: add clz() and use __builtin_clz() if available
Bryn M. Reeves [Mon, 12 Dec 2016 12:03:50 +0000 (12:03 +0000)]
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.

7 years agoconfigure: check for __builtin_clz()
Bryn M. Reeves [Mon, 12 Dec 2016 12:03:16 +0000 (12:03 +0000)]
configure: check for __builtin_clz()

7 years agolibdm: fix start of file detection in _stats_map_extents()
Bryn M. Reeves [Tue, 13 Dec 2016 18:14:13 +0000 (18:14 +0000)]
libdm: fix start of file detection in _stats_map_extents()

7 years agolibdm: break up _stats_get_extents_for_file()
Bryn M. Reeves [Tue, 13 Dec 2016 12:03:00 +0000 (12:03 +0000)]
libdm: break up _stats_get_extents_for_file()

Split out the loop that iterates over each batch of FIEMAP
extent data from the function that sets up and calls the ioctl
to reduce nesting and simplify local variable use:

  _stats_get_extents_for_file()
  ->  _stats_map_extents()

The _stats_map_extents() function is responsible for detecting
eof and extent boundaries and adding whole, allocated extents
to the file extent table for region creation.

7 years agolibdm: fix dm_stats_foreach_group() macro
Bryn M. Reeves [Tue, 13 Dec 2016 15:32:34 +0000 (15:32 +0000)]
libdm: fix dm_stats_foreach_group() macro

7 years agolibdm: check for non-existent region_id values in groups
Bryn M. Reeves [Tue, 13 Dec 2016 14:31:39 +0000 (14:31 +0000)]
libdm: check for non-existent region_id values in groups

Check that all region_id values specified in a group bitmap are
actually present: although this should not normally happen when
using the dmstats tool, it is possible as a result of manual
changes (or bugs) for a group descriptor to contain one or more
group_id values that do not exist.

Check for this situation when reading group descriptors, warn
the user the user, and clear these bits in the bitmap when
formatting it for output.

7 years agolibdm: fix segfault with invalid group descriptor
Bryn M. Reeves [Tue, 13 Dec 2016 13:56:10 +0000 (13:56 +0000)]
libdm: fix segfault with invalid group descriptor

If a region has a a DMS_GROUP tag in aux_data where the first
region_id in the bitmap is not the same as the containing region,
dmstats will segfault:

  # '2' is never a valid group bitset list for region_id == 0
  # dmsetup message vg_hex/root 0 "@stats_set_aux 0 DMS_GROUP=img:2#"

  # dmsetup message vg_hex/root 0 "@stats_list"
  0: 45383680+16384 16384 dmstats DMS_GROUP=img:2#
  1: 46071808+32768 32768 dmstats -
  2: 47382528+16384 16384 dmstats -

  # dmstats list
  Segmentation fault (core dumped)

The crash will occur in some arbitrary dm_stats_get_* property
method - this happens while processing the 1st region_id in the
bitset, because the region is marked as grouped, but there is
no group bitmap present at dms->groups[2]->regions.

Fix this by detecting a mismatch between the expected region_id
and dm_bit_get_first() for the parsed bitset during
_parse_aux_data_group().

7 years agolibdm: fix region overlap tests
Bryn M. Reeves [Mon, 12 Dec 2016 22:49:31 +0000 (22:49 +0000)]
libdm: fix region overlap tests

7 years agolibdm: fix _stats_get_extents_for_file()
Bryn M. Reeves [Mon, 12 Dec 2016 20:40:27 +0000 (20:40 +0000)]
libdm: fix _stats_get_extents_for_file()

Handle files that contain multiple logical extents in a single
physical extent properly:

  - In FIEMAP terms a logical extent is a contiguous range of
    sectors in the file's address space.

  - One or more physically adjacent logical extents comprise a
    physical extent: these are the disk areas that will be mapped
    to regions.

  - An extent boundary occurs when the start sector of extent
    n+1 is not equal to (n.start + n.length).

This requires that we accumulate the length values of extents
returned by FIEMAP until a discontinuity is found (since each
struct fiemap_extent returned by FIEMAP only represents a single
logical extent, which may be contiguous with other logical
extents on-disk).

This avoids creating large numbers of regions for physically
adjacent (logical) extents and fixes the earlier behaviour which
would only map the first logical extent of the physical extent,
leaving gaps in the region table for these files.

7 years agolvchange: allow a transiently failed RaidLV to be refreshed
Heinz Mauelshagen [Mon, 12 Dec 2016 21:06:17 +0000 (22:06 +0100)]
lvchange: allow a transiently failed RaidLV to be refreshed

Enhance commit 0b8bf73a63d8 to refresh the top-level LV correctly
in case of a clustered, remotely activated RaidLV.

Related: rhbz1399844

7 years agotests: update seg_size_pe
Zdenek Kabelac [Mon, 12 Dec 2016 10:49:26 +0000 (11:49 +0100)]
tests: update seg_size_pe

Default prepare_vg uses 512K - so update test accordingly

7 years agotests: use prepare_vg more often
Zdenek Kabelac [Mon, 12 Dec 2016 10:22:41 +0000 (11:22 +0100)]
tests: use prepare_vg more often

7 years agotests: no left devices check for skipped test
Zdenek Kabelac [Mon, 12 Dec 2016 10:22:10 +0000 (11:22 +0100)]
tests: no left devices check for skipped test

7 years agocov: use unsigned for single bit values
Zdenek Kabelac [Mon, 12 Dec 2016 10:21:42 +0000 (11:21 +0100)]
cov: use unsigned for single bit values

Avoid using signed int.

7 years agotests: track leaked devices in tests
Zdenek Kabelac [Sun, 11 Dec 2016 09:25:15 +0000 (10:25 +0100)]
tests: track leaked devices in tests

When test calls teardown, no devices created by test are expected
to be left in table. Trap such orphans and make the test fail.

7 years agotests: remove unwanted exit
Zdenek Kabelac [Sun, 11 Dec 2016 09:21:26 +0000 (10:21 +0100)]
tests: remove unwanted exit

Exit seemes slipped in from local testing in:
eb6b2a11e3548f7598c726787494be2c3ea4dca1

7 years agotests: remove some leaking device
Zdenek Kabelac [Sun, 11 Dec 2016 09:24:06 +0000 (10:24 +0100)]
tests: remove some leaking device

These tests leaks devices (known bugs).
Remove them via dmsetup.

TODO: fix actual commands

7 years agotests: test should clean devices it has created
Zdenek Kabelac [Sun, 11 Dec 2016 09:18:44 +0000 (10:18 +0100)]
tests: test should clean devices it has created

To be able to detect lvm2 command is not leaking some
'unexpected' device - remove all devices before
test exits by its own command so test teardown
now can check what was 'left' unexpectedly.

7 years agotests: slower device
Zdenek Kabelac [Sat, 10 Dec 2016 14:07:14 +0000 (15:07 +0100)]
tests: slower device

Some of test machines are too fast, slow raid syncing even more.

7 years agocov: declaration matching
Zdenek Kabelac [Fri, 9 Dec 2016 22:10:00 +0000 (23:10 +0100)]
cov: declaration matching

7 years agocov: add internal error for impossible code path
Zdenek Kabelac [Fri, 9 Dec 2016 21:55:25 +0000 (22:55 +0100)]
cov: add internal error for impossible code path

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