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

2423 Commits

Author SHA1 Message Date
Zdenek Kabelac
128131dbc5 lvconvert: external detects more conflicts
Check for more prohibited types for external origin conversion.
TODO: Move this function to separate validation code.
(Continuing in release fixes.)
2014-10-24 16:39:31 +02:00
Zdenek Kabelac
237c54802c tools: read yes_no_arg via int_value
yes_no_arg is already parsed so read parsed value as int.
2014-10-24 16:39:31 +02:00
Zdenek Kabelac
5bdf48b489 tools: refactor reporter code
Use new libdm macro DM_LIST_HEAD_INIT().
Embeded 'free' segment type (so it's not needed in the list)
Drop assignments of 0,NULL since they are defaults.
2014-10-24 16:39:31 +02:00
Zdenek Kabelac
1c7aae40a1 raid: query lock holder
Ask for lock the proper LV.
Use the top-most LV to query for locally exclusive lock.

The rest of operations are then using 'lv_info()'

TODO:
  Check all devices are reloaded from proper level.
  In general any query on lv_is_active is supposed to be running
  ona lv_lock_holder() volume.
2014-10-24 16:39:31 +02:00
Zdenek Kabelac
e901a87a69 cache: better error message 2014-10-24 16:39:31 +02:00
Zdenek Kabelac
9411c19b31 segments: introduce lvseg_name
Instead of segtype->ops->name()  introduce lvseg_name().

This also allows us to leave name() function 'empty' for default
return of segtype->name.

TODO: add functions for rest of ops->
2014-10-24 16:39:30 +02:00
Peter Rajnoha
4988d799a2 liblvm2cmd: recognize quotes properly when splitting cmd line string into argv array fields
Fix lvm_split that is called when cmd line string is separated into
argv fields to recognize quote chars ('\'" and '"') properly and
when these quotes are used, consider the text within quotes as one
argument, do not separate it based on space characters inside.

The lvm_split is used during processing lvm shell command line or
when calling lvm commands through cmdlib (e.g. dmeventd plugins).

For example, the lvm shell scenario:

Before this patch:
$lvm
lvm> lvs --config 'global{ suffix=0 }'
  Parse error at byte 9 (line 1): unexpected token
  Failed to set overridden configuration entries.

With this patch applied:
$lvm
lvm> lvs --config 'global{ suffix=0 }'
  LV    VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log  Cpy%Sync Convert
  root  fedora -wi-ao----   9.00g
  swap  fedora -wi-ao---- 512.00m

(Exactly the same problem is hit when calling LVM commands with
quoted arguments via lvm2cmd lib in dmeventd plugins.)
2014-10-17 14:03:43 +02:00
David Teigland
a6c294c5d0 toollib: remove unsed variable in process_each_segment_in_pv
Was left unused from the last change to this function.
2014-10-16 15:16:52 -05:00
David Teigland
23a38d242b toollib: remove dead code
Because of the recent change to process_each_pv(), the vg is always
provided when the pv is in a vg.  is_pv(pv) means the pv is in a vg,
which means that the vg arg will not be NULL, which means the removed
block of code is not needed.
2014-10-15 15:47:45 -05:00
Alasdair G Kergon
5e6e2d6b1b vgcreate: Permit non-power-of-2 extent sizes.
Relax validation to permit extent sizes > 128KB that are not powers of 2
with lvm2 format.  Existing code was already capable of handling this.
2014-10-14 18:12:15 +01:00
Petr Rockai
22a6b0e40b lvchange: Allow appropriate actions on cache (in addition to thin) pools. 2014-10-13 16:21:41 +02:00
Zdenek Kabelac
b59335fb39 toollib: validate_restricted_lvname_param
Lets make a separate new function to validate names that has
to follow up restriction rules.
2014-10-08 11:35:50 +02:00
Alasdair G Kergon
f3bb1c018f vgremove: Use process_each_lv_in_vg. 2014-10-07 16:45:45 +01:00
Zdenek Kabelac
0cbb381e15 lvcreate: regression fix on lv name limits
When we are given an existing LV name - it needs to be allowed
to pass in even restricted name as the LV could have existed
long before we introduced some new restriction on prefix/suffix.i

Fix the regression on name limits and drop restriction to be applied
on any existing LVs - only the new created LV names have to be
complient with current name restrictions.

FIXME: we are currently using restricted names incorrectly in few
other places - device_is_usable() skips restricted names,
and udev flags are also incorrectly set for restricted names
so these LVs are not getting links properly.
2014-10-07 15:52:31 +02:00
Zdenek Kabelac
27ff61d012 cleanup: rename _name, _lv and _size
Use some standard names for lv char * names, logical_volume * lv
and sizes internally.
2014-10-07 15:51:53 +02:00
Petr Rockai
b66f16fd63 lvconvert: Allow --repair and --splitmirrors on reserved-name LVs. 2014-10-07 08:58:24 +02:00
David Teigland
8dc5f42254 metadata: Use flags to control warnings.
The warnings arg was used to enable logging of warnings
when reading a PV.  This arg is turned into a set of flags
with the WARN_PV_READ flag matching the existing behavior.

A new flag WARN_INCONSISTENT is added that will cause
vg_read_internal() to log the "VG is not consistent"
warning so the various callers do not need to log
this warning themselves.

A new vg_read flag READ_WARN_INCONSISTENT is used from
reporting to enable the WARN_INCONSISTENT flag in
vg_read_internal.

[Committed by agk with cosmetic changes and tweaks.]
2014-10-07 01:15:43 +01:00
David Teigland
e458fc9a6a vgreduce: Use process_each_pv.
Adapt process_each_pv for use by vgreduce in the non-repair case.

[Committed by agk with cosmetic changes and tweaks.]
2014-10-07 01:15:43 +01:00
David Teigland
f1a000a477 toollib: Rewrite process_each_pv.
Process PVs by iterating through VGs, then iterating through
devices if the command needs to process non-PV devices.
The process_single function can always use the VG and PV args.

[Committed by agk with cosmetic changes and tweaks.]
2014-10-07 01:15:43 +01:00
Alasdair G Kergon
97b16ec26f toollib: Shuffle PV functions. 2014-10-06 22:02:00 +01:00
Alasdair G Kergon
1115a9ea51 toollib: Remove unused functions from header file. 2014-10-06 15:22:01 +01:00
Zdenek Kabelac
b7a78d81bc cleanup: indent 2014-10-06 15:23:08 +02:00
Zdenek Kabelac
73c74d582c cleanup: lvconvert use standard function exit
Use 1|0 inside _lvconvert_splitsnapshot to match rest of code.
2014-10-06 15:23:07 +02:00
Zdenek Kabelac
57a52e7878 lvcreate: validate sizes
Earlier validation of --size and --extents.
Reject 0 size on command line instantly.
2014-10-06 15:23:07 +02:00
Zdenek Kabelac
a0693da97f toolib: early validation of chunk size
Since we now have validate_pool_chunk_size() we could
validate entered values directly prior openning vg.
2014-10-06 15:23:07 +02:00
Zdenek Kabelac
79ca382b2c vg/lvremove: support --yes
Make --yes equivalent to DONT_PROMT (--force).

So user could use 'lvremove --yes vg/lvol1' skipping prompt.
2014-10-06 15:22:24 +02:00
Zdenek Kabelac
cb49dd4aa4 lvconvert: splitsnapshot supports --yes
Handle --yes arg to skip prompt.
2014-10-06 15:22:22 +02:00
Zdenek Kabelac
b2b18a5f8b lvconvert more test for thin external origin
Some LV types were not properly disallowed to be used as external origin.
2014-10-06 15:21:36 +02:00
Zdenek Kabelac
60d2a63368 lvconvert: cache and thin conversion validation
More test for supported conversion.
2014-10-06 15:18:06 +02:00
Zdenek Kabelac
ee344f1a9e lvconvert: validate cache conversion to snapshot
Cache cannot be converted into snapshot cow nor origin.
2014-10-06 15:18:06 +02:00
Zdenek Kabelac
d46c2f1c94 cache: improve creation code
Move code to better locations.
Improve test and remove invalid ones
(i.e. no reason to require cache size to be >= then origin).

Correctly comment where the code is doing actual conversion
of other existing volume - we do already a similar thing with
external origins.

Lots of new command line options and combinations is now supported.
Hopefully older syntax still works as well.

lvcreate --cache --cachepool vg/pool  -l1
lvcreate --type cache --cachepool vg/pool  -l1
lvcreate --type cache-pool vg/pool  -l1
lvcreate --type cache-pool --name pool vg  -l1
... and many many more ...
2014-10-06 15:18:06 +02:00
Zdenek Kabelac
20803f2275 lvcreate: reuse validation of names
Use validate_lvname_param() for name validation.
2014-10-06 15:18:06 +02:00
Zdenek Kabelac
a0cfc5eee2 lvconvert: reuse cache validation
Validation is now already in
validate_lv_cache_create() so reuse it.

Also properly rename var origin -> origin_lv.
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
a8497e329b lvconvert: options splitcache, split, uncache
--splitcache
  Splits only cached LV (also pool could be specified).
  Detaches cachepool from cached LV.

  --split
  Should be univerzal command to split various complex targets.
  At this moment it knows cache.

  --uncache
  Opposite command to --cache. Detaches and DELETES cachepool for
  cached LV.

Note: we support thin pool cached metadata device for uncaching.
Also use may specify wither cached LV or association cachepool device
to request split of cache.
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
4e9fbb4b96 toollib: validate also name
In validate_lvname_param() call also validate_name().
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
68bf974769 lvcreate: support --cache and --cachepool
Enable in cmdline options for cache and cachepool.
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
fc77e4291b commands: support shortcut -H for cache objects
Introduce cache_long_ARG for those instancies
where --cache is not related to caching LV.
(pvchange,vg|lv|pvscan).

cache_ARG is now with -H shortcut.
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
1a6c892864 thin: better thin snapshot error detection
While creating thin snapshot, we cannot use size argument.
2014-10-06 15:18:05 +02:00
Zdenek Kabelac
1ef660be46 thin: lvcreate improve check of thin params
Use arg_from_list_is_set()
Resolve pool_lv at one single place.
Replace use of find_lv_in_vg() with find_lv().
2014-10-06 14:53:16 +02:00
Zdenek Kabelac
487723e0df lvcreate: refactor code
Over the time lvcreate code has accumulated various hacks.
So try to move that code in right places.

Detect all types early in _lvcreate_params() so functions like
_read_size_params() do not need to change volume types.

Also ultimately respect give volume --type, that its shortcut
(-T, H, -m, -s) and after that options which do type estimation.
(i.e. --cachepool, --thinpool)

Avoid repeative tests - if we know all types are decode at once
place we can 'optimize' number of validations.
2014-10-06 14:52:16 +02:00
Petr Rockai
d2f901f04f lvconvert: Forward --splitmirror to a cache origin when applicable. 2014-10-06 08:11:06 +02:00
David Teigland
91615603cd toollib: Rewrite process_each_lv.
Copy the same form as the new process_each_vg.
Replace unused struct cmd_vg and cmd_vg_read() replicator
code with struct vg and vg_read() directly.
The failed_lvnames arg is no longer used since the
cmd_vg replicator wrapper was removed.

[Committed by agk with cosmetic changes and tweaks.]
2014-10-03 23:37:49 +01:00
David Teigland
bfb6a4ecc6 toollib: Rewrite process_each_vg.
Split VG argument collection from processing.
This allows the two different loops through VGs to
be replaced by a single loop.
Replace unused struct cmd_vg and cmd_vg_read() replicator
code with struct vg and vg_read() directly.

[Committed by agk with cosmetic changes and tweaks.]
2014-10-03 20:47:19 +01:00
David Teigland
17ab39f743 cache: include cache mode in vg metadata and display
The cache mode of a new cache pool is always explicitly
included in the vg metadata.  If a cache mode is not
specified on the command line, the cache mode is taken
from lvm.conf allocation/cache_pool_cachemode, which
defaults to "writethrough".

The cache mode can be displayed with lvs -o+cachemode.
2014-10-02 11:17:41 -05:00
Peter Rajnoha
5011cac9cf filters: add cmd->full_filter - composite of cmd->filter and cmd->lvmetad_filter
There are actually three filter chains if lvmetad is used:
  - cmd->lvmetad_filter used when when scanning devices for lvmetad
  - cmd->filter used when processing lvmetad responses
  - cmd->full_fiilter (which is just cmd->lvmetad_filter + cmd->filter chained together) used
    for remaining situations

This patch adds the third one - "cmd->full_filter" - currently this is
used if device processing does not fall into any of the groups before,
for example, devices which does not have the PV label yet and we're just
creating a new one or we're processing the devices where the list of the
devices (PVs) is not returned by lvmetad initially.

Currently, the cmd->full_filter is used exactly in these functions:
  - lvmcache_label_scan
  - _pvcreate_check
  - pvcreate_vol
  - lvmdiskscan
  - pvscan
  - _process_each_label

If lvmetad is used, then simply cmd->full_filter == cmd->filter because
cmd->lvmetad_filter is NULL in this case.
2014-10-02 13:06:46 +02:00
David Teigland
1cdb8766a7 tools: Add ENABLE_ALL_DEVS flag.
The ENABLE_ALL_DEVS flag is added to the command structure
for commands that should process all devs (pvs and non-pvs)
when they call process_each_pv and the command includes the
--all arg.  This will be used in a later process_each_pv patch.
2014-10-01 22:58:23 +01:00
David Teigland
e6ab275aa0 tools: Add ALL_VGS_IS_DEFAULT flag.
The ALL_VGS_IS_DEFAULT flag is added to the command structure
for commands that should process all vgs when they call
process_each_vg or process_each_lv with no args.
This will be used in later patches to process_each functions.
2014-10-01 22:58:00 +01:00
Peter Rajnoha
a5f01dad22 filters: refresh filters when lvmetad use is toggled
We need to use proper filter chain when we disable lvmetad use
explicitly in the code by calling lvmetad_set_active(0) while
overriding existing configuration. We need to reinitialize filters
in this case so proper filter chain is used. The same applies
for the other way round - when we enable lvmetad use explicitly in
the code (though this is not yet used).
2014-09-30 16:08:05 +02:00
Peter Rajnoha
00d8ab8492 refactor: make it possible to select what to check exactly when calling device_is_usable fn
Currently, there are 5 things that device_is_usable function checks
(for DM devices only, of course):
  - is device empty?
  - is device blocked? (mirror)
  - is device suspended?
  - is device composed of an error target?
  - is device name/uuid reserved?

If answer to any of these questions is "yes", then the device is not usable.
This patch just adds possibility to choose what to check for exactly - the
device_is_usable function now accepts struct dev_usable_check_params make
this selection possible. This is going to be used by subsequent patches.
2014-09-30 13:11:58 +02:00
Zdenek Kabelac
f3e9ff7179 cleanup: drop unused variable 2014-09-28 13:49:01 +02:00
Zdenek Kabelac
ad60805ffd lvconvert: switch to validate_lvname_param
Use new toollib function for validation.
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
0d4baeba18 toollib: introduce validate_lvname_param
Function for parsing and validating of lvname parameter.
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
89e1190ef0 cleanup: rename func
Update name of function read_and_validate_major_minor
and put it into the right header file toollib.h.

(In release update for f09f85d027)
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
911d6efa51 toollib: refactor extract_vgname
Split internals of extract_vgname into _extract_vgname.
This common code will be used for other similar function.

Reuse skip_dev_dir() instead of less mature coded to skip
device dir.

Instead of duplicating full vg/lv name - allocate string
only vg portion of lv name.
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
b0dde9e8f0 toollib: refactor skip_dev_dir
Detect dev dir just once.
2014-09-28 13:49:01 +02:00
Zdenek Kabelac
26dd17f834 lvchange: missed bits for a8aee7dba2
lv_info is not used here any more.
This code should have been committed with
lv_check_not_in_use API change commit.
2014-09-24 16:30:02 +02:00
Heinz Mauelshagen
45f57477f4 cleanup: Use segtype.h definitions of segment type names wherever possible
We are not using already defined segement type names where we could.

There is a lot of other places in device-mapper and LVM2 we have those
hardcoded so we should better finally have a common interface in
libdevmapper to avoid this.
2014-09-24 15:24:41 +02:00
Zdenek Kabelac
edb3902c25 debug: show stacktrace on error path 2014-09-24 10:54:48 +02:00
Zdenek Kabelac
4319e06a0f debug: add missing stack trace 2014-09-24 10:54:48 +02:00
Zdenek Kabelac
03aeb86762 cleanup: reindent
Save some code lines.
2014-09-24 10:54:48 +02:00
Zdenek Kabelac
f809fa5a78 cleanup: drop uneeded backup call
lv_update_and_reload already handle backup.
2014-09-24 10:54:48 +02:00
Zdenek Kabelac
ec4ffeb51c cleanup: use supplied cmd pointer 2014-09-24 10:54:48 +02:00
Zdenek Kabelac
a8aee7dba2 activate: update lv_check_not_in_use: API
Use of lv_info() internally in lv_check_not_in_use(),
so it always could use with_open_count properly.

Skip sysfs() testing in open_count == 0 case.

Accept just 'lv' pointer like other functions.

The function has 'built-in' lv_is_active_locally check,
which however is not what we need to check in many place.
For now at least remotely active snapshot merge is
detected and for this case merge on next activation is scheduled.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
c96665e6a8 lvconvert: reoder old snapshot merge
Move check for snapshot-merge support before archiving.

Split code on 2 paths - with merge_on_activate
using vg_write & vg_commit
and lv_update_reload call for instant merging.

Move printing after backup.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
84cdf85bd2 cleanup: constify activation usage of lv pointer
Let's enforce cheking of write access to LV by compiler.
Activation part does never need to write anything to LV
so keep LV pointer const.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
af18e7cfbf cleanup: move printing after backup
Print successful result after making backup.
In this place we are sure to not keep memlock.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
93fbef1a45 vgchange: use NULL 'feature' of lv_info call
When NULL is passed for info the call itself
already does the same evaluation.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
5b70bdc104 vgchange: add sync point
Before leaving _activate_lvs_in_vg() wait till devices
are active - so we do not print message about active
devices earlier then it really happens for a user.
2014-09-24 10:54:47 +02:00
Zdenek Kabelac
13c07c685a thin and cache: improve conversion validation
More validations before any thin or cache related conversion begins.

We allow to use and stack:

pool data: cache or raid
pool metadata: raid

pool:  linear, striped
cache: linear, striped, raid
thin(extorig): linear, origin, cow, virtual, thin
2014-09-24 10:53:44 +02:00
Zdenek Kabelac
cd3345a5b0 thin: no pool can be used for external origins
Cache pool can't be external origin either.
For simplicity use vg from passed LV.
2014-09-24 10:52:02 +02:00
Zdenek Kabelac
736f40134b mirror: extend adjusted_mirror_region_size API
We use adjusted_mirror_region_size() in two different contexts.

Either on command line -
 here we do want to inform user about reduction of size.

Or in pvmove activation context -
 here we should only use 'verbose' info.
2014-09-24 10:48:02 +02: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
702b648215 cleanup: lvchange remove some extra code.
We do not need to restore LV content on error path - since
for reactivation we always use  ondisk/commited metadata,
so passed data are never used.

Drop some unneded extra message, since the called function
repeated logs same info.
2014-09-19 15:55:46 +02:00
Zdenek Kabelac
3adc50ac22 lvchange: backup final metadata
Shift backup after final metadata commit.

Synchronize with wiping.
2014-09-19 15:55:34 +02:00
Zdenek Kabelac
f09f85d027 tools: common handling of --persistent option
Move common code for reading and processing
of --persistent arguments for lvcreate and lvchange
into lvmcmdline.

Reuse validate_major_minor() routine for validation.

Don't blindly activate LVs after change in cluster
and instead only local reactivation is supported.
(we have now many limited targets now).

Dropping 'sigint_caught()' handling, since
prompt() is resolving this case itself.
2014-09-19 15:54:20 +02:00
Zdenek Kabelac
656ba3a744 cleanup: use const for cmd context 2014-09-19 15:51:31 +02:00
Zdenek Kabelac
e2312d28ed cleanup: switch to use CHANGE_AEY
Since for other enums we use 'Y' or 'N' use it with 'AE' as well.
2014-09-19 15:51:31 +02:00
Zdenek Kabelac
34bdb83c52 cleanup: update message 2014-09-18 00:53:42 +02:00
Zdenek Kabelac
31548e4e7c cleanup: detect unsupported options earlier
Avoid unnecessary converions of pool.
2014-09-18 00:42:53 +02:00
Alasdair G Kergon
ab2dacf6f6 lvconvert: Further restrictions on cache/pools.
Would be better to define what is supported not what isn't, but this'll
have to do for now.
2014-09-17 23:00:41 +01:00
Alasdair G Kergon
a2a869afc8 lvconvert: Disallow mixing of cache and thin pools.
--cachepool can't take a thin pool and --thinpool can't take a
cache pool.
2014-09-17 17:11:01 +01:00
Alasdair G Kergon
bdb05cc05e lvconvert: Restrict use of cache LVs.
Refuse use of -m and -s with cache LVs until full support
can be provided.
2014-09-17 16:41:58 +01:00
Alasdair G Kergon
b4f5be76a3 cleanup: Remove metadata.h from tools dir.
metadata.h is meant to be internal to the library.
metadata-exported.h contains the things needed by tools.
2014-09-17 15:50:24 +01:00
Zdenek Kabelac
98414ca7dd vgchange: support clustered conversion for active lv
If we want to support conversion of VG to clustered type,
we currently need to relock active LV to get proper DLM lock.

So add extra loop after change of VG clustered attribute
to exlusively activate all active top level LVs.

When doing change -cy -> -cn  we should validate LVs are not
active on other cluster nodes - we could be sure about this only
when with local exclusive activation - for other types
we require user to deactivate volumes first.

As a workaround for this limitation there is always
locking_type = 0 which amongs other skip the detection
of active LVs.

FIXME:
 clvmd should handle looks for cluster locking type all the time.
2014-09-17 14:41:42 +02:00
Jonathan Brassow
9d57aa9a0f cache-pool: Fix specification of cachemode when converting to cache-pool
Failure to copy the 'feature_flags' lvconvert_param to the matching
lv_segment field meant that when a user specified the cachemode argument,
the request was not honored.
2014-09-16 22:19:53 -05:00
Jonathan Brassow
b87a7683e2 clean-up: better macro usage
Use 'lv_is_mirror' instead of 'lv_is_mirrored && !lv_is_raid' - both
are the same as asking if the non-RAID mirror implementation is being
used.
2014-09-16 21:24:14 -05: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
e9216eedfe cleanup: fix last commit 2014-09-15 22:04:14 +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
f0cafc9281 conf: add allocation/physical_extent_size config option for default PE size of VGs.
Removes a need to use "vgcreate -s <desired PE size>" all the
time time just to override hardcoded default which is 4096KiB.
2014-09-12 10:09:21 +02:00
Zdenek Kabelac
47ff145e08 debug: turn message into debug
This message should be printed only for activation commands,
however since the handling of this flag is not correct
(rhbz 1140029) and will require further changes,
do now just a minor change and switch message into log_debug
(so it's not printed i.e. with every  'lvs -v')
2014-09-10 10:10:13 +02:00
Zdenek Kabelac
c710f02e01 lv_update_and_reload: replace code sequence
Use lv_update_and_reload() and lv_update_and_reload_origin()
to handle write/suspend/commit/resume sequence.

In few places this properly handle vg_revert() after suspend failure,
and also ensures there is metadata backup after successful vg_commit().
2014-09-09 19:20:09 +02:00
Zdenek Kabelac
e4e50863a2 lvconvert: use lv_update_and_reload
Use lib function.
2014-09-09 19:15:26 +02:00
Zdenek Kabelac
fa1a0d170a cleanup: drop extra ()
Pure  '==' test doesn't need extra ().
2014-08-29 13:11:35 +02:00
Alasdair G Kergon
8b8d21f873 pre-release 2014-08-26 16:34:14 +01:00
Peter Rajnoha
50babdf123 revert: commit 8d00499167
Let's test this more...
2014-08-26 17:07:37 +02:00
Zdenek Kabelac
24001a08ab cleanup: check pv_count is not 0
Since we already detect writemostly_ARG is non-zero
make it obvious pv_count will also be non-zero in this case.
2014-08-26 14:13:06 +02:00
David Teigland
a67c484fac lvcreate: disallow snapshot of cache lv 2014-08-22 11:54:49 -05:00
Peter Rajnoha
8d00499167 lvconvert: snapshot: allow using raid1 for snapshot and snapshot origin
When testing conversion sanity, we checked lv->status & MIRRORED
which encompasses both old mirrors and raid1 mirrors. But we need to
ban only the old mirrors here hence allow raid1 mirrors.
2014-08-20 10:12:09 +02:00
Zdenek Kabelac
c5f2c541f6 cleanup: simplier struct init
Use simplier struct initilizer.
2014-08-19 14:33:07 +02:00
Zdenek Kabelac
24df01f735 cleanup: avoid double assign
Skip setting a value to a variable which is never
used and overwritten/set afterwards.
2014-08-19 14:33:06 +02:00
Zdenek Kabelac
cdb16a6039 lvscan: check result of id_write_format
Currently rather impossible to happen - but check
for returned value of id_write_format().
2014-08-19 14:33:06 +02:00
Peter Rajnoha
84860fd54f lv: remove lv_type_name fn
The lv_type_name function is remnant from old code that reported
only single string for the LV type. LV types are now reported
in a more extended way as keyword list that describe the type
precisely (using lv_layout_and_type fn).

The lv_type_name was used in some error messages to display the
type of the LV so just reinstate the old messages back referencing
the type directly with a string - this is enough for error messages.
They don't need to display the LV type as precisely as it's used
on lvs output (which is optimized for selection anyway).
2014-08-19 14:16:39 +02:00
Alasdair G Kergon
42e07d2bce dmsetup: Support remove --deferred.
This patch adds a new flag --deferred to dmsetup remove. If this flag is
specified and the device is open, it is scheduled to be deleted on
close.

struct dm_info is extended.

The existing dm_task_get_info() is converted into a wrapper around the
new version dm_task_get_info_with_deferred_remove() so existing binaries
can still use the old smaller structure.

Recompiled code will pick up the new larger structure.

From: Mikulas Patocka <mpatocka@redhat.com>
2014-08-16 00:34:48 +01:00
Zdenek Kabelac
ec41bd1920 cleanup: use display_lvname
Show more complete LV names.
2014-08-15 15:53:17 +02:00
Zdenek Kabelac
c894c3c87f cleanup: gcc warn fix
Since gcc fail to see the origin has been already set under condition
above, just set origin again.
2014-08-15 15:53:17 +02:00
Zdenek Kabelac
ff33d215ba cleanup: drop extra braces 2014-08-15 15:06:45 +02:00
Zdenek Kabelac
1bde4c19e6 cleanup: drop unneeded inits 2014-08-15 15:06:44 +02:00
Zdenek Kabelac
5095a6517d cleanup: simplier struct initilization 2014-08-15 15:06:44 +02:00
Zdenek Kabelac
338b991e40 cleanup: move test for free arg
Move test for list of volumes into common place.
2014-08-15 15:06:44 +02:00
Zdenek Kabelac
6872adc0ff cleanup: postpone confirmation prompt for snapshot
Prompt user for confimation after more checks are done.
(So we avoid case prompting and failing after prompt)
2014-08-15 15:06:44 +02:00
Zdenek Kabelac
7f4b1e7411 toollib: print ignoring vorigin
When ignoring 'listed' volume, print info message.
(So the final command error message is a bit less confusing,
i.e. when user tries to deactive virtual origin:

> lvchange -an vg/lvol2_vorigin
  Ignoring virtual origin logical volume vg/lvol2_vorigin.
  One or more specified logical volume(s) not found.
2014-08-15 15:06:44 +02:00
Zdenek Kabelac
10e3715564 lvconvert: show name of activated volume
Display the name of volume that needs to be activated for merging.
2014-08-15 15:06:44 +02:00
Alasdair G Kergon
bf78e55ef3 pvcreate: Fix cache state with filters/sig wiping.
_pvcreate_check() has two missing requirements:
  After refreshing filters there must be a rescan.
    (Otherwise the persistent filter may remain empty.)
  After wiping a signature, the filters must be refreshed.
    (A device that was previously excluded by the filter due to
     its signature might now need to be included.)

If several devices are added at once, the repeated scanning isn't
strictly needed, but we can address that later as part of the command
processing restructuring (by grouping the devices).

Replace the new pvcreate code added by commit
54685c20fc "filters: fix regression caused
by commit e80884cd080cad7e10be4588e3493b9000649426"
with this change to _pvcreate_check().

The filter refresh problem dates back to commit
acb4b5e4de "Fix pvcreate device check."
2014-08-14 01:30:01 +01:00
Peter Rajnoha
ea662ca060 pvmove: remove spurious "Skipping mirror LV" message on pvmove of clustered mirror
With cmirrord, we can do pvmove of clustered mirror. The code checking
suitability of LVs on the PV being moved issued a message if a mirror
LV was found and the VG was clustered. However, the actual pvmove did
work correctly.

The top-level mirror LV is actually skipped in the code since it's
always layered on top of internal LVs making up the mirror LV and for pvmove
we consider these internal devices only as they're actually layered on
top of concrete PVs then. But we don't need to issue any message here
about skipping the top-level mirror LV - it's misleading here.
2014-08-07 15:23:58 +02:00
Petr Rockai
2dac5525fb lvscan: Fix possible gcc warnings in --cache implementation. 2014-08-04 17:36:12 +02:00
Petr Rockai
0208665209 lvscan: Make --cache impervious to already-missing devices. 2014-08-04 17:03:17 +02:00
Peter Rajnoha
54685c20fc filters: fix regression caused by commit e80884cd08
Commit e80884cd08 tried to dump filters
for them to be reevaluated when creating a PV to avoid overwriting
any existing signature that may have been created after last
scan/filtering.

However, we need to call refresh_filters instead of
persistent_filter->dump since dump requires proper rescannig to fill
up the persistent filter again. However, this is true only for pvcreate
but not for vgcreate with PV creation where the scanning happens before
this PV creation and hence the next rescan (if not full scan), does not
fill the persistent filter.

Also, move refresh_filters so that it's called sooner and only for
pvcreate, vgcreate already calls lvmcache_label_scan(cmd, 2) which
then calls refresh_filters itself, so no need to reevaluate this again.

This caused the persistent filter (/etc/lvm/cache/.cache file) to be
wrong and contain only the PV just being processed with
vgcreate <vg_name> <pv_name_to_create>.

This regression caused other block devices to be filtered out in case
the vgcreate with PV creation was used and then the persistent filter
is used by any other LVM command afterwards.
2014-08-01 11:39:53 +02:00
Petr Rockai
a9ea014e51 lvscan: Implement a --cache mode. 2014-07-22 22:48:21 +02:00
Zdenek Kabelac
894eda4707 thin and cache: unify pool common code
Fix get_pool_params to only read params.
Add poolmetadataspare option to get_pool_params.
Move all profile code into update_pool_params.
Move recalculate code into pool_manip.c
2014-07-22 22:41:38 +02:00
Zdenek Kabelac
8c56c5fbac lvconvert: better testing order
Avoid duplicate tests through implicit calls - check directly
result of string assignment.
2014-07-22 22:38:59 +02:00
Zdenek Kabelac
ab7bcc26f6 tools: switch logic for new arg_ func
Revert logic and rename new arg_ functions to:

arg_from_list_is_set()
arg_outside_list_is_set()

When err_found is given, log_error message is automaticaly
printed.
2014-07-22 22:38:59 +02:00
Alasdair G Kergon
99e3c13012 raid: Moved degraded activation code to raid_manip.
Adjust some messages & fn names.
2014-07-22 20:50:29 +01:00
Alasdair G Kergon
8c231a5f4d raid: Correct degraded warning message level 2014-07-21 15:40:59 +01:00
Zdenek Kabelac
53b787e519 cleanup: drop testing impossible path
We cannot get NULL in this test - since if the arg is set
it will always return non-NULL value here.
(in-release update)
2014-07-17 16:20:21 +02:00
Zdenek Kabelac
ffa1a7b046 cleanup: typo in message
in-release fix.
2014-07-17 16:19:57 +02:00
Zdenek Kabelac
ab72cdbf81 cleanup: check arg_count once
Do not check quiet_ARG more then necessary.
2014-07-17 16:18:35 +02:00
Zdenek Kabelac
f5d6c4b0f3 cache: use get_cache_mode for validation
Use a single function to validate cache mode arg
and set DM_ feature flags.
2014-07-17 16:16:45 +02:00
Zdenek Kabelac
8f9f180139 lvconvert: improve merge validation
Easier check for conflicting options with --merge.
2014-07-17 16:16:00 +02:00
Zdenek Kabelac
7abad9ef88 lvconvert: improve splitsnapshot test
Easier check for conflicting options with --splitsnapshot.
2014-07-17 16:15:30 +02:00
Zdenek Kabelac
4dcacbe369 lvconvert: move to single name validation
Validate all LV names in _lvconvert_name_params().
2014-07-17 16:14:36 +02:00
Zdenek Kabelac
04acf7a8d0 lvconvert: add missing option for repair
Few more option needs to be allowed with --repair.
(in-release fix).
2014-07-17 16:14:18 +02:00
Zdenek Kabelac
65a3f50556 lvconvert: fix missing repair option
Support --repair and --use-policies with mirrors.
(fixes another regression from lvconvert change for thin and cache).
TODO: the code path for mirror needs update.
2014-07-11 14:42:21 +02:00
Zdenek Kabelac
af219fbc04 cleanup: lets make it really obvious for gcc 2014-07-11 14:19:22 +02:00
Zdenek Kabelac
c0ebe78ef8 lvconvert: fix mirror path
lvconvert rewrite commit missed proper handling
of mirror path for --corelog and --mirrorlog options.
Document this even in man page.
2014-07-11 14:12:35 +02:00
Zdenek Kabelac
7913f64a02 cleanup: drop unintend debug error line 2014-07-11 13:54:54 +02:00
Zdenek Kabelac
a62cea3371 cleanup: older gcc is not smart enough
Avoid gcc warning about uninitialized 'seg' variable.
It's not easy for older gcc compiler to deduce it's been set.
2014-07-11 13:52:30 +02:00
Zdenek Kabelac
9f703d35a0 cleanup: lvconvert reoder repair check 2014-07-11 13:32:23 +02:00
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
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
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
ba048612a3 lvchange: just skip on cache pool 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
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
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