1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00
Commit Graph

169 Commits

Author SHA1 Message Date
David Teigland
cd937efa77 lvmetad: change recent cleanups
with better alternatives.
2015-11-09 12:18:43 -06:00
Zdenek Kabelac
c2d5cfbdb8 cleanup: use _ for local function 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
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
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
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
David Teigland
73e679f33f man: document possible lvmetad -l values
In the man page and the lvmetad help output.
2015-10-21 13:36:57 -05:00
Ondrej Kozina
f67a52677b lvmetad: add optional timeout option 2015-10-20 15:45:14 +02:00
Zdenek Kabelac
fd3d795b93 makefiles: distclean missing files 2015-09-11 21:52:27 +02:00
Alasdair G Kergon
fb12308416 style: Standardise some error paths. 2015-09-05 23:56:30 +01:00
David Teigland
f0b3e05add lvmetad: also accept vg name for set_vg_info
set_vg_info previously accepted only vg uuid,
now accept both vg uuid and vg name.  If the
uuid is provided, it's used just as before,
but if the uuid is not provided, or if it's
not found, then fall back to using the vg
name if that is provided.
2015-08-28 14:36:48 -05:00
Peter Rajnoha
f6473baffc toolcontext: add switches to create_toolcontext for connections and filters init
Make it possible to decide whether we want to initialize connections and
filters together with toolcontext creation.

Add "filters" and "connections" fields to struct
cmd_context_initialized_parts and set these in cmd_context.initialized
instance accordingly.

(For now, all create_toolcontext calls do initialize connections and
filters, we'll change that in subsequent patch appropriately.)
2015-07-30 13:54:09 +02:00
Alasdair G Kergon
3934ade5a2 gitignore: Update for in-place build. 2015-07-27 13:18:35 +01:00
Peter Rajnoha
10d27998b3 coverity: missing return value checks 2015-07-09 15:15:15 +02:00
Peter Rajnoha
023cf21848 coverity: fix possible invalid dereferences
lib/format1/import-export.c:167: var_deref_op: Dereferencing null pointer "vg->lvm1_system_id"
lib/cache/lvmetad.c:1023: var_deref_op: Dereferencing null pointer "this"
daemons/lvmlockd/lvmlockd-core.c:2659: check_after_deref: Null-checking "act" suggests that it may be null, but it has already been dereferenced on all paths leading to the check
/daemons/lvmetad/lvmetad-core.c:1024: check_after_deref: Null-checking "pvmeta" suggests that it may be null, but it has already been dereferenced on all paths leading to the check
2015-07-09 12:07:41 +02:00
David Teigland
d16332be72 lvmetactl: program to interact with lvmetad
This is not installed; it's only a developer utility
at this point.
2015-07-06 15:54:22 -05:00
Alasdair G Kergon
dfe3eb12d0 include: Standardise around new tool.h. 2015-07-06 17:30:18 +01:00
David Teigland
bf77f71711 lvmetad: add invalidation method
Add the ability to invalidate global or individual VG metadata.
The invalid state is returned to lvm commands along with the metadata.
This allows lvm commands to detect stale metadata from the cache and
reread the latest metadata from disk (in a subsequent patch.)

These changes do not change the protocol or compatibility between
lvm commands and lvmetad.

Global information
------------------

Global information refers to metadata that is not isolated
to a single VG , e.g. the list of vg names, or the list of pvs.

When an external system, e.g. a locking system, detects that global
information has been changed from another host (e.g. a new vg has been
created) it sends lvmetad the message: set_global_info: global_invalid=1.
lvmetad sets the global invalid flag to indicate that its cached data is
stale.

When lvm commands request information from lvmetad, lvmetad returns the
cached information, along with an additional top-level config node called
"global_invalid".  This new info tells the lvm command that the cached
information is stale.

When an lvm command sees global_invalid from lvmated, it knows it should
rescan devices and update lvmetad with the latest information.  When this
is complete, it sends lvmetad the message: set_global_info:
global_invalid=0, and lvmetad clears the global invalid flag.  Further lvm
commands will use the lvmetad cache until it is invalidated again.

The most common commands that cause global invalidation are vgcreate and
vgextend.  These are uncommon compared to commands that report global
information, e.g. vgs.  So, the percentage of lvmetad replies containing
global_invalid should be very small.

VG information
--------------

VG information refers to metadata that is isolated to a single VG,
e.g. an LV or the size of an LV.

When an external system determines that VG information has been changed
from another host (e.g. an lvcreate or lvresize), it sends lvmetad the
message: set_vg_info: uuid=X version=N.  X is the VG uuid, and N is the
latest VG seqno that was written.  lvmetad checks the seqno of its cached
VG, and if the version from the message is newer, it sets an invalid flag
for the cached VG.  The invalid flag, along with the newer seqno are saved
in a new vg_info struct.

When lvm commands request VG metadata from lvmetad, lvmetad includes the
invalid flag along with the VG metadata.  The lvm command checks for this
flag, and rereads the VG from disk if set.  The VG read from disk is sent
to lvmetad.  lvmetad sees that the seqno in the new version matches the
seqno from the last set_vg_info message, and clears the vg invalid flag.
Further lvm commands will use the VG metadata from lvmetad until it is
next invalidated.
2015-06-23 16:36:33 -05:00
David Teigland
fd1376ebef libdaemon: move compare_config to lib
so it can be used elsewhere.
2015-06-17 13:07:52 -05:00
Petr Rockai
4f91ad64c3 lvmetad: Make it possible to clear the outdated PVs list for a VG. 2015-06-10 16:18:57 +02:00
David Teigland
fd29c7f3a1 lvmetad, lvmpolld: remove DL_LIBS from Makefile
and rdynamic.  They are not needed.
2015-06-08 11:48:22 -05:00
Zdenek Kabelac
d1531ab26d cleanup: gcc warn fix, don't hide pvs() 2015-05-27 11:10:43 +02:00
Petr Rockai
55f3369692 lvmetad: Provide entire pvmeta sections for outdated_pvs. 2015-05-20 19:46:14 +02:00
Petr Rockai
1562cd7320 lvmetad: Attach an outdated_pvs list to vg_lookup replies. 2015-05-20 19:46:13 +02:00
Petr Rockai
da1527d65d lvmetad: Clear the vgid_to_outdated_pvs hash on shutdown. 2015-05-20 19:46:13 +02:00
Petr Rockai
925268794f lvmetad: Maintain info about outdated PVs. 2015-05-20 19:46:13 +02:00
Zdenek Kabelac
7bd1559db6 makefiles: testclient is not valid target 2015-05-14 00:19:32 +02:00
Zdenek Kabelac
923902013c lvmetad: drop unused vars
Squash some unused vars introduced in some previous commit.s
2015-04-29 15:09:58 +02:00
Petr Rockai
4946c64092 lvmetad: Avoid duplicate entries in the list of alternate devices. 2015-04-29 13:23:23 +02:00
Petr Rockai
a1dd61459c lvmetad: Track alternate devices for PVs.
There are two reasons for this: first, this allows the client side to notice
that some PV has multiple devices associated with it and print appropriate
warnings. Second, if a duplicate device pops up and disappears, after this
change the original connection between the PV and device is not lost.
2015-04-14 20:18:27 +02:00
Alasdair G Kergon
6521c4b215 libdaemon: Fix some client leaks.
Free (and clear) h.protocol string on daemon_open() error paths
so it's OK for caller to skip calling daemon_close() if returned
h.socket_fd is -1.

Close h.socket_fd in daemon_close() to avoid possible leak.

https://bugzilla.redhat.com/1164234
2014-11-28 21:31:51 +00:00
Zdenek Kabelac
f12e3da639 cleanup: gcc warnings 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
3fda296da6 cleanup: lvmetad use dm_hash_iterator
Simplify code with the use of dm_hash_iterator
2014-03-26 14:11:37 +01:00
Petr Rockai
551b6b7998 lvmetad: Fix pvmeta_old_{pvid,dev} logic when they are the same. 2014-03-14 10:09:16 +01:00
Marian Csontos
67c539f346 lvmetad: Fix previous commit
"%d" in buffer_append_vf is 64 bit wide. Using just `int` for the
variable will fetch more from va_list than intended and shifting
remaining arguments resulting in errors like:

    Internal error: Bad format string at '#orphan'
2014-03-14 08:09:37 +01:00
Petr Rockai
816197aaab lvmetad: Indicate whether pv_found caused the VG to change. 2014-03-14 03:08:19 +01:00
Petr Rockai
5eef269f77 lvmetad: Also return vgname in reply to pv_found requests. 2014-03-14 03:08:19 +01:00
Zdenek Kabelac
a92fae079b lvmetad: fix minor gcc warning
Cast to pass in non-const pointer
2014-03-03 11:23:32 +01:00
Zdenek Kabelac
bda98c4b8d lvmetad: move memalloc/free out of lock
Small code move to lower locking time and make memory
allocation and free outside of lock.

Drop duplicate test of NULL pointer before calling dm_free.
2014-03-01 14:08:58 +01:00
Zdenek Kabelac
d8513da9be lvmetad: fix memleak when pv changes it device
Test vgimportclone invokes mem leak of pvid which
would be otherwise lost when device_old_pvid
is removed from hash table.
2014-03-01 14:00:15 +01:00
Petr Rockai
c8e868f6e0 lvmetad: Fix an invalid memory read that could cause a deadlock. 2014-03-01 00:42:09 +01:00
Petr Rockai
bf29eabdba lvmetad: Keep the cache consistent when a PV moves around.
In cases where PV appears on a new device without disappearing from an old one
first, the device->pvid pointers could become ambiguous. This could cause the
ambiguous PV to be lost from the cache when a different PV comes up on one of
the ambiguous devices.
2014-02-28 11:23:52 +01:00
Petr Rockai
4143b284f8 lvmetad: Make "reason" in a token_mismatch reply more informative. 2014-02-26 15:10:21 +01:00
Zdenek Kabelac
408e276a61 cleanup: extend struct init usage 2014-02-24 21:13:35 +01:00
Petr Rockai
8a8e59fb5a lvmetad: Fix getting vgid_old & avoid removing in-transition VGs. 2014-01-08 15:22:24 +01:00
Zdenek Kabelac
4417cd288b lvmetad: add parentheses around assignment 2014-01-08 11:57:43 +01:00
Petr Rockai
a832120521 lvmetad: Flush a VG if it goes completely missing due to pv_found. 2014-01-07 03:28:20 +01:00