]> sourceware.org Git - lvm2.git/log
lvm2.git
11 years agoWHATS_NEW: vgextend and PV with 0 MDAs
Peter Rajnoha [Tue, 19 Mar 2013 14:41:21 +0000 (15:41 +0100)]
WHATS_NEW: vgextend and PV with 0 MDAs

11 years agocleanup: remove unused 'pv_by_path' fn
Peter Rajnoha [Tue, 19 Mar 2013 13:17:53 +0000 (14:17 +0100)]
cleanup: remove unused 'pv_by_path' fn

The pv_by_path might be also dangerous to use as it does not
count with any other metadata areas but the ones found on the PV
itself. If metadata was not found on the PV referenced by the path,
it returned no PV though it might have been referenced by metadata
elsewhere (on other PVs...).

11 years agovgextend: do not allow PV with 0 MDAs to be added while already in a VG
Peter Rajnoha [Tue, 19 Mar 2013 13:13:44 +0000 (14:13 +0100)]
vgextend: do not allow PV with 0 MDAs to be added while already in a VG

If extending a VG and including a PV with 0 MDAs that was already
a part of a VG, the vgextend allowed that PV to be added and we
ended up *with one PV in two VGs*!

The vgextend code used the 'pv_by_path' fn that returned a PV for
a given path. However, when the PV did not have any metadata areas,
the fn just returned a PV without any reference to existing VG.
Consequently, any checks for the existing VG failed.

[0] raw/~ # pvcreate --metadatacopies 0 /dev/sda
  Physical volume "/dev/sda" successfully created

[0] raw/~ # pvcreate --metadatacopies 1 /dev/sdb
  Physical volume "/dev/sdb" successfully created

[0] raw/~ # vgcreate vg1 /dev/sda /dev/sdb
  Volume group "vg1" successfully created

[0] raw/~ # pvcreate --metadatacopies 1 /dev/sdc
  Physical volume "/dev/sdc" successfully created

[0] raw/~ # vgcreate vg2 /dev/sdc
  Volume group "vg2" successfully created

Before this patch (incorrect):
[0] raw/~ # vgextend vg2 /dev/sda
  Volume group "vg2" successfully extended

With this patch (correct):
[0] raw/~ # vgextend vg2 /dev/sda
  Physical volume '/dev/sda' is already in volume group 'vg1'
  Unable to add physical volume '/dev/sda' to volume group 'vg2'.

11 years agometadata: add 'allow_orphan' arg to find_pv_by_name fn
Peter Rajnoha [Tue, 19 Mar 2013 13:05:19 +0000 (14:05 +0100)]
metadata: add 'allow_orphan' arg to find_pv_by_name fn

Before, the find_pv_by_name call always failed if the PV found was orphan.
However, we might use this function even for a PV that is not part of any VG.
This patch adds 'allow_orphan' arg to find_pv_by_name fn that allows that.

11 years agocleanup: remove superfluous wrappers
Peter Rajnoha [Tue, 19 Mar 2013 12:58:02 +0000 (13:58 +0100)]
cleanup: remove superfluous wrappers

_find_pv_by_name -> find_pv_by_name
_find_pv_in_vg -> find_pv_in_vg
_find_pv_in_vg_by_uuid -> find_pv_in_vg_by_uuid

The only callers of the underscored variants were their wrappers
without the underscore. No other part of the code referenced the
underscored variants.

11 years agothin: rework lvconvert
Zdenek Kabelac [Mon, 11 Mar 2013 08:49:10 +0000 (09:49 +0100)]
thin: rework lvconvert

Usage of layer was not the best plan here - for proper devices stack
we have to keep correct reference in volume_group structure and
make the new thin pool LV appear as a new volume.

11 years agothin: cannot use snapshot merge with thinpool
Zdenek Kabelac [Mon, 11 Mar 2013 09:44:05 +0000 (10:44 +0100)]
thin: cannot use snapshot merge with thinpool

11 years agothin: assign through structure
Zdenek Kabelac [Fri, 8 Mar 2013 13:12:56 +0000 (14:12 +0100)]
thin: assign through structure

Just simplify code.

11 years agothin: read paramaters in front
Zdenek Kabelac [Mon, 11 Mar 2013 11:40:05 +0000 (12:40 +0100)]
thin: read paramaters in front

Fill paramaters into lvconvert_params -
so we could use it independently on args()

11 years agothin: lvconvert read params sooner
Zdenek Kabelac [Mon, 11 Mar 2013 09:44:49 +0000 (10:44 +0100)]
thin: lvconvert read params sooner

Move code for reading stripesize and readahead to the
_read_params function.

11 years agothin: move update_pool_params
Zdenek Kabelac [Mon, 11 Mar 2013 11:37:09 +0000 (12:37 +0100)]
thin: move update_pool_params

Now we may recongnize preset arguments, move
the code for updating thin pool related values
into /lib portion of the code.

11 years agothin: mark passed args
Zdenek Kabelac [Wed, 6 Mar 2013 10:58:09 +0000 (11:58 +0100)]
thin: mark passed args

Keep the flag whether given thin pool argument has been given on command
line or it's been 'estimated'

Call of update_pool_params() must not change cmdline given args and
needs to know this info.

Since there is a need to move this update function into /lib, we cannot
use arg_count().

FIXME: we need some generic mechanism here.

11 years agocleanup: move comment
Zdenek Kabelac [Sun, 24 Feb 2013 18:42:40 +0000 (19:42 +0100)]
cleanup: move comment

11 years agocleanup: indent
Zdenek Kabelac [Sun, 24 Feb 2013 18:37:01 +0000 (19:37 +0100)]
cleanup: indent

11 years agodmsetup: fix 'splitname -o' to not fail if used without '-c'
Peter Rajnoha [Tue, 12 Mar 2013 11:37:24 +0000 (12:37 +0100)]
dmsetup: fix 'splitname -o' to not fail if used without '-c'

This was a regression introduced with e33fd978a8a56228677c14612fce99b3b3588125
(libdm v1.02.68/lvm2 v2.02.89) with the introduction of new output
fields blkdevname and blkdevs_used for ls and deps dmsetup commands.

A new common '_process_options' fn was added with that commit, but the
fn was called prematurely which then broke processing of
'dmsetup splitname -o' which should implicitly use '-c' option
and this was failing after the commit:

  alatyr/~ $ dmsetup splitname -o lv_name /dev/mapper/vg_data-test
  Option not recognised: lv_name
  Couldn't process command line.

The '-c' had to be used for correct operation:

  alatyr/~ $ dmsetup splitname -c -o lv_name /dev/mapper/vg_data-test
  LV
  test

Now fixed to work as it did before:

  alatyr/~ $ dmsetup splitname -o lv_name /dev/mapper/vg_data-test
  LV
  test

11 years agofilters: power2 devs get precedence if PVIDs match
Alasdair G Kergon [Mon, 11 Mar 2013 20:10:49 +0000 (20:10 +0000)]
filters: power2 devs get precedence if PVIDs match

Give precedence to EMC "power2" devices with duplicate PVIDs like
we already do with "emcpower" devices.

11 years agotest: Fix the way in_sync calculates the sync field location
Jonathan Brassow [Wed, 6 Mar 2013 17:12:09 +0000 (11:12 -0600)]
test: Fix the way in_sync calculates the sync field location

'in_sync' was using the last field in the RAID status output as
the location for the sync ratio field.  The sync ratio may not always
be the last field, but it will always be the 7th field.  So we switch
to using the absolute value rather than computing the last field
index number.

11 years agoRAID: Code changes missing from previous commit (bbc6378)
Jonathan Brassow [Wed, 6 Mar 2013 16:17:11 +0000 (10:17 -0600)]
RAID:  Code changes missing from previous commit (bbc6378)

Previous commit included changes to WHATSNEW, but the code changes
were missing.  Here is the description from the previous commit:
commit bbc6378b73246d7ef00c16274fea38118531ae95
Author: Jonathan Brassow <jbrassow@redhat.com>
Date:   Thu Feb 21 11:31:36 2013 -0600

    RAID:  Make 'lvchange --refresh' restore transiently failed RAID PVs

    A new function (dm_tree_node_force_identical_table_reload) was added to
    avoid the suppression of identical table reloads.  This allows RAID LVs
    to reload the on-disk superblock information that contains which devices
    have failed and the bitmaps.  If the failed device has returned, this has
    the effect of restoring the device and initiating recovery.  Without this
    patch, the user had to completely deactivate their RAID LV and re-activate
    it in order to restore the failed device.  Now they simply need to
    suspend and resume (which is done by 'lvchange --refresh').

    The identical table suppression is only avoided if the LV is not PARTAIL
    (i.e. all of it's devices can be seen and read by LVM) and the kernel
    status of the array contains failed devices.  In other words, the function
    will only be called in the case where we may have success in restoring
    a failed device in the array.

11 years agoclean-up: Typo 's/should had/should have/'
Jonathan Brassow [Wed, 6 Mar 2013 14:42:03 +0000 (08:42 -0600)]
clean-up:  Typo 's/should had/should have/'

11 years agocleanup: get rid of compiler's warning about possible unitialized variable
Peter Rajnoha [Wed, 6 Mar 2013 11:53:27 +0000 (12:53 +0100)]
cleanup: get rid of compiler's warning about possible unitialized variable

11 years agoconfig: make DEFAULT_MAX_HISTORY unconditional
Peter Rajnoha [Wed, 6 Mar 2013 11:47:23 +0000 (12:47 +0100)]
config: make DEFAULT_MAX_HISTORY unconditional

11 years agoWHATS_NEW: add lines for config validation support
Peter Rajnoha [Wed, 6 Mar 2013 09:38:40 +0000 (10:38 +0100)]
WHATS_NEW: add lines for config validation support

11 years agodumpconfig: add --ignoreadvanced and --ignoreunsupported switch
Peter Rajnoha [Wed, 6 Mar 2013 08:35:33 +0000 (09:35 +0100)]
dumpconfig: add --ignoreadvanced and --ignoreunsupported switch

lvm dumpconfig [--ignoreadvanced] [--ignoreunsupported]

--ignoreadvanced causes the advanced configuration options to be left
out on dumpconfig output

--ignoreunsupported causes the options that are not officially supported
to be lef out on dumpconfig output

11 years agoconfig: add comment note about advanced and unsupported config nodes
Peter Rajnoha [Wed, 6 Mar 2013 08:31:15 +0000 (09:31 +0100)]
config: add comment note about advanced and unsupported config nodes

This shows up in the output as a short commentary:

  $ lvm dumpconfig --type default --withcomments metadata/disk_areas
  # Configuration option metadata/disk_areas.
  # This configuration option is advanced.
  # This configuration option is not officially supported.
  disk_areas=""

11 years agodumpconfig: add --withcomments and --withversions switch
Peter Rajnoha [Tue, 5 Mar 2013 17:21:13 +0000 (18:21 +0100)]
dumpconfig: add --withcomments and --withversions switch

lvm dumpconfig [--withcomments] [--withversions]

The --withcomments causes the comments to appear on output before each
config node (if they were defined in config_settings.h).

The --withversions causes a one line extra comment to appear on output
before each config node with the version information in which the
configuration setting first appeared.

11 years agoconfig: add support for enhanced config node output
Peter Rajnoha [Tue, 5 Mar 2013 17:02:13 +0000 (18:02 +0100)]
config: add support for enhanced config node output

There's a possibility to interconnect the dm_config_node with an
ID, which in our case is used to reference the configuration
definition ID from config_settings.h. So simply interconnecting
struct dm_config_node with struct cfg_def_item.

This patch also adds support for enhanced config node output besides
existing "output line by line". This patch adds a possibility to
register a callback that gets called *before* the config node is
processed line by line (for example to include any headers on output)
and *after* the config node is processed line by line (to include any
footers on output). Also, it adds the config node reference itself
as the callback arg in addition to have a possibility to extract more
information from the config node itself if needed when processing the
output callback (e.g. the key name, the id, or whether this is a
section or a value etc...).

If the config node from lvm.conf/--config tree is recognized and valid,
it's always coupled with the config node definition ID from
config_settings.h:

 struct dm_config_node {
   int id;
   const char *key;
   struct dm_config_node *parent, *sib, *child;
   struct dm_config_value *v;
 }

For example if the dm_config_node *cn holds "devices/dev" configuration,
then the cn->id holds "devices_dev_CFG" ID from config_settings.h, -1 if
not found in config_settings.h and 0 if matching has not yet been done.

To support the enhanced config node output, a new structure has been
defined in libdevmapper to register it:

  struct dm_config_node_out_spec {
    dm_config_node_out_fn prefix_fn; /* called before processing config node lines */
    dm_config_node_out_fn line_fn; /* called for each config node line */
    dm_config_node_out_fn suffix_fn; /* called after processing config node lines */
  };

Where dm_config_node_out_fn is:

  typedef int (*dm_config_node_out_fn)(const struct dm_config_node *cn, const char *line, void *baton);

(so in comparison to existing callbacks for config node output, it has
an extra dm_config_node *cn arg in addition)

This patch also adds these functions to libdevmapper:
  - dm_config_write_node_out
  - dm_config_write_one_node_out

...which have exactly the same functionality as their counterparts
without the "out" suffix. The "*_out" functions adds the extra hooks
for enhanced config output (prefix_fn and suffix_fn mentioned above).

One can still use the old interface for config node output, this is
just an enhancement for those who'd like to modify the output more
extensively.

11 years agodumpconfig: add --type, --atversion and --validate arg
Peter Rajnoha [Tue, 5 Mar 2013 16:48:29 +0000 (17:48 +0100)]
dumpconfig: add --type, --atversion and --validate arg

lvm dumpconfig [--type {current|default|missing|new}] [--atversion] [--validate]

This patch adds above-mentioned args to lvm dumpconfig and it maps them
to creation and writing out a configuration tree of a specific type
(see also previous commit):

  - current maps to CFG_TYPE_CURRENT
  - default maps to CFG_TYPE_DEFAULT
  - missing maps to CFG_TYPE_MISSING
  - new maps to CFG_TYPE_NEW

If --type is not defined, dumpconfig defaults to "--type current"
which is the original behaviour of dumpconfig before all these changes.

The --validate option just validates current configuration tree
(lvm.conf/--config) and it writes a simple status message:

  "LVM configuration valid" or "LVM configuration invalid"

11 years agoconfig: use config checks and add support for creating trees from config definition...
Peter Rajnoha [Tue, 5 Mar 2013 16:36:10 +0000 (17:36 +0100)]
config: use config checks and add support for creating trees from config definition (config_def_create_tree fn)

Configuration checking is initiated during config load/processing
(_process_config fn) which is part of the command context
creation/refresh.

This patch also defines 5 types of trees that could be created from
the configuration definition (config_settings.h), the cfg_def_tree_t:

  - CFG_DEF_TREE_CURRENT that denotes a tree of all the configuration
    nodes that are explicitly defined in lvm.conf/--config

  - CFG_DEF_TREE_MISSING that denotes a tree of all missing
    configuration nodes for which default valus are used since they're
    not explicitly used in lvm.conf/--config

  - CFG_DEF_TREE_DEFAULT that denotes a tree of all possible
    configuration nodes with default values assigned, no matter what
    the actual lvm.conf/--config is

  - CFG_DEF_TREE_NEW that denotes a tree of all new configuration nodes
    that appeared in given version

  - CFG_DEF_TREE_COMPLETE that denotes a tree of the whole configuration
    tree that is used in LVM2 (a combination of CFG_DEF_TREE_CURRENT +
    CFG_DEF_TREE_MISSING). This is not implemented yet, it will be added
    later...

The function that creates the definition tree of given type:

  struct dm_config_tree *config_def_create_tree(struct config_def_tree_spec *spec);

Where the "spec" specifies the tree type to be created:

  struct config_def_tree_spec {
    cfg_def_tree_t type; /* tree type */
    uint16_t version; /* tree at this LVM2 version */
    int ignoreadvanced; /* do not include advanced configs */
    int ignoreunsupported; /* do not include unsupported configs */
  };

This tree can be passed to already existing functions that write
the tree on output (like we already do with cmd->cft).

There is a new lvm.conf section called "config" with two new options:

  - config/checks which enables/disables checking (enabled by default)

  - config/abort_on_errors which enables/disables aborts on any type of
    mismatch found in the config (disabled by default)

11 years agoconfig: add support for configuration check (config_def_check fn)
Peter Rajnoha [Tue, 5 Mar 2013 16:14:18 +0000 (17:14 +0100)]
config: add support for configuration check (config_def_check fn)

Add support for configuration checking - type checking and recognition
of registered configuration settings that LVM2 understands and also
check the structure of the configuration. Log error on any mismatch
found.

A hash over all allowed configuration paths is created which helps
with matching the exact configuration (lvm.conf/--config tree) with
the configuration item definition from config_settings.h in an
efficient and one-step way.

Two more helper flags are introduced for each configuration definition
item:

  - CFG_USED which marks the item as being used (lvm.conf/--config)
    This helps with identifying missing configuration options
    (and for which defaults were used) when traversing the tree later.

  - CFG_VALID which denotes that the item has already been checked and
    it was found valid. This improves performance, so if the check
    is called once again on the same tree which was not reloaded, we
    can just return the state from previous check (with a possibility
    to force the check if needed).

The new function that config.h exports and which is going to be used
to perform the configuration checking is:

  int config_def_check(struct cmd_context *cmd, int force, int skip, int suppress_messages)

...which is exported internally via config.h.

11 years agolibdevmapper: add dm_config_value_is_bool function
Peter Rajnoha [Tue, 5 Mar 2013 16:10:30 +0000 (17:10 +0100)]
libdevmapper: add dm_config_value_is_bool function

Export this functionality from libdevmapper just for
convenience and general use when reading boolean values
which could be defined either in a numeric way with 0/1
or by using strings with "true"/"false", "yes"/"no",
"on"/"off", "y"/"n".

11 years agoconfig: refer to config nodes using assigned IDs
Peter Rajnoha [Tue, 5 Mar 2013 16:00:43 +0000 (17:00 +0100)]
config: refer to config nodes using assigned IDs

For example, the old call and reference:

  find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)

...now becomes:

  find_config_tree_str(cmd, devices_dir_CFG)

So we're referring to the named configuration ID instead
of passing the configuration path and the default value
is taken from central config definition in config_settings.h
automatically.

11 years agoconfig: add structs to represent config definition and register config_settings.h...
Peter Rajnoha [Tue, 5 Mar 2013 15:49:42 +0000 (16:49 +0100)]
config: add structs to represent config definition and register config_settings.h content

This patch adds basic structures that encapsulate the config_settings.h
content - it takes each item and puts it in structures:

  - cfg_def_type_t to define config item type

  - cfg_def_value_t to define config item (default) value

  - flags used to define the nature and use of the config item:
      - CFG_NAME_VARIABLE for items with variable names (e.g. tags)
      - CFG_ALLOW_EMPTY for items where empty value is allowed
      - CFG_ADVANCED for items which are considered as "advanced settings"
      - CFG_UNSUPPORTED for items which are not officially supported
        (config options mostly for internal use and testing/debugging)

  - cfg_def_item_t to encapsulate the whole definition of the config
    definition itself

Each config item is referenced by named ID, e.g. "devices_dir_CFG"
instead of directly typing the path "devices/dir" as it was before.

This patch also adds cfg_def_get_path helper function to get the
config setting path up to the root for given config ID
(it returns the path in form of "abc/def/.../xyz" where the "abc"
is the topmost element).

11 years agoconfig: add config_settings.h
Peter Rajnoha [Tue, 5 Mar 2013 15:42:32 +0000 (16:42 +0100)]
config: add config_settings.h

This file centrally defines all recognized LVM2 configuration
sections and settings. Each item here has its parent, set of
allowed types, default value, brief comment, version the setting
first appeared in and flags that further define the nature of
the configuration setting and its use.

11 years agoconfig: add vsn macro
Peter Rajnoha [Tue, 5 Mar 2013 15:39:36 +0000 (16:39 +0100)]
config: add vsn macro

The 'vsn' macro encodes the LVM2 version major, minor
and patchlevel number in a packed form using 16 bits.

11 years agoconfig: fix config node lookup inside empty sections to not return the section itself
Peter Rajnoha [Wed, 27 Feb 2013 12:47:57 +0000 (13:47 +0100)]
config: fix config node lookup inside empty sections to not return the section itself

When a section was empty in a configuration tree (no children - this is
allowed) and we were looking for a config node inside that section, the
_find_config_node function incorrectly returned the section itself if
the node inside that section was not found.

For example the configuration below:

The config:
    abc {
    }

And a function call to get the "def" node inside "abc" section:
     _find_config_node(..., "abc/def")

...returned the "abc" node instead of NULL ("def" not found).

This in turn caused segfaults in the code using lookups in such
a configuration tree as we (correctly) expected that the node
returned was always the one we were looking for or NULL if not
found. But if incorrect node was returned instead, we processed
that as if this was the node we were looking for and so we
processed its value as well. But sections don't have values => segfault.

11 years agocleanup: remove struct pv_header_extension reference from struct pv_header
Peter Rajnoha [Wed, 27 Feb 2013 09:47:24 +0000 (10:47 +0100)]
cleanup: remove struct pv_header_extension reference from struct pv_header

Just to prevent accidental and improper use when reading the layout
from disk because of the already existing disk_areas_xl[0] lists
that are variable in size. We can read pv_header_extension only
after we know exactly where the lists end...

11 years agolvmetad: fix to properly process embedding area
Peter Rajnoha [Wed, 27 Feb 2013 09:36:49 +0000 (10:36 +0100)]
lvmetad: fix to properly process embedding area

11 years agoWHATS_NEW: add lines for embedding area support
Peter Rajnoha [Tue, 26 Feb 2013 14:50:43 +0000 (15:50 +0100)]
WHATS_NEW: add lines for embedding area support

11 years agoman: update pvcreate/pvs/vgconvert man page to cover embedding area support
Peter Rajnoha [Tue, 26 Feb 2013 13:10:11 +0000 (14:10 +0100)]
man: update pvcreate/pvs/vgconvert man page to cover embedding area support

11 years agoreport: add reporting fields for Embedding Area start and size
Peter Rajnoha [Sat, 16 Feb 2013 14:10:47 +0000 (15:10 +0100)]
report: add reporting fields for Embedding Area start and size

There are new reporting fields for Embedding Area: ea_start and ea_size.

An example of 1m Embedding Area and relevant reporting fields:
raw/~ # pvs -o pv_name,pe_start,ea_start,ea_size
  PV         1st PE  EA start EA size
  /dev/sda     2.00m    1.00m   1.00m

11 years agotools: add embeddingareasize arg to pvcreate and vgconvert
Peter Rajnoha [Fri, 15 Feb 2013 10:14:26 +0000 (11:14 +0100)]
tools: add embeddingareasize arg to pvcreate and vgconvert

To create an Embedding Area during PV creation (pvcreate or as part of
the vgconvert operation), we need to define the Embedding Area size.
The Embedding Area start will be calculated automatically by the tools.

This patch adds --embeddingareasize argument to pvcreate and vgconvert.

11 years agopv_header_extension: add support for writing PV header extension (flags & Embedding...
Peter Rajnoha [Fri, 15 Feb 2013 10:02:53 +0000 (11:02 +0100)]
pv_header_extension: add support for writing PV header extension (flags & Embedding Area)

The PV header extension information (PV header extension version, flags
and list of Embedding Area locations) is stored just beyond the PV header base.

When calculating the Embedding Area start value (ea_start), the same logic is
used as when calculating the pe_start value for Data Area - the value must
follow exactly the same alignment restrictions for its start value
(the alignment detected automatically or provided via command line using
the --dataalignment and --dataalignmentoffset arguments).

The Embedding Area is placed at the very start of the PV, starting at
ea_start. The Data Area starting at pe_start is placed next. The pe_start is
still properly aligned. Due to the pe_start alignment, it's possible that the
resulting Embedding Area size (ea_size) ends up bigger in size than requested
(but never less than requested).

11 years agopv_header_extension: add support for reading PV header extension (flags & Embedding...
Peter Rajnoha [Thu, 14 Feb 2013 15:04:35 +0000 (16:04 +0100)]
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.

11 years agopv_header_extension: add supporting infrastructure for PV header extension (flags...
Peter Rajnoha [Thu, 14 Feb 2013 14:35:57 +0000 (15:35 +0100)]
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).

11 years agocleanup: use struct pvcreate_restorable_params throughout
Peter Rajnoha [Mon, 18 Feb 2013 11:47:31 +0000 (12:47 +0100)]
cleanup: use struct pvcreate_restorable_params throughout

11 years agocleanup: add struct pvcreate_restorable_params and move relevant items from pvcreate_...
Peter Rajnoha [Mon, 18 Feb 2013 09:51:32 +0000 (10:51 +0100)]
cleanup: add struct pvcreate_restorable_params and move relevant items from pvcreate_params

Extract restorable PV creation parameters from struct pvcreate_params into
a separate struct pvcreate_restorable_params for clarity and also for better
maintainability when adding any new items later.

11 years agoactivation: fix pvmove partial tree creation
Zdenek Kabelac [Sat, 23 Feb 2013 11:09:12 +0000 (12:09 +0100)]
activation: fix pvmove partial tree creation

Do not try to add LV again into the partial tree, if it's been
already added. Otherwise we may end in endless loop.

11 years agothin: lvconvert support for external origin
Zdenek Kabelac [Tue, 5 Feb 2013 10:26:27 +0000 (11:26 +0100)]
thin: lvconvert support for external origin

Add basic support for converting LV into an external origin volume.

Syntax:

lvconvert --thinpool vg/pool  --originname renamed_origin -T origin

It will convert volume  'origin' into a thin volume, which will
use 'renamed_origin' as an external read-only origin.
All read/write into origin will go via 'pool'.

renamed_origin volume is read-only volume, that could be activated
only in read-only mode, and cannot be modified.

11 years agothin: removal of external_origin
Zdenek Kabelac [Wed, 20 Feb 2013 15:14:24 +0000 (16:14 +0100)]
thin: removal of external_origin

11 years agothin: report external origin
Zdenek Kabelac [Tue, 15 Jan 2013 14:16:16 +0000 (15:16 +0100)]
thin: report external origin

Use the field 'origin' for reporting external origin lv name.

For thin volumes with external origin, report the size of
external origin size via:

  lvs -o+origin_size

11 years agothin: external origin cannot be changed
Zdenek Kabelac [Tue, 5 Feb 2013 13:03:43 +0000 (14:03 +0100)]
thin: external origin cannot be changed

Do not allow conversion of external origin into writeable LV,
and prohibit changing the external origin size.

If the snapshot origin is also external origin, merge is prohibited.

11 years agothin: add support for external origin
Zdenek Kabelac [Thu, 21 Feb 2013 09:25:44 +0000 (10:25 +0100)]
thin: add support for external origin

Add internal support for thin volume's external origin.

11 years agolvremove: easier removal of dependent lvs
Zdenek Kabelac [Wed, 20 Feb 2013 15:13:17 +0000 (16:13 +0100)]
lvremove: easier removal of dependent lvs

Add function to remove lvs which are depending on removed lv
prior the lv is removed.

User is asked for confirmation.

11 years agoactivation: simplify activation code
Zdenek Kabelac [Thu, 21 Feb 2013 09:39:47 +0000 (10:39 +0100)]
activation: simplify activation code

Reorder activation code to look similar for preload tree and
activation tree.

Its also give much better suppport for device stacking,
since now we also support activation of snapshot which might
be then used for other devices.

11 years agoactivation: add _add_layer_target_to_dtree
Zdenek Kabelac [Thu, 21 Feb 2013 09:24:28 +0000 (10:24 +0100)]
activation: add _add_layer_target_to_dtree

Add function for creation of simple linear mapping over layer device.

11 years agothin: replace _thin_layer with lv_layer()
Zdenek Kabelac [Mon, 18 Feb 2013 08:53:05 +0000 (09:53 +0100)]
thin: replace  _thin_layer with lv_layer()

Use consitently lv_layer function internally for thin pool layer name.

11 years agoactivation: extend _cached_info
Zdenek Kabelac [Sun, 17 Feb 2013 23:08:38 +0000 (00:08 +0100)]
activation: extend _cached_info

Add layer string to support check of layered devices.

11 years agoconfigure: Respect pkg-config --cflags for udev.
Petr Rockai [Mon, 18 Feb 2013 15:18:41 +0000 (16:18 +0100)]
configure: Respect pkg-config --cflags for udev.

11 years agoconf: add missing '=' for raid10_segtype_default
Peter Rajnoha [Fri, 22 Feb 2013 11:36:03 +0000 (12:36 +0100)]
conf: add missing '=' for raid10_segtype_default

11 years agoRAID: Make 'lvchange --refresh' restore transiently failed RAID PVs
Jonathan Brassow [Thu, 21 Feb 2013 17:31:36 +0000 (11:31 -0600)]
RAID:  Make 'lvchange --refresh' restore transiently failed RAID PVs

A new function (dm_tree_node_force_identical_table_reload) was added to
avoid the suppression of identical table reloads.  This allows RAID LVs
to reload the on-disk superblock information that contains which devices
have failed and the bitmaps.  If the failed device has returned, this has
the effect of restoring the device and initiating recovery.  Without this
patch, the user had to completely deactivate their RAID LV and re-activate
it in order to restore the failed device.  Now they simply need to
suspend and resume (which is done by 'lvchange --refresh').

The identical table suppression is only avoided if the LV is not PARTAIL
(i.e. all of it's devices can be seen and read by LVM) and the kernel
status of the array contains failed devices.  In other words, the function
will only be called in the case where we may have success in restoring
a failed device in the array.

11 years agovgimport: Allow '--force' to import VGs with missing PVs.
Jonathan Brassow [Wed, 20 Feb 2013 22:28:26 +0000 (16:28 -0600)]
vgimport:  Allow '--force' to import VGs with missing PVs.

When there are missing PVs in a volume group, most operations that alter
the LVM metadata are disallowed.  It turns out that 'vgimport' is one of
those disallowed operations.  This is bad because it creates a circular
dependency.  'vgimport' will complain that the VG is inconsistent and that
'vgreduce --removemissing' must be run.  However, 'vgreduce' cannot be run
because it has not been imported.  Therefore, 'vgimport' must be one of
the operations allowed to change the metadata when PVs are missing.  The
'--force' option is the way to make 'vgimport' happen in spite of the
missing PVs.

11 years agopvcreate: fix alignment to incorporate alignment offset if PV has 0 MDAs
Peter Rajnoha [Thu, 21 Feb 2013 13:47:49 +0000 (14:47 +0100)]
pvcreate: fix alignment to incorporate alignment offset if PV has 0 MDAs

If zero metadata copies are used, there's no further recalculation of
PV alignment that happens when adding metadata areas to the PV and
which actually calculates the alignment correctly as a matter of fact.
So fix this for "PV without MDA" case as well.

Before this patch:
[1] raw/~ # pvcreate --dataalignment 8m --dataalignmentoffset 4m
--metadatacopies 1 /dev/sda
  Physical volume "/dev/sda" successfully created
[1] raw/~ # pvs -o pv_name,pe_start
  PV         1st PE
  /dev/sda    12.00m
[1] raw/~ # pvcreate --dataalignment 8m --dataalignmentoffset 4m
--metadatacopies 0 /dev/sda
  Physical volume "/dev/sda" successfully created
[1] raw/~ # pvs -o pv_name,pe_start
  PV         1st PE
  /dev/sda     8.00m

After this patch:
[1] raw/~ # pvcreate --dataalignment 8m --dataalignmentoffset 4m
--metadatacopies 1 /dev/sda
  Physical volume "/dev/sda" successfully created
[1] raw/~ # pvs -o pv_name,pe_start
  PV         1st PE
  /dev/sda    12.00m
[1] raw/~ # pvcreate --dataalignment 8m --dataalignmentoffset 4m
--metadatacopies 0 /dev/sda
  Physical volume "/dev/sda" successfully created
[1] raw/~ # pvs -o pv_name,pe_start
  PV         1st PE
  /dev/sda    12.00m

Also, remove a superfluous condition "pv->pe_start < pv->pe_align" in:
  if (pe_start == PV_PE_START_CALC && pv->pe_start < pv->pe_align)
    pv->pe_start = pv->pe_align ...
This part of the condition is not reachable as with the PV_PE_START_CALC,
we always have pv->pe_start set to 0 from the PV struct initialisation
(...the pv->pe_start value is just being calculated).

11 years agoRAID: Add new 'raid10_segtype_default' setting in lvm.conf
Jonathan Brassow [Wed, 20 Feb 2013 21:10:04 +0000 (15:10 -0600)]
RAID:  Add new 'raid10_segtype_default' setting in lvm.conf

If '--mirrors/-m' and '--stripes/-i' are used together when creating
a logical volume, mirrors-over-stripes is currently chosen.  The user
can override this by using the '--type raid10' option on creation.
However, we want a place where we can set the default behavior to
'raid10' explicitly - similar to the "mirror" and "raid1" tunable,
mirror_segtype_default.

A follow-on patch should use this new setting to change the default
from "mirror" to "raid10", as this is the preferred segment type.

11 years agoclean-up: Remove a FIXME question that has been settled
Jonathan Brassow [Wed, 20 Feb 2013 21:03:58 +0000 (15:03 -0600)]
clean-up:  Remove a FIXME question that has been settled

It is ok for us to use the shorthand 'lv_is_virtual' to detect error
targets in a RAID LV when searching for candidates for device replacement.

11 years agoRAID: Allow remove/replace of sub-LVs composed of error segments.
Jonathan Brassow [Wed, 20 Feb 2013 20:58:56 +0000 (14:58 -0600)]
RAID:  Allow remove/replace of sub-LVs composed of error segments.

When a device fails, we may wish to replace those segments with an
error segment.  (Like when a 'vgreduce --removemissing' removes a
failed device that happens to be a RAID image/meta.)  We are then left
with images that we will eventually want to remove or replace.

This patch allows us to pull out these virtual "error" sub-LVs.  This
allows a user to 'lvconvert -m -1 vg/lv' to extract the bad sub-LVs.
Sub-LVs with error segments are considered for extraction before other
possible devices so that good devices are not accidentally removed.

This patch also adds the ability to replace RAID images that contain error
segments.  The user will still be unable to run 'lvconvert --replace'
because there is no way to address the 'error' segment (i.e. no PV
that it is associated with).  However, 'lvconvert --repair' can be
used to replace the image's error segment with a new PV.  This is also
the most appropriate way to do it, since the LV will continue to be
reported as 'partial'.

11 years agoRAID: Make 'vgreduce --removemissing' work with RAID LVs
Jonathan Brassow [Wed, 20 Feb 2013 20:52:46 +0000 (14:52 -0600)]
RAID: Make 'vgreduce --removemissing' work with RAID LVs

Currently it is impossible to remove a failed PV which has a RAID LV
on it.  This patch fixes the issue by replacing the failed PV with an
'error' segment within the affected sub-LVs.  Once there is no longer
a RAID LV using the PV, it can be removed.

Most often, it is better to replace a failed RAID device with a spare.
(You can use 'lvconvert --repair <vg>/<LV>' to accomplish that.)
However, if there are no spares in the volume group and none will be
added, it is useful to be able to removed the failed device.

Following patches address the ability to perform 'lvconvert' operations
on RAID LVs that contain sub-LVs composed of 'error' segments.

11 years agoclean-up: Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'
Jonathan Brassow [Wed, 20 Feb 2013 20:40:17 +0000 (14:40 -0600)]
clean-up:  Rename lvm.conf setting 'mirror_region_size' to 'raid_region_size'

We have been using 'mirror_region_size' in lvm.conf as the default region
size for RAID logical volumes as well as mirror logical volumes.  Since,
"raid" is more inclusive and representative than "mirror", I have changed
the name of this setting.  We must still check for the old setting and warn
the user if we are overriding it with the new setting if both happen to be
present.

11 years agofix: 'Couldn't read extent size' --> '... extent start'
Peter Rajnoha [Thu, 21 Feb 2013 12:33:27 +0000 (13:33 +0100)]
fix: 'Couldn't read extent size' --> '... extent start'

11 years agoreport: fix pvs -o pv_free reporting for PVs with 0 PEs
Peter Rajnoha [Thu, 21 Feb 2013 12:28:07 +0000 (13:28 +0100)]
report: fix pvs -o pv_free reporting for PVs with 0 PEs

[0] raw/~ # lsblk -o NAME,SIZE /dev/sda
NAME  SIZE
sda   128M

[0] raw/~ # pvcreate --dataalignment 128m /dev/sda
  Physical volume "/dev/sda" successfully created

[0] raw/~ # vgcreate vg /dev/sda
  Volume group "vg" successfully created

[0] raw/~ # lvcreate -l1 vg
  Volume group "vg" has insufficient free space (0 extents): 1 required.

Before this patch:
[0] raw/~ # pvs -o pv_name,pv_free
  PV         PFree
  /dev/sda   128.00m

After this patch:
[0] raw/~ # pvs -o pv_name,pv_free
  PV         PFree
  /dev/sda      0

11 years agocleanup: old style gcc
Zdenek Kabelac [Tue, 5 Feb 2013 15:48:48 +0000 (16:48 +0100)]
cleanup: old style gcc

11 years agocleanup: preserve signesss and type size on return values
Zdenek Kabelac [Tue, 5 Feb 2013 15:43:16 +0000 (16:43 +0100)]
cleanup: preserve signesss and type size on return values

11 years agothin: update pool_is_active
Zdenek Kabelac [Tue, 5 Feb 2013 15:49:09 +0000 (16:49 +0100)]
thin: update pool_is_active

Change it to take LV and move it to exported header - seems
to be a better fit for usability from tools/ directory.

11 years agothin: properly unmark volume after detach
Zdenek Kabelac [Tue, 5 Feb 2013 10:07:09 +0000 (11:07 +0100)]
thin: properly unmark volume after detach

When the volume is detached form thin pool,
unmask THIN_VOLUME flag and reset related pointers.

11 years agotest: update using exclusive activation
Zdenek Kabelac [Tue, 5 Feb 2013 08:20:17 +0000 (09:20 +0100)]
test: update using exclusive activation

For testing in cluster exclusive activation of origin is needed.

11 years agothin: fix forbidden discards checks
Zdenek Kabelac [Sat, 2 Feb 2013 11:48:52 +0000 (12:48 +0100)]
thin: fix forbidden discards checks

Instead of check for lv_is_active() for thin pool LV,
query the whole pool via new  pool_is_active().

Fixes a problem when we cannot change discards settings
for active pool device where the actual layer for pool
device was inactive, but thin volumes using thin pool
have been active.

11 years agothin: add function pool_is_active
Zdenek Kabelac [Tue, 5 Feb 2013 09:52:39 +0000 (10:52 +0100)]
thin: add function pool_is_active

This internal function check for active pool device.
For cluster it checks every thin volume,
On the non-clustered VG we need to check just
for presence of -tpool device.

11 years agoreport: leave empty report field for 0
Zdenek Kabelac [Tue, 5 Feb 2013 12:59:15 +0000 (13:59 +0100)]
report: leave empty report field for 0

Since we do not support LVs with 0 size, use this value
as 'error' value for devices without origin, and leave this
field blank as in other cases.

11 years agolvconvert: update error path
Zdenek Kabelac [Tue, 5 Feb 2013 10:21:21 +0000 (11:21 +0100)]
lvconvert: update error path

Update the error path after problems with suspend_lv or vg_commit.
It's not exactly well defined what should happen, and this
code seems to appear in many different instancies<F2> in the
whole source code tree - we should probably pick the best version.

11 years agolvconvert: fix accepting second lv name
Zdenek Kabelac [Mon, 4 Feb 2013 12:56:54 +0000 (13:56 +0100)]
lvconvert: fix accepting second lv name

Do not allow to accept second LV name on lvconvert --thinpool
command line.

11 years agoheaders: add headers for musl libc
Zdenek Kabelac [Tue, 5 Feb 2013 08:33:30 +0000 (09:33 +0100)]
headers: add headers for musl libc

On glibc, those are erroneously (namespace pollution) pulled in via
other headers. this doesn't work with conformant libcs (musl libc in
this case), we simply need to include all needed headers.

Signed-Off-By: John Spencer <maillist-lvm@barfooze.de>
11 years agocleanup: avoid overflow warning
Zdenek Kabelac [Mon, 4 Feb 2013 19:32:21 +0000 (20:32 +0100)]
cleanup: avoid overflow warning

Even we do not expect to support chunks bigger then 2GB.

11 years agocleanup: remove extra braces
Zdenek Kabelac [Mon, 4 Feb 2013 19:31:56 +0000 (20:31 +0100)]
cleanup: remove extra braces

11 years agocleanup: malloc attributes
Zdenek Kabelac [Mon, 4 Feb 2013 19:29:59 +0000 (20:29 +0100)]
cleanup: malloc attributes

11 years agocleanup: add internal error check
Zdenek Kabelac [Fri, 14 Dec 2012 18:42:28 +0000 (19:42 +0100)]
cleanup: add internal error check

Check if 'is_removable' is defined and report internal error,
if it's missing.

11 years agoclean-up: Another functiont that can use 'lv_layer'
Jonathan Brassow [Mon, 4 Feb 2013 23:10:16 +0000 (17:10 -0600)]
clean-up:  Another functiont that can use 'lv_layer'

lib/activate/dev_manager.c:dev_manager_raid_status() can also use
the new 'lv_layer' function.

11 years agothin: use noflush for obtaining transaction_id
Zdenek Kabelac [Thu, 17 Jan 2013 09:54:41 +0000 (10:54 +0100)]
thin: use noflush for obtaining transaction_id

Do not flush thin pool data, when reading transation_id status.

11 years agocleanup: comment update
Zdenek Kabelac [Fri, 25 Jan 2013 14:29:42 +0000 (15:29 +0100)]
cleanup: comment update

Just update code comment and use single line if().

11 years agocleanup: indent line
Zdenek Kabelac [Sat, 19 Jan 2013 11:04:17 +0000 (12:04 +0100)]
cleanup: indent line

11 years agolibdm: support newer thin pool status parameters
Zdenek Kabelac [Mon, 10 Dec 2012 09:23:17 +0000 (10:23 +0100)]
libdm: support newer thin pool status parameters

Support read_only and discards information.

11 years agotest: regression test for lvmetad error
Zdenek Kabelac [Mon, 7 Jan 2013 09:57:59 +0000 (10:57 +0100)]
test: regression test for lvmetad error

11 years agothin: replace is_active with send_messages
Zdenek Kabelac [Thu, 17 Jan 2013 09:35:27 +0000 (10:35 +0100)]
thin: replace is_active with send_messages

Since is_active is only used for thinp
replace struct member with more meaningful
send_messages flag

11 years agouse lv_layer
Zdenek Kabelac [Fri, 1 Feb 2013 23:16:36 +0000 (00:16 +0100)]
use lv_layer

11 years agoactivate: add lv_layer function
Zdenek Kabelac [Fri, 1 Feb 2013 10:09:34 +0000 (11:09 +0100)]
activate: add lv_layer function

Add function to return layer name for LV.

11 years agolibdm: fix segault for truncated string token.
Zdenek Kabelac [Fri, 1 Feb 2013 10:07:44 +0000 (11:07 +0100)]
libdm: fix segault for truncated string token.

This patch fixes problem reported here:

https://www.redhat.com/archives/dm-devel/2013-January/msg00311.html

Fixing it by separating function for duplicating string token.

---
When /etc/lvm/lvm.conf is truncated at the first '"' of a line, all LVM
utilities crash with a segfault.

The segfault only seems to occur if the last character is the first '"'
(double quote) of a line. If you truncate it at any other point, lvm
detects the error and report parse error

lvm.conf ends like this.

$hexdump -C lvm.conf
....
69 72 20 3d 20 22 2f 64  65 76 22 0a 0a 0a 20 20  |ir = "/dev"...  |
20 20 23 20 41 6e 20 61  72 72 61 79 20 6f 66 20  |  # An array of |
64 69 72 65 63 74 6f 72  69 65 73 20 74 68 61 74  |directories that|
20 63 6f 6e 74 61 69 6e  20 74 68 65 20 64 65 76  | contain the dev|
69 63 65 20 6e 6f 64 65  73 20 79 6f 75 20 77 69  |ice nodes you wi|
73 68 0a 20 20 20 20 23  20 74 6f 20 75 73 65 20  |sh.    # to use |
77 69 74 68 20 4c 56 4d  32 2e 0a 20 20 20 20 73  |with LVM2..    s|
63 61 6e 20 3d 20 5b 20  22 2f 78 22 2c 0a 20 20  |can = [ "/x",.  |
20 20 20 20 20 20 20 20  20 20 20 22              | "|
...

Reported-by: dongmao zhang <dmzhang suse com>
11 years agocleanup: postpone lv_is_thin_volume check
Zdenek Kabelac [Fri, 1 Feb 2013 23:44:07 +0000 (00:44 +0100)]
cleanup: postpone lv_is_thin_volume check

Code move to make it easier to follow and
call _add_dev_to_dtree() in the separate if() branch
for thin volumes.

11 years agoWHATS_NEW: Better description of previous change
Jonathan Brassow [Fri, 1 Feb 2013 17:52:25 +0000 (11:52 -0600)]
WHATS_NEW:  Better description of previous change

11 years agoRAID: Improve 'lvs' attribute reporting of RAID LVs and sub-LVs
Jonathan Brassow [Fri, 1 Feb 2013 17:33:54 +0000 (11:33 -0600)]
RAID:  Improve 'lvs' attribute reporting of RAID LVs and sub-LVs

There are currently a few issues with the reporting done on RAID LVs and
sub-LVs.  The most concerning is that 'lvs' does not always report the
correct failure status of individual RAID sub-LVs (devices).  This can
occur when a device fails and is restored after the failure has been
detected by the kernel.  In this case, 'lvs' would report all devices are
fine because it can read the labels on each device just fine.
Example:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)

However, 'dmsetup status' on the device tells us a different story:
  [root@bp-01 lvm2]# dmsetup status vg-lv
  0 1024000 raid raid1 2 DA 1024000/1024000

In this case, we must also be sure to check the RAID LVs kernel status
in order to get the proper information.  Here is an example of the correct
output that is displayed after this patch is applied:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r-p   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor-p          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor-p          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)

The other case where 'lvs' gives incomplete or improper output is when a
device is replaced or added to a RAID LV.  It should display that the RAID
LV is in the process of sync'ing and that the new device is the only one
that is not-in-sync - as indicated by a leading 'I' in the Attr column.
(Remember that 'i' indicates an (i)mage that is in-sync and 'I' indicates
an (I)mage that is not in sync.)  Here's an example of the old incorrect
behaviour:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
[root@bp-01 lvm2]# lvconvert -m +1 vg/lv; lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--     0.00 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   Iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   Iwi-aor--          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)                            ** Note that all the images currently are marked as 'I' even though it is
   only the last device that has been added that should be marked.

Here is an example of the correct output after this patch is applied:
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--   100.00 lv_rimage_0(0),lv_rimage_1(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
[root@bp-01 lvm2]# lvconvert -m +1 vg/lv; lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   rwi-a-r--     0.00 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   iwi-aor--          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor--          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)
** Note only the last image is marked with an 'I'.  This is correct and we can
   tell that it isn't the whole array that is sync'ing, but just the new
   device.

It also works under snapshots...
[root@bp-01 lvm2]# lvs -a -o name,vg_name,attr,copy_percent,devices vg
  LV            VG   Attr      Cpy%Sync Devices
  lv            vg   owi-a-r-p    33.47 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0)
  [lv_rimage_0] vg   iwi-aor--          /dev/sda1(1)
  [lv_rimage_1] vg   Iwi-aor-p          /dev/sdb1(1)
  [lv_rimage_2] vg   Iwi-aor--          /dev/sdc1(1)
  [lv_rmeta_0]  vg   ewi-aor--          /dev/sda1(0)
  [lv_rmeta_1]  vg   ewi-aor-p          /dev/sdb1(0)
  [lv_rmeta_2]  vg   ewi-aor--          /dev/sdc1(0)
  snap          vg   swi-a-s--          /dev/sda1(51201)

11 years agoRAID: Cache previous results of lv_raid_dev_health for future use
Jonathan Brassow [Fri, 1 Feb 2013 17:32:18 +0000 (11:32 -0600)]
RAID:  Cache previous results of lv_raid_dev_health for future use

We can avoid many dev_manager (ioctl) calls by caching the results of
previous calls to lv_raid_dev_health.  Just considering the case where
'lvs -a' is called to get the attributes of a RAID LV and its sub-lvs,
this function would be called many times.  (It would be called at least
7 times for a 3-way RAID1 - once for the health of each sub-LV and once
for the health of the top-level LV.)  This is a good idea because the
sub-LVs are processed in groups along with their parent RAID LV and in
each case, it is the parent LV whose status will be queried.  Therefore,
there only needs to be one trip through dev_manager for each time the
group is processed.

11 years agoRAID: Add RAID status accessibility functions
Jonathan Brassow [Fri, 1 Feb 2013 17:31:47 +0000 (11:31 -0600)]
RAID:  Add RAID status accessibility functions

Similar to the way thin* accesses its kernel status, we add a method
for RAID to grab the various values in its status output without the
higher levels (LVM) having to understand how to parse the output.
Added functions include:
        - lib/activate/dev_manager.c:dev_manager_raid_status()
          Pulls the status line from the kernel

        - libdm/libdm-deptree.c:dm_get_status_raid()
          Parses status line and puts components into dm_status_raid struct

        - lib/activate/activate.c:lv_raid_dev_health()
          Accesses dm_status_raid to deliver raid dev_health string

The new structure and functions can provide a more unified way to access
status information.  ('lv_raid_percent' could switch to using these
functions, for example.)

11 years agoTest (RAID): Test for RAID10 activations when devices are missing
Jonathan Brassow [Mon, 28 Jan 2013 18:32:33 +0000 (12:32 -0600)]
Test (RAID):  Test for RAID10 activations when devices are missing

Test the fix for bug 889358.  RAID10 had been failing to activate when
there were devices that had failed in more than one mirror set.

This page took 0.088329 seconds and 5 git commands to generate.