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

116 Commits

Author SHA1 Message Date
Zdenek Kabelac
ff2e8b0de6 thin: simplify thin volume creation
Move code for creation of thin volume into a single place
out of lv_extend().  This allows to drop extra pool arg
for alloc_lv_segment() && lv_extend() and makes code
more easier to read and follow.
2014-10-26 18:37:13 +01:00
Zdenek Kabelac
392bb6f46e fix: regression for recent persistent commit
Do not let fly metadata with just 'minor' set
(since they would not be readable on older version)

Be permissive with invalid major/minor number and
just report them as problem, but allow to use
such metadata with default major:minor.
2014-09-19 17:08:41 +02:00
Zdenek Kabelac
73f4fa6bc1 metadata: validate major, minor numbers
Validate major, minor numbers after reading them from metadata.
2014-09-19 15:53:27 +02:00
Alasdair G Kergon
979be63f25 mirrors: Fix checks for mirror/raid/pvmove LVs.
Try to enforce consistent macro usage along these lines:

lv_is_mirror - mirror that uses the original dm-raid1 implementation
               (segment type "mirror")
lv_is_mirror_type - also includes internal mirror image and log LVs

lv_is_raid - raid volume that uses the new dm-raid implementation
             (segment type "raid")
lv_is_raid_type - also includes internal raid image / log / metadata LVs

lv_is_mirrored - LV is mirrored using either kernel implementation
                 (excludes non-mirror modes like raid5 etc.)

lv_is_pvmove - internal pvmove volume
2014-09-16 00:13:46 +01:00
Alasdair G Kergon
2360ce3551 cleanup: Use lv_is_ macros.
Use lv_is_* macros throughout the code base, introducing
lv_is_pvmove, lv_is_locked, lv_is_converting and lv_is_merging.

lv_is_mirror_type no longer includes pvmove.
2014-09-15 21:33:53 +01:00
Peter Rajnoha
9e3e4d6994 config: differentiate command and metadata profiles and consolidate profile handling code
- When defining configuration source, the code now uses separate
  CONFIG_PROFILE_COMMAND and CONFIG_PROFILE_METADATA markers
  (before, it was just CONFIG_PROFILE that did not make the
  difference between the two). This helps when checking the
  configuration if it contains correct set of options which
  are all in either command-profilable or metadata-profilable
  group without mixing these groups together - so it's a firm
  distinction. The "command profile" can't contain
  "metadata profile" and vice versa! This is strictly checked
  and if the settings are mixed, such profile is rejected and
  it's not used. So in the end, the CONFIG_PROFILE_COMMAND
  set of options and CONFIG_PROFILE_METADATA are mutually exclusive
  sets.

- Marking configuration with one or the other marker will also
  determine the way these configuration sources are positioned
  in the configuration cascade which is now:

  CONFIG_STRING -> CONFIG_PROFILE_COMMAND -> CONFIG_PROFILE_METADATA -> CONFIG_FILE/CONFIG_MERGED_FILES

- Marking configuration with one or the other marker will also make
  it possible to issue a command context refresh (will be probably
  a part of a future patch) if needed for settings in global profile
  set. For settings in metadata profile set this is impossible since
  we can't refresh cmd context in the middle of reading VG/LV metadata
  and for each VG/LV separately because each VG/LV can have a different
  metadata profile assinged and it's not possible to change these
  settings at this level.

- When command profile is incorrect, it's rejected *and also* the
  command exits immediately - the profile *must* be correct for the
  command that was run with a profile to be executed. Before this
  patch, when the profile was found incorrect, there was just the
  warning message and the command continued without profile applied.
  But it's more correct to exit immediately in this case.

- When metadata profile is incorrect, we reject it during command
  runtime (as we know the profile name from metadata and not early
  from command line as it is in case of command profiles) and we
  *do continue* with the command as we're in the middle of operation.
  Also, the metadata profile is applied directly and on the fly on
  find_config_tree_* fn call and even if the metadata profile is
  found incorrect, we still need to return the non-profiled value
  as found in the other configuration provided or default value.
  To exit immediately even in this case, we'd need to refactor
  existing find_config_tree_* fns so they can return error. Currently,
  these fns return only config values (which end up with default
  values in the end if the config is not found).

- To check the profile validity before use to be sure it's correct,
  one can use :

    lvm dumpconfig --commandprofile/--metadataprofile ProfileName --validate

  (the --commandprofile/--metadataprofile for dumpconfig will come
   as part of the subsequent patch)

- This patch also adds a reference to --commandprofile and
  --metadataprofile in the cmd help string (which was missing before
  for the --profile for some commands). We do not mention --profile
  now as people should use --commandprofile or --metadataprofile
  directly. However, the --profile is still supported for backward
  compatibility and it's translated as:

    --profile == --metadataprofile for lvcreate, vgcreate, lvchange and vgchange
                 (as these commands are able to attach profile to metadata)

    --profile == --commandprofile for all the other commands
                (--metadataprofile is not allowed there as it makes no sense)

- This patch also contains some cleanups to make the code handling
  the profiles more readable...
2014-05-20 16:21:48 +02:00
Zdenek Kabelac
460d0254eb thin: add pool metadata spare lv support
Add support for pool's metadata spare volume.
2013-07-18 18:22:43 +02:00
Peter Rajnoha
c5e6bc393e metadata: read VG/LV profile name from metadata if it exists and load it
This is per VG/LV profile loading on demand. The profile itself is saved
in struct volume_group/logical_volume as "profile" field so we can
reference it whenever needed.
2013-07-02 15:19:09 +02:00
Peter Rajnoha
0ca1688134 metadata: log_debug only when BA found in metadata
...not the other way round as it was before. This way it makes
more sense as BA use is exceptional and it's useless to
contaminate the log with messages about BA not being found
in metadata.
2013-06-27 16:03:35 +02:00
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
a7d6a612b8 fix: 'Couldn't read extent size' --> '... extent start' 2013-02-21 13:33:27 +01:00
Petr Rockai
60668f823e Automatically restore MISSING PVs with no MDAs. 2012-11-25 20:41:56 +01:00
Alasdair Kergon
d742cdf327 Change pvscan --lvmetad to pvscan --cache. 2012-03-02 18:09:46 +00:00
Zdenek Kabelac
d2a3352755 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.
2012-02-27 11:40:58 +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
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
e6771e50a9 Check for correctness of uint64 value if exists 2012-01-25 21:43:51 +00:00
Zdenek Kabelac
53d7985fa1 Add support to keep info about creation time and host for each LV
Basic support to keep info when the LV was created.
Host and time is stored into LV mda section.

FIXME: Current version doesn't support configurable string via lvm.conf
and used fixed version strftime "%Y-%m-%d %T %z".
2012-01-19 15:31:45 +00:00
Zdenek Kabelac
2465451549 Rename internal macro to match signess
Since _read_int64 called dm_config_get_uint64, rename it to
less confusing _read_uint64.
2012-01-19 15:17:46 +00:00
Zdenek Kabelac
61158adbcf Allow empty strings for description and creation_host config fields 2011-12-21 12:49:00 +00:00
Zdenek Kabelac
f2c56bc3b6 Drop mempool parameter from read functions
Use implicit vgmem pool.
2011-10-23 16:05:45 +00:00
Zdenek Kabelac
72ff89d279 Always use vg memory pool for allocated lv segment
Remove mem pool parameter from alloc_lv_segment()
Since we should always allocate LV segment from the vg mempool.
2011-10-23 16:02:01 +00:00
Alasdair Kergon
9ac61d2ba2 lvcreate parsing for thin provisioning.
The rest is incomplete so this isn't usable yet.
2011-09-06 00:26:42 +00:00
Petr Rockai
97a4b5165e Replace const usage of dm_config_find_node with more appropriate value-lookup
functionality. A number of bugs (copied and pasted all over the code) should
disappear:

- most string lookup based on dm_config_find_node would segfault when
  encountering a non-zero integer (the intention there was to print an
  error message instead)
- check for required sections in metadata would have been satisfied by
  values as well (i.e. not sections)
- encountering a section in place of expected flag value would have
  segfaulted (due to assumed but unchecked cn->v != NULL)
2011-08-31 15:19:19 +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
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
Jonathan Earl Brassow
cac52ca4ce Add basic RAID segment type(s) support.
Implementation described in doc/lvm2-raid.txt.

Basic support includes:
- ability to create RAID 1/4/5/6 arrays
- ability to delete RAID arrays
- ability to display RAID arrays
Notable missing features (not included in this patch):
- ability to clean-up/repair failures
- ability to convert RAID segment types
- ability to monitor RAID segment types
2011-08-02 22:07:20 +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
Alasdair Kergon
5510b4e7d7 test update without WHATS_NEW to check it gives warning now 2011-04-29 19:06:17 +00:00
Alasdair Kergon
9c58641e74 Rename _check_version 2011-03-27 13:44:08 +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
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
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
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
ff4a77c5ca Intentionaly ignore result from get_config_uint32 2011-01-06 15:25:07 +00:00
Zdenek Kabelac
0ddb15964a Remove check for existance of vg pointer
Checking for vg being != NULL in this place is not needed.
Pointer vg is already dereferced in this function above this code line.
Also this internal function _read_pv is always called with valid 'vg' pointer.
2010-12-22 15:44:09 +00:00
Zdenek Kabelac
760d1fac55 Add more strict const pointers around config tree
To have better control were the config tree could be modified use more
const pointers and very carefully downcast them back to non-const
(for config tree merge).
2010-12-20 13:12:55 +00:00
Alasdair Kergon
1415afcdba Fix memory leak when VG allocation policy in metadata is invalid.
Ignore unrecognised allocation policy found in metadata instead of aborting.
Fix another missing vg_release() in _vg_read_by_vgid.
2010-11-29 18:35:37 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Dave Wysochanski
7042e06a2a Make vg->mda_copies persistent in on disk vg metadata.
This patch adds the ability to read/write the vg->mda_copies values
from/to the vg metadata.

If we read the VG metadata and this field does not exist, we set
mda_copies to the default value of 0.  Later in the code, we use
this special '0' value to indicate a disable of metadata balancing.
This should preserve existing LVM behavior and ensure metadata balancing
can be turned off should the need arise.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:10 +00:00
Petr Rockai
9409998d71 Suppress duplicate error messages about read failures and missing devices. 2010-05-05 22:37:52 +00:00
Alasdair Kergon
aab7a3978b Fix pvmove allocation to take existing parallel stripes into account.
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.)
2010-04-08 00:28:57 +00:00
Dave Wysochanski
9e82787da2 Add add_pvl_to_vgs() - helper function to add a pv to a vg list.
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>
2010-04-06 14:04:54 +00:00
Dave Wysochanski
36e9d03d1b Refactor _read_pv() code that updates vg->extent_count and vg->free_count.
Simple refactor to mov code that updates the vg extent counts from a
single pv's counts close to the code that adds a pv to vg->pvs and
updates vg->pv_count.  No functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-06 14:04:03 +00:00
Alasdair Kergon
258db3ad8e Change most remaining log_error WARNING messages to log_warn. 2010-04-01 10:34:09 +00:00
Milan Broz
d59a2b6109 Use hash table for quick lv reference when reading metadata.
The _read_vg uses already hash for PVs to optimise
reading of large VGs and avoiding repeated PV list traversing.

Use the same aproach to speed up parsing VG with many LVs.
2010-03-31 17:20:02 +00:00
Alasdair Kergon
0a5182fc97 Suppress repeated errors about the same missing PV uuids.
Bypass full device scans when using internally-cached VG metadata.
2010-03-17 02:11:18 +00:00
Alasdair Kergon
b1f9a2f5d1 Only do one full device scan during each read of text format metadata. 2010-03-16 17:30:00 +00:00
Dave Wysochanski
59baeb838c Update a few more uint64_t's related to the 64-bit status change.
At this point they probably do not matter but going forward they
may - depends on future patches for replicator, etc.  I think
these probably got missed because they were 'flags' so I changed
the name to 'status' to be consistent.  So the on-disk
things 'flags' and the in structure 'status' (bits).
NOTE: WHATS_NEW already has entry for this in current release.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
2009-12-04 17:48:32 +00:00