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

992 Commits

Author SHA1 Message Date
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
Zdenek Kabelac
760714829b cleanup: skip double assign
Assing NULL to type only in defaut: switch.
Debug print '--'  for  unlocked and unused resource (-1)
2013-12-17 14:08:54 +01:00
Zdenek Kabelac
7c5feaed3b dmeventd: prevent busy looping on CPU
Use usleep when looping on DM_WAIT_RETRY.
2013-12-12 13:40:55 +01:00
Zdenek Kabelac
b87c148499 dmeventd: change locking code
Ensure global lock is being hold when working with thread->.
2013-12-12 13:38:55 +01:00
Zdenek Kabelac
4fc97980b6 dmeventd: drop taking timeout mutex
Taking _timeout_mutex is not needed when registering and unregistering.
Global mutex is already being hold for this case.
2013-12-12 13:32:49 +01:00
Zdenek Kabelac
30a81e5989 cleanup: self compilable headers 2013-12-12 13:28:19 +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
5bdbaf4ed7 cleanup: convert log_sys_error to log_sys_debug
Use debug for those error reports which do not lead to error return
call.
2013-11-28 12:48:01 +01:00
Zdenek Kabelac
6c787d9b6e cleanup: move declaration to the front 2013-11-28 12:48:01 +01:00
Zdenek Kabelac
50e1fad86a cleanup: use matching signed types 2013-11-28 12:47:51 +01:00
Zdenek Kabelac
b3679590df dmeventd: simplify error path
Use common 'bad:' label for exit error path where
fifo is closed before exit().
2013-11-28 12:45:02 +01:00
Zdenek Kabelac
6dae237303 dmeventd: fifo init and close cleanup
Use structure initialization for easier to read code.
Close only descriptors >= 0.
2013-11-28 12:43:14 +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
879ea38c53 dmeventd: drop duplicated code
Do not call pthread_attr_init() twice.
The second call has all proper tests.
2013-11-22 21:00:55 +01:00
Zdenek Kabelac
6fa95d17ee dmeventd: move format text to printf
Instead of passing argument with format string to printf(),
put the string as arg directly.
Also move there remains args to make the code shorter.
2013-11-22 21:00:51 +01:00
Alasdair G Kergon
527db4645f gcc: replace #ifdef linux with __linux__ 2013-11-13 13:56:29 +00:00
Jonathan Brassow
7de533ad12 mirror: Handle failures in tmp mirror used when up-converting.
Failures in the temporary mirror used when up-converting cause dmeventd
to issue 'lvconvert --repair' on the sub-LV, <lv_name>_mimagetmp_?.  The
'lvconvert' command refuses to deal with this sub-LV outright - it
expects to be given the name of the top-level LV.  So, just like we do
with mirrored logs, we strip-off the portion of the name that is not
the top-level LV and issue the command on the top-level LV instead.
2013-11-08 09:52:00 -06:00
Peter Rajnoha
b6b5299d1e corosync: fix some gcc warnings
warning: function declaration isn't a prototype [-Wstrict-prototypes]
warning: old-style function definition [-Wold-style-definition]
2013-11-06 14:55:18 +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
David Teigland
4c0db84948 clvmd: fix verify message rejection of REMOTE flag
This fixes a bug in commit 19baf842 where verify_message
was rejecting the CLVMD_FLAG_REMOTE flag.  It was missed
since the patch was ported from an lvm version where that
flag does not exist.
2013-10-24 11:18:22 -05:00
Peter Rajnoha
039bdad732 activation: flag temporary LVs internally
Add LV_TEMPORARY flag for LVs with limited existence during command
execution. Such LVs are temporary in way that they need to be activated,
some action done and then removed immediately. Such LVs are just like
any normal LV - the only difference is that they are removed during
LVM command execution. This is also the case for LVs representing
future pool metadata spare LVs which we need to initialize by using
the usual LV before they are declared as pool metadata spare.

We can optimize some other parts like udev to do a better job if
it knows that the LV is temporary and any processing on it is just
useless.

This flag is orthogonal to LV_NOSCAN flag introduced recently
as LV_NOSCAN flag is primarily used to mark an LV for the scanning
to be avoided before the zeroing of the device happens. The LV_TEMPORARY
flag makes a difference between a full-fledged LV visible in the system
and the LV just used as a temporary overlay for some action that needs to
be done on underlying PVs.

For example: lvcreate --thinpool POOL --zero n -L 1G vg

- first, the usual LV is created to do a clean up for pool metadata
  spare. The LV is activated, zeroed, deactivated.

- between "activated" and "zeroed" stage, the LV_NOSCAN flag is used
  to avoid any scanning in udev

- betwen "zeroed" and "deactivated" stage, we need to avoid the WATCH
  udev rule, but since the LV is just a usual LV, we can't make a
  difference. The LV_TEMPORARY internal LV flag helps here. If we
  create the LV with this flag, the DM_UDEV_DISABLE_DISK_RULES
  and DM_UDEV_DISABLE_OTHER_RULES flag are set (just like as it is
  with "invisible" and non-top-level LVs) - udev is directed to
  skip WATCH rule use.

- if the LV_TEMPORARY flag was not used, there would normally be
  a WATCH event generated once the LV is closed after "zeroed"
  stage. This will make problems with immediated deactivation that
  follows.
2013-10-23 14:09:37 +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
Peter Rajnoha
ce7489ed22 activation: add support for flagging an LV to skip udev scanning during activation
A common scenario is during new LV creation when we need to wipe the
newly created LV and avoid any udev scanning before this stage otherwise
it could cause the device (the LV) to be claimed by some other subsystem
for which there were stale metadata within LV data.

This patch adds possibility to mark the LV we're just about to wipe with
a flag that gets passed to udev via DM_COOKIE as a subsystem specific
flag - DM_SUBSYSTEM_UDEV_FLAG0 (in this case the subsystem is "LVM")
so LVM udev rules will take care of handling that.
2013-10-08 13:43:14 +02:00
Petr Rockai
0d03503a45 lvmetad: Fix vgname->vgid hash updates w/ duplicate VG names. 2013-10-04 14:31:45 +02:00
Christine Caulfield
431eda63cc clvmd: Fix node up/down handing in corosync module
The corosync cluster interface for clvmd did not correctly
deal with node up/down events so that when a node was removed
from the cluster clvmd would prevent remote operations
from happening, as it thought the node was up but not
running clvmd.

This patch fixes that code by simplifying the case to node
being  up or down - which was the original intention
and is supported by pacemaker and CPG in the higher layers.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2013-09-23 13:23:00 +01:00
Zdenek Kabelac
a94e28ae01 dmeventd: simplify fifos init
Simplier code.
2013-09-23 11:35:15 +02:00
Petr Rockai
25bed99681 clvmd: Avoid a 3-way deadlock in dead-client cleanup. 2013-09-18 21:17:48 +02:00
Zdenek Kabelac
4dc1668467 tests: singlenode cleanup for prev commit
Add few more comments and cleanup some warnings.
2013-09-12 11:29:18 +02:00
Zdenek Kabelac
2a6abcb80a tests: singlenode updates
Add more 'realistic' simulation of dlm locking.
Previous version was not capable to maintain multiple locks.
Current version doesn't handle multiqueues for locks,
so the ordering is different.
2013-09-12 10:40:39 +02:00
Zdenek Kabelac
7b5f2e7f34 clvmd: add missing debug newline
Just missing new line.
2013-09-12 10:38:49 +02:00
Jonathan Brassow
f0be9ac904 cmirrord: Prevent secondary checkpoints from corrupting bitmaps
The bug addressed by this patch manifested itself during testing
by showing a mirror that never became 'in-sync' after creation.
The bug is isolated to distributions that do not have support
for openAIS checkpointing (i.e. > RHEL6, > F16).

When a node joins a group that is managing a mirror log, the other
machines in the group send it a checkpoint representing the current
state of the bitmap.  More than one machine can send a checkpoint,
but only the initial one should be imported.  Once the bitmap state
has been imported from the initial checkpoint, operations (such
as resync, mark, and clear operations) can begin.  When subsequent
checkpoints are allowed to be imported, it has the effect of erasing
all the log operations between the initial checkpoint and the ones
that follow.

When cmirrord was updated to handle the absence of openAIS
checkpointing (commit 62e38da133),
the new import_checkpoint() function failed to honor the 'no_read'
parameter.  This parameter was designed to avoid reading all but
the initial checkpoint.  Honoring this parameter has solved the
issue of corrupting bitmap data with secondary checkpoints.
2013-08-20 13:21:09 -05:00
Peter Rajnoha
0563bd0037 fix: some issues reported by coverity
- null_fd resource leak on error path in _reopen_fd_null fn
  - dead code in verify_message in clvmd code
  - dead code in _init_filter_components in toolcontext code
  - null dereference in dm_prepare_selinux_context on error path if
    setfscreatecon fails while resetting SELinux context
2013-08-15 12:23:49 +02:00
Zdenek Kabelac
003f08c164 clogd: fix descriptor leak when daemonzing 2013-08-06 16:21:51 +02:00
Zdenek Kabelac
7b1315411f clmvd: fix decriptor leak on restart
Do not leave descriptor used for dup2() openned.
2013-08-06 16:20:36 +02:00
David Teigland
19baf84290 clvmd: verify messages before processing
Check that fields in clvm_header are valid when
local or remote messages are received.  If not,
log an error, dump the message data and ignore
the message.
2013-08-02 09:55:54 -05:00
Jonathan Brassow
5ca54c4f0b dmeventd: Fix memory leak
When creating a timeout thread for snapshots, the thread is not
tracked and thus never joined.  This means that the exit status
of the timeout thread is held indefinitely.  Saves a bit of
memory to set PTHREAD_CREATE_DETACHED when creating this thread.

I've also added pthread_attr_init|destroy to setup the creation
pthread_attr_t.

Reported-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2013-07-31 15:23:13 -05:00
Alasdair G Kergon
7c6526aae2 lvresize: separate validation from action
Start separating the validation from the action in the basic lvresize
code moved to the library.
Remove incorrect use of command line error codes from lvresize library
functions.  Move errors.h to tools directory to reinforce this,
exporting public versions of the error codes in lvm2cmd.h for dmeventd
plugins to use.
2013-07-06 03:28:21 +01:00
Peter Rajnoha
8769033e07 toolcontext: add a few comments for struct cmd_context and rename config_valid -> config_initialized
Just to make it more clear and also not to confuse
config_valid with check against config definition
(and its 'valid' flag within the config defintion tree).
2013-07-02 15:22:11 +02:00
Peter Rajnoha
50bf2c0db1 config: add profile arg to find_config_tree_int 2013-07-02 15:19:09 +02:00
Peter Rajnoha
06dd66af54 config: add profile arg to find_config_tree_str 2013-07-02 15:19:09 +02:00
Zdenek Kabelac
47419d21ac cleanup: stack usage
Shortening code with macros return_0, return_NULL.
Add some missing stack prints in error paths.
2013-07-01 23:11:14 +02:00
Zdenek Kabelac
2fb116e71e cleanup: more dmeventd code cleanup 2013-07-01 23:06:41 +02:00
Zdenek Kabelac
fd399d52a9 dmeventd: move code from signal handler
Instead of calling syslog() from signal event handler,
run all logging code in the main loop.

Also it needs to take the lock and check for list
only when really needed.
2013-07-01 23:06:11 +02:00
Zdenek Kabelac
9233e6d0bb dmeventd: fix cleanup commit
Fixing wrong rebase of cleanup commit.
Put back call to outth.
2013-06-25 23:05:06 +02:00
Zdenek Kabelac
01174b8b8b cleanup: reformat code of dmeventd 2013-06-25 13:47:39 +02:00
Zdenek Kabelac
5e19410d93 cleanup: use simplier structure initialization
And also use static struct for _out_spec.
2013-06-16 00:07:33 +02:00
Zdenek Kabelac
636c51ae3f cleanup: use unrelated temporary variables
use of tmp_rq2 is unrelated to tmp_rq - so use separate
variable.
2013-06-16 00:07:33 +02:00
Alasdair G Kergon
c2dc21d89f text: miscellaneous comments & message tweaks 2013-06-15 01:28:54 +01:00
Petr Rockai
7d644443e0 activation: Pass both ondisk and incore LV to suspend. 2013-06-10 17:26:38 +02:00
Petr Rockai
f65dd341a5 locking: Make it possible to pass down an LV to activation code.
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.
2013-06-10 17:26:38 +02:00
Zdenek Kabelac
55f42944bd dmeventd: revert back percent to int
int is perfectly ok here.
2013-05-30 16:46:58 +02:00
Peter Rajnoha
6ad17fd712 dmeventd: always return success on dmevetnd -V 2013-05-29 12:54:42 +02:00
Zdenek Kabelac
e992cb253c dmeventd: use dm_get_status_snapshot()
Switch to use libdm dm_get_status_snapshot() function for
reading status info.
This fixes bug, where the code was using 32bit integers,
while the snapshot target is able to return 64bit sizes.
However this also means, someone is using >1TB snapshot
cow devices, which is actually very bad idea anyway, since the
perfomance and memory usage in this case is very bad.
2013-05-27 10:33:06 +02:00
Zdenek Kabelac
810bc4f8c1 dmeventd: use dm_mountinfo_read
Reuse mountinfo reading code from libdm.
2013-05-20 16:47:33 +02:00
Alasdair G Kergon
2fbe1e6e00 rephrasing: miscellaneous changes
Miscellaneous changes to messages, man pages, comments and WHATS_NEW.
2013-05-15 01:50:42 +01:00
Zdenek Kabelac
a5ad1ee858 dmeventd: return error if device is not found
Do not return 'ok' status if we have failed to found device.
(Since it looks like the device is monitored)
2013-04-25 17:33:24 +02:00
Zdenek Kabelac
d51b7e5404 clvmd: avoid pretesting of dev availability
Patch fixes hidden problem with lvm metadata caching.

When the pretest was made, only the commited data have been cached back
since the call lv_info_by_lvid() triggers mda read operation.
However call of lv_suspend_if_active() also reads precommited metadata.
The problem is visible in this sequence of calls:

vg_write(), suspend_lv(), vg_commit(), resume_lv()

which may end with leaving outdated mda in lvm cache, since vg_write()
drops cached metadata and vg_commit() only transforms precommited
to commited metadata, but in the case of pretesting we have
no precommited mda available so the cache will continue to use
old metadata. This happens, when suspend LV is inactive.
2013-04-25 17:33:22 +02:00
Zdenek Kabelac
994c32272e test: singlenode minor cleanups
Move unnecessary code out of locks.
2013-04-21 23:15:07 +02:00
Zdenek Kabelac
9cdcde494f cleanup: drop unwanted ';' 2013-04-21 23:15:07 +02:00
Zdenek Kabelac
d38af2857f cleanup: cast to len's type
Cleanup different signess gcc warning.
2013-04-21 23:14:05 +02:00
Zdenek Kabelac
a2b76a6f02 thin: fix resource leak in err path
If the devices list could not have been obtained, FILE* was leaked.
2013-04-21 23:10:30 +02:00
Zdenek Kabelac
377e06b0f8 lvmetad: cleanup
Move individual assignments to simplier structure setup.
2013-04-21 23:02:43 +02:00
Zdenek Kabelac
bee3f4b930 dmeventd: cleanup
Drop unneeded reset of data pointer to NULL, since this if() code path
is executed when data is NULL.
2013-04-21 23:02:43 +02:00
Zdenek Kabelac
8184a57c2b dmeventd: prevent double free
Since device.name is relased on more places, mark already
released name with NULL.
2013-04-21 23:02:36 +02:00
Zdenek Kabelac
5ea466673a dmeventd: convert union to struct members
Sharing char* with field has a problem in error path,
when we allocate event, but fail to allocate timeout string.
Instead of creating complicated error paths to resolve
it individually stop using unions, and let the resource
to be released in a simple _free_message().
2013-04-21 23:01:35 +02:00
Zdenek Kabelac
45f396f2a0 dmeventd: check for msg.data nonnull
Ensure we will not use  msg.data as NULL for strchr.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
5070ffbca7 clvmd: avoid logging in signal handler
debuglog in the main thread.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
61d0ae7019 clvmd: use pclose
For popened FILE use pclose.
2013-04-21 22:56:59 +02:00
Zdenek Kabelac
0125518d6d clvmd: preserve foreground mode across restart
Keep clvmd in foreground when restarted.
Useful for testing.
2013-04-21 22:56:48 +02:00
Zdenek Kabelac
c9d8d22224 clmvd: fix responce status
Failing status code is expected to be 0.
Also do not return '*response' as pointer which has been already free().
2013-04-21 22:54:42 +02:00
Petr Rockai
95372a852b lvmetad: Fix a memory leak introduced in 15fdd5c90d. 2013-04-03 13:46:12 +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
Zdenek Kabelac
d3b8f270ea headers: add headers for musl libc
On glibc, those are erroneously (namespace pollution) pulled in via
other headers. this doesn't work with conformant libcs (musl libc in
this case), we simply need to include all needed headers.

Signed-Off-By: John Spencer <maillist-lvm@barfooze.de>
2013-02-05 14:27:25 +01:00
Zdenek Kabelac
8bcc1da2f3 locales: use higher prio LC_ALL variable
For reseting locale environment into significantly less memory
consuming version 'C' - use LC_ALL instead of LANG since it has
higher priority in locale settings.

Otherwise we may observe whole locale-archive which might be
over 100MB on i.e. Fedora systems locked in memory with
some daemons.
2013-01-22 11:25:02 +01: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
Peter Rajnoha
6fc596ca90 dmeventd: close dmeventd FIFO FDs on exec (add FD_CLOEXEC). 2013-01-15 14:59:54 +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
6f9e26f5c0 thin: dmeventd fix memleak on error path
Some error paths on _umount have leaked bitset.
2012-12-15 17:23:27 +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
a266154e1f cleanup: singlenode minor change
Use strcpy instead of sprintf for plain string.
And use dm_strncpy for safer strncpy.

TODO: Fix API return values for cluster functions.
2012-12-15 14:57:40 +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
Zdenek Kabelac
1d774e5667 cleanup: drop test for optarg NULL
Since -d takes an argument, we do not need to check for
optarg being NULL here.
2012-12-15 14:57:40 +01:00
Zdenek Kabelac
13fe333b54 clvmd: fix parsing of -d argument
clvmd -d option parsing was not working properly.

clvmd -d 2   (with space) has been ignored because of
'::' used in getopt string, and as failsafe it's been used '1'.

Later this debug_arg has been ignored and debug_opt was used
instead which happend to have value '1'.

Submitted-by: Robert Milasan <rmilasan at suse.com>
Reported-by: Robert Milasan  <rmilasan at suse.com>
2012-10-19 15:35:56 +02: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
3972bd98fb thin: add support to unmount volumes
Reset counter after thin pool resize failure.

If the pool goes above threshold, support unmounting
of all thin volumes if the lvextend fails to avoid
overfilling of the pool.
2012-10-14 23:19:20 +02: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
Petr Rockai
a63b46bf36 lvmetad: Implement a "dump" request to capture lvmetad state. 2012-10-11 20:31:29 +02:00
Petr Rockai
b07df8850a libdaemon: Make buffer handling asymptotically more efficient. 2012-10-11 18:09:41 +02:00
Petr Rockai
2ba9fb4019 lvmetad: Fix help output (flags and their meaning). 2012-10-10 21:55:24 +02:00
Petr Rockai
622fb968a2 lvmetad: Fix the -f pidfile (non-)creation logic. 2012-10-10 13:53:21 +02:00
Petr Rockai
1997149263 lvmetad: Only create pidfile when running as a daemon (no -f).
Additionally, -f now makes -s mandatory, so the foreground (debugging) lvmetad
does not steal the system-wide socket accidentally.
2012-10-09 20:37:34 +02:00
Petr Rockai
06243be91b lvmetad: Fix a leak on duplicated PVs (same PVID, different device). 2012-10-09 01:38:58 +02:00
Petr Rockai
665b6b308e lvmetad: Fix a leak in an error path in update_metadata. 2012-10-08 23:52:44 +02:00
Petr Rockai
138b4e1719 lvmetad: Fix a typo-induced leak in destroy_metadata_hashes. 2012-10-08 20:35:29 +02:00
Petr Rockai
6e312c56ad lvmetad: Avoid overlapping locks that could cause a deadlock (BZ 862253). 2012-10-08 09:12:51 +02:00
Petr Rockai
662a2122f6 libdaemon: Split daemon-shared.[hc] into daemon-io.[hc] and config-util.[hc]. 2012-09-26 17:26:23 +02:00
Petr Rockai
9f96286c29 lvmetad: Initialise debug_config also if no -d is given. 2012-09-26 17:26:23 +02:00
Petr Rockai
1ff2245c23 lvmetad: Give inconsistent metadata warnings in pvscan --cache. 2012-09-26 17:26:23 +02:00
Petr Rockai
d2d6663428 lvmetad: Clear metadata/PV cache before a token-triggered rescan. 2012-09-26 17:26:23 +02:00
Petr Rockai
c7b17836ea Implement devices/global_filter.
The global filter is applied first, and is also applied in pvscan --cache (which
is called from udev rules to keep lvmetad updated). Cf. example.conf.
2012-09-26 14:49:15 +02:00
Petr Rockai
ea14d5159c libdaemon: Extend and refactor APIs.
- move common dm_config_tree manipulation functions from lvmetad-core to
  daemon-shared
- add config-tree-based request manipulation APIs to daemon-client
- factor out _v (va_list) variants of most variadic functions in libdaemon
2012-09-26 14:49:09 +02:00
Peter Rajnoha
847e2856a2 config: require dm_config_create_value for dm_config_node's value
If we were defining a section (which is a node without a value) and
the value was created automatically on dm_config_create_node call,
we were wasting resources as the next step after creating the config
node itself was assigning NULL for the node's value.

The dm_config_node_create + dm_config_create_value sequence should be
used instead for settings and dm_config_node_create alone for sections.

The majority of the code already used the correct sequence. Though
with dm_config_node_create fn creating the value as well, the pool
memory was being trashed this way.

This patch removes the node value initialization on dm_config_create_node
fn call and keeps it for the direct dm_config_create_value fn call.
2012-08-27 14:33:54 +02:00
Zdenek Kabelac
c6f680ee49 clvmd,lvmetad: check for fcntl result
Report any problem of fcntl.
2012-08-23 14:38:48 +02:00
Zdenek Kabelac
15891d366d cleanup: add error message and simplify creation
Report error for malloc failure, and use zeroed allocation
to initialize handler structure.
2012-08-23 14:37:38 +02:00
Zdenek Kabelac
286cd2006b cleanup: drop unneeded included header files
This headers were not resolving anything used for compiled .c files.
Remove unused util.c file.
2012-08-23 14:37:20 +02:00
Zdenek Kabelac
6d0abc6b48 cmirrord: check for result of chdir
Error exit if chdir fails.
2012-08-23 14:37:20 +02:00
Zdenek Kabelac
59ca324c35 clvmd: release excl_uuid hash
Release allocated hash before exit.
2012-08-23 14:34:56 +02:00
Petr Rockai
b61be64370 libdaemon: Draft logging infrastructure.
- logging is not controlled by "levels" but by "types"; types are
  independent of each other... implementation of the usual "log level"
  user-level semantics can be simply done on top; the immediate
  application is enabling/disabling wire traffic logging independently
  of other debug data, since the former is rather bulky and can easily
  obscure almost everything else
- all logs go to "outlets", of which we currently have 2: syslog and
  stderr; which "types" go to which "outlets" is entirely configurable
2012-08-08 09:44:19 +02:00
Petr Rockai
8791d01fee lvmetad: Fix an obscure error message. 2012-07-31 11:43:35 +02:00
Peter Rajnoha
9a96f930a7 configure: run directory configuration cleanup
There were several hard-coded values for run directory around the code.
Also, some tools are DM specific only, others are LVM specific and there
was no distinction made here before. With this patch applied, we have
this cleaned up a bit (subsystem in brackets, defaults in parentheses):

          [common] configurable PID_DIR     (/var/run)

 lvm      [lvm]    configurable RUN_DIR     (/var/run/lvm)
                   configurable locking dir (/var/lock/lvm)

 clvmd    [lvm]    configurable pid file    (PID_DIR/clvmd.pid)
                   socket                   (RUN_DIR/clvmd.sock)

 lvmetad  [lvm]    configurable pid file    (PID_DIR/lvmetad.pid)
                   socket                   (RUN_DIR/lvmetad.socket)

 dm       [dm]     configurable DM_RUN_DIR  (/var/run)

 cmirrord [dm]     configurable pid file    (PID_DIR/cmirrord.pid)

 dmeventd [dm]     configurable pid file    (PID_DIR/dmeventd.pid)
                   server fifo              (DM_RUN_DIR/dmeventd-server)
                   client fifo              (DM_RUN_DIR/dmeventd-client)

The changes briefly:
  - added configure --with-default-pid-dir
  - added configure --with-default-dm-run-dir
  - added configure --with-lvmetad-pidfile
  - by default, using one common pid directory for everything
    (only lvmetad was not following this before)
2012-06-27 12:11:47 +02:00
Zdenek Kabelac
6f3cd63551 cleanup: replace memset with struct initilization
Simplifies the code, properly detects too long socket paths,
drops unused parameter.
2012-06-22 13:23:03 +02:00
Zdenek Kabelac
461eb1ac6a cmirrord: add missing checks for kernel_send
Log errors if kernel_send fails.
2012-06-20 14:48:26 +02:00
Zdenek Kabelac
865b9d3701 cmirrord: fix cut&paste 2012-06-20 14:41:57 +02:00
Zdenek Kabelac
fb4584b83d cmirrord: add test for closedir() and close() 2012-06-20 14:40:39 +02:00
Alasdair G Kergon
9f01f1453c dmeventd: Improve comment about repeated DIE msgs 2012-06-08 21:52:02 +01:00
Jonathan Earl Brassow
e5b9338ada Fix bug in cmirror that caused incorrect status info to print on some nodes.
Looking at the code in cmirrord/local.c, we can see the various different
request types handled in different ways.  Some information that is non-changing
does not need to go around the cluster and can be short-circuited.  For
example, once the cluster mirror is in-sync, it is pointless to continue
sending that query around the cluster.  We can save network bandwidth and reply
directly back to the kernel.  When it comes to status information, there are
two types 'TABLE' and 'INFO'.  The 'TABLE' information never changes and
belongs to the group of requests that can be safely short-circuited.  The
'STATUS' information can change - and will change if a device fails.  Thus it
cannot be short-circuited, but this is exactly what was found.  The 'STATUS'
information request was being short-circuited and therefore never reporting the
failure condition to anyone other than the "server" that experienced it
directly.
2012-04-26 17:30:49 +00:00
Zdenek Kabelac
d6f894edf8 Synchronize with self-destruction of dmeventd
In some occasional case dmevent restart was experiencing problems
with obtaining pid lockfile. So this patch tries to send several more kill
message until daemon kills itself so there is would reponse.
With this small loop the restart seems to work reliable,
although the loopsize and usleep are just randomly picked for now.
2012-04-24 12:25:12 +00:00
Zdenek Kabelac
8262a3f6ca Update singlenode locking
Support lock conversion
Work also with LCK_READ
TODO: do more validation.
2012-04-24 12:16:40 +00:00
Jonathan Earl Brassow
bad8b5848f Commit ID 46a75dedb4 consolidated code from the
various dmeventd plug-ins into a new function called 'dmeventd_lvm2_command',
but the new function did not strip off the "_mlog" extentions that the
mirror plug-in had been doing.  This created bug 794904 - failure to replace
devices in a redundant log.

The test suite did catch this scenario because it performs repair tests (mainly)
through the CLI and not dmeventd.  It's also not easy to test because the test
itself will hang if the bug is encountered.
2012-04-10 23:34:41 +00:00
Milan Broz
61a1effcf1 Avoid closing clvmd socket twice. 2012-03-27 16:59:28 +00:00
Zdenek Kabelac
2dba563206 Add fixmes
There is missing some proper reaction when update fails ?
2012-03-23 10:34:51 +00:00
Zdenek Kabelac
0fc9a3dce3 Always free hash table
also in error path
2012-03-23 10:33:26 +00:00
Zdenek Kabelac
5da4d94adc Return mem fail if hash insert fails 2012-03-23 09:48:17 +00:00
Zdenek Kabelac
4ea8533f30 Make sure namelen fits into buffer allocated on stack 2012-03-23 09:43:44 +00:00
Zdenek Kabelac
467f454c09 Update debug message
(compiled only with special debug define)
2012-03-23 09:39:59 +00:00
Zdenek Kabelac
516b79299a Fix check for passed in path for dmeventd startup
Check passed in executable path for dmeventd instead of predefined
compiled in path which is not the thing to be executed.
2012-03-20 17:38:47 +00:00
Peter Rajnoha
08e846e3d9 Remove dmeventd fifos on exit if they are not managed by systemd. 2012-03-15 08:45:55 +00:00
Peter Rajnoha
93945bb616 Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
LISTEN_PID and LISTEN_FDS environment variables are defined only during systemd
"start" action. But we still need to know whether we're activated during
"reload" action as well - we use the reload action to call "dmeventd -R"/"lvmetad -R"
for statefull daemon restart. We can't use normal "restart" as that is simply
composed of "stop" and "start" and we would lose any state the daemon has.
2012-03-14 15:51:51 +00:00
Peter Rajnoha
c02af0773f Do not run a new dmeventd instance on restart if there's no existing one. 2012-03-14 11:16:00 +00:00
Zdenek Kabelac
65cfc5d16d We need longer window for checking read from fifo.
Seems like some dmeventd startups are taking more time then expected,
so make the time window longer here.
2012-03-12 14:46:53 +00:00