Zdenek Kabelac [Tue, 28 Feb 2012 11:06:56 +0000 (11:06 +0000)]
Ensure clvmd message is always \0 terminated
Drop whole buffer clearing (most messages at <100 bytes).
Just make sure we have always \0 terminated string for strlen() operations.
(before for PIPE_BUF sized messages this was not set).
Zdenek Kabelac [Tue, 28 Feb 2012 10:06:53 +0000 (10:06 +0000)]
Duplicate standard in/out descriptors for daemon
Addressing somewhat tricky bug here.
Since stdin,stdout,stderr were closed it's been occasionally possible to
see some unexpected messages to be flowing into a clvmd and generating some
randomly sized allocation of many megabytes. Since the message was not
being generated by standard send_message() construction, after some more
testing it apperead to be a debug log message - thus something has flown
to local socket opened on strandard out descriptor.
To fix the issue - use standard file descriptor duplication code for daemons.
For making easier debugging of polling daemon - developer might want to recompile
without modifition of standard file descriptors.
Zdenek Kabelac [Tue, 28 Feb 2012 09:58:19 +0000 (09:58 +0000)]
Limit max size of clvmd message
This could be seen as some sort of simple validation - it's not easy to
recognize a valid message for now - but we definitely do not want to
allocate a lot of megabytes in clvmd memory locked daemon when broken
message gets in.
Size of 8000 is just selected for now - possibly there could be much
lower value put in.
Zdenek Kabelac [Mon, 27 Feb 2012 11:49:16 +0000 (11:49 +0000)]
Do not hide deallocation of buffer
As API is passing structures by value, do not leave
the function which created buffer and keeps valid pointer
look like it would be some memory leak and move
free of buffer from inner function - makes more obvious,
how is the memory management handled.
Zdenek Kabelac [Mon, 27 Feb 2012 11:45:05 +0000 (11:45 +0000)]
Use unsigned type for bitmask
Using report_type_t for bitmask is not correct, since we have not defined types
for all bit combinations - so switching to unsigned type, since values of
report_type_t enum are unsigned.
Zdenek Kabelac [Mon, 27 Feb 2012 11:40:58 +0000 (11:40 +0000)]
Just code move of hash initialization in front of function
Make sure both hash tables are initialized before _read_sections() call.
Presents no functional change (since PV scan phase was not adding LV hashes),
but makes the code easier to handle mem failing case, and static analyzer is
hapier as well.
Zdenek Kabelac [Mon, 27 Feb 2012 11:35:59 +0000 (11:35 +0000)]
Add stack traces for lock_vol failures
Adding at least stack traces with some FIXMEs for cases,
where we might want to do something cleaver - maybe fail command
or give user hints something is not going well ?
For remote_backup is stack probably 'good' enough for now.
Zdenek Kabelac [Mon, 27 Feb 2012 11:31:30 +0000 (11:31 +0000)]
Explicitely ignore fail error on hash_insert
We cannot do anything better here anyway - we are already in logging function,
so just ignore this issue here - it will most likely stop application later.
Zdenek Kabelac [Mon, 27 Feb 2012 10:19:00 +0000 (10:19 +0000)]
Add assert for oldname
Code cannot proceed if oldname would be NULL.
Since lvmetad currently doesn't use logging mechanism of lvm to report
internal errors - stay with current code style of lvmetad which uses
plain asserts for cases like this.
Petr Rockai [Sun, 26 Feb 2012 08:49:40 +0000 (08:49 +0000)]
- Improve error reporting on lvmetad connection failure.
- Fix a couple of memory leaks in the lvmetad client code.
- Avoid an error in lvmetad_pv_gone when we aren't using lvmetad.
Peter Rajnoha [Fri, 24 Feb 2012 09:53:12 +0000 (09:53 +0000)]
Add skeleton for lvmetad udev rules - 69-dm-lvm-metad.rules.
Why using the order 69:
- Storage processing in general happens in 60-persistent-storage.rules,
including the blkid call that adds some usable information we can use
for filtering and speedup (these rules are part of upstream udev and
the order is preserved on most distros)
- There's still some other storage-related processing done after
60-persistent-storage.rules in general. These might add some detailed
storage-related information we might use to filter devices effectively
(e.g. MD udev rules, ...).
- We need lvmetad rules to be processed before any consumers can use the
output - so the metadata cache is ready soon enough (e.g. udisks rules).
- There's no official (upstream udev) document about assigning the order,
so this number is chosen in best belief it will suit all scenarios.
Petr Rockai [Thu, 23 Feb 2012 23:52:11 +0000 (23:52 +0000)]
Couple of improvements in the daemon (common + lvmetad) code:
- some client-side memory leak fixes
- announce and check protocols and protocol versions
Zdenek Kabelac [Thu, 23 Feb 2012 22:45:43 +0000 (22:45 +0000)]
Introduce dm_strncpy
Should be faster then strncpy - since we could avoid clearing 4KB pages
with each strncpy(...,PATH_MAX).
Also it's easy to check whether string fit - and eventually avoid
to continue working we incomplete string.
Zdenek Kabelac [Thu, 23 Feb 2012 18:05:12 +0000 (18:05 +0000)]
Limit number of mem allocs and copies
If we have good enough glibc to return number of needed chars, do not
loop try to reach good size, but use this size directly for allocation,
saving also last strdup.
Since now we start with 16 bytes - skip buffer realloc for shorter string.
Petr Rockai [Thu, 23 Feb 2012 14:55:29 +0000 (14:55 +0000)]
Add a vgscan to lvcreate-repair.sh. The old test applied device filter hacks to
make devices invisible to lvm, but the behaviour of those is slightly different
than of actual missing devices. Running vgscan after re-enabling the device
triggers a metadata repair which is not done by vgremove -ff. This is not a
regression, merely an odd behaviour that has been around even before lvmetad.