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

135 Commits

Author SHA1 Message Date
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
Petr Rockai
89e7d81d92 lvmetad: Fix a corruption-prone race in error path. 2014-01-07 03:04:14 +01:00
Peter Rajnoha
481edce41f compile/link: use RELRO/PIE compiler/linker options for executables 2013-12-05 14:03:10 +01:00
Alasdair G Kergon
ac6cd9baa7 lvmetad: remove unused override variables 2013-12-05 01:13:18 +00:00
Peter Rajnoha
37853cc7a9 make: CFLAGS, not CLDFLAGS 2013-12-04 14:28:40 +01:00
Peter Rajnoha
a65ab773b4 daemons: use PIE and RELRO compiler/linker options
The PIE and RELRO compiler/linker options can be used to produce a code
some techniques applied that makes the code more immune to some attacks:

  - PIE (Position Independent Executable). It can make use of the ASLR
    (Address Space Layout Randomization) provided by kernel to avoid
    static locations for .text regions of executables (this is the 'pie'
    compiler and linker option)

  - RELRO (Relocation Read-Only). This prevents overwrite attacks of
    the GOT (Global Offset Table) and PLT (Procedure Lookup Table)
    used for relocations by making it read-only after all relocations
    are resolved (these are the 'relro' and 'now' linker options) -
    hence all symbols are resolved at the very start so there's no
    need for those tables to be writeable later.

These compiler/linker options are now used by default for daemons
if the compiler/linker supports it.
2013-12-04 13:30:08 +01:00
Alasdair G Kergon
84394c0219 lvmetad: extend socket/pid file handling
Make it easier to run a live lvmetad in debugging mode and
to avoid conflicts if multiple test instances need to be run
alongside a live one.

No longer require -s when -f is used: use built-in default.
Add -p to lvmetad to specify the pid file.
No longer disable pidfile if -f used to run in foreground.
If specified socket file appears to be genuine but stale, remove it
before use.
On error, only remove lvmetad socket file if created by the same
process.  (Previous code removes socket even while a running instance
is using it!)
2013-11-29 20:56:29 +00:00
Alasdair G Kergon
b3074560eb lvmetad: Add newline to missing socket error mesg 2013-11-28 19:16:25 +00:00
Zdenek Kabelac
6c787d9b6e cleanup: move declaration to the front 2013-11-28 12:48:01 +01:00
Peter Rajnoha
8d5cff5b9b lv/vgchange: do not try to connect to lvmetad if socket absent and --sysinit -aay used
If using lv/vgchange --sysinit -aay and lvmetad is enabled, we'd like to
avoid the direct activation and rely on autoactivation instead so
it fits system initialization scripts.

But if we're calling lv/vgchange --sysinit -aay too early when even
lvmetad service is not started yet, we just need to do the direct
activation instead without printing any error messages (while
trying to connect to lvmetad and not finding its socket).

This patch adds two helper functions - "lvmetad_socket_present" and
"lvmetad_used" which can be used to check for this condition properly
and avoid these lvmetad connections when the socket is not present
(and hence lvmetad is not yet running).
2013-11-26 14:51:23 +01:00
Zdenek Kabelac
8e1f2e733e gcc: fix comparing floating point warning
Since we enabled some more gcc warnings - let's adapt for
it and check for double equals with DBL_EPSILON.

Current close_enough() is far from perfect
for more details see i.e. here:
http://randomascii.wordpress.com/2012/01/11/tricks-with-the-floating-point-format/
but fairly enough for lvm2 use-case.
2013-10-25 10:43:32 +02:00
Peter Rajnoha
304159c99a cleanup: WHATS_NEW + compiler warning about discarding const 2013-10-10 09:09:16 +02:00
Petr Rockai
cb613d4c10 lvmetad: Fix a possible deadlock in pv_clear_all. 2013-10-10 00:34:35 +02:00
Petr Rockai
bcb44281b7 lvmetad: Do not try to lock a NULL vgid. 2013-10-09 14:56:06 +02:00
Peter Rajnoha
a7c73154ea cleanup: remove 'discards 'const' qualifier' compilation warning 2013-10-09 10:05:02 +02:00
Petr Rockai
d888a0557e lvmetad: Properly grab locks in pv_gone. 2013-10-08 23:21:09 +02:00
Petr Rockai
805f7e4042 lvmetad: Clean up pvid->vgid map when last PV in a VG disappears. 2013-10-08 23:21:09 +02:00
Petr Rockai
0d03503a45 lvmetad: Fix vgname->vgid hash updates w/ duplicate VG names. 2013-10-04 14:31:45 +02:00
Zdenek Kabelac
377e06b0f8 lvmetad: cleanup
Move individual assignments to simplier structure setup.
2013-04-21 23:02:43 +02:00
Petr Rockai
95372a852b lvmetad: Fix a memory leak introduced in 15fdd5c90d. 2013-04-03 13:46:12 +02:00
Petr Rockai
15fdd5c90d lvmetad: Fix a race in metadata update.
The idea is to avoid a period when an existing VG is not mapped to either the
old or the new name. (Note that the brief "blackout" was present even if the
name did not actually change.) We instead allow a brief overlap of a VG existing
under both names, i.e. a query for a VG might succeed but before a lock is
acquired the VG disappears.
2013-01-16 11:19:33 +01:00
Zdenek Kabelac
69099e7ef5 Revert "lvmetad: simplify pvid memory allocation."
This reverts commit ed23da95b6.

Hash table device_to_pvid  seems to contain references to
already deleted pvids and so revert to the older
behaviour using allocated memory.
2012-12-17 13:49:19 +01:00
Petr Rockai
5294a6f77a lvmetad: Fix a possible race in remove_metadata.
All operations on shared hash tables need to be protected by mutexes. Moreover,
lookup and subsequent key removal need to happen atomically, to avoid races (and
possible double free-ing) between multiple threads trying to manipulate the same
VG.
2012-12-17 00:47:55 +01:00
Petr Rockai
fae1a611d2 lvmetad: Fix a possible deadlock.
If an update and a query were running in parallel, there was a slim but non-zero
chance of a deadlock due to (unnecessary) mutex nesting.
2012-12-17 00:47:55 +01:00
Zdenek Kabelac
ed23da95b6 lvmetad: simplify pvid memory allocation.
Since pvid_dup and cft config appears to be tightly
binded together - reuse it's memory pool for string.
Simplifies release of hashes.
2012-12-15 17:23:28 +01:00
Zdenek Kabelac
ba3f37c9e4 lvmetad: fix memleak on pv_found error path
Free resources allocated in pv_found when going out
through error path.
2012-12-15 17:23:27 +01:00
Zdenek Kabelac
399fc1bb33 lvmetad: keep returned struct fully initialized
Always clear the response structure.
Simplify daemon_reply initialization.
2012-12-15 17:23:27 +01:00
Zdenek Kabelac
a4269aadf3 lvmetad: unlock vg on out-of-memory path
If we fail to get memory for mutex, hash the mutex
or fail somewhere along pthread function calls
return allocated resources back and unlock vg_lock_map mutex.
2012-12-15 17:23:26 +01:00
Zdenek Kabelac
1b05438fcb cleanup: ignore errors
Since we are doing just dump and function doesn't report
any error, explicitely ignore return values from
dm_config_write_node and dm_asprintf.

Same applies for the logging function.
2012-12-15 14:57:40 +01:00
Alasdair G Kergon
8290de964f lvmetad: rename DEBUG() to DEBUGLOG()
DEBUG is already defined by -DDEBUG
2012-10-15 14:20:11 +01:00
Alasdair G Kergon
78dafcba99 lvmetad: use -l for logging level not -d 2012-10-15 10:44:43 +01:00
Alasdair G Kergon
a0e60d27ff lvmetad: document and tidy cmdline args
Try to bring the lvmetad usage text and man page closer to the code.
There seem to be 3 useful ways to use -d with lvmetad at the moment:
  -d all
  -d wire
  -d debug
(They can also be comma-separated like -d wire,debug.)
Prior to the last release, -d, -dd and -ddd were supported.
Fail if an unrecognised debug arg is supplied on the command line.
Change -V to report the same version as the lvm binary: previously it
just reported version 0.
2012-10-15 02:06:27 +01:00
Zdenek Kabelac
9effc6ab31 cleanup: drop unused assignment
Since 'n' is later reassigned and unused between, drop it's first
assign.
2012-10-13 19:17:10 +02:00
Zdenek Kabelac
c4dcbf67a3 lvmetad: initialize cft value
the error should not test garbage value.
2012-10-12 10:59:10 +02:00
Zdenek Kabelac
9ee071705b cleanup: fix compiler warnings
remove unused vars
move var declarations into the front of functions.
fix some sign warnings
2012-10-12 10:25:07 +02:00