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

877 Commits

Author SHA1 Message Date
Zdenek Kabelac
a6292f2a6d Remove unneeded assignments
Variables have (or will have) those values set.
2012-02-08 11:36:18 +00:00
Zdenek Kabelac
3a8b6a9948 Keep page_size as signed number
Since it's return value from sysconf and is checked for <0.
2012-02-08 11:34:46 +00:00
Zdenek Kabelac
b63b775143 Add boundary test for number of mirror devs and logs
As atoi may return negative value - test for both limits.
Test log_args for limits before calling alloca().
Code from dmeventd mirror plugin should probably share same code as
we have in mirrored.c.
2012-02-08 11:29:13 +00:00
Petr Rockai
cd466297f4 Remove a dubious log message ("another thread is handling an event") from LVM
dmeventd plugins. Fixes RHBZ 771419.
2012-02-01 20:11:58 +00:00
Alasdair Kergon
b6d7a48480 Automatically detect whether corosync clvmd needs to use confdb or cmap. (fabio) 2012-01-31 21:21:53 +00:00
Zdenek Kabelac
eb2dd721ab Oops missed braces in previous commit
This has disabled clvmd for being executed.
(FIXME improve testing part to catch this fault)
2012-01-26 17:55:55 +00:00
Zdenek Kabelac
4125cf5067 Fix leak of hash table
Minor leak on command initialization.
2012-01-25 22:36:33 +00:00
Zdenek Kabelac
254944d890 Set to a defined value vars used after error path
Static analyzer noticed this vars are used even when error is reported
back thus their state is undefined - set to 0 for this case.
2012-01-25 22:20:11 +00:00
Zdenek Kabelac
b45035ee14 Test for uname result
in fail path initialize to 0.
2012-01-25 22:17:57 +00:00
Zdenek Kabelac
d85050930b Add breaks for cases 2012-01-25 21:42:09 +00:00
Zdenek Kabelac
5f3191097d Ensure reply struct has all fields defined
Reply is returned by value.
2012-01-25 21:31:59 +00:00
Zdenek Kabelac
6e2761e928 Check and print perror for syscalls 2012-01-25 21:30:27 +00:00
Zdenek Kabelac
a16915cb0b Clean var declarations to the front of the function 2012-01-25 13:06:57 +00:00
Alasdair Kergon
cab1c8ade1 Add CLVMD_FLAG_REMOTE to skip processing on local node. 2012-01-21 05:31:54 +00:00
Zdenek Kabelac
d4016dd4d0 Thin forgotten initialisation of pointer to NULL
Since the code may go in error path, set to defined NULL.
2012-01-20 10:59:26 +00:00
Jonathan Earl Brassow
25d1410592 Preserve exclusive activation of cluster mirror when converting.
This patch to the suspend code - like the similar change for resume -
queries the lock mode of a cluster volume and records whether it is active
exclusively.  This is necessary for suspend due to the possibility of
preloading targets.  Failure to check to exclusivity causes the cluster target
of an exclusively activated mirror to be used when converting - rather than
the single machine target.
2012-01-20 00:27:18 +00:00
Zdenek Kabelac
80b21b0b50 Drop unused variable 2012-01-19 15:59:51 +00:00
Zdenek Kabelac
5fd459f0ab Thin use consistentely metadata
Do not shortcut to 'meta' and stay with 'metadata'
Also matches kernel doc for dm API then.
2012-01-19 15:21:23 +00:00
Petr Rockai
cf1b05e7dd Beef up the lvmetad code with more functionality and a bunch of bugfixes. There
used to be a few mis-ordered memory accesses (release and access in the next
block). Fix that set_flag could have sometimes corrupted the flags being
modified.

A few issues with metadata tracking are sorted out as well now, and there are
only a few problems remaining before we can integrate lvmetad, mostly on the
client side:

- metadata areas need to be tracked in lvmetad (most likely to be addressed
  through an extension of metadata, meaning no special support in lvmetad would
  be needed)
- non-udev scanning code needs to be taught about telling lvmetad about device
  disappearance (pvscan most importantly)
- this last item also needs to mesh with metadata inconsistencies and
  suddenly-incomplete volume groups (aux disable_dev in tests); udev-based
  scanning should address this separately and more elegantly
2012-01-16 08:25:32 +00:00
Petr Rockai
3556560b38 Fix a boundary condition in read_buffer in daemon-shared.c. 2012-01-16 05:09:16 +00:00
Petr Rockai
d528658f97 Fix prototypes for daemon_send_simple (const char). 2012-01-15 15:16:50 +00:00
Petr Rockai
f43c89bf71 Unfortunately, blank lines are sometimes produced by config serializer, and
this interferes with their role as message separator in the lvmetad
protocol. Switch to using "##" on an otherwise blank line as a separator.
2012-01-15 11:17:16 +00:00
Petr Rockai
d540685159 Fix a couple of resource leaks in daemon-common server code -- filehandles and
unjoined threads were leaked for each connection.
2012-01-15 10:33:41 +00:00
Zdenek Kabelac
1aae627433 Use new dmeventd_lvm2_command function in dmeventd plugins.
For snapshot, prepare whole command in front into private buffer.
Add also some missing '\n' for syslog messages.
For raid and mirror only convert creation of command line string.
This should avoid any unbound growth of mempool for dm_split_names.
2011-12-22 16:37:01 +00:00
Zdenek Kabelac
ed1289140e Thin use helper function
Fix some minor outstading issue from thin plugin introduction -
Call dmeventd_lvm2_exit() in failpath for registration.
Add some missing '\n' in syslog messages.
2011-12-22 15:57:29 +00:00
Zdenek Kabelac
8527b92738 Add helper function dmeventd_lvm2_command().
Since this code is in all plugins - create a common helper function.
2011-12-22 15:55:21 +00:00
Zdenek Kabelac
59e1bb62de Updated documentation for dmeventd.
Update man page style.
Mention raid and thin plugins.
Update help text printed by command to match man page.
2011-12-22 15:50:38 +00:00
Zdenek Kabelac
351bf47486 Exported functions from thin plugin 2011-12-21 13:42:07 +00:00
Zdenek Kabelac
2bc1d7598e Thin add dmeventd support
This is basic version with still few unresolved issue mainly in case,
when the pool resize is failing.
2011-12-21 13:08:11 +00:00
Zdenek Kabelac
169470b621 Fix missing thread list manipulation
For manipulation with thread list to avoid race with timeout thread,
take also _timeout_mutex.
2011-12-21 13:03:06 +00:00
Petr Rockai
f401655ee8 Fix up lvmetad for the minor API change in dm_config_create. 2011-12-18 22:31:10 +00:00
Alasdair Kergon
594753751a Only use built-in stack size in clvmd - ignore lvm.conf. 2011-12-08 21:24:08 +00:00
Alasdair Kergon
585aaa922f Test for LCK_CLUSTER_VG directly in args[0].
Drop unused LCK_LOCAL from debug msg.
2011-12-08 18:32:33 +00:00
Jonathan Earl Brassow
d098140177 Add policy based automated repair of RAID logical volumes
The RAID plug-in for dmeventd now calls 'lvconvert --repair' to address failures
of devices in a RAID logical volume.  The action taken can be either to "warn"
or "allocate" a new device from any spares that may be available in the
volume group.  The action is designated by setting 'raid_fault_policy' in
lvm.conf - the default being "warn".
2011-12-06 19:30:15 +00:00
Petr Rockai
9a4b04139d Fix clvmd to respect DMEVENTD_MONITOR_IGNORE. Fixes a bug where dmeventd
actions caused clvmd to turn off monitoring of the volume causing the action.
2011-11-30 17:00:57 +00:00
Petr Rockai
58ea7af08c Fix a bug in dmeventd snapshot monitoring code where the monitoring threshold
would grow with subsequent snapshot extensions (RHBZ 754198).
2011-11-21 12:31:18 +00:00
Alasdair Kergon
bf09a32006 Make dmsetup.static and lvm.static build when dmeventd is disabled.
udev may also need to be disabled if you didn't build it statically too.

dmeventd.static could be fixed with some more work but I don't really see the
point: without dlopen() it's useless, and if you have dlopen(), why not support
normal shared libraries too?
2011-11-14 21:30:35 +00:00
Petr Rockai
44190723a8 Correctly handle concurrent read (CR) locks in singlenode clvmd. This means
that we can also test clustered volume groups (vgcreate -c y) in the test
suite. Unfortunately we can't make this the testing default since cluster
mirrors require further infrastructure, and snapshots probably don't work at
all. I'll eventually add a few test cases that create clustered VGs
specifically.
2011-11-07 17:11:23 +00:00
Zdenek Kabelac
ade2b9345f Cleanup for lvmetad passing uninit structure
Shown by clang analyzer.
2011-10-30 21:58:59 +00:00
Petr Rockai
6825ae1e28 Remove a redundant (and in some cases, misleading) message about snapshot
extension, in the snapshot dmeventd plugin. The reporting is done as needed by
the LVM command nowadays.
2011-10-19 14:31:49 +00:00
Petr Rockai
61cf772e70 Keep the LVM-based dmeventd plugins from trying to manipulate the dmeventd
monitoring state of the logical volumes they are currently acting on.

Until now, every time a logical volume has been changed by a dmeventd plugin,
this plugin would have called back to dmeventd through the external FIFO
mechanism. I am fairly sure this was superfluous, inefficient and possibly even
dangerous.
2011-10-19 08:46:26 +00:00
Jonathan Earl Brassow
3b032963d5 cmirrord now returns log name to kernel in CTR so it can be registered
Version 2 of the userspace log protocol accepts return information during the
DM_ULOG_CTR exchange.  The return information contains the name of the log
device that is being used (if there is one).  The kernel can then register the
device via 'dm_get_device'.  Amoung other things, this allows for userspace to
assemble a correct dependency tree of devices - critical for LVM handling of
suspend/resume calls.

Also, update dm-log-userspace.h to match the kernel header associated with
this protocol change.  (Includes a version inc.)
2011-10-14 14:18:49 +00:00
Zdenek Kabelac
5ba3b21921 Remove unused variables 2011-10-11 10:06:57 +00:00
Zdenek Kabelac
1ba44957bf Add some fixme locking
Code here is using thread write protected variable without locking.
So add locking, for proper synchronization and a FIXME, since the
code needs closer look.
2011-10-11 09:56:44 +00:00
Zdenek Kabelac
8a706f836d Simplify worker loop
Do not reacquire mutex several times without a real reason.
Code readability is also better.
2011-10-11 09:54:39 +00:00
Zdenek Kabelac
96de8adcc9 Use barrier instead of mutex
Barrier is supposed to be used in situation like this
and replace tricky mutex usage, where mutex has been unlocked
by a different thread than the locking thread.
2011-10-11 09:26:04 +00:00
Zdenek Kabelac
61a45c7b3a Add FIXMEs for init_test
Usage of thread unprotected init_test is not correct and needs probably lvm lock
since it part of lvm library. Current implementation may probably fail with
test mode and actually create something unexpectedly (and vice versa).
2011-10-11 09:23:48 +00:00
Zdenek Kabelac
0448a9265a Limit thread stack
Since default thread stack size is around 8MB and clvmd creates for now thread
for message, clvmd may easily reach multi GB size of in-memory locked pages
(runs with mlockall()).

This patch significantly reduces memory usage to just tens of MB,
and now different reasons are the cause of server overloading.
Now we are running out of free file descriptors mostly.
2011-10-11 09:18:49 +00:00
Zdenek Kabelac
efe62a3411 Use condition instead of sleep
Replace usleep with pthread condition to increase speed testing
(for simplicity just 1 condition for all locks).

Use thread mutex also for unlock resource (so it wakes up awaiting
threads)

Better check some error states and return error in fail case with
unlocked mutex.
2011-10-11 09:05:20 +00:00
Zdenek Kabelac
834d5d70d1 Typo in debug message 2011-09-29 08:57:21 +00:00
Alasdair Kergon
10d0d9c7c4 Introduce revert_lv for better pvmove cleanup.
(One further fix needed to remove the stray pvmove LVs left behind.)
2011-09-27 22:43:40 +00:00
Zdenek Kabelac
7ae124743e Use execvp for clvmd restart
Since execve passed only NULL as environ, we had lost all environment vars on
restart - thus actually running  'different' clvmd then the one at start.

Preserving environ allows to restart clvmd with the same settings
(i.e. LD_LIBRARY_PATH)

Add test for second restart.
2011-09-26 07:51:23 +00:00
Zdenek Kabelac
90d106ef19 Restart CLVMD with same cluster manager
Add named cluster_ops to easily learn the name of the active cluster manager,
so we are able to restart singlenode manager in testing.

Add simple test for clvmd -S  (restart) and -R (refresh)
(though it needs some extensions).
2011-09-25 19:37:00 +00:00
Zdenek Kabelac
9e5486bb65 Drop cleanup of .exported_symbols_generated in DISTCLEAN_TARGETS
Makefile cosmetics - since .exported_symbols_generated in cleardir:
target via make.tmpl, there is no need to set them in DISTCLEAN_TARGETS.
2011-09-24 21:00:52 +00:00
Zdenek Kabelac
13dd31381c Use Makefile for daemmons/common library.
Next iteration for better fit of lvmetad compilation.

Move build of libdaemon.a into common subdir Makefile.
libdaemon.a is device-mapper target.

Build and install lvmetad as lvm2 target.
2011-09-24 20:57:49 +00:00
Zdenek Kabelac
d2c116058e CLVMD support for LVM_CLVMD_BINARY and LVM_BINARY
Read 2 environmental vars to learn about overide position for
CLVMD and LVM binaries.

We support LVM_BINARY in other script - and this way we could easily
test restart in our test-suite.
2011-09-24 20:50:35 +00:00
Zdenek Kabelac
a039e204e7 CLVMD bugfix support for args -S -E
Bugfix:
Add (most probably unfinished) support for -E arg with list of exclusive
locks.  (During clvmd restart all exclusive locks would have been lost and
in fact, if there would have been an exclusive lock, usage text would be
printed and clvmd exits.)

Instead of parsing list options multiple times every time some lock UUID is
checked - put them straight into the hash table - make the code easier to
understand as well.

Remove  was_ex_lock() function (replaced with dm_hash_lookup()).

Swap return value for get_initial_state() (1 means success).

Update man pages and usage info for -E option.
2011-09-24 20:48:34 +00:00
Zdenek Kabelac
f79f7250ce Clvmd restart cleanup
Patch fixes Clang warnings about possible access via lv_name NULL pointer.

Replaces allocation of memory (strdup) with just pointer assignment
(since execve is being called anyway).

Checks for  !*lv_name only when lv_name is defined.
(and as I'm not quite sure what state this really is - putting a FIXME
around - as this rather looks suspicios ??).

Add debug print of passed clvmd args.
2011-09-22 09:47:34 +00:00
Zdenek Kabelac
f1f42ab732 Add all exclusive locks to clvmd restart option args
Fix bug when only every even lock has been passed.

Warning: currently -E causes clvmd to exit with usage text being printed.
2011-09-22 09:45:24 +00:00
Milan Broz
f5d39ec97a Always sent the whole command header in restart/reload clvmd commands.
(Newly added check catch this as invalid packet.)

(N.B. that code is so fragile that it need full rewrite soon:-)
2011-09-21 13:40:46 +00:00
Zdenek Kabelac
d9bba4f16f Check for failing 'stat' and skip this loop iteration
(since data in statbuf are invalid).

Check whether sysconf managed to find _SC_PAGESIZE.

Report at least debug warning about failing unlink
(logging scheme here seems to be a different then in lvm).

Duplicate terminal FDs and use similar code as is made in clvmd
and cleanup warns about missing open/close tests.
FIXME: Looks like we already have 3 instancies of the same code in lvm repo.
2011-09-21 10:42:53 +00:00
Zdenek Kabelac
11dd5cf2aa Few more updates to lvmetad build deps
It seem lvmetad deps must be expressed after the include.
Also adding lvmetad deps to device-mapper target in daemons dir.
2011-09-19 00:29:11 +00:00
Zdenek Kabelac
de154812a9 Build fixes for lvmetad
Should now be giving better build order and install lvmetad.
2011-09-17 14:50:22 +00:00
Zdenek Kabelac
6d40458530 More gcc warnings removed 2011-09-17 14:49:18 +00:00
Zdenek Kabelac
1b8724d866 Fix for gcc compilation warnings
and put _XOPEN_SOURCE so pthread_mutexattr is properly defined.
2011-09-17 13:33:51 +00:00
Milan Broz
63b8ed7c37 Fix clvmd processing of invalid request on local socket. (rommer)
Code now detects small packet and wrong arglen and reply with
error intead of infinite loop.

https://bugzilla.redhat.com/show_bug.cgi?id=738484
2011-09-16 14:40:06 +00:00
Zdenek Kabelac
37341289e6 Keep the old-style function definition 2011-09-14 09:53:32 +00:00
Zdenek Kabelac
e9047f4f9c Detect sscanf recovering_region input error
Missing check for sscanf found by static analyzer.
2011-09-06 18:24:27 +00:00
Zdenek Kabelac
b647de3e07 Fix memory leak of allocated bitmap in error path
Found by static analyzer.
2011-09-06 18:15:43 +00:00
Zdenek Kabelac
7b83071708 Log unlink() error 2011-09-06 18:11:21 +00:00
Zdenek Kabelac
0945b313bf Hack for build rules of lvmetad
FIXME
2011-09-02 14:49:00 +00:00
Zdenek Kabelac
49cd515cd2 Compile fix
Reflecting change in dm_config_value  float r -> float f.
2011-09-02 11:04:12 +00:00
Alasdair Kergon
1ca0eea5bb Only build libdaemon.a when we need it at the moment. 2011-09-01 17:56:53 +00:00
Zdenek Kabelac
08a95743a2 Keep the old-style prototypes 2011-09-01 13:25:50 +00:00
Petr Rockai
e68a6fbf20 Fix warnings and constness handling in lvmetad-core (adjusting the
dm_config_find_node to give non-const node pointer, since that better reflects
the contract of that function).
2011-08-31 12:39:58 +00:00
Petr Rockai
6e4e30827d Fix warnings in daemons/common. 2011-08-31 12:18:40 +00:00
Petr Rockai
d008fc86a0 Get rid of the old lvmetad Makefile. 2011-08-31 11:44:27 +00:00
Petr Rockai
615534d305 A compromise integration of LVMetaD into the build: I have kept all the
daemon/common code in a single libdaemon.a, which is completely private. This
is currently linked into the lvmetad binary, and will be linked into LVM (the
client part, since static linking only picks up only symbols that are actually
used). I have also added --enable/disable-lvmetad to ./configure; although the
current default is off, I expect this to be flipped to on shortly. There's no
LVM-side support yet, but when there is, even when built, it'll still need to
be enabled by an lvm.conf option.
2011-08-31 11:31:57 +00:00
Zdenek Kabelac
316d14d45f Fix resource leak when strdup fails
Static analyzer noticed, strdup failing path leaks dmt structure.
2011-08-31 08:23:05 +00:00
Petr Rockai
04e647aa84 Adapt LVMetaD to use the new dm_config interfaces. 2011-08-30 15:44:01 +00:00
Petr Rockai
c033ea0170 Adapt the daemon/common code to use the new dm_config interface. 2011-08-30 15:42:56 +00:00
Alasdair Kergon
d8b1aa198b more pre-release fixes 2011-08-12 02:16:46 +00:00
Alasdair Kergon
6b2717ae83 Drop CCS* variables no longer used. 2011-08-12 01:52:16 +00:00
Alasdair Kergon
40dbaac892 pre-release fixes incl make distclean and configure --with-raid=none/shared 2011-08-11 19:18:17 +00:00
Milan Broz
fc438d74b7 Never ever use uninitialised descriptors if pipe() fails
(because of maximum open count fd exceeded or so).

Better return busy message, so even clients fail in more controlled way.

Without patch,  clvmd crashes with various strange backtraces
if under heavy load of connection requests.

https://bugzilla.redhat.com/show_bug.cgi?id=698393
https://bugzilla.redhat.com/show_bug.cgi?id=697945

(It still can OOM but that's different issue.)
2011-08-11 12:57:10 +00:00
Jonathan Earl Brassow
3041b72f06 Add dmeventd monitoring for RAID devices. 2011-08-11 05:00:20 +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
Milan Broz
5ddda8cd56 Initialise clvmd locks before lvm context to avoid open descriptor leaks.
(At least /dev/mapper/control is open after lvm context init.)
2011-08-10 11:00:32 +00:00
Milan Broz
7cf607705b Remove obsoleted GULM clvmd cluster locking support. 2011-08-09 18:11:00 +00:00
Zdenek Kabelac
fb2f985dfe Add test for fcntl error in singlenode client code.
Static analyzer noticed this check could be handy.
2011-08-04 12:13:50 +00:00
Peter Rajnoha
3c614ef1c1 Add support for systemd file descriptor handover in dmeventd.
Systemd preloads file descriptors for us and passes them in for
newly spawned daemon when using on-demand fifo (or socket)
based activation.

This patch adds checks for file descriptors preloaded by
systemd and uses them instead of opening the FIFOs again
to properly support on-demand FIFO-based activation.

(We'll change FIFOs to sockets soon - but still this
part of the code will stay almost the same.)
2011-07-28 13:06:50 +00:00
Peter Rajnoha
7d47d109b9 Add support for new oom killer adjustment interface (oom_score_adj).
The filename to adjust the oom score was changed in 2.6.36.
We should use oom_score_adj instead of oom_adj (which is still
there under /proc, but it's scheduled for removal in August 2012).

New oom_score_adj uses a range from -1000 (OOM_SCORE_ADJ_MIN,
disable oom killing) to 1000 (OOM_SCORE_ADJ_MAX).
2011-07-28 13:03:37 +00:00
Petr Rockai
1d9c083fcc lvmetad: Edit the MISSING_PV flags only after making a "reply" copy of the
metadata, which is then serialised and discarded. This fixes a couple of
outstanding TODO items about handling the MISSING flags correctly.
2011-07-25 17:59:50 +00:00
Petr Rockai
059ee25951 lvmetad: Check integrity of multiple metadata copies, i.e. ensure that seqno
equality implies metadata equality. Signal error in response to any update
requests that try to overwrite metadata without providing a higher seqno.
2011-07-25 15:51:51 +00:00
Petr Rockai
9474992482 lvmetad: A couple of TODOs, and fix a few trivial memory leaks. 2011-07-25 15:33:04 +00:00
Petr Rockai
c2ca1a707a lvmetad: Obliterate vg_status by returning the same information from
update_pv_status, saving a dozen lines of code and execution time of one
walkthrough of the PV list.
2011-07-20 21:33:41 +00:00
Petr Rockai
bc0a902434 lvmetad: Fix a possible infinite loop in vg_status. 2011-07-20 21:27:28 +00:00
Petr Rockai
fba6c62b84 lvmetad: Robustify update_pv_status and remove an useless lookup. 2011-07-20 21:26:18 +00:00
Petr Rockai
0cfb99d385 First stab at making lvmetad-core threadsafe. The current design should allow
very reasonable amount of parallel access, although the hash tables may become
a point of contention under heavy loads. Nevertheless, there should be orders
of magnitude less contention on the hash table locks than we currently have on
block device scanning.
2011-07-20 21:23:43 +00:00
Petr Rockai
dcbf5a3b5d lvmetad: Avoid stale PV -> VG mappings on metadata update. 2011-07-20 18:45:32 +00:00
Petr Rockai
cd7bca83e1 Optimise PV -> VG lookups by using a UUID (hash) map. 2011-07-20 18:34:57 +00:00
Petr Rockai
652e0757c9 Free up allocated memory before exiting, in lvmetad. 2011-07-20 18:24:49 +00:00
Petr Rockai
a720420466 Fix two small (but eventually unbounded) leaks in daemon-server.c. 2011-07-20 18:23:33 +00:00
Petr Rockai
42e23dbf6c Can't have a global memory pool in lvmetad (that would constitute an ongoing
memory leak) => remove it (it's been unused anyway).
2011-07-20 16:49:21 +00:00
Petr Rockai
50ff3c076e Make lvmetad also report VGID in reply when adding a PV without MDAs (this
obviously only works for VGs that already had at least some MDA discovered).
2011-07-20 16:46:40 +00:00
Petr Rockai
4eb53158e5 Add code to lvmetad's testclient that scans an actual physical device,
effectively emulating a future "pvscan --lvmetad" command.
2011-07-20 15:15:41 +00:00
Petr Rockai
c33d33bab7 Make lvmetad report the VG ID and status (complete, partial) in reply to pv_add
requests.
2011-07-20 15:14:17 +00:00
Petr Rockai
2ef620ec7f Towards MISSING (PV) flag management in lvmetad. 2011-07-19 19:15:22 +00:00
Petr Rockai
3c238baf03 Work out some more details in metadata update in lvmetad. 2011-07-19 16:48:13 +00:00
Petr Rockai
9796bd4db6 More work on cache maintenance code in lvmetad: keep track of PV status. 2011-07-19 14:13:59 +00:00
Petr Rockai
252853560c Start filling in the core LVMetaD functionality and the corresponding
testclient bits.
2011-07-18 14:48:30 +00:00
Petr Rockai
372e9b3d64 Various improvements to the daemon-common code, including automated response
formatting from config trees provided by the daemon implementation.
2011-07-18 14:46:54 +00:00
Petr Rockai
aac236f4a8 Improve format_buffer in daemon-shared.c, adding block formatting in addition
to string/integer (this propagates to the *simple* family of request/response
functionality).
2011-07-18 14:42:44 +00:00
Alasdair Kergon
730cfc74b8 move doc to doc dir 2011-07-08 18:55:28 +00:00
Alasdair Kergon
c837830f6a report which dev was not found 2011-07-08 12:35:48 +00:00
Petr Rockai
14e012871f Differentiate the request and response format, in daemon/common. 2011-06-29 22:20:14 +00:00
Zdenek Kabelac
88fca3eff4 Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd 2011-06-28 13:42:15 +00:00
Petr Rockai
94bb67ab37 Add int/str lookup routines specific to the reply (in client) and request (in
server) for nicer-looking code (thin wrapping around find_config_{int,str}).
2011-06-27 14:03:58 +00:00
Petr Rockai
aaca7f111f Also parse the config_tree on the client end (daemon-client.c). 2011-06-27 13:58:11 +00:00
Petr Rockai
55e300716f Parse the incoming config tree in daemon-server.c, providing the
daemon-specific handler with a struct config_tree pointer to look things up in.
2011-06-27 13:46:45 +00:00
Petr Rockai
9925977b07 LVMetaD build hack: link to lvm-internal &c. and add a simple test script. 2011-06-27 13:44:33 +00:00
Petr Rockai
4fcbeed6ef Implement daemon_send_simple and use it in the testclient. 2011-06-27 13:15:49 +00:00
Petr Rockai
308963261c Do not open the socket with SOCK_NONBLOCK in daemon-client, since we have no
use for that behaviour (at least for now).
2011-06-27 13:14:53 +00:00
Petr Rockai
ea32ca07e7 Call daemon_close before exit in the testclient. 2011-06-27 12:27:34 +00:00
Petr Rockai
5c1706e3ef Sketch out the actual on-wire format in daemon-client.h documentation, and add
a simplified send interface.
2011-06-27 12:26:54 +00:00
Petr Rockai
acf3616b3a Add a skeleton for lvmetad, a test client, and a temporary Makefile to build
them. These are currently mostly for testing the daemon-common code. LVMetaD
functionality is expected to trickle in soon though.
2011-06-14 02:36:38 +00:00
Petr Rockai
92658f5661 Common daemon code: Implement basic socket-based communication infrastructure
(both client and server side). The server handles each connection in a separate
thread.
2011-06-14 02:34:18 +00:00
Alasdair Kergon
df390f1799 Major pvmove fix to issue ioctls in the correct order when multiple LVs
are affected by the move.  (Currently it's possible for I/O to become
trapped between suspended devices amongst other problems.

The current fix was selected so as to minimise the testing surface.  I
hope eventually to replace it with a cleaner one that extends the
deptree code.

Some lvconvert scenarios still suffer from related problems.
2011-06-11 00:03:06 +00:00
Peter Rajnoha
554923e0ae Fix a few compile warnings.
clvmd-command.c:84:2: warning: implicit declaration of function ‘init_test’
lvm-functions.c:141:3: warning: too many arguments for format
2011-06-03 09:05:30 +00:00
Milan Broz
7c1a2417f5 Use /var/run/lvm for lvmetad socket. 2011-06-02 08:58:05 +00:00
Alasdair Kergon
0ebd0960b4 Propagate test mode to clvmd to skip activation and changes to held locks. 2011-06-01 21:16:55 +00:00
Petr Rockai
ba7d33be9c Mention code layout in lvmetad DESIGN. 2011-05-23 14:46:48 +00:00
Petr Rockai
dc85d3fb57 More work on the common daemon framework. Make things compile, too. 2011-05-15 11:02:29 +00:00
Petr Rockai
73ffd6e748 More scavenging of common daemon code, this time the clvmd local socket setup
sequence.
2011-05-13 09:34:12 +00:00
Petr Rockai
d7448a721b Start filling in some of the common daemon (server-side) functionality, taking
dmeventd code as a starting point.
2011-05-13 08:45:46 +00:00
Petr Rockai
04507b0ace First go at the lvmetad client-side interface. 2011-05-13 08:17:26 +00:00
Petr Rockai
56517bad21 First stab at the prototypes of the daemon-common functionality (to be
eventually shared by dmeventd, lvmetad and clvmd).
2011-05-13 08:07:28 +00:00
Petr Rockai
f03e3ac15b Initial design document for LVMetaD, building on the draft from June of last
year, incorporating the outcomes of today's and yesterday's discussions.
2011-05-12 17:49:46 +00:00
Petr Rockai
eee66d2a80 When glibc needs buffers for line buffering of input and output buffers, it
allocates these buffers in such way it adds memory page for each such buffer
and size of unlock memory check will mismatch by 1 or 2 pages.

This happens when we print or read lines without '\n' so these buffers are
used. To avoid this extra allocation, use setvbuf to set these bufffers ahead.

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
Reviewed-by: Milan Broz <mbroz@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2011-05-07 13:50:11 +00:00
Zdenek Kabelac
a1eba521e3 Fix some unmatching sign comparation gcc warnings
Simple replacement for unsigned type - usually in for() loops.
2011-04-08 14:40:18 +00:00
Zdenek Kabelac
6b7fe2852a Use dm_snprintf
and fix differently signed comparation.
2011-04-08 14:18:40 +00:00
Petr Rockai
968cdc0066 Add rudimentary versioning to the dmevend protocol, allowing us to detect the
(protocol) version of the running dmeventd on the client side.

Right now this is only used in dmeventd -R.
2011-04-04 16:11:09 +00:00
Zdenek Kabelac
81e269fe15 Keep noreturn attribute for lvm_thread_fn
Even thought my gcc seems to not need it, as it's deduced from pthread_exit(),
keep it here for older compiler to avoid getting warnings.
2011-03-30 12:48:16 +00:00
Zdenek Kabelac
e3cce4b66a Better shutdown for clvmd
'a small step' towards cleaner shutdown sequence.
Normally clvmd doens't care about unreleased memory on exit -
but for valgrind testing it's better to have them cleaned all.

So - few things are left on exit path - this patch starts to remove
just some of them.

1. lvm_thread_fs is made as a thread which could be joined on exit()
2. memory allocated to local_clien_head list is released.
   (this part is somewhat more complex if the proper reaction is
   needed - and as it requires some heavier code moving - it will
   be resolved later.
2011-03-30 12:36:19 +00:00
Zdenek Kabelac
6460d5a405 Add attribute printf
gcc suggested to add these attributes to instrumentat
printf arguments. Adding it for internal functions as well.
2011-03-29 21:53:46 +00:00
Zdenek Kabelac
7f0d89f8b4 Fix sending uninitilised bytes in cluster messages
Fix 2 more functions sending cluster messages to avoid passing uninitilised bytes
and compensate 1 extra byte attached to the message from the clvm_header.args[1]
member variable.
2011-03-29 21:05:39 +00:00
Zdenek Kabelac
aaf92617b0 Fix -Wold-style-definition gcc warnings 2011-03-29 20:30:05 +00:00
Zdenek Kabelac
dc4150e018 Release allocated memory on closedown
Release allocated buffers before exit() in debug singlenode - so it's not
poping out in valgrind as memory leak.
2011-03-24 10:45:00 +00:00
Peter Rajnoha
2011571bf5 Remove compile warning for lock_id.
%llx --> PRIx64
2011-03-13 18:08:26 +00:00
Zdenek Kabelac
ee12300a56 Do not send random bytes in message
Fixing few issues:

struct clvm_header  contains  'char args[1]' - so adding '+ 1' here
for message length calculation is 1 byte off.
Message with last byte uninitialized is then passed to write function.
Update also related arglen.

Initialise xid and clintid to 0.

Memory allocation is checked for NULL
2011-03-08 22:48:50 +00:00
Milan Broz
5a47eb762a Fix clvmd return code for bad options.
We should return exit code 2 for unknown option.

Patch also adds standard --help option instead.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=666991
2011-03-08 13:27:39 +00:00
Peter Rajnoha
eb36643cb7 Lower severity of selabel_lookup and matchpathcon failure to log_debug. 2011-03-03 13:05:40 +00:00
Milan Broz
faa6ac9439 Fix syslog initialisation in clvmd to respect lvm.conf setting. 2011-03-02 23:38:22 +00:00
Petr Rockai
0263cd7bbc Do not run past the end of an array in dmeventd's _handle_request when faced
with an unknown command ID.
2011-03-02 14:20:48 +00:00
Petr Rockai
61394ca4aa As requested in BZ 454618:
- dmeventd -R will continue to start up even if no dmeventd is currently
  running + a test for this behaviour
- add -R to dmeventd manpage
2011-03-02 12:49:13 +00:00
Milan Broz
cbedb99e4c Fix some compile warnings on RHEL5
- returned char not needed to be explicitly const
- warn if pipe() fails in clvmd (more fixes here needed for error paths...)
- assign (and ignore) read() output in drain buffer
2011-03-01 20:17:56 +00:00
Zdenek Kabelac
ebcbe00d17 Remove dead code
Remove code which is no longer used.
Code which has been using msg_malloced was removed in 2007.
2011-02-28 19:50:15 +00:00
Zdenek Kabelac
eba7348340 Test result of dm_task_set_uuid 2011-02-28 19:47:22 +00:00
Peter Rajnoha
93cca5c1c8 Remove a few size_t type warnings. 2011-02-22 10:01:11 +00:00
Zdenek Kabelac
faf2288895 Fix gcc warnings for unused variables
Put dead assigment code into comment.
2011-02-18 16:17:56 +00:00
Zdenek Kabelac
aec2115410 Const fixing
Fixing some const warnings - with API change in:

int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,

Change is needed - as lvm2api expects const behaviour here.
So vg_extend() is doing local strdup for unescaping.

skip_dev_dir return const char* from const char* vg_name.

Rest of the patch is cleanup of related warnings.

Also using dm_report_filed_string() API change to simplify
casting in _string_disp and _lvname_disp.
2011-02-18 14:47:28 +00:00
Zdenek Kabelac
4ebc6404ee Void* arithmetic replaced with char* 2011-02-18 14:34:41 +00:00
Zdenek Kabelac
b1bcff7424 Critical section
New strategy for memory locking to decrease the number of call to
to un/lock memory when processing critical lvm functions.

Introducing functions for critical section.

Inside the critical section - memory is always locked.
When leaving the critical section, the memory stays locked
until memlock_unlock() is called - this happens with
sync_local_dev_names() and sync_dev_names() function call.

memlock_reset() is needed to reset locking numbers after fork
(polldaemon).

The patch itself is mostly rename:

memlock_inc  -> critical_section_inc
memlock_dec  -> critical_section_dec
memlock      -> critical_section

Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec
(mlockall()) thus they will never release or relock memory they've
already locked memory.

Macros sync_local_dev_names() and sync_dev_names() are functions.
It's better for debugging - and also we do not need to add memlock.h
to locking.h header (for memlock_unlock() prototyp).
2011-02-18 14:16:11 +00:00
Jonathan Earl Brassow
c054e7cc56 Fix for bug 677739: removing final exclusive cmirror snapshot,
results in clvmd deadlock

When a logical volume is activated exclusively in a cluster, the
local (non-cluster-aware) target is used.  However, when creating
a snapshot on the exclusive LV, the resulting suspend/resume fails
to load the appropriate device-mapper table - instead loading the
cluster-aware target.

This patch adds an 'exclusive' parameter to the pertinent resume
functions to allow for the right target type to be loaded.
2011-02-18 00:36:04 +00:00
Petr Rockai
228fbb6f84 Avoid flooding syslog with redundant messages when a snapshot is invalidated
(reported by Corey).
2011-02-14 14:26:36 +00:00
Jonathan Earl Brassow
27ff8813da Allow snapshots in a cluster as long as they are exclusively
activated.

In order to achieve this, we need to be able to query whether
the origin is active exclusively (a condition of being able to
add an exclusive snapshot).

Once we are able to query the exclusive activation of an LV, we
can safely create/activate the snapshot.

A change to 'hold_lock' was also made so that a request to aquire
a WRITE lock did not replace an EX lock, which is already a form
of write lock.
2011-02-04 20:30:17 +00:00
Zdenek Kabelac
09d288535b Remove extra sync calls.
Remove temporaly added fs_unlock() calls to fix clmvd usablity.
Now when the message passing is properly working - they are no longer needed.
Simplify no_locking  check for VG unlock - as message is always send
for all targets - clustered & non-clustered.
2011-02-04 19:21:47 +00:00
Zdenek Kabelac
fa6a525c2d Use cluster-wide message to request device name sync
Thanks to CLVMD_CMD_SYNC_NAMES propagation fix the message passing started
to work. So starts to send a message before the VG is unlocked.
Removing also implicit sync in VG unlock from clmvd as now the message
is delievered and processed in do_command().
Also add support for this new message into external locking
and mask this event from further processing.
2011-02-04 19:18:16 +00:00
Zdenek Kabelac
135af49da5 Increase hash table size to 1024 lv names and 64 pv uuids 2011-02-03 16:03:13 +00:00
Zdenek Kabelac
3a00204a23 Remove fs_unlock from lv_resume path
Keep it within clvmd until message for SYNC starts to work.
2011-02-03 01:58:20 +00:00
Zdenek Kabelac
fccfa9e929 Better fix for no-locking udev sync and clvmd
This is better way how to fix clustered synchronization with udev.
As the code for message passing needs fixed - put currently
fs_unlock() after every active/deactive command in clvmd to
ensure nodes are properly created in time.
2011-02-02 20:04:39 +00:00
Zdenek Kabelac
9dc3afb1fa Revert wrong fix for nolock locking missing fs_unlock
Patch was wrond and introduced recursive lock_vol
Reverting it.
2011-02-02 13:34:00 +00:00
Zdenek Kabelac
116cbc267c Fix udev synchronization for no-locking mode
Instead of implicitly syncing udev operation in clustered and
file locking code -  call synchronization directly in lock_vol() when
the operation unlocks VG

The problem is missing implicit fs_unlock() in the no_locking code.
This is used with --sysinit on read-only filesystem locking dir.
In this case vgchange -ay could exit before all udev nodes are properly
synchronised and may cause problems with accessing such node right after
vgchange --sysinint command is finished.

Add test case for vgchange --sysinit.
2011-01-31 19:52:40 +00:00
Milan Broz
679830cf58 In some versions (RHEL6) dlm_create_lockspace() always
return lockspace reference (even if lockspace already exists)
and thus increases DLM lockspace count. It means that after
clvmd restart the lockspace is still in use.

(The only way to clean environment to enable clean cluster
shutdown is call "dlm_tool leave clvmd" several times.)

Because only one clvmd can run in time, we can use simpler logic,
try to open lockspace with dlm_open_lockspace() and only if it fails
try to create new one. This way the lockspace reference doesn not
increase.

Very easily reproducible with  "clvmd -S" command.

Patch also fixes return code when clvmd_restart fails and fixes
double free if debug option was specified during restart.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=612862
2011-01-19 23:09:31 +00:00
Milan Broz
4c29343443 Remove DEBUGLOG from dmeventd. 2011-01-17 23:14:05 +00:00
Milan Broz
92e6277c28 Add -f (don't fork) option to clvmd and fix clvmd -d<num> description. 2011-01-17 23:13:14 +00:00
Alasdair Kergon
4299c31d26 remove unused definitions 2011-01-17 19:02:44 +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
937a21f0d2 Speedup consequent activation calls
Stop calling fs_unlock() from lv_de/activate().
Start using internal lvm fs cookie for dm_tree.
Stop directly calling dm_udev_wait() and
dm_tree_set/get_cookie() from activate code -
it's now called through fs_unlock() function.

Add lvm_do_fs_unlock()

Call fs_unlock() when unlocking vg where implicit unlock solves the
problem also for cluster - thus no extra command for clustering
environment is required - only lvm_do_fs_unlock() function is added
to call lvm's fs_unlock() while holding lvm_lock mutex in clvmd.

Add fs_unlock() also to set_lv() so the command waits until devices
are ready for regular open (i.e. wiping its begining).

Move fs_unlock() prototype to activation.h to keep fs.h private
in lib/activate dir and not expose other functions from this header.
2011-01-10 14:02:30 +00:00
Zdenek Kabelac
0a9b444a60 Remove dead assignment of 'ret' value
Variable 'ret' assigned from _do_event() was actually not used and replaced with next
assignment without any read of the returned value.

Code is reformated - so the error path is put in the if() branch and normal
code is put after the 'if' together with FIXME comment.


FIXME lowprio: logging needs to be fixed in this code,
 - multiple log_errors are printed, stacks are missing...
2011-01-06 10:45:41 +00:00
Zdenek Kabelac
4b1232984b Remove unneeded stack prints after log_error 2011-01-06 09:45:05 +00:00
Zdenek Kabelac
4522d931f6 Remove dead assignment to thisfd
Value of 'thisfd' is not read again after its assigment
2011-01-05 12:17:19 +00:00
Zdenek Kabelac
4388a09b0f Detect errors from dm_task_set calls
Check for errors in dm_task_set calls.
Use  goto_bad macro with stack trace.
Replace  label  failed: with bad:.
2010-12-22 15:28:44 +00:00
Zdenek Kabelac
3812984422 Fix last pthread_join fix commit
Call for pthread_join() does not set errno value even though return values
looks like that. For now assign errno from return value and still use
strerror() to print some error message as this seems to be commonly used.

Add also log_sys_error() message for error close of local pipe.
2010-12-22 14:00:28 +00:00
Zdenek Kabelac
8382fc3e85 Fix memory leak in debug mode of restart_clvmd() error path 2010-12-22 12:14:11 +00:00
Zdenek Kabelac
1febdf9a37 Log error state from pthread_join operation
Value jstat is unused - so replace it with logging via log_sys_error().
2010-12-22 12:10:56 +00:00
Zdenek Kabelac
6bc840fd2a Add check for unlink errors 2010-12-20 14:08:46 +00:00
Zdenek Kabelac
35ce2b332b Removed unused pointer
Pointer 'duplicate' is unused.
2010-12-20 13:58:38 +00:00
Zdenek Kabelac
9d3be13f4f Use dm_free for dm_malloc-ed areas in _clog_ctr/_clog_dtr (cmirrord).
Use dm_zalloc to obtain zeroed memory block.
Use dm_free for dm_ allocated memory blocks.
Test close() for error.
2010-12-20 13:57:19 +00:00
Zdenek Kabelac
a91a9dfaf8 Replace multiple fprintf calls with one large string parameter 2010-12-20 13:48:28 +00:00
Zdenek Kabelac
bebfa29b48 Fix NULL pointer check for *buf
As ternary operator has lower priority then add operation, this check
was not doing what seemed to be expected.

So enclose the test in braces and check for NULL in *buf.
2010-12-17 12:37:49 +00:00
Peter Rajnoha
91106a4a2d Create /var/run/lvm directory during clvmd initialisation if missing.
We need to be sure that /var/run and /var/lock is always there.
(E.g. these two directories could be using tmpfs which then loose
all the content after reboot.)
2010-12-13 10:49:02 +00:00
Peter Rajnoha
7dfce0e467 Add new dm_prepare_selinux_context fn to libdevmapper and use it throughout.
Detect existence of new SELinux selabel interface during configure.
Use new dm_prepare_selinux_context instead of dm_set_selinux_context.

We should set the SELinux context before the actual file system object creation.
The new dm_prepare_selinux_context function sets this using the selabel_lookup
fn in conjuction with the setfscreatecon fn. If selinux/label.h interface
(that should be a part of the selinux library) is not found during configure,
we fallback to the original matchpathcon function instead.
2010-12-13 10:43:56 +00:00
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Alasdair Kergon
9d03132282 pre-release 2010-12-06 17:57:14 +00:00
Alasdair Kergon
ea7c621b0a Fix debug logging of derived flag LCK_CACHE in clvmd. 2010-12-06 17:37:09 +00:00
Zdenek Kabelac
250238d04c Log error from unlink failure 2010-12-01 12:41:49 +00:00
Zdenek Kabelac
062181292a Add logging for pipe write() and close() error
Check values from write() and close() system calls.

FIXME: Missing wrapper around 'write()'.
2010-12-01 10:46:20 +00:00
Zdenek Kabelac
a8d4cd68eb Replace snprintf with dm_snprintf
Use dm_snprintf with known error case return code (-1).
2010-11-30 22:16:25 +00:00
Zdenek Kabelac
41cf252f0b Check reallocated buffer for NULL before use
As *buf is reallocated in case CLVMD_CMD_TEST: test for NULL is needed
before printing status.
(realloc() == NULL and status != 0)
2010-11-30 22:11:26 +00:00
Zdenek Kabelac
b20e74d5d6 Remove dead assignment in wait_for_child
'pid' is not used anywhere - remove it.
2010-11-29 12:44:52 +00:00
Zdenek Kabelac
693ec4b404 Use one fprintf call for usage print
Replace multiple fprintf calls with multiline one.
2010-11-29 12:15:41 +00:00
Zdenek Kabelac
2e8d681cf2 Remove dead assignment in 'main'
'ret' is never read anywhere - remove it.
2010-11-29 11:23:14 +00:00
Zdenek Kabelac
1b88184104 Remove printing of LCK_CACHE
LCK_CACHE is defined as 0x100 so it cannot be passed through
unsigned char parameter - remove it from the sprintf code.

If the LCK_CLUSTER should be printed here - lot of code need
to be reworked - so adding FIXME comment.
2010-11-29 11:05:15 +00:00
Zdenek Kabelac
2044eacc7e Add missing fclose
Fixing resource leak in _umount().

CHECKME: mountpoints with spaces need to be checked
2010-11-23 21:19:45 +00:00
Alasdair Kergon
728074ac83 Suppress 'No PV label' message when removing several PVs without mdas. 2010-11-23 01:55:53 +00:00
Alasdair Kergon
962e678174 pre-release 2010-11-08 19:37:40 +00:00
Petr Rockai
fe9ac4d3f4 Add code to the dmeventd snapshot plugin to automatically unmount snapshots
that have been invalidated.
2010-10-29 16:43:51 +00:00
Petr Rockai
63b8dfbde7 Alasdair correctly pointed out that if the two closes are concurrent (I haven't
checked, so they *might*), there is still a race possibility with the last
fix. This patch fixes that.
2010-10-27 11:40:14 +00:00
Petr Rockai
9b2800e861 Fix a double close in clvmd.
The management threads (main_loop, the socket thread) could close a single fd
twice in a row sometimes. At least one other thread can be running at the same
time as the threads doing the double close. That one running thread also
happens to do some IO (namely, open /proc/devices, read from it, close it). If
there was enough "demand" for the local socket, this could happen:

- a connection to clvmd is about to finish, let's say the fd is 13 (it often
  happens to be in my test script, don't ask why)
- the local_sock thread calls close(13)
- the lvm thread calls open("/proc/devices"...) and gets 13
- the main_loop thread calls close(13) [OOPS!]
- new connection arrives, and is accept'd by a (new) local_sock thread
- the accept gives an fd of 13 (since it's the lowest free fd at this point)
- the lvm thread gets around to read from it's /proc/devices handle... 13,
  again
- the lvm thread hangs forever trying to read from the socket instead of
  /proc/devices

Signed-off-by: Petr Rockai <prockai@redhat.com>
Reviewed-by: Milan Broz <mbroz@redhat.com>
2010-10-27 09:13:37 +00:00
Zdenek Kabelac
44110cd33e Add missing return for NULL passed buffer
Function pull_stateo() checks for NULL 'buf' - but return for this error
path was missing.  cmirror code never calls this function with NULL 'buf',
so this fix has no effect on current code base, but makes clang happier.
2010-10-26 10:14:41 +00:00
Zdenek Kabelac
2ecd717dc4 Hotfix usage of __builtin_unreachable()
It's quite new feature which is not supported by older compilers.
So until some better macros are introduced into LVM code - hotfix current
compilation problems and compile this code only for __clang__ defining compilers.
2010-10-26 09:57:03 +00:00
Zdenek Kabelac
6426e5d3e6 Instrument compiler about code unreachability
Clang needs some instrumentation help for static code analysis.
It helps gcc and human reader as well.
2010-10-26 09:01:47 +00:00
Zdenek Kabelac
3a32d104bd Update C declaration () -> (void) 2010-10-26 08:54:37 +00:00
Zdenek Kabelac
321ae653b6 Fix missing initilisation to 0
Add missing init value for variable 'found' which is later tested and may
have contained some garbage value.
2010-10-25 12:59:24 +00:00
Zdenek Kabelac
d80f8cf41b Fix clang warning for ntohl(*((uint32_t *)buf))
We cast (char*) to (uint32_t*) that changes alignment requierements.
For our case the code has been correct as alloca() returns properly
aligned buffer, however this patch make it cleaner and more readable
and avoids warning generation.
2010-10-25 11:57:06 +00:00
Petr Rockai
d95a85ca36 Implement dmeventd -R, allowing dmeventd to be restarted without losing
monitoring state.
2010-10-20 15:12:12 +00:00
Petr Rockai
8f1ead4640 Revert some debug statements that slipped in with last checkin. 2010-10-20 14:51:18 +00:00
Petr Rockai
d28c8ccfbd Fix a deadlock in clvmd.
The signalling code (pthread_cond_signal/pthread_cond_wait) in the
pre_and_post_thread was using the wait mutex (see man pthread_cond_wait)
incorrectly, and this could cause clvmd to deadlock when timing was
right. Detailed explanation of the problem follows.

There is a single mutex around (L for Lock, U for Unlock), a signal (S) and a
wait (W). C for pthread_create. Time flows from left to right, each arrow is a
thread.

So first the "naive" scenario, with no mutex (PPT = pre_and_post_thread, MCT =
main clvmd thread; well actually the thread that does read_from_local_sock). I
will also use X, for a moment when MCT actually waits for something to happen
that PPT was supposed to do.


MCT -----C ------S--X-----S----X----------------------S------XXXXXXXXX
         |                everything OK up to this --> <-- point...
PPT       -----WWW-----WWWW------------------------------WWWWWWWWWWWWW

Ok, so pthread API actually does not let you use W/S like that. It goes out of
its way to tell you that you need a mutex to protect the W so that the above
cannot happen. *But* if you are creative and just lock around the W's and S's,
this happens:

MCT ----C-----LSU----X-----LSU----X------------LSU------XXXXXXX
        |
PPT      ---LWWWU-------LWWWWU-----------------------LWWWWWWWWW

Ooops. Nothing changed (the above is what actually was done by clvmd before
this satch). So let's do it differently, holding L locked *all* the time in
PPT, unless we are actually in W (this is something that the pthread API does
itself, see the man page).

MCT ----C-----LSU------X---LSU---X-----LLLLLLLSU----X----
        |                             (and they live happily ever after)
PPT     L---WWWWW---------WWWW----------------W----------

So W actually ensures that L is unlocked *atomically* together with entering
the wait. That means that unless PPT is actually waiting, it cannot be
signalled by MCT. So if MCT happens to signal it too soon (it wasn't waiting
yet), it (MCT) will be blocked on the mutex (L), until PPT is actually ready to
do something.
2010-10-20 14:46:45 +00:00
Petr Rockai
a341cab721 Implement automatic snapshot extension with dmeventd, and add two new options
to lvm.conf in the activation section: 'snapshot_autoextend_threshold' and
'snapshot_autoextend_percent', that define how to handle automatic snapshot
extension. The former defines when the snapshot should be extended: when its
space usage exceeds this many percent. The latter defines how much extra space
should be allocated for the snapshot, in percent of its current size.
2010-10-15 16:28:14 +00:00
Alasdair Kergon
ac0252ca07 Add dm_zalloc and use it and dm_pool_zalloc throughout. 2010-09-30 21:06:50 +00:00
Zdenek Kabelac
1ebbfd9958 Fix leaked pool report
Swap pool destruction order in dmeventd_lvm2_exit() to fix leak report.
2010-09-30 11:40:14 +00:00
Zdenek Kabelac
c7df0240f9 Add missing cleanup rule for generated .exported_symbols_generated 2010-09-30 10:08:58 +00:00
Jonathan Earl Brassow
34cbedceaf This patch fixes an issue where cluster mirror write I/O
can be opprobriously slow if created with '--nosync'.

One of the ways cluster mirrors coordinate I/O and recovery
amoung the different machines is by the use of the log
function 'is_remote_recovering()' which lets nodes know if
a region they wish to perform a write on is currently being
recovered on another node.  If the region is being recovered,
the I/O is delayed.

The 'is_remote_recovering' routine has been optimized to
avoid the deluge of requests that would be issued to the
userspace log server by maintaining a marker of how far
the recovery has gotten.  It can then immediately return
'not recovering' if the region being inquired about is
less than this mark.  Additionally, if the region of
concern is greater than the mark, the function will
limit the number of transmissions to userspace by assuming
the region /is/ being recovered when skipping the
transmission.  This limits the amount of processing
and updates the mark in 1/4 sec time steps.

This patch fixes a problem where 'the mark' is not being
updated because of faulty logic in the userspace log
daemon.  When '--nosync' is used to create a cluster
mirror, the userspace log daemon never has a chance
to update the mark in the normal way.  The fix is to set
the mark to "complete" if the mirror was created with
the --nosync flag.
2010-08-30 18:37:42 +00:00
Milan Broz
586b56b18c Fix wrong use of LCK_WRITE
In all top vg read functions only LCK_VG_READ/WRITE can be used.
All other vg lock definitions are low-level backend machinery.

Moreover, LCK_WRITE cannot be tested through bitmask.
This patch fixes these mistakes.

For _recover_vg() we do not need lock_flags, it can be only
two of above and we always upgrading to LCK_VG_WRITE lock there.
(N.B. that code is racy)

There is no functional change in code (despite wrong masking
it produces correct bits:-)
2010-08-19 23:26:31 +00:00
Jonathan Earl Brassow
53670b18f5 Fix for bug 596453: multiple mirror image failures cause lvm repair...
The lvm repair issues I believe are the superficial symptoms of this
bug - there are worse issues that are not as clearly seen.  From my
inline comments:
* If the mirror was successfully recovered, we want to always
* force every machine to write to all devices - otherwise,
* corruption will occur.  Here's how:
*    Node1 suffers a failure and marks a region out-of-sync
*    Node2 attempts a write, gets by is_remote_recovering,
*          and queries the sync status of the region - finding
*          it out-of-sync.
*    Node2 thinks the write should be a nosync write, but it
*          hasn't suffered the drive failure that Node1 has yet.
*          It then issues a generic_make_request directly to
*          the primary image only - which is exactly the device
*          that has suffered the failure.
*    Node2 suffers a lost write - which completely bypasses the
*          mirror layer because it had gone through generic_m_r.
*    The file system will likely explode at this point due to
*    I/O errors.  If it wasn't the primary that failed, it is
*    easily possible in this case to issue writes to just one
*    of the remaining images - also leaving the mirror inconsistent.
*
* We let in_sync() return 1 in a cluster regardless of what is
* in the bitmap once recovery has successfully completed on a
* mirror.  This ensures the mirroring code will continue to
* attempt to write to all mirror images.  The worst that can
* happen for reads is that additional read attempts may be
* taken.
2010-08-17 23:56:23 +00:00
Alasdair Kergon
22149572e8 Use 'SINGLENODE' instead of 'dead' in clvmd singlenode messages.
Ignore snapshots when performing mirror recovery beneath an origin.
Pass LCK_ORIGIN_ONLY flag around cluster.
Add suspend_lv_origin and resume_lv_origin using LCK_ORIGIN_ONLY.
2010-08-17 19:25:05 +00:00
Alasdair Kergon
2d6fcbf67d Allow internal suspend and resume of origin without its snapshots. 2010-08-17 16:25:32 +00:00
Alasdair Kergon
d1e8046f56 Various small cleanups and fixes related to monitoring. 2010-08-16 22:54:35 +00:00
Alasdair Kergon
470c18847d Remove superfluous NULL pointer tests before dm_free from dmeventd. 2010-08-16 18:19:46 +00:00
Jonathan Earl Brassow
498747d792 A misunderstanding of the return value of 'dm_bit' has been causing a data
corruption bug in cmirror.  'dm_bit' is only ever used as a boolean operation
within LVM, but it can return a range of values.  If the bit is set, a power of
2 is returned.  If the bit is unset, 0 is returned.

'log_test_bit' (a function in the cluster mirror log daemon code) has switched
to using the dm bit operations in rhel6.  There are two places in the daemon
code where 'log_test_bit' is not used merely as a boolean, but rather the
return value is used as the return value for the log functions 'is_clean' and
'in_sync' - having assumed that 'dm_bit' was returning 0 or 1 only.

One place the 'in_sync' function is utilized is in 'dm_rh_get_state' - a
function that informs the mirroring code how to treat I/O and which devices to
read/write from.  'dm_rh_get_state' was checking if the return value of
'in_sync' was 1 to determine if the region was DM_RH_CLEAN.  Since 'dm_bit'
(and by extension 'log_test_bit' and 'in_sync') was returning powers of 2,
DM_RH_CLEAN was rarely being reported as it should have been.  Thinking the
region was out-of-sync, the mirroring code would write only to the primary
device.  When the primary device was failed, all of those writes were lost -
leaving the entire mirror corrupted.
2010-08-04 18:18:18 +00:00
Zdenek Kabelac
9f926fd060 Use void parameter for function definition. 2010-08-03 13:06:35 +00:00
Alasdair Kergon
65ce9feb72 Never use clvmd singlenode unless explicitly requested with -Isinglenode. 2010-07-28 14:01:40 +00:00
Alasdair Kergon
8bae0a1ecf Change clvmd to communicate with lvm via a socket in /var/run/lvm. (mbroz)
https://bugzilla.redhat.com/show_bug.cgi?id=614248 [CVE-2010-2526]
2010-07-28 13:55:42 +00:00
Fabio M. Di Nitto
8c4e8a185a Add dm_create_lockfile to libdm to handle pidfiles for all daemons.
Switch dmeventd to use dm_create_lockfile and drop duplicate code.
Allow clvmd pidfile to be configurable.
Switch cmirrord and clvmd to use dm_create_lockfile.
2010-07-13 13:51:01 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Milan Broz
b5243aac02 Fix another segfault in clvmd -R if no response from daemon received.
Missed the same problem in another function...
2010-07-01 21:46:09 +00:00
Milan Broz
185ac73d18 Remove superfluous suspended device counter from clvmd.
Moreover, in current mirror handling, when it calls activate
on removed but suspended detached log this counter drops below zero
and confuses debug log.
2010-07-01 21:23:47 +00:00
Petr Rockai
6472c7e11f Maintain memlock balance in clvmd.
When a mirror is being downconverted in a cluster, a series of suspends and
resumes is executed.

With the change to using UUIDs in dev_manager instead of names, the behaviour
has changed with regards to including an _mlog in the deptree of a logical
volume. In the old (pre-UUID-enabled) code, the _mlog would appear in a deptree
of any volume purely based on a name match: a linear volume foo would include
foo_mlog in its dependencies if that happened to exist. This behaviour was
fixed and the mlog is now only included for mirrors.

By a coincidence, this mlog bug had been hiding a different bug in clvmd. When
a mirror is being dismantled (and converted to a linear volume), it is first
suspended as a whole, then later resumed in parts. Nevertheless, the overall
memlock balance is maintained in this operation. The problem kicks in, because
even though the mirror log was suspended as part of the mirror, when the
dismantled mirror is resumed again, it is no longer a mirror and therefore the
mirror log stays suspended. This would not be a problem in itself, since
_delete_lv (from metadata/mirror.c) is called on it subsequently, which does an
activate/deactivate cycle and removes the LV. The activate/deactivate cycle
correctly prompts clvmd to resume the device: however, in doing this, it will
issue an unpaired resume operation (the suspend that caused the mirror log to
be suspended is paired with resuming the dismantled mirror later). We have
concluded that the path in clvmd should never affect memlock_count, since there
should never be an unmatched explicit suspend preceding this resume.
2010-06-30 21:40:27 +00:00
Jonathan Earl Brassow
548cc88947 Add error checking for calls to sprintf - it can fail for more
reasons than just 'out-of-space'.
2010-06-21 16:07:06 +00:00
Alasdair Kergon
b4ee00356b Various cleanups following recent commits. 2010-06-21 15:56:57 +00:00
Milan Broz
aec39dcc34 Let running clvmd process time to reexec.
Because execve stops the command loop,
we never receive response (only socket close) for clvmd -S,
so waiting for response here makes no sense.

But if the calling process (clvmd -S)  exits too early, connection
is closed from client side, clvmd takes this as an error and
never run restart code.

Ugly hack(TM).
2010-06-21 10:45:15 +00:00
Jonathan Earl Brassow
2995925278 daemons/cmirrord/functions.c (part of cmirrord) was referencing
linux/kdev_t.h even though it wasn't needed.  Strangely, it seems
to be causing problems on various architectures (i686) in the
function daemons/cmirrord/functions.c:disk_status_info()->sprintf.

I'm not sure why this is a problem since none of the macros in
kdev_t.h are used in that code, but it certainly doesn't hurt to
pull an unnecessary header and it seems to fix the problem.
2010-06-18 20:58:04 +00:00
Milan Broz
d2031f6a16 Clean up cluster lock mode and flags definition.
Code is mixing up internal DLM and LVM definitions of lock
modes and flags.

OpenAIS and singlenode locking do not depend on DLM but
code currently cannot be compiled without libdlm.h!

LCK_* flags is LVM abstraction, used through all the code.
Only low-level backend (clvmd-cman etc) should use DLM definitions,
also this code should do all needed conversions.

Because there are two DLM flags used in generic code
(NOQUEUE, CONVERT) we define it similar way like lock modes.
(So all needed binary-compatible flags are on one place in locking.h)

(Further code cleaning still needed, though:-)
2010-06-17 12:48:54 +00:00
Zdenek Kabelac
cee2f123a4 Use "" instead of <> for configure.h and libdevmapper.h
Move configure.h as the first header for clvmd source files.
2010-06-15 11:00:44 +00:00
Milan Broz
4c10ab5627 Fix segfault in clvmd -R if no response from daemon received. 2010-06-07 13:52:52 +00:00
Milan Broz
8d6e0c9562 Fix restart of clvmd using -S switch
- allocate environment dynamically (still missing some limit?)
 - try to recover, if destroy failed (do not destroy lvm here) and free memory
 - check strdup() return codes
 - report failure to log
 - do not print NULL in exclusive lock loop
2010-06-04 12:59:30 +00:00
Zdenek Kabelac
b5c2529bf8 Use absolute paths in commands
clvmd restart does not work at all if clvmd binary is not in current
dir.
2010-06-03 13:50:26 +00:00
Alasdair Kergon
bdadde2f7a Use -d to control level of messages sent to syslog by dmeventd.
Change -d to -f to run dmeventd in foreground.
(mornfall)
2010-05-14 14:56:39 +00:00
Alasdair Kergon
e2d136477b Fix static build. 2010-05-14 13:36:56 +00:00