summaryrefslogtreecommitdiffstats
path: root/lib/format1
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: format1 test whether PV was foundZdenek Kabelac2012-08-231-1/+4
| | | | Avoid dereferecing NULL pointer.
* cleanup: uint64_t castsZdenek Kabelac2012-08-233-3/+3
|
* cleanup: drop unneeded included header filesZdenek Kabelac2012-08-231-1/+0
| | | | | This headers were not resolving anything used for compiled .c files. Remove unused util.c file.
* cleanup: replace memset with struct initilizationZdenek Kabelac2012-06-222-5/+2
| | | | | Simplifies the code, properly detects too long socket paths, drops unused parameter.
* Pass 'single_device' parameter down to suppress 'Can't find uuid' messagesAlasdair Kergon2012-02-291-1/+2
| | | | | | when reading VG text metadate and called from pvscan --lvmetad. (Longer-term, that check needs moving outside of that code.)
* Check for vg_name existanceZdenek Kabelac2012-02-271-1/+2
| | | | | Since vg_read() mda ops could be called with NULL vg_name, check it before derefence also for pool and format1.
* The lvmetad client-side integration. Only active when use_lvmetad = 1 is set inPetr Rockai2012-02-231-0/+3
| | | | lvm.conf *and* lvmetad is running.
* Fix pool names of the format1/format_pool orphan VGs.Petr Rockai2012-02-151-1/+1
|
* Add free_orphan_vgZdenek Kabelac2012-02-131-6/+2
| | | | | | | Move commod code to destroy orphan VG into free_orphan_vg() function. Use orphan vgmem for creation of PV lists. Remove some free_pv_fid() calls (FIXME: check all of them) FIXME: Check whether we could merge release_vg back again for all VGs.
* Clean error paths for format instanceZdenek Kabelac2012-02-131-4/+10
| | | | | With updated orphan VG code this code needed some updates. Add missing log_error for allocation failures.
* Release_vg instead of plain free in error pathZdenek Kabelac2012-02-131-1/+1
|
* FMT_INSTANCE_VG is redundant nowAlasdair Kergon2012-02-121-1/+1
|
* Keep a global (per-format) orphan_vg and keep any and all orphan PVs linked toPetr Rockai2012-02-101-0/+22
| | | | | it. Avoids the need for FMT_INSTANCE_PV and enables further simplifications. No functional change, internal refactor only.
* Move lvmcache data structures behind an API (making the structures private toPetr Rockai2012-02-103-32/+53
| | | | lvmcache.c). No functional change.
* Fix resource leaks for failing allocationZdenek Kabelac2012-02-081-1/+4
| | | | | In case, something would fail during format initialization, return allocated memory.
* Always use vg memory pool for allocated lv segmentZdenek Kabelac2011-10-231-3/+3
| | | | | Remove mem pool parameter from alloc_lv_segment() Since we should always allocate LV segment from the vg mempool.
* lvcreate parsing for thin provisioning.Alasdair Kergon2011-09-061-2/+2
| | | | The rest is incomplete so this isn't usable yet.
* Defer writing PV labels to vg_write.Alasdair Kergon2011-06-012-4/+20
| | | | Store label_sector only in struct physical_volume.
* Use new dev_open_readonly fn to prevent opening devices for read-write when ↵Peter Rajnoha2011-05-281-1/+1
| | | | | | | | | | | | | | | | | | | not necessary. Before, we used vg_write_lock_held call to determnine the way a device is opened. Unfortunately, this opened many devices in RW mode when it was not really necessary. With the OPTIONS+="watch" rule used in the udev rules, this could fire numerous events while closing such devices (and it caused useless scans from within udev rules in return). A common bug we hit with this was with the lvremove command which was unable to remove the LV since it was being opened from within the udev rules. This patch should minimize such situations (at least with respect to LVM handling of devices). Though there's still a possibility someone will open a device 'outside' in parallel and fire the event based on the watch rule when closing a device once opened for RW.
* Fix reading of unitialized memoryZdenek Kabelac2011-03-301-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Could be reached via few of our lvm2 test cases: ==11501== Invalid read of size 8 ==11501== at 0x49B2E0: _area_length (import-extents.c:204) ==11501== by 0x49B40C: _read_linear (import-extents.c:222) ==11501== by 0x49B952: _build_segments (import-extents.c:323) ==11501== by 0x49B9A0: _build_all_segments (import-extents.c:334) ==11501== by 0x49BB4C: import_extents (import-extents.c:364) ==11501== by 0x497655: _format1_vg_read (format1.c:217) ==11501== by 0x47E43E: _vg_read (metadata.c:2901) cut from t-vgcvgbackup-usage.sh -- pvcreate -M1 $(cat DEVICES) vgcreate -M1 -c n $vg $(cat DEVICES) lvcreate -l1 -n $lv1 $vg $dev1 -- Idea of the fix is rather defensive - to allocate one extra element to 'map' array which is then used in _area_length() - where the loop checks, whether next map entry is continuous. By placing there always one extra zero entry - we fix the read of unallocated memory, and we make sure the data would not make a continous block. FIXME: there could be a problem if some special broken lvm1 data would be imported. As the format1 is currently not really used - leave it for future fix and use this small hotfix for now.
* Fix allocation of system_idZdenek Kabelac2011-03-131-1/+1
| | | | | | | | | | | 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.
* Use format instance mempool where possible and adequate.Peter Rajnoha2011-03-111-2/+1
|
* Use only vg_set_fid and new pv_set_fid fn to assign the format instance.Peter Rajnoha2011-03-111-1/+1
| | | | | | 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!
* Add mem and ref_count fields to struct format_instance for own mempool use.Peter Rajnoha2011-03-111-2/+10
| | | | | | | | | | | | | 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.
* Use new alloc_fid fn for common format instance initialisation.Peter Rajnoha2011-03-111-7/+1
|
* Refactor vg allocation codeZdenek Kabelac2011-03-101-50/+24
| | | | | | | | | | | | | | 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
* vgconvert is fixed now to work with the changes in metadata area handling - ↵Peter Rajnoha2011-02-251-1/+1
| | | | | | | | enable the tests. Add a small fix that preserves pe_start for lvm1 PVs when being converted. (this fix needs to be replaced with something more clever, but let's have this working now)
* Change pv_write code to work with the changes in metadata handling interfacePeter Rajnoha2011-02-211-2/+1
| | | | and changes in format_instance.
* Change the code throughout to use new pv_initialise and modified pv_setup fn.Peter Rajnoha2011-02-211-8/+0
| | | | | Change pv_create code to work with these changes together with using new pv_add_metadata_area fn to add metadata areas for a PV being created.
* Separate new pv_initialise function out of the original pv_setup code.Peter Rajnoha2011-02-211-10/+24
| | | | | pv_initiliase initialises a new PV pv_setup sets up an existing PV with a VG
* Remove useless mdas parameter for pv_read (from now on, we store mdas in aPeter Rajnoha2011-02-211-2/+1
| | | | format instance)
* Change create_instance to create PV-based as well as VG-based format instances.Peter Rajnoha2011-02-211-3/+3
| | | | | | | | Add supporting functions to work with the format instance and metadata area structures stored within the format instance. Add support for simple indexing of metadata areas using PV id and mda order (for on-disk PV only for now, we can extend the indexing even for other mdas if needed - we only need to define a proper key for the index).
* Remove unused variable labelZdenek Kabelac2010-12-201-2/+1
| | | | Variable 'label' is unused in _format1_pv_write().
* Remove const usage from destroy callbacksZdenek Kabelac2010-12-201-2/+2
| | | | | | As const segment_type or const format_type are never released use their non-const version and remove const downcast from dm_free calls. This change fixes many gcc warnings we were getting from them.
* Fallback to full rescan for missing deviceZdenek Kabelac2010-12-011-1/+1
| | | | | | | Fix bug when NULL could have been passsed as 'data' to _add_pv_to_list() if 'dev' is NULL. Now it fallbacks to complete scan.
* Remove unneeded test for NULLZdenek Kabelac2010-11-301-1/+1
| | | | Remove check for system_id (it is defined as int8_t[], so cannot be NULL).
* Rename 'flags' to 'status' for struct metadata_area.Dave Wysochanski2010-10-051-1/+1
| | | | | | | | | | | | | | In other LVM memory structures such as volume_group, the field used to store flags is called "status", and on-disk fields are called 'flags', so rename the one inside metadata_area to be consistent. Not only is it more consistent with existing code but is cleaner to say "the status of this mda is ignored". Background for this patch - prajnoha pinged me on IRC this morning about a fix he was working on related to metadataignore when metadata/dirs was set. I was reviewing my patches from this year and realized the 'flags' field was probably not the best choice when I originally did the metadataignore patches.
* Restrict lvm1 partial mode.Milan Broz2010-10-041-2/+26
| | | | | | | | | | | | | | Current lvm1 allocation code seems to not properly map segments on missing PVs. For now disable this functionality. (It never worked and previous commit just introduced segfault here.) So the partial mode in lvm1 can only process missing PVs with no LV segments only. Also do not use random PV UUID for missing part but use fixed string derived from VG UUID (to not confuse clvmd tests).
* Add dm_zalloc and use it and dm_pool_zalloc throughout.Alasdair Kergon2010-09-303-7/+3
|
* Fix handling of partial VG for lvm1 format metadataMilan Broz2010-09-221-2/+49
| | | | | | | | | | | | | | | | | If some lvm1 device is missing, lvm fails on all operations # vgcfgbackup -f bck -P vg_test Partial mode. Incomplete volume groups will be activated read-only. 3 PV(s) found for VG vg_test: expected 4 PV segment VG free_count mismatch: 152599 != 228909 PV segment VG extent_count mismatch: 152600 != 228910 Internal error: PV segments corrupted in vg_test. Volume group "vg_test" not found Allow loading of lvm1 partial VG by allocating "new" missing PV, which covers lost space. Also this fake mising PV inform code that it is partial VG. https://bugzilla.redhat.com/show_bug.cgi?id=501390
* Use __attribute__ consistently throughout.Alasdair Kergon2010-07-095-32/+32
|
* Pass metadataignore to pv_create, pv_setup, _mda_setup, and add_mda.Dave Wysochanski2010-07-081-7/+9
| | | | | | | | | | | Pass metadataignore through PV creation / setup paths. As a result of this cleanup, we can remove the unnecessary setting of mda_ignore bits inside pvcreate_single(), after call to pv_create. For now, just set metadataignore to '0' in some places. This is equivalent to the prior functionality, although the 0 is given by the caller not hardcoded in _mda_setup() call. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Add more initializations of 'mda->flags' field.Dave Wysochanski2010-06-291-1/+2
| | | | | Mda allocation needs refactored into a single function but as an interim step, ensure mda->flags is initialized properly.
* Add metadata_areas_ignored list and functions to manage ignored mdas.Dave Wysochanski2010-06-281-0/+1
| | | | | | | | | | | | | Add a second mda list, metadata_areas_ignored to fid, and a couple functions, fid_add_mda() and fid_add_mdas() to help manage the lists. These functions are needed to properly count the ignored mdas and manage the lists attached to the 'fid' and ultimately the 'vg'. Ensure metadata_areas_ignored is initialized in other formats, even if the list is never used. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
* Rename fid->metadata_areas to fid->metadata_areas_in_use.Dave Wysochanski2010-06-281-2/+2
| | | | | Rename the metadata_areas list to an 'in_use' list to prepare for future 'ignored' list.
* Install plugins to subdirsZdenek Kabelac2010-05-061-1/+1
| | | | | | | | | | | Target install_dm_plugin installs files to libdir/device-mapper. Target install_lvm2_plugin installs files to libdir/lvm2. Both targets creates relative links to libdir to keep the code compatible with current dlopen handling. Once we will be able to read plugins from subdir, links could be removed.
* INSTALL rules updatesZdenek Kabelac2010-04-091-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Patch is inspired by Debian's extra patch. - removes OWNER & GROUP make vars they are parts of INSTALL command. - adds INSTALL_PROGRAM for executable, uses $(INSTALL) - adds INSTALL_DATA for non-executable data, uses ($INSTALL) - adds INSTALL_WDATA for writable non-executable data, uses ($INSTALL) - adds configure option --enable-write_install - to support installatin of writable files used by distribution - replaces usage of ifeq @LIB_SUFFIX@ with $(LIB_SUFFIX) - installs .a files from static builds without executable flag - installs .a files to $(usrlibdir) instead of $(libdir) - installs all static binaries to $(staticdir) - create .so links for devel package in $(usrlibdir) instead of $(libdir) - makes .so and .so.LIB_VERSION files within builddir - removes VERSIONED_SHLIB and created versioned LIB_SHARED automagicaly - install LIB_SHARED via install_lib_shared target - install plugins via install_lib_shared_plugin target - prints whole 'install' command during installation instead of less informative "Installing $(something) $(somewhere)" - install multiple man pages with one INSTALL command - use DISTCLEAN_TARGETS instead of creating multiple distclean targets
* Use vpath instead of VPATH.Zdenek Kabelac2010-04-091-1/+0
| | | | | | | | | | | | | | | Usage of VPATH makes troubles when used within $(builddir). Not only source files are being found through VPATH, but targets as well. (make --debug=v) Thus if user builds the code in $(srcdir) and also in some $(builddir) he gets mangled results as some generated files (i.e. .export.sym) are 'reused' from $(srcdir) instead of $(builddir). This patch switches to use vpath were we could explicitly name suffixes that should be looked via vpath - we must take care, we do not generate files with these suffixes: .c, .in, .po, .exported_symbols
* Fix pvmove allocation to take existing parallel stripes into account.Alasdair Kergon2010-04-081-2/+2
| | | | | | When moving parts of striped LVs, pvmove wouldn't care about leaving you with two stripes on the same disk. Now --alloc anywhere is needed for that. (Tried and gave up on two alternative approaches before the one committed here.)
* Add add_pvl_to_vgs() - helper function to add a pv to a vg list.Dave Wysochanski2010-04-061-2/+1
| | | | | | | | Small refactor of main places in the code where a pv is added to a vg into a small function which adds the pv to the list and updates the vg counts. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>