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

5582 Commits

Author SHA1 Message Date
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
Alasdair Kergon
129526b826 Fix last checkin - added error message text wrong. 2011-03-20 02:00:52 +00:00
Zdenek Kabelac
681858db90 Improve debug stack trace
dm_check_version reports log_error() - so use return_NULL.
2011-03-18 13:21:02 +00:00
Milan Broz
52a5cd31c4 Mitigate some warnings if running as non-root user.
LVM doesn't behave correctly if running as non-root user,
there is warning when it detects it.

Despite this, it produces many error messages, saying nothing.
See https://bugzilla.redhat.com/show_bug.cgi?id=620571

This patch fixes two things:
1) Removes eror message from device_is_usable() which has no
information value anyway (real warning is printed inside it).

2) it fixes device-mapper initialization, if we support
core dm module autoload and device node is present, it should
fail early and not try recreate existing and correct node.
(non-root == permission denied here)

N.B. In future code should support user roles, some more
drastic checks in code are probably contraproductive now.
2011-03-18 12:17:57 +00:00
Jonathan Earl Brassow
547d3f13ab Watch out for collisions in GDB global namespace.
Better 'lv_status_r' printing.
2011-03-14 18:05:56 +00:00
Zdenek Kabelac
b8ccce3500 Add missing \0 for grown debug object
Attach \0 for proper char* display - otherwise somewhat random message could
be displayed in debug more and read of unpredictable read of uninitilized
memory values could happen.
2011-03-14 17:00:57 +00:00
Zdenek Kabelac
612e606392 Revert this commit
This buffer allocation must have been problem somewhere else.
(as sizeof() already has the 'extra' '\0' included).
For now reverting this commit.
2011-03-13 23:18:30 +00:00
Zdenek Kabelac
844b75f4d6 Fix allocation of system_id
As code uses strncpy(system_id, NAME_LEN) and doesn't set '\0'
Fix it by always allocating NAME_LEN + 1 buffer size and with zalloc
we always get '\0' as the last byte.

This bug may trigger some unexpected behavior of the string operation
code - depends on the pool allocator.

FIXME: refactor this code to alloc_vg.
2011-03-13 23:05:48 +00:00
Zdenek Kabelac
e1cb521dd9 Use proper size of strncpy
Avoid reading extra character if we expect to have there '\0'.
2011-03-13 23:01:08 +00:00
Zdenek Kabelac
c9c1730705 Fix buffer allocation size for uuid string
We have 3 components and traling '\0' so allocate proper room for all of them.
Problem was nicely hidden by allocation from pool and allocation aligment
offset - so to trigger real problem with this one is actually hard.
2011-03-13 22:57:51 +00:00
Zdenek Kabelac
218f657794 Fix usage of readlink
Return value of readlink limits valid string size.
Characters after returned size present some garbage to printf.
Fix it by placing '\0' on the return size value.
2011-03-13 22:52:16 +00:00
Peter Rajnoha
2011571bf5 Remove compile warning for lock_id.
%llx --> PRIx64
2011-03-13 18:08:26 +00:00
Jonathan Earl Brassow
0b1a79bf1f lv_status_r now prints out status of attached log LVs
(Print layout could be nicer... :(
2011-03-11 22:25:36 +00:00
Jonathan Earl Brassow
ab999c86cc lv_status_r has been fixed-up so that it supports infinite LV stacking
(It does not yet follow 'log_lv' or 'origin' links.)
2011-03-11 22:16:38 +00:00
Jonathan Earl Brassow
1e094d3428 detect RAID* LV and segment flags. 2011-03-11 18:22:39 +00:00
Peter Rajnoha
ff4479414c Use format instance mempool where possible and adequate. 2011-03-11 15:10:16 +00:00
Peter Rajnoha
e8d4946ec7 Various cleanups for fid mem and ref_count changes.
Missing free_vg on error_path in lvmcache_get_vg fn. Call destroy_instance
only if the fid is not part of the vg in backup_read_vg fn (otherwise it's
part of the VG we're returning and we definitely don't want to destroy it!).
2011-03-11 15:08:31 +00:00
Peter Rajnoha
2feb2a66fd Call destroy_instance for any PVs found in VG structure during vg_free call.
This is necessary for proper format instance ref_count support. We iterate
over vg->pvs and vg->removed_pvs list and the ref_count is decremented and
then it is destroyed if not referenced anymore.
2011-03-11 15:06:13 +00:00
Peter Rajnoha
84f48499a3 Add new free_pv_fid fn and use it throughout to free all attached fids.
Since format instances will use own memory pool, it's necessary to properly
deallocate it. For now, only fid is deallocated. The PV structure itself
still uses cmd mempool mostly, but anytime we'd like to add a mempool
in the struct physical_volume, we can just rename this fn to free_pv and
add the code (like we have free_vg fn for VGs).
2011-03-11 14:56:56 +00:00
Peter Rajnoha
1307ddf4cf Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
This is essential for proper format instance ref_count support. We must
use these functions to set the fid everywhere from now on, even the NULL
value!
2011-03-11 14:50:13 +00:00
Peter Rajnoha
293481107f Make create_text_context fn static and move it inside create_instance fn.
We'd like to use the fid mempool for text_context that is stored
in the instance (we used cmd mempool before, so the order of
initialisation was not a matter, but now it is since we need to
create the fid mempool first which happens in create_instance fn).

The text_context initialisation is not needed anywhere outside the
create_instance fn so move it there.
2011-03-11 14:45:17 +00:00
Peter Rajnoha
a1bec4e685 Add mem and ref_count fields to struct format_instance for own mempool use.
Format instances can be created anytime on demand and it contains
metadata area information mostly (at least for now, but in the future,
we may store more things here to update/edit in a PV/VG). In case we
have lots of metadata areas, memory consumption will rise. Using cmd
context mempool is not quite optimal here because it is destroyed too
late. So let's use a separate mempool for format instances.

Reference counting is used because fids could be shared, e.g. each PV
has either a PV-based fid or VG-based fid. If it's VG-based, each PV has
a shared fid with the VG - a reference to VG's fid.
2011-03-11 14:38:38 +00:00
Peter Rajnoha
56f5b12eed Use new alloc_fid fn for common format instance initialisation. 2011-03-11 14:30:27 +00:00
Zdenek Kabelac
a6f38f9d6a Missed merge fix in vg_validate patch 2011-03-10 22:39:36 +00:00
Zdenek Kabelac
8c162552d7 Document pv_min_size in lvm.conf manpage 2011-03-10 15:20:10 +00:00
Zdenek Kabelac
027a55d0fb Optimise _eat_space and _get_token
Makes the code more readable and has a smaller number of memory
accesses thus it's small optimisation as well.

For _get_token() optimize number parsing. Check for '.' char only
if it's not a digit. Move pointer incrementation into one place.

For _eat_space() check only p->te for '\0' in skipping of comment line.
Avoid check for '\0' when we know it is space. Also master while loop
doesn't need checking p->tb for '\0'. We just need to check p->tb
isn't already at the end of buffer. This could give 'extra' loop cycle
if we are already there - but safes memory access in every other case.
2011-03-10 14:51:35 +00:00
Zdenek Kabelac
36b9ec636d Keep pool name also for pool-fast
It's cheap to keep this name - and it is useful for 'non pool debug code'
compilation.
2011-03-10 14:49:01 +00:00
Zdenek Kabelac
1092ae2dbe Indent spaces to tabs 2011-03-10 14:47:22 +00:00
Zdenek Kabelac
442dbf9ad8 Refactor code for _lv_postoder
Add _lv_postorder_vg() - for calling _lv_postorder() for every LV from VG.
We use this in 2 places -  vg_mark_partial_lvs() and vg_validate()
so make it as a one function.

Benefit here is - to use only one cleanup code and avoid
potentially duplicate scans of same LVs.
2011-03-10 14:40:32 +00:00
Jonathan Earl Brassow
0a1d29b1d3 gdbinit - A GDB init file to help while debugging LVM.
Copy this file as '.gdbinit' to your home directory or your working
directory.  It adds the following commands to gdb:
 - first_seg
 - lv_status
 - lv_status_r
 - lv_is_mirrored
 - seg_item
 - seg_status
 - segs_using_this_lv

You can get a list of these user-defined commands by typing:
(gdb) help user-defined

You can get more information on each command by typing:
(gdb) help <command>
2011-03-10 13:45:12 +00:00
Zdenek Kabelac
4ee2b4965f Use hash tables for validating names
Accelerate validation loop by using lvname, lvid, pvid hash tables.
Also merge pvl loop into one cycle now - no need to scan the list twice.
List scan is stopped when dm_hash_insert fails.

The error message with loop_counter1 is no longer provided - however
the message has been misleading anyway.
2011-03-10 13:11:59 +00:00
Milan Broz
825b169e22 Fix dmsetup man page typo (John Bradshaw) 2011-03-10 13:11:45 +00:00
Zdenek Kabelac
8b6ce11d02 Use void pointer instead of char for binary key
dm_hash binary functions takes void* key - so there is no need to cast
pointers to char* (also the hash key does not have trailing '\0').

This is slight API change, but presents no change for the API user side
it just allows to write code easier as the casting could be removed.
2011-03-10 12:48:40 +00:00
Zdenek Kabelac
3019419e95 Refactor vg allocation code
Create new function alloc_vg() to allocate VG structure.

It takes pool_name (for easier debugging).
and also take vg_name to futher simplify code.

Move remainder of _build_vg_from_pds  to _pool_vg_read
and use vg memory pool for import functions.
(it's been using smem -> fid mempool -> cmd mempool)
(FIXME: remove mempool parameter for import functions and use vg).

Move remainder of the _build_vg to _format1_vg_read
2011-03-10 12:43:29 +00:00
Alasdair Kergon
9cfdf8031e Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name. 2011-03-10 03:03:03 +00:00
Alasdair Kergon
2f25c320fb Use empty string instead of /dev// for LV path when there's no VG.
Don't allocate unused VG mempool in _pvsegs_sub_single.
2011-03-09 12:44:42 +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
Zdenek Kabelac
e134ce7c3c Fix reading byte from char params[-1] position
When the ->params string is empty - memory access is made on the byte
before allocated buffer (catched by valgrind) - in the case it would
constain 0x20 - it would even overwrite this buffer.
So fix by checking len > 0 before doing such access.
Also slightly optimise this loop from repeated strlen call.
2011-03-08 22:43:19 +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
Milan Broz
5446fc8cea Fix test for 8k page (fails on Sparc architecture). 2011-03-06 18:28:09 +00:00
Zdenek Kabelac
2bd6583a34 Use lvm_getpagesize wrapper 2011-03-06 17:52:07 +00:00
Milan Broz
affd9c086d Fix hardcoded page size, fixing test fails with 8k page and new kernel. 2011-03-06 16:47:43 +00:00
Milan Broz
688be28794 Move secure flag warning to verbose level.
This feature is not yet upstream and becuase cryptsetup in next version
uses this flag, it will cause a lot of noise on old kernels.
2011-03-05 21:17:19 +00:00
Zdenek Kabelac
55f6627427 Fix reading of released memory
lvseg_segtype_dup used memory pool vg memory pool for strind duplication.
However this one gets released before reporting happens so the command like:

pvs -o segtype

prints data from already released memory pool. Thanks to the fact there
is not much allocation happing after the VG is released, the memory
stays unmodified and correct result is printed.

Fix adds support for mempool passed parameter (like other similar
query commands) and uses dm_report memory pool for string duplication.
2011-03-05 12:14:00 +00:00
Milan Broz
e7f77b36f5 Make the lock test a little bit better... 2011-03-04 15:04:08 +00:00
Milan Broz
90c9d95c15 Wait until dmeventd properly starts in test. 2011-03-04 14:19:18 +00:00
Zdenek Kabelac
26e000eecf Leave some time to scheduler
Looks like scheduler prefers running task before exiting tasks.
So leave some time to finish running flock process.
2011-03-03 16:04:53 +00:00
Zdenek Kabelac
6a9646d1ce Avoid using pipes on lv commands
Failure on pipe kills lv command and produces memory stacktrace.
Add 'true' for empty grep/sed to avoid generating stacktrace.

This should help with long time (7min) for this test on Lenny testing maching
(mimage was filler with stacktrace and each word was used as LV name).
2011-03-03 15:46:05 +00:00
Milan Broz
8595f0c6ac Fix test, "echo n" is not needed when -y is specified. 2011-03-03 14:16:08 +00:00
Peter Rajnoha
eb36643cb7 Lower severity of selabel_lookup and matchpathcon failure to log_debug. 2011-03-03 13:05:40 +00:00