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

141 Commits

Author SHA1 Message Date
Peter Rajnoha
732859d21f refactor: rename embedding area -> bootloader area 2013-05-28 12:37:22 +02:00
Peter Rajnoha
9dbe25709e pv_header_extension: add support for reading PV header extension (flags & Embedding Area)
New tools with PV header extension support will read the extension
if it exists and it's not an error if it does not exist (so old PVs
will still work seamlessly with new tools).

Old tools without PV header extension support will just ignore any
extension.

As for the Embedding Area location information (its start and size),
there are actually two places where this is stored:
  - PV header extension
  - VG metadata

The VG metadata contains a copy of what's written in the PV header
extension about the Embedding Area location (NULL value is not copied):

    physical_volumes {
        pv0 {
          id = "AkSSRf-difg-fCCZ-NjAN-qP49-1zzg-S0Fd4T"
          device = "/dev/sda"     # Hint only

          status = ["ALLOCATABLE"]
          flags = []
          dev_size = 262144       # 128 Megabytes
          pe_start = 67584
          pe_count = 23   # 92 Megabytes
          ea_start = 2048
          ea_size = 65536 # 32 Megabytes
        }
    }

The new metadata fields are "ea_start" and "ea_size".
This is mostly useful when restoring the PV by using existing
metadata backups (e.g. pvcreate --restorefile ...).

New tools does not require these two fields to exist in VG metadata,
they're not compulsory. Therefore, reading old VG metadata which doesn't
contain any Embedding Area information will not end up with any kind
of error but only a debug message that the ea_start and ea_size values
were not found.

Old tools just ignore these extra fields in VG metadata.
2013-02-26 11:27:23 +01:00
Peter Rajnoha
60c5d4c42f pv_header_extension: add supporting infrastructure for PV header extension (flags & Embedding Area)
PV header extension comes just beyond the existing PV header base:

PV header base (existing):
 - uuid
 - device size
 - null-terminated list of Data Areas
 - null-terminater list of MetaData Areas

PV header extension:
 - extension version
 - flags
 - null-terminated list of Embedding Areas

This patch also adds "eas" (Embedding Areas) list to lvmcache (lvmcache_info)
and it also adds support for common operations on the list (just like for
already existing "das" - Data Areas list):
 - lvmcache_add_ea
 - lvmcache_update_eas
 - lvmcache_foreach_ea
 - lvmcache_del_eas

Also, add ea_start and ea_size to struct physical_volume for processing
PV Embedding Area location throughout the code (currently only one
Embedding Area is supported, though the definition on disk allows for
more if needed in the future...).

Also, define FMT_EAS format flag to mark that the format actually
supports Embedding Areas (currently format-text only).
2013-02-26 11:25:16 +01:00
Zdenek Kabelac
d97605beaf cleanup: preserve signesss and type size on return values 2013-02-05 16:54:11 +01:00
Alasdair G Kergon
06abb2dd4c logging: classify log_debug messages
Place most log_debug() messages into a class.
2013-01-07 22:30:29 +00:00
Petr Rockai
c7b17836ea Implement devices/global_filter.
The global filter is applied first, and is also applied in pvscan --cache (which
is called from udev rules to keep lvmetad updated). Cf. example.conf.
2012-09-26 14:49:15 +02:00
Zdenek Kabelac
fd417db274 check: add internal errors for unexpected paths
Adding couple INTERNAL_ERROR reports for unwanted parameters:

Ensure the 'top' metadata node cannot be NULL for lvmetad.

Make obvious vginfo2 cannot be NULL.

Report internal error if handler and vg is undefined.

Check for handle in poll_vg().

Ensure seg is not NULL in dev_manager_transient().

Report missing read_ahead for _lv_read_ahead_single().

Check for report handler in dm_report_object().

Check missing VG in _vgreduce_single().
2012-08-23 14:37:52 +02:00
Zdenek Kabelac
8a81716325 Minor fixes
Just small updates and remove <backtrace> after log_error.
2012-03-28 11:11:25 +00:00
Zdenek Kabelac
ec19a5a62f Check pointer before deref in debug message 2012-03-01 21:58:55 +00:00
Zdenek Kabelac
7038d527a6 Explicitely ignore fail from this label_read 2012-03-01 21:57:43 +00:00
Alasdair Kergon
03b18d96ad If lvmetad fails, don't set _has_scanned 2012-02-28 18:20:17 +00:00
Zdenek Kabelac
d13b5db28e Add stacktrace for init_lvmcache_orphans fail path 2012-02-28 11:08:04 +00:00
Zdenek Kabelac
89bce34cfb Explicitely ignore errors in label_read iteration.
We don't want stack traces here, so mark as void.
2012-02-28 10:10:07 +00:00
Zdenek Kabelac
ba337a5f3e Remaing code suffling
Move declaration to the front of function to follow coding rules.
2012-02-23 22:23:12 +00:00
Petr Rockai
dae0822698 The lvmetad client-side integration. Only active when use_lvmetad = 1 is set in
lvm.conf *and* lvmetad is running.
2012-02-23 13:11:07 +00:00
Zdenek Kabelac
382a1a6bea Add internal error to guard vgname2 NULL dereference 2012-02-13 14:26:15 +00:00
Alasdair Kergon
b719e3d323 FMT_INSTANCE_VG is redundant now 2012-02-12 23:01:19 +00:00
Petr Rockai
6e41729eb8 Keep a global (per-format) orphan_vg and keep any and all orphan PVs linked to
it. Avoids the need for FMT_INSTANCE_PV and enables further simplifications. No
functional change, internal refactor only.
2012-02-10 02:53:03 +00:00
Petr Rockai
8e5f7cf3dc Move lvmcache data structures behind an API (making the structures private to
lvmcache.c). No functional change.
2012-02-10 01:28:27 +00:00
Zdenek Kabelac
9278655de1 Some fixmes
'len' calculation is unused ?
Unreachable code could be removed or moved upward ?
2012-02-08 12:57:15 +00:00
Petr Rockai
845b1df617 Make a cleaner split between config tree and config file functionality. Move
the latter out of libdm.
2011-12-18 21:56:03 +00:00
Alasdair Kergon
898fec25e5 When dropping the VG metadata from the cache during a VG revert, we must
reset the 'precomitted' flag, just as we'd clear if we next did a 'commit'.
2011-12-08 23:18:00 +00:00
Zdenek Kabelac
d4f134b8f6 Check for refresh_filter failure
Properly detect if the filters were refreshed properly.

(May needs few more fixes ??)

Filter refresh may fail because it may be out of free file descriptors
when clvmd gets overloaded.
2011-10-11 09:09:00 +00:00
Zdenek Kabelac
3caa77f831 Use size_t return type
Since these function returns buffer size - use size_t type for them.
2011-09-01 10:25:22 +00:00
Petr Rockai
e59e2f7c3c Move the core of the lib/config/config.c functionality into libdevmapper,
leaving behind the LVM-specific parts of the code (convenience wrappers that
handle `struct device` and `struct cmd_context`, basically). A number of
functions have been renamed (in addition to getting a dm_ prefix) -- namely,
all of the config interface now has a dm_config_ prefix.
2011-08-30 14:55:15 +00:00
Zdenek Kabelac
cf98c05082 Add detect_internal_vg_cache_corruption to lvm.conf
Add config option to enable crc checking of VG structures.
Currently it's disabled by default.

For the internal test-suite this check it is enabled.

Note: In the case the internal error is detected, debug build with
compile option DEBUG_ENFORCE_POOL_LOCKING helps to catch the source
of the problem.
2011-08-11 17:46:13 +00:00
Zdenek Kabelac
031c986ea8 Lock memory for shared VG
Use debug pool locking functionality. So the command could check,
whether the memory in the pool has not been modified.

For lv_postoder() instead of unlocking and locking for every changed
struct status member do it once when entering and leaving function.
(mprotect would trap each such memory access).
Currently lv_postoder() does not modify other part of vg structure
then status flags of each LV with flags that are reverted back to
its original state after function exit.
2011-08-11 17:34:30 +00:00
Zdenek Kabelac
bb115a7a6c Cache and share generated VG structs
Extend vginfo cache with cached VG structure. So if the same metadata
are use, skip mda decoding in the case, the same data are in use.
This helps for operations like activation of all LVs in one VG,
where same data were decoded giving the same output result.

Patch adds 1-to-1 connection between volume_group and lvmcache_vginfo.
2011-08-11 17:24:23 +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
Petr Rockai
2710477deb Slightly refactor the config code to allow better reuse (no functional change). 2011-07-18 13:26:08 +00:00
Alasdair Kergon
3cac20f850 Defer writing PV labels to vg_write.
Store label_sector only in struct physical_volume.
2011-06-01 19:29:31 +00:00
Zdenek Kabelac
5c246f4876 Skip check for NULL before dm_free
dm_free makes this test itself.
2011-04-21 13:15:26 +00:00
Zdenek Kabelac
d992bbbaa3 Keep the cache content when the exported vg buffer is matching
Instead of regenerating config tree and parsing same data again,
check whether export_vg_to_buffer does not produce same string as
the one already cached - in this case keep it, otherwise throw cached
content away.

For the code simplicity calling _free_cached_vgmetadata() with
vgmetadata == NULL as the function handles this itself.

Note: sometimes export_vg_to_buffer() generates almost the same data
with just different time stamp, but for the patch simplicity,
data are reparsed in this case.

This patch currently helps for vgrefresh.
2011-03-30 13:14:34 +00:00
Zdenek Kabelac
3aef5ae7fb Fix access to released memory
Invalid primary_vginfo was supposed to move all its lvmcache_infos to
orphan_vginfo - however it has called _drop_vginfo() inside the loop
that released primary_vginfo itself - thus made the loop using released
memory.

Use _vginfo_detach_info() instead and call _drop_vginfo after
th loop is finished.

Valgrind trace it should fix:

Invalid read of size 8
   at 0x41E960: _lvmcache_update_vgname (lvmcache.c:1229)
   by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
   by 0x441393: _text_read (text_label.c:329)
   by 0x442221: label_read (label.c:289)
   by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
   by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
   by 0x45B4A6: lv_from_lvid (metadata.c:3381)
   by 0x41B555: lv_activation_filter (activate.c:1346)
   by 0x415868: do_activate_lv (lvm-functions.c:343)
   by 0x415E8C: do_lock_lv (lvm-functions.c:532)
   by 0x40FD5F: do_command (clvmd-command.c:120)
   by 0x413D7B: process_local_command (clvmd.c:1686)
 Address 0x63eba10 is 16 bytes inside a block of size 160 free'd
   at 0x4C2756E: free (vg_replace_malloc.c:366)
   by 0x41DE70: _free_vginfo (lvmcache.c:980)
   by 0x41DEDA: _drop_vginfo (lvmcache.c:998)
   by 0x41E854: _lvmcache_update_vgname (lvmcache.c:1238)
   by 0x41EF86: lvmcache_update_vgname_and_id (lvmcache.c:1360)
   by 0x441393: _text_read (text_label.c:329)
   by 0x442221: label_read (label.c:289)
   by 0x41CF92: lvmcache_label_scan (lvmcache.c:635)
   by 0x45B303: _vg_read_by_vgid (metadata.c:3342)
   by 0x45B4A6: lv_from_lvid (metadata.c:3381)
   by 0x41B555: lv_activation_filter (activate.c:1346)
   by 0x415868: do_activate_lv (lvm-functions.c:343)

problematic line:
dm_list_iterate_items_safe(info2, info3, &primary_vginfo->infos)
2011-03-29 21:34:18 +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
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
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
Peter Rajnoha
c0c21864c6 Change the code throughout for recent changes in format_instance handling. 2011-02-21 12:07:03 +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
Zdenek Kabelac
2dd15068fb Cache config_tree
Start to use config_tree for cache just like vgmetadata.
When vgmetadata are erased destroy its cached config tree.
2011-01-10 13:15:57 +00:00
Zdenek Kabelac
6feecf76d4 Change import_vg_from_buffer to use config_tree
Change function import_vg_from_buffer() to import_vg_from_config_tree().
Instead of creating config tree inside the function allow config tree to
be passed as parameter - usable later for caching.
2011-01-10 13:13:42 +00:00
Alasdair Kergon
acb037657c Fix scanning of VGs without in-PV mdas.
Set cmd->independent_metadata_areas if metadata/dirs or disk_areas in use.
- Identify and record this state.

Don't skip full scan when independent mdas are present even if memlock is set.
- Clusters and OOM aren't supported, so no problem doing the proper scans.

Avoid revalidating the label cache immediately after scanning.
- A simple optimisation.

Support scanning for a single VG in independent mdas.
- Not used by the fix but I left it in anyway as later patches might use it.
2010-12-10 22:39:52 +00:00
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Zdenek Kabelac
e3552d738c Check result of vginfo_from_vgname
Check for some potential internal error.
2010-12-01 10:39:28 +00:00
Zdenek Kabelac
faa1268182 Fix constness warnings
After update of device_from_pvid() API fix constness warnings
Also fix info_from_pvid() constness warning for char* usage.
2010-10-25 13:33:42 +00:00
Zdenek Kabelac
710784945c Use 'const' struct id *pvid for device_from_pvid()
Update interface for device_from_pvid and use const pointer.
2010-10-25 13:02:26 +00:00
Alasdair Kergon
ac0252ca07 Add dm_zalloc and use it and dm_pool_zalloc throughout. 2010-09-30 21:06:50 +00:00
Alasdair Kergon
a171bb6e85 Track recursive filter iteration to avoid refreshing while in use. (2.02.56) 2010-09-22 01:36:13 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Dave Wysochanski
bb723d7897 Use mdas_empty_or_ignored() in place of checks for empty mda list.
With the addition of ignored mdas, we replace all checks for an empty
mda list with a new function to look for either an empty mda list or
ignored mdas.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:34:58 +00:00