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

9832 Commits

Author SHA1 Message Date
Zdenek Kabelac
b2988a917a lvconvert: update help
Extend help for lvconvert.
Use COMMON_OPTS for some common options.
2014-07-11 13:32:22 +02:00
Zdenek Kabelac
970989655f lvconvert: update for thin a cache
Major update of lvconvert code to handle cache and thin.
related targets.

Code tries to unify handling of cache and thin pools.
Better supports lvm2 syntax:

lvconvert --type cache --cachepool vg/pool vg/cache
lvconvert --type thin --thinpool vg/pool vg/extorg
lvconvert --type cache-pool vg/pool
lvconvert --type thin-pool vg/pool

as well as:

lvconvert --cache --cachepool vg/pool vg/cache
lvconvert --thin --thinpool vg/pool vg/extorg
lvconvert --cachepool vg/pool
lvconvert --thinpool vg/pool

While catching much more command line errors.
(Yet couple paths still needs more tests)

Detects as much cmdline errors prior opening VG.

Uses single lvconvert_name_params to convert LV names.

Detects as much incompatibilies in VG prior prompting.

Uses single prompt to confirm whole conversion.

TODO: still the code needs fixes...
2014-07-11 13:32:22 +02:00
Zdenek Kabelac
fe3ea94e58 cleanup: shift detection of chunksize sign
Sign should be checked prior opening of VG.
Since get_pool_params() needs profiles,
we need to move check for sign earlier.
2014-07-11 13:32:22 +02:00
Zdenek Kabelac
9955204e0d cleanup: reorder code
Simplify code.
2014-07-11 13:32:21 +02:00
Zdenek Kabelac
de1ee0bc52 cleanup: move merge option
Put long --merge option into section with long options.
2014-07-11 13:32:21 +02:00
Zdenek Kabelac
d5d883d91b cleanup: indent changes 2014-07-11 13:32:21 +02:00
Zdenek Kabelac
f7d6614061 cache: warn about metadata size limits
Cache pools are similar as with thin pools.
Add (needs %s) - since cache has currently
a bit strange need for extra few kb over
our default 4M extent size so make it more obvious.
2014-07-11 13:31:19 +02:00
Zdenek Kabelac
04b8e55f2a lvconvert: relocate mirror tests 2014-07-11 12:57:45 +02:00
Zdenek Kabelac
1931d1e58e tools: arg_is_any_set and arg_is_only_set
Helpful functions to more easily detect conflicting
set of options.
2014-07-11 12:57:45 +02:00
Zdenek Kabelac
c0c1ada88e pool: callback handle cache
Extend the callback functionality to handle also cache pools.

cache_check is now executed on cachepool metadata when
it's activated and deactivated.
2014-07-11 12:57:45 +02:00
Zdenek Kabelac
120bd2d6b1 pool: move code to pool source file
More code is used commonly for all pool types (cache & thin)
2014-07-11 12:57:25 +02:00
Zdenek Kabelac
4db5d78cef display: show C only for cache and cachepool
Keep target type (attr6) as the cache data and metadata volume has.
(i.e. when will show 'raid' type if metadata is raid)
2014-07-11 12:50:44 +02:00
Zdenek Kabelac
ba048612a3 lvchange: just skip on cache pool 2014-07-11 12:50:06 +02:00
Zdenek Kabelac
8932d4a625 lv_is_pool: add new defines
Defines for lv_is_pool() and  lv_is_pool_metadata()
Also update comments for prompts for their current meaning.
(Though maybe they should be renamed)
2014-07-11 12:50:06 +02:00
Zdenek Kabelac
56c5ad7b19 lvconvert: snapshot prompts to confirm conversion
Since the type passed LV is changed and content of data detroyed,
query user with prompt to confirm this operation.
Also add a proper wiping of header.

Using '--yes' will skip this prompt:

lvconvert -s --yes vg/lv vg/lvcow
2014-07-11 12:49:55 +02:00
Zdenek Kabelac
64828d877e lvconvert: fix return codes
Error codes in some function are directly used
as command result - thus return 0 is not error code,
but success - switch to proper ECMD_FAILED.
2014-07-11 12:49:02 +02:00
Zdenek Kabelac
baf825331c prompt: display 'n' for EOF
When EOF is detect - it could be either 'Ctrl+C'
or empty stdin.

For Ctrl+C there is visual ^C sign.
For EOF print 'n' so decision is clear in debug print.
2014-07-11 12:47:41 +02:00
Zdenek Kabelac
39cb8aa3ab configure 2014-07-11 12:47:41 +02:00
Zdenek Kabelac
f9d80c9d31 cache: add tool support
Introducing cache tool support.
2014-07-11 12:47:35 +02:00
Peter Rajnoha
5c3d894013 metadata: fix ALLOCATABLE_PV for lvm1 format
This is addendum for commit 6dc7b783c8.

LVM1 format stores the ALLOCATABLE flag directly in PV header, not
in VG metadata. So the code needs to be fixed further to work
properly for lvm1 format so that the correct PV header is written
(the flag is set only if the PV is in some VG, unset otherwise).
2014-07-11 12:24:15 +02:00
Peter Rajnoha
fd5912762b report: display 'unknown' value for lv_active_remotely field if the LV is also active locally
Currently, we can't determine whether the LV is active remotely
or not in that case.
2014-07-11 11:56:50 +02:00
Peter Rajnoha
c9ae21798e report: display 'unknown' value for active/active_locally/active_remotely/active_exclusively if info bypassed
Before the patch:

$ lvs -o name,active vg/lvol1 --driverloaded n
  WARNING: Activation disabled. No device-mapper interaction will beattempted.
  LV    Active
  lvol1 active

With this patch applied:
$ lvs -o name,active vg/lvol1 --driverloaded n
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  LV    Active
  lvol1 unknown

The same for active_{locally,remotely,exclusively} fields.
Also, rename headings for these fields (ActLocal/ActRemote/ActExcl).
2014-07-11 11:15:06 +02:00
Peter Rajnoha
52af0dfbc0 report: display 'unknown' value for LVSINFO fields if unable to get info
If the lv_info call fails for whatever reason/INFO dm ioctl fails or
the dm driver communication is disabled (--driverloaded n), make
sure we always display "unknown" for LVSINFO fields as that's exactly
what happens - we don't know the state.

Before the patch:

$ lvs -o name,device_open --driverloaded n
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  Command failed with status code 5.

With this patch applied:

$ lvs -o name,device_open --driverloaded n
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  LV        DevOpen
  lvol1        unknown
2014-07-11 10:18:59 +02:00
Jonathan Brassow
f33d75e2e5 test: Test failing due to too few PVs
Commit 33d69162e4 reduced the number of
PVs to a level where the test could not function.  (It is impossible
to replace 3 PVs of a 4-way RAID1 LV if there are only 5 PVs.)
2014-07-10 18:53:46 -05:00
Peter Rajnoha
3063b48602 report: also report linear and striped for lv_target_type 2014-07-10 16:41:42 +02:00
Peter Rajnoha
d169ff1e03 conf: add report/list_item_separator lvm.conf option
For example:

$ lvm dumpconfig report/list_item_separator
list_item_separator=","

$ lvs -o name,tags vg/lvol1
  LV    LV Tags
  lvol1 a,x,y

$ lvm dumpconfig report/list_item_separator
list_item_separator=":"

$ lvs -o name,tags vg/lvol1
  LV    LV Tags
  lvol1 ay
2014-07-10 16:18:45 +02:00
Peter Rajnoha
e38af4e28f libdm: report: fix string list internal representation if delimiter is composed of more than one char 2014-07-10 16:18:05 +02:00
Peter Rajnoha
1e5ec893c7 tests: LV's zero field now reported as binary field 2014-07-10 15:30:28 +02:00
Peter Rajnoha
e2448bb0dc report: report LV's zero field as binary field
Like other binary fields we already have:

$ lvs -o name,zero vg/lvx vg/pool vg/pool1
  LV    Zero
  lvx   unknown
  pool
  pool1    zero

$ lvs -o name,zero vg/lvx vg/pool vg/pool1 --binary
  LV    Zero
  lvx     -1
  pool     0
  pool1    1
2014-07-10 15:25:01 +02:00
Peter Rajnoha
e31ec38d8e report: reserved value: description for undefined value 2014-07-10 13:42:16 +02:00
Peter Rajnoha
175de52ded cleanup: also use values.h for final dm_report_reserved_value array composition 2014-07-10 13:37:40 +02:00
Peter Rajnoha
f598aa38ae cleanup: report reserved value macros 2014-07-10 11:54:37 +02:00
Peter Rajnoha
fafd10d564 conf: command_profile_template: global/binary_values_as_numeric -> report/binary_values_as_numeric 2014-07-10 09:48:45 +02:00
Peter Rajnoha
a4e798bd30 report: add values.h for per-field reserved value declaration 2014-07-10 09:41:21 +02:00
Jonathan Brassow
be75076dfc activation: Add "degraded" activation mode
Currently, we have two modes of activation, an unnamed nominal mode
(which I will refer to as "complete") and "partial" mode.  The
"complete" mode requires that a volume group be 'complete' - that
is, no missing PVs.  If there are any missing PVs, no affected LVs
are allowed to activate - even RAID LVs which might be able to
tolerate a failure.  The "partial" mode allows anything to be
activated (or at least attempted).  If a non-redundant LV is
missing a portion of its addressable space due to a device failure,
it will be replaced with an error target.  RAID LVs will either
activate or fail to activate depending on how badly their
redundancy is compromised.

This patch adds a third option, "degraded" mode.  This mode can
be selected via the '--activationmode {complete|degraded|partial}'
option to lvchange/vgchange.  It can also be set in lvm.conf.
The "degraded" activation mode allows RAID LVs with a sufficient
level of redundancy to activate (e.g. a RAID5 LV with one device
failure, a RAID6 with two device failures, or RAID1 with n-1
failures).  RAID LVs with too many device failures are not allowed
to activate - nor are any non-redundant LVs that may have been
affected.  This patch also makes the "degraded" mode the default
activation mode.

The degraded activation mode does not yet work in a cluster.  A
new cluster lock flag (LCK_DEGRADED_MODE) will need to be created
to make that work.  Currently, there is limited space for this
extra flag and I am looking for possible solutions.  One possible
solution is to usurp LCK_CONVERT, as it is not used.  When the
locking_type is 3, the degraded mode flag simply gets dropped and
the old ("complete") behavior is exhibited.
2014-07-09 22:56:11 -05:00
Alasdair G Kergon
a098cba0eb report: Rename common fields to special fields.
Change the help heading from 'Common Fields' to 'Special Fields' for
the fields: selected, help, ?

Remove the code that does 'all' processing with these special fields as
each of them changes the behaviour of the command in an undesirable way.

'lvs -o all,selected' was of course just printing help.
(via internal expansion to 'lv_all,common_all')

and if we ignored the help fields, then '-o common_all' would still
pull in 'selected' and change the way rows were output.
2014-07-09 23:33:09 +01:00
Peter Rajnoha
46ea315f09 report: also recognize 'yes'/'no' for selection criteria on binary fields
We have 1/"descriptive word"/"yes" for 1 and 0/"no" for 0.
For example (the new recognized values are "yes" and "no"):

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2
  LV    DevOpen
  root        open
  swap        open
  lvol1       open
  lvol2

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=open'
  LV    DevOpen
  root        open
  swap        open
  lvol1       open

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=1'
  LV    DevOpen
  root        open
  swap        open
  lvol1       open

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=yes'
  LV    DevOpen
  root        open
  swap        open
  lvol1       open

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=0'
  LV    DevOpen
  lvol2

$ lvs -o name,device_open fedora vg/lvol1 vg/lvol2 -S 'device_open=no'
  LV    DevOpen
  lvol2
2014-07-09 15:57:05 +02:00
Peter Rajnoha
c1bed36b67 cleanup: move _lvactive_disp and _thinzero_disp under 'attribute' display functions
So all attribute reporting functions are all in one section of code
for quick orientation (all these functions are defined in the order
of their attribute character displayed in pv/vg/lv_attr field).
2014-07-09 15:57:05 +02:00
Peter Rajnoha
bccc2bef33 report: add lv_active_{locally,remotely,exclusively} LV reporting fields
lv_active_{locally,remotely,exclusively} display the original
"lv_active" field in a more separate way so that we can create
selection criteria in a binary-based form (yes/no).
2014-07-09 15:57:05 +02:00
Peter Rajnoha
b6ac8819f6 report: 'whether' -> 'set if' in field description 2014-07-09 15:57:05 +02:00
Peter Rajnoha
ccab185aa7 cleanup: use macros for definition of reporting/selection reserved values
The macros for reserved value definition makes the process a bit easier,
but there's still a place for improvement and make this even more
transparent. We can optimize and provide better automatism here later on.
2014-07-09 15:55:54 +02:00
Peter Rajnoha
1a05862732 report: report unknown/-1 for binary fields with unknown value
Also respect --binary arg and/or report/binary_values_as_numeric
when displaying unknown values. If textual form is used, use "unknown",
if numeric value is used, use "-1" (which we already use to denote
unknown numeric values in other reports like lv_kernel_major and
lv_kernel_minor).
2014-07-08 16:16:02 +02:00
Peter Rajnoha
f76879ba44 conf: comment out devices/preferred_names and filter setting
This avoids creating void matchers which have no effect anyway and
they just use resources. Also, it makes lvm dumpconfig --type diff
to mark these settings properly as not being different from defaults
(where by default, devices/preferred_names as well as devices/filter
are void).

Also, add a few comments about builtin rules used to select device
alias in case preferred_names is not defined or it doesn't match
any of device aliases.
2014-07-08 10:22:59 +02:00
Peter Rajnoha
f6001465ef lv_manip: pool-metadata-spare is just a spare LV, not tightly bound to thin or cache 2014-07-07 17:02:06 +02:00
Peter Rajnoha
4b65d7ec72 WHATS_NEW: commits a473435..7021c8f1 2014-07-07 16:52:43 +02:00
Peter Rajnoha
9e1c4a3818 report: addendum for previous commit
Really call lv_info only if needed!
2014-07-07 16:28:13 +02:00
Peter Rajnoha
83b55c2dfb report: fix segfault while reporting PV/LV segment fields together with LV fields needeing device status (LVSINFO)
There was missing lv_info call for situations where there were
mixed PV/LV segment fields together with LVSINFO fields which
require extra lv_info call for LV device status. This ended up
with NULL lvinfo passed to the field reporting functions, hence
the segfault.
2014-07-07 15:54:13 +02:00
Peter Rajnoha
6dc7b783c8 metadata: fix regression causing PVs not in VGs to be marked as allocatable
If the PV is not yet in a VG, it's not allocatable.
A regression introduced by commit 0283c439ec
(_pv_create) and later commit a7ca101517
(pv_read).
2014-07-07 14:07:21 +02:00
Peter Rajnoha
7021c8f1a4 report: define reserved values/synonyms for some attribute fields
All binary attr fields have synonyms so selection criteria can use
either 0/1 or words to match against the field value (base type
for these binary fields is numeric one - DM_REPORT_FIELD_TYPE_NUMBER
so words are registered as reserved values):

pv_allocatable          - "allocatable"
pv_exported             - "exported"
pv_missing              - "missing"

vg_extendable           - "extendable"
vg_exported             - "exported"
vg_partial              - "partial"
vg_clustered            - "clustered"

lv_initial_image_sync   - "initial image sync", "sync"
lv_image_synced_names   - "image synced", "synced"
lv_merging_names        - "merging"
lv_converting_names     - "converting"
lv_allocation_locked    - "allocation locked", "locked"
lv_fixed_minor          - "fixed minor", "fixed"
lv_merge_failed         - "merge failed", "failed"

For example, these three are all equivalent:

$ lvs -o name,fixed_minor -S 'fixed_minor=fixed'
  LV    FixMin
  lvol8 fixed minor

$ lvs -o name,fixed_minor -S 'fixed_minor="fixed minor"'
  LV    FixMin
  lvol8 fixed minor

$ lvs -o name,fixed_minor -S 'fixed_minor=1'
  LV    FixMin
  lvol8 fixed minor

The same with binary output - it has no effect on this functionality:

$ lvs -o name,fixed_minor --binary -S 'fixed_minor=fixed'
  LV    FixMin
  lvol8          1

$ lvs -o name,fixed_minor --binary -S 'fixed_minor="fixed
minor"'
  LV    FixMin
  lvol8          1

[1] f20/~ # lvs -o name,fixed_minor --binary -S 'fixed_minor=1'
  LV    FixMin
  lvol8          1
2014-07-04 15:50:50 +02:00
Peter Rajnoha
0956fd230f report: adapt selection code to recognize per-field reserved values
In contrast to per-type reserved values that are applied for all fields
of that type, per-field reserved values are only applied for concrete
field only.

Also add 'struct dm_report_field_reserved_value' to libdm for per-field
reserved value definition. This is defined by field number (an index
in the 'fields' array which is given for the dm_report_init_with_selection
function during report initialization) and the value to use for any
of the specified reserved names.
2014-07-04 15:50:50 +02:00