1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00
Commit Graph

104 Commits

Author SHA1 Message Date
Peter Rajnoha
8cfc385491 toollib: make it possible to also process internal VGs, add 'include_internal' switch to process_each_vg fn
The lvm fullreport works per VG and as such, the vg, lv, pv, seg and
pvseg subreport is done for each VG. However, if the PV is not part of
any VG yet, we still want to display pv and pvseg subreports for these
"orphan" PVs - so enable this for lvm fullreport's process_each_vg call.
2016-06-20 11:33:42 +02:00
Peter Rajnoha
f752a95302 toollib: add 'parent' field to processing_handle; init report format only if there's no parent
If there's parent processing handle, we don't need to create completely
new report group and status report - we'll just reuse the one already
initialized for the parent.

Currently, the situation where this matter is when doing internal report
to do the selection for processing commands where we have parent processing
handle for the command itself and processing handle for the selection
part (that is selection for non-reporting tools).
2016-06-20 11:33:41 +02:00
David Teigland
55683a659f toollib: add vg name list arg to process_each_vg 2016-05-23 11:18:16 -05:00
David Teigland
4d095c2fbb poll daemon: only call lvmetad_connect when needed
When lvm is not using lvmetad, the lvmetad_connect()
in the forked polling process is not needed and was
generating unwanted warnings.
2016-04-21 15:58:34 -05:00
David Teigland
5c104c5de9 lvmetad: connect from forked polling process
With commit 5e9e43074a, lvmetad connections are
now made explicitly, so a new connection must be
created from a child created for polling.
2016-04-20 09:04:39 -05:00
Zdenek Kabelac
0584e85736 lvconvert: show percent with %.2
lvm2 shows percent values with 2 decimal digits elsewhere so use
it consistently also for this output.
2016-04-06 11:31:02 +02:00
Zdenek Kabelac
5c29b54d4d cleanup: poll better check for internal errors 2016-02-25 23:30:25 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
David Teigland
ea74215fa1 vgextend: pass single vgname as process_each_vg arg
Pass the single vgname as a new process_each_vg arg
instead of setting a cmd flag to tell process_each_vg
to take only the first vgname arg from argv.

Other commands with different argv formats will be
able to use it this way.
2015-12-01 09:36:45 -06:00
Ondrej Kozina
33465066c5 polldaemon: fix missing mirror in-sync info with lvmpolld
CONVERTING status flag is a tricky one. It's not set when converting
a non-mirror LV type to the mirror type, i.e.: linear -> two leg mirror.
Also the conversion itself is instant and doesn't require to be polled.
When mirror reaches sync state there's no final update on VG metadata
for lvmpolld to be made thereby report_progress in fact doesn't report
percentage of mirror being converted but percentage of mirror
being in sync. Perhaps we should reword the lvconvert output here.

On the other hand CONVERTING is set while we upconvert the mirror
from i.e. two leg mirror to four leg mirror. In such case the operation
is required to be polled so that lvmpolld can cleanup temporary
conversion log when the conversion is over.

Ignore CONVERTING lv_type for the moment and match LVs only by uuids
during 'mirror conversion'/'waiting for a sync to finish'.
2015-10-20 12:18:55 +02:00
David Teigland
7b570840cd lockd: no error when unlock fails
The unlock call will fail in expected and normal cases,
and should not cause the command to fail.  (An actual
unlock in the lock manager should never fail.)
2015-08-18 11:18:40 -05:00
Zdenek Kabelac
ae4db9f302 lockd: check for failing unlock
Avoid ignoring unlocking error.
2015-08-18 15:00:07 +02:00
Peter Rajnoha
1f3d04cddf coverity: variable init must be done before its use
tools/polldaemon.c:465: uninit_use_in_call: Using uninitialized value "id.vg_name" when calling "print_log".
tools/polldaemon.c:465: uninit_use_in_call: Using uninitialized value "id.lv_name" when calling "print_log".
2015-08-04 09:51:16 +02:00
David Teigland
27e6aee390 lvconvert: merge polling fixes for lockd
. the poll check will eventually call finish which will
  write the VG, so an ex VG lock is needed from lvmlockd.

. fix missing unlock on poll error path

. remove the lockd locking while monitoring the progress
  of the command, as suggested by the earlier FIXME comment,
  as it's not needed.
2015-07-22 12:28:06 -05:00
Peter Rajnoha
6b48233f25 coverity: fix NULL check in lv->lvid.s
tools/polldaemon.c:457: array_null: Comparing an array to null is not useful: "lv->lvid.s"

The lv->lvid.s is never NULL. The check was supposed to be *lv->lvid.s
to check if the string is not empty.
2015-07-08 15:08:39 +02:00
Peter Rajnoha
3ec4813ba2 coverity: fix missing initialization
... Using uninitialized value "lockd_state" when calling "lockd_vg"
(even though lockd_vg assigns 0 to the lockd_state, but it looks at
previous state of lockd_state just before that so we need to have
that properly initialized!)

libdm/libdm-report.c:2934: uninit_use_in_call: Using uninitialized value "tm". Field "tm.tm_gmtoff" is uninitialized when calling "_get_final_time".

daemons/lvmlockd/lvmlockctl.c:273: uninit_use_in_call: Using uninitialized element of array "r_name" when calling "format_info_r_action". (just added FIXME as this looks unfinished?)
2015-07-08 14:53:30 +02:00
Alasdair G Kergon
dfe3eb12d0 include: Standardise around new tool.h. 2015-07-06 17:30:18 +01:00
David Teigland
fe70b03de2 Add lvmlockd 2015-07-02 15:42:26 -05:00
Ondrej Kozina
01b06cb71b polldaemon.c: modify log levels in report_progress
There's a race when asking lvmpolld about progress_status and
actually reading the progress info from kernel:

Even with lvmpolld being used we read status info from
LVM2 command issued by a user (client side from lvmpolld perspective).
The whole cycle may look like following:

1) set up an operation that requires polling (i.e. pvmove /dev/sda)
2) notify lvmpolld about such operation (lvmpolld_poll_init())
3) in case 1) was not called with --background it would continue with:
4) Ask lvmpolld about progress status. it may respond with one of:
   a) in_progress
   b) not_found
   c) finished
   d) any low level error

5) provided the answer was 4a) try to read progress info from polling LV
(i.e. vg00/pvmove1). Repeat steps 4) and 5) until the answer is != 4a).

And now we got into racy configuration: lvmpolld answered with in_progress
but it may be the that in_between 4) and 5) the operation has already
finished and polling LV is already gone or there's nothing to ask for.
Up to now, 5) would report warning and it could print such warning many
times if --interval was set to 0.

We don't want to scary users by warnings in such situation so let's just
print these messages in verbose mode. Error messages due to error while
reading kernel status info (on existing, active and locked LV) remained
the same.
2015-05-21 11:20:11 +02:00
Ondrej Kozina
e6b5eb88f2 polldaemon.c: do not report error when LV not found
currently in wait_for_single_lv() fn trying to poll missing pvmove LV
is considered success. It may have been already finished by another
instance of polldaemon. either by another forked off polldaemon
or by lvmpolld.

Let's try to handle the mirror conversion and snapshot merge the same
way.
2015-05-19 20:56:46 +02:00
David Teigland
7a8ce8dbf7 polldaemon: remove get_copy_vg and get_copy_lv wrappers
These wrappers have been replaced by direct calls
to vg_read() and find_lv() in previous commits.

This commit should have no functional impact since
all bits were already unreachable.
2015-05-19 20:56:15 +02:00
Ondrej Kozina
6fba37777c polldaemon.c: call find_lv directly 2015-05-19 20:56:07 +02:00
David Teigland
0d300b70f9 polldaemon.c: call vg_read directly
replace calls in wait_for_single_lv() and report_progress() fns
2015-05-19 20:55:50 +02:00
Ondrej Kozina
e5e0e22022 polldaemon: move dev_close_all out of poll_get_copy_vg
let's call dev_close_all() only before we're about to 'sleep'
for at least one second during the polling.

(it's questionable whether to call dev_close_all() at all in
polldaemon code. Natural extension would be to drop it completely)
2015-05-19 20:55:22 +02:00
Ondrej Kozina
e587b0677b lvmpolld: Add standalone polldaemon.
See doc/lvmpolld_overview.txt
2015-05-09 00:59:18 +01:00
Ondrej Kozina
7fca7f196d polldaemon: make wait_for_single_lv public
referenced by new lvpoll command after lvmpolld
gets merged.
2015-05-05 20:52:24 +02:00
Ondrej Kozina
81c038934c polldaemon: introduce _nanosleep function
querying future lvmpolld with zero wait time is highly undesirable
and can cause serious performance drop of the future daemon. The new
wrapper function may avoid immediate return from syscal by
introducing minimal wait time on demand.
2015-05-05 20:52:17 +02:00
Ondrej Kozina
76a0dffe6f polldaemon: refactor polling interfaces
Routines responsible for polling of in-progress pvmove, snapshot merge
or mirror conversion each used custom lookup functions to find vg and
lv involved in polling.

Especially pvmove used pvname to lookup pvmove in-progress. The future
lvmpolld will poll each operation by vg/lv name (internally by lvid).
Also there're plans to make pvmove able to move non-overlaping ranges
of extents instead of single PVs as of now. This would also require
to identify the opertion in different manner.

The poll_operation_id structure together with daemon_parms structure they
identify unambiguously the polling task.
2015-05-05 20:52:07 +02:00
Ondrej Kozina
bda26acf70 polldaemon: optimise out waiting after polling
Waiting even after _check_lv_status returned success and
'finished' flag was set to true doesn't make much sense.

Note that while we skip the wait() we also skip the
init_full_scan_done(0) inside the routine. This should
have no impact as long as the code after _wait_for_single_lv
doesn't presume anything about the state of the cache.
2015-05-05 20:51:45 +02:00
Ondrej Kozina
22ae43a11e polldaemon: get get_copy_vg ready for refactoring
with refactored code we take some VG locks as read-only.
Make the poll_get_copy_vg ready for the change.
2015-05-05 20:51:34 +02:00
Ondrej Kozina
32527861d0 polldaemon: respect lv_attr parm in poll_get_copy_lv
as a part of bigger effort to unify polling intefaces
poll_get_copy_lv should be able to look up LVs based
on theirs lv->status field.

Effective after pvmove starts using poll_get_copy_lv
fn as well.
2015-05-04 16:56:52 +02:00
Ondrej Kozina
26f4b1da88 polldaemon: move lvconvert_get_copy_lv code
Moving lvconvert_get_copy_lv to polldaemon (poll_get_copy_lv).
Clear move and rename.
2015-05-04 16:56:39 +02:00
Ondrej Kozina
079895b8be polldaemon: move lvconvert_get_copy_vg code
Moving lvconvert_get_copy_vg to polldaemon (poll_get_copy_vg).
Clear move and rename.
2015-05-04 16:56:28 +02:00
Ondrej Kozina
15a563c376 polldaemon: remove redundant log messages
also alter comments describing the change in _poll_vg
wrt correct handling of multiple LVs
2015-04-28 23:19:20 +02:00
Zdenek Kabelac
4f94669eca pvmove: don't crash when name is not found
If the device name is not found in our metadata,
we cannot call strdup few lines later with NULL name.

More intersting story goes behind how it happens -
pvmove removal is unfortunatelly 'multi-state' process
and at some point (for now)  we have in lvm2 metadata
LV  pvmove0 as stripe  and mirror image as error.

If such metadata are left - we fail with any further removal.
2015-04-03 17:18:11 +02:00
Ondrej Kozina
f199aeb9ea polldaemon: alter few lines related to interval
we do not allow 0 interval for pvmove command issued
without parameters with classical polldaemon. It would
query the kernel too often with possibly many pvmoves
in-progress.
2015-04-01 20:41:52 +02:00
Ondrej Kozina
7abb7894e4 polldaemon: separate daemon_parms initialisation 2015-04-01 20:41:39 +02:00
Ondrej Kozina
3929b00466 polldaemon: prepare wrapper poll_daemon function
with lvmpolld we'll have two polldaemon implementations
2015-04-01 20:41:30 +02:00
Ondrej Kozina
04826db7c4 polldaemon: fix indentation in _poll_vg fn 2015-03-31 13:16:01 +02:00
Ondrej Kozina
663254d7a5 polldaemon: proper error check in _poll_vg fn
could theoretically cause NULL pointer dereference
2015-03-31 11:26:53 +02:00
Ondrej Kozina
c282a66132 pvmove: fix pvmove --abort or pvmove w/o parameters
_check_lv_status was called from within dm_list_iterate_items cycle.
This was utterly wrong! _check_lv_status may remove more than one LV from
vg->lvs list we iterated in the same time.

In some scenarios this could lead to deadlock iterationg over same LV
indefinitely or segfault depending on the circumstances.

Fixed by moving the _check_lv_status outside iterating the vg->lvs
list.

Note that commit 6e7b24d34f was not enough
as _check_lv_status may result in removal of more than one LV from the list.
2015-03-30 18:38:50 +02:00
Peter Rajnoha
6e7b24d34f pvmove: use safe version of iteration when iterating over vg->lvs list in _poll_vg
When we're iterating over LVs in _poll_vg fn, we need to use the safe
version of iteration - the LV can be removed from the list which we're
just iterating over if we're finishing or aborting pvmove operation.
2015-03-23 13:40:39 +01:00
Peter Rajnoha
969d2bf448 cleanup: remove deallocate_handle_root arg from destroy_procesing_handle fnw 2015-02-13 11:27:09 +01:00
Peter Rajnoha
66b10d6d12 cleanup: replace static struct processing_handle initializer with common init_processing_handle
It's cleaner this way - do not mix static and dynamic
(init_processing_handle) initializers. Use the dynamic one everywhere.
This makes it easier to manage the code - there are no "exceptions"
then and we don't need to take care about two ways of initializing the
same thing - just use one common initializer throughout and it's clear.

Also, add more comments, mainly in the report_for_selection fn explaining
what is being done and why with respect to the processing_handle and
selection_handle.
2015-02-13 11:26:57 +01:00
Peter Rajnoha
56011918e6 toollib: initialize handles (including reporting for selection) for _select_match_* used in process_each_* fns
Call _init_processing_handle, _init_selection_handle and
_destroy_processing_handle in process_each_* and related functions to
set up and destroy handles used while processing items.
2015-02-10 16:05:29 +01:00
Peter Rajnoha
51d96a1703 toollib: replace void *handle with struct processing_handle for use in processing functions (process_each_*/process_single_* and related)
This patch replaces "void *handle" with "struct processing_handle *handle"
in process_each_*, process_single_* and related functions.

The struct processing_handle consists of two handles inside now:

  - the "struct selection_handle *selection_handle" used for
    applying selection criteria while processing process_each_*,
    process_single_* and related functions (patches using this
    logic will follow)

  - the "void* custom_handle" (this is actually the original handle
    used before this patch - a pointer to custom data passed into
    process_each_*, process_single_* and related functions).
2015-02-10 16:05:24 +01:00
Peter Rajnoha
cfed0d09e8 report: select: refactor: move percent handling code to libdm for reuse 2014-06-17 16:27:21 +02:00
Jonathan Brassow
a20de8af20 poll_daemon: Cleanly exit polling if the LV is no longer active
If the we are polling an LV due to some sort of conversion and it
becomes inactive, a rather worrisome message is produced, e.g.:
"  ABORTING: Mirror percentage check failed."

We can cleanly exit if we do a simple check to see if the LV is
active before performing the check.  This eliminates the scary
message.
2014-06-16 18:56:32 -05:00
Zdenek Kabelac
45f45c9932 polldaemon: ret invalid cmd for negative interval
Negative intervals are not supported.
2014-04-14 12:47:14 +02:00
Alasdair G Kergon
bbcc120e5a pvmove: clean exit on failed pvmove restart
At present, before the pvmove command can be used to restart pvmove
polling, the LVs concerned need to be activated e.g. with lvchange -ay.
2013-09-23 19:46:28 +01:00