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

86 Commits

Author SHA1 Message Date
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
Peter Rajnoha
008c33a21b tools: add -b/--background for pvscan --cache -aay
Udev daemon has recently introduced a limit on the number of udev
processes (there was no limit before). This causes a problem
when calling pvscan --cache -aay in lvmetad udev rules which
is supposed to activate the volumes. This activation is itself
synced with udev and so it waits for the activation to complete
before the pvscan finishes. The event processing can't continue
until this pvscan call is finished.

But if we're at the limit with the udev process count, we can't
instatiate any more udev processes, all such events are queued
and so we can't process the lvm activation event for which the
pvscan is waiting.

Then we're in a deadlock since the udev process with the
pvscan --cache -aay call waits for the lvm activation udev
processing to complete, but that will never happen as there's
this limit hit with the number of udev processes.

The process with pvscan --cache -aay actually times out eventually
(3min or 30sec, depends on the version of udev).

This patch makes it possible to run the pvscan --cache -aay
in the background so the udev processing can continue and hence
we can avoid the deadlock mentioned above.
2013-09-03 16:49:21 +02:00
Peter Rajnoha
50bf2c0db1 config: add profile arg to find_config_tree_int 2013-07-02 15:19:09 +02:00
Peter Rajnoha
386886f71c config: refer to config nodes using assigned IDs
For example, the old call and reference:

  find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)

...now becomes:

  find_config_tree_str(cmd, devices_dir_CFG)

So we're referring to the named configuration ID instead
of passing the configuration path and the default value
is taken from central config definition in config_settings.h
automatically.
2013-03-06 10:14:33 +01:00
Alasdair G Kergon
438e0050df config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.

When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]

Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 20:35:48 +01:00
Zdenek Kabelac
fd417db274 check: add internal errors for unexpected paths
Adding couple INTERNAL_ERROR reports for unwanted parameters:

Ensure the 'top' metadata node cannot be NULL for lvmetad.

Make obvious vginfo2 cannot be NULL.

Report internal error if handler and vg is undefined.

Check for handle in poll_vg().

Ensure seg is not NULL in dev_manager_transient().

Report missing read_ahead for _lv_read_ahead_single().

Check for report handler in dm_report_object().

Check missing VG in _vgreduce_single().
2012-08-23 14:37:52 +02:00
Zdenek Kabelac
6ddce3b6a7 Check for error from dup2
Do not take correct fd as error result.
2012-03-01 23:20:45 +00:00
Zdenek Kabelac
fbf6b89a84 Using enum types for enums
alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
2012-02-28 14:24:57 +00:00
Zdenek Kabelac
6f8bd07b40 Duplicate standard in/out descriptors for daemon
Addressing somewhat tricky bug here.
Since stdin,stdout,stderr were closed it's been occasionally possible to
see some unexpected messages to be flowing into a clvmd and generating some
randomly sized allocation of many megabytes. Since the message was not
being generated by standard send_message() construction, after some more
testing it apperead to be a debug log message - thus something has flown
to local socket opened on strandard out descriptor.

To fix the issue - use standard file descriptor duplication code for daemons.

For making easier debugging of polling daemon - developer might want to recompile
without modifition of standard file descriptors.
2012-02-28 10:06:53 +00:00
Alasdair Kergon
2ef5b7cca6 Start using 64-bit status flags - most of the code already handles them.
tdata -> tpool
remove commented out definitions from metadata.h
formatting clean-ups
2011-09-06 18:49:31 +00:00
Zdenek Kabelac
077a6755ff Replace free_vg with release_vg
Move the free_vg() to  vg.c  and replace free_vg  with release_vg
and make the _free_vg internal.

Patch is needed for sharing VG in vginfo cache so the release_vg function name
is a better fit here.
2011-08-10 20:25:29 +00:00
Zdenek Kabelac
45afc15547 Use return_0 to get bactrace 2011-02-18 15:05:40 +00:00
Milan Broz
74863007ee If other process finishes (or aborts) pvmove operation and
polling function cannot find any lv with PVMOVE flag, return
success and do not print  "aborting" message.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=602389
2011-01-19 23:11:39 +00:00
Alasdair Kergon
a8de276520 Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)
Introduce sync_local_dev_names and CLVMD_CMD_SYNC_NAMES to issue fs_unlock.
2011-01-12 20:42:50 +00:00
Zdenek Kabelac
ad50450a22 Avoid cookie sharing between forked processes
Before fork, ensure cookie is reset so it's not shared between processes.
2011-01-10 19:31:02 +00:00
Zdenek Kabelac
de0ae6a18f Fail deamonization if lvmcache_init fail
FIXME Add proper cleanup
2011-01-05 12:59:46 +00:00
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Petr Rockai
8191fe4f4a Refactor the percent (mirror sync, snapshot usage) handling code to use
fixed-point values instead of a combination of a float value and an enum.
2010-11-30 11:53:31 +00:00
Jonathan Earl Brassow
6ec8c52201 This patch fixes a problem where the mirror polling process
may never complete.

If you convert from a linear to a mirror and then convert that
mirror back to linear /while/ the previous (up)convert is
taking place, the mirror polling process will never complete.
This is because the function that polls the mirror for
completion doesn't check if it is still polling a mirror and
the copy_percent that it gets back from the linear device is
certainly never 100%.

The fix is simply to check if the daemon is still looking at
a mirror device - if not, return PROGRESS_CHECK_FAILED.

The user sees the following output from the first (up)convert
if someone else sneaks in and does a down-convert shortly
after their convert:
[root@bp-01 ~]# lvconvert -m1 vg/lv
  vg/lv: Converted: 43.4%
  ABORTING: Mirror percentage check failed.
2010-08-26 16:29:12 +00:00