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

1205 Commits

Author SHA1 Message Date
David Teigland
931fede81b hash: change name of new lookup function 2015-11-17 11:59:44 -06:00
David Teigland
485d2ca945 lvmetad: different style for hash functions
In lookup, return a count of entries with the
same key rather than the value from a second
entry with the same key.

Using some slightly different names.
2015-11-17 10:27:16 -06:00
David Teigland
d42cedae58 lvmetad: add error explaining duplicate VG names
When a VG name lookup fails because the name matches
multiple VGs, return an explanatory error.
2015-11-16 16:25:49 -06:00
David Teigland
7d1c9e1d5a lvmetad: fix some error logging
For some errors old_meta may not be set, so
check before logging it.
2015-11-16 15:13:26 -06:00
David Teigland
68c386cce7 lvmetad: use lookup_withval in another location
Simply use lookup_withval right away rather than doing a
standard lookup, checking for the wrong mapping, then
repeating with lookup_withval to get the right mapping.
2015-11-16 15:13:22 -06:00
David Teigland
4a984cabc4 lvmetad: remove unneeded FIXME
This case is now handled correctly.
2015-11-16 13:44:57 -06:00
Stéphane Aulery
376892ddf8 clvmd: remove -v option from getopt
-V is documented, not -v.

Signed-off-by: Stéphane Aulery <saulery@free.fr>
2015-11-16 01:15:03 +01:00
David Teigland
d9295410e9 lvmetad: change the new hash to take data len
If the data len is passed into the hash table
and saved there, then the hash table internals
do not need to assume that the data value is
a string at any point.
2015-11-13 16:54:22 -06:00
David Teigland
46193f4a59 lvmetad: handle duplicate VG names
New hash table functions are added that allow for
multiple entries with the same key.  Use of the
vgname_to_vgid hash table is converted to these
new functions since there are multiple entries
in vgname_to_vgid that have the same key (vgname).

When multiple VGs with the same name exist, commands
that reference only a VG name will fail saying the
VG could not be found (that error message could be
improved.)  Any command that works with the select
option can access one of the VGs with -S vg_uuid=X.
vgrename is a special case that allows the first VG
name arg to be replaced by a uuid, which also works.

(The existing hash table implementation is not well
suited for handling this case, but it works ok with
the new extensions.  Changing lvmetad to use its own
custom hash tables may be preferable at some point.)
2015-11-13 14:56:35 -06:00
David Teigland
43777b551d lvmetad: tail chasing to shut up coverity 2015-11-12 09:35:41 -06:00
Zdenek Kabelac
058725c721 dmeventd: fix check for failing open.
Recent change 2c8d6f5c90
actually droped restart when the reason of failing open is missing
device completely - check for ENOENT now as another reason
to start new dmeventd server  (when there is no systemd to maintain it).
2015-11-11 19:54:55 +01:00
David Teigland
cd937efa77 lvmetad: change recent cleanups
with better alternatives.
2015-11-09 12:18:43 -06:00
David Teigland
d2d5191b78 lvmlockd: reverse some unnecessary checking
These are unnecessary or not useful.
2015-11-09 12:18:43 -06:00
David Teigland
6762eec88c lvmlockd: fix the NO_GL_LS condition
indicating when no global lockspace exists.
2015-11-09 11:33:16 -06:00
Zdenek Kabelac
b1215b7f8c lvmlockd: enforce 64bit arithmetic
Coverity suggest to stay on the 'safe' side and widen operators early
so 64bit offset is made from 64bit arithmentic.
2015-11-09 17:04:10 +01:00
Zdenek Kabelac
d6767d753f lvmlockd: add missing error checks
Detect error from function and report them.
2015-11-09 17:04:10 +01:00
Zdenek Kabelac
c2d5cfbdb8 cleanup: use _ for local function 2015-11-09 17:04:10 +01:00
Zdenek Kabelac
3db5ba08b1 cleanup: drop unneded headers
Coverity notices they are not really needed.
2015-11-09 17:04:10 +01:00
Zdenek Kabelac
32762e2a9c libdaemon: fix passing 32bit values for %d
Since %d is now prohibited for its great confusion,
replace it with  FMTd64 and correctly converted int64_t
parameter.
2015-11-09 17:04:10 +01:00
David Teigland
e207ededd6 lvmlockd: shut up warnings 2015-11-09 10:00:04 -06:00
Zdenek Kabelac
0b5a75c9af lvmetad: restore use of FMTd64
daemon_reply_simple() eats just 64bit numbers - so make it explicit.
2015-11-09 14:02:27 +01:00
Zdenek Kabelac
5aae8de776 lvmetad: maintain seqno as int
Keep seqno as 32bit value.
Also use '_' prefix for local _update_metadata.
2015-11-09 12:21:17 +01:00
Zdenek Kabelac
b1dab26be0 cleanup: coverity quiet
While through all codepaths we never 'read' lock_id unless LCKF_CONVERT,
coverity cannot decrypt this.

As since it's usually better to pass in 'well-defined' data structures
preset lock_id to 0.
2015-11-09 10:22:52 +01:00
Zdenek Kabelac
11151121aa cleanup: use fputs for plain strings
Use fputs() when printing plain string,
easier then fprintf which needs to parse it.

Also check fd before close is >= 0 -
it is - but coverity fail to see it, so eliminate
this false-positive warning.
2015-11-09 10:22:52 +01:00
Zdenek Kabelac
c4c5635870 cleanup: drop unneeded assign
prio is always assigned later.
2015-11-09 10:22:52 +01:00
Zdenek Kabelac
99def8f439 lvmetad: check for pointers not NULL
Check for  arg_vgid_lookup and arg_name_lookup not being NULL.
Drop checking arg_vgid and arg_name for NULL since they
are already dereference earlier - thus mostly must be NOT NULL.

(If that would be possible larger rework of this function would be
required).
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
f66fe2c444 lvmetad: require meta_lookup
Coverity: do not call update_pvid_to_vgid() with
meta_lookup == NULL since it is dereferencing it.
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
91bde0f4a1 lvmetad: check for allocation fail
Coverity: missing check for root != NULL as this pointer is
later dereferenced in add_last_node().
2015-11-09 10:19:19 +01:00
Zdenek Kabelac
9df3069083 clvmd: check for pthread_create status
Coverity: likes to see checked function result.
2015-11-09 10:19:18 +01:00
Zdenek Kabelac
2c8d6f5c90 dmeventd: open fifo in one function
Put calls related to fifo opening into a single function.

Fix  Time-Of-Check-Time-Of-Use and use fstat()
and fchmod() on already opened fd instead of
checking first path and then risking to open something
different.
2015-11-09 10:18:53 +01:00
Zdenek Kabelac
e1b111b02a dmeventd: reorder tou 2015-11-09 10:00:33 +01:00
Zdenek Kabelac
8b857bfdc6 libdevmapper-event: fix fifo leak on error path
Coverity: when _init_client() fails, client fifo could have
been already openned and needs to be closed on error path.
2015-11-09 10:00:13 +01:00
David Teigland
4e6377f5ba lvmetad: refactor and document
update_metadata and pv_found update the cached metadata;
these are both reworked to improve the code, organize it
by each possible state and transition, make it much more
clear what's changing, add more error checking and
handling, and add comments.

The state and content of the cache (hash tables) does not
change (apart from some things that didn't work before),
and the communication to/from commands does not change.
The implementation and organization of the code making
the state changes does change significantly.

One detail related to the content of the cache does change:
different hash tables do not reference the same memory any more;
the target values in each hash table are allocated and freed
individually.
2015-11-03 13:18:27 -06:00
Zdenek Kabelac
099466939e thin: dmeventd plugin check number of failures
If plugin's lvm command execution fails too often (>10 times),
there is no point to torture system more then necessary, just log
and drop monitoring in this case.
2015-10-29 12:14:20 +01:00
Zdenek Kabelac
5d76bdcdbd dmeventd: event string parser handles empty field
Improve event string parser to avoid unneeded alloc+free.

Daemon talk function uses '-' to mark NULL/missing field.
So restore the NULL pointer back on parser.

This should have made old tools like 'dmevent_tool' work again.
As now 'uuid' or 'dso' could become NULL and then be
properly used in _want_registered_device() function.

Since lvm2 always fill these parameters, this change should
have no effect on lvm2.
2015-10-27 11:42:40 +01:00
Zdenek Kabelac
b702d67747 dmevent: fix referencing
Plugin increments DSO refcounter in _alloc_thread_status().
2015-10-26 23:31:23 +01:00
Zdenek Kabelac
1a7bea0f0f cleanup: drop debug 2015-10-23 10:54:13 +02:00
Zdenek Kabelac
b5b2a54834 cleanup: fix gcc compile with older pthread
Older pthread library was missing 'trick'
in pthread_cleanup_pop() which lead to
compilation error:

error: label at end of compound statement

Use explicit ';' to fix it.
2015-10-23 10:54:13 +02:00
Zdenek Kabelac
87a39d8bac dmeventd: ensure filter is empty
On some error path we could have left filter set to some value.
Not a big issue - but lets make reporting correct as soon
as we can.
2015-10-23 10:54:13 +02:00
Zdenek Kabelac
cff1c728d8 dmeventd: debug error paths 2015-10-23 10:54:13 +02:00
Zdenek Kabelac
1a2d0a0c72 cleanup: indents 2015-10-22 22:46:10 +02:00
Zdenek Kabelac
8be60e6a65 cleanup: easier to read code
Avoid using #ifdef code and use 'cmd' instead of 'die'.
2015-10-22 22:46:10 +02:00
Zdenek Kabelac
2af696c32f dmeventd: exit on idle
Implementing exit when 'dmeventd' is idle.
Default idle timeout set to 1 hour - after this time period
dmeventd will cleanly exit.

On systems with 'systemd' - service is automatically started with
next contact on dmeventd communication socket/fifo.

On other systems - new dmeventd starts again when lvm2 command detects
its missing and monitoring is needed.
2015-10-22 22:43:03 +02:00
Zdenek Kabelac
4284ba65eb dmeventd: debug signals 2015-10-22 22:41:12 +02:00
Zdenek Kabelac
aeec62ad19 dmeventd: snapshot plugin unmonitor
Send signal to itself to mark plugin as 'finished' as
the watching rule is no longer usable.
2015-10-22 22:41:12 +02:00
Zdenek Kabelac
12aa56d298 dmeventd: handle signal from plugin
Add support to unmonitor device when monitor recognizes there is
nothing to monitor anymore.

TODO: possibly API change with return value could be also used.
2015-10-22 22:40:07 +02:00
Zdenek Kabelac
9156c5d088 dmeventd: rework locking code
Redesign threading code:

- plugin registration runs within its new created thread for
  improved parallel usage.

- wait task is created just once and used during whole plugin lifetime.

- event thread is based over  'events' filter being set - when
  filter is 0, such thread is 'unused'.

- event loop is  simplified.

- timeout thread is never signaling 'processing' thread.

- pending of events filter cnange is properly reported and
  running event thread is signalled when possible.

- helgrind is not reporting problems.
2015-10-22 22:39:24 +02:00
Zdenek Kabelac
466a1c72b7 cleanup: use enums 2015-10-22 22:36:00 +02:00
Zdenek Kabelac
81e9ab3156 dmeventd: code mode _get_device_status
Move _get_device_status() in code.
Use dm_task_no_flush() function when reading status.
(e.g. none blocking for thins pool)
2015-10-22 22:35:25 +02:00
Zdenek Kabelac
15dbd4b56a dmeventd: minimize locking time for get_imeout
Don't hold lock when creating message (allocating memory).
Thread cannot dissapear as it's only the same thread which
may clean it.
2015-10-22 22:34:30 +02:00