1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

411 Commits

Author SHA1 Message Date
Zdenek Kabelac
57f8b33d5d cleanup: a bit better error message 2014-07-02 10:45:43 +02:00
Zdenek Kabelac
165cfab7db cleanup: verbose in human readable size
Use normal size like we use everywhere else.
2014-07-02 10:45:42 +02:00
Zdenek Kabelac
6b3a49876e cleanup: line indent 2014-07-02 10:45:42 +02:00
Zdenek Kabelac
7bdf4719e8 pool: delay conversion prompt
First validate as much params as possible before prompting user
about conversion to data and metadata LV.
2014-07-02 10:45:39 +02:00
Zdenek Kabelac
3af761ba16 thin: fix chunk_size conversion prompt skip
Use --force only enables prompting for dangerous operation.
User has to add --yes to skip this prompt.
2014-07-02 10:43:56 +02:00
Zdenek Kabelac
0b872ce870 raid: don't skip prompt with force
Yes is meant to be used to skip all new prompts.
(--force just adds more prompts).
2014-07-02 10:36:32 +02:00
Zdenek Kabelac
c460f35cda raid: switch to log_warn
Use log_warn for warning message.
log_error is printed when command returns error code.
2014-07-02 10:34:40 +02:00
Zdenek Kabelac
355258be58 mirror: mirror_or_raid_type_requested update
mirror_or_raid_type_requested really checks for mirror type.

Convert macros mirror_or_raid_type_requested() and
snapshot_type_requested() into inline functions.
2014-07-02 10:34:39 +02:00
Zdenek Kabelac
13fb02ff1f cleanup: ignore vg_name in /lib
Since  vg_name inside /lib function has already been ignored mostly
except for a few debug prints - make it and official internal API
feature.

vg_name is used only in  /tools while the VG is not yet openned,
and when  lvresize/lvcreate /lib function is called with VG pointer
already being used, then vg_name becomes irrelevant (it's not been
validated anyway).

So any internal user of lvcreate_params and lvresize_params does not
need to set vg_name pointer and may leave it NULL.
2014-06-30 12:21:36 +02:00
Zdenek Kabelac
eadcea2dae thin: repaired LV uses _meta%d
Don't leave 'regular' LV with reserved suffix for a user.
After succefull repair use 'normal' (non-reserved) LV name
for backup of original metadata.
2014-06-30 12:15:13 +02:00
Zdenek Kabelac
e6a4cc9c31 lvconvert: print warning when not convert thinpool
Warning about destruction should not be printed,
When we are converting already existing pool
(improving original in-release commit bbf4b2c1c9)
2014-06-18 15:00:18 +02:00
Peter Rajnoha
cfed0d09e8 report: select: refactor: move percent handling code to libdm for reuse 2014-06-17 16:27:21 +02:00
Zdenek Kabelac
0558b1a086 cleanup: we already know max device name size
Use NAME_LEN constant to simplify creation of device name.
Since the max size should be already tested in validation,
throw INTERNAL_ERROR if the size of vg/lv is bigger then NAME_LEN.
2014-06-17 13:43:04 +02:00
Zdenek Kabelac
435c82f8f6 snapshot: check it's still snapshot
While polling for snapshot, detect first the snapshot still
exits.  It's valid to have multiple polling threads watching
for the same thing and just 1 can 'win' the finish part.
All others should nicely 'fail'.
2014-06-17 13:36:07 +02:00
Zdenek Kabelac
496953fb39 cleanup: use y/n instead of y|n
Use same for of yes no query everywhere.
2014-05-22 12:01:43 +02:00
Zdenek Kabelac
16424fed54 thin: improve lvconvert messages
Add more info into printed message.
2014-05-20 21:50:29 +02:00
Zdenek Kabelac
d1d50d4023 cleanup: use print when displaying info
Use error or warn only when we really have some problem in the code.
2014-05-20 21:50:29 +02:00
Zdenek Kabelac
54184f92ac cleanup: indent 2014-05-20 21:50:28 +02:00
Zdenek Kabelac
2941cffd2c cleanup: unneeded initialization
Move or drop initialization where it is not needed.
2014-05-20 21:50:28 +02:00
Zdenek Kabelac
9fd0be2a85 debug: fix backtracing 2014-05-20 21:50:28 +02:00
Zdenek Kabelac
c70c100cce lvconvert: check ret code of mirror_remove_missing
When mirror_remove_missing() fails, stop repairing mirror.
2014-05-20 21:49:42 +02:00
Zdenek Kabelac
bbf4b2c1c9 thin: lvconvert warn before conversion
Warn user before converting volume to different type.

  WARNING: Converting vg/lvol0 logical volume to pool's meta/data volume.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)

Since the content of volume is lost we have to query user to confirm
such operation.  If user is 100% sure, he may use '--yes' to avoid prompts.
2014-05-20 21:48:47 +02:00
Zdenek Kabelac
43f849296e lvconvert: do not activate cache pool
Cache pool cannot be active alone.
2014-04-08 11:00:14 +02:00
Zdenek Kabelac
d686f3856a cleanup: relocate check for mirror
Move testing code into _lvconvert_snapshot function.
2014-03-17 14:31:43 +01:00
Zdenek Kabelac
b738260c7c lvconvert: delay archiving of metadata
Delay archiving of metadata until we really start to
update metadata when converting volume into a snapshot.
Archive is not necessary when we abort operation early.
2014-03-17 14:31:43 +01:00
Zdenek Kabelac
d425e788e9 lvconvert: validate min chunk size for snapshot
Do not allow conversion of too small LV into a COW snapshot device.

Without this patch snapshot target is generating these kernel
messages before creation fails:

attempt to access beyond end of device
dm-9: rw=16, want=8, limit=2
attempt to access beyond end of device
...
device-mapper: table: 253:11: snapshot: Failed to read snapshot metadata
device-mapper: ioctl: error adding target to table
device-mapper: reload ioctl on  failed: Input/output error
2014-03-17 14:31:43 +01:00
Zdenek Kabelac
f3b9ee37e9 lvconvert: disallow usage of origin for snapshot
Usage of origin as a snapshot 'COW' volume is unsupported.

Without this test lvm2 is able to generate this ugly internal error message.

To test this:

lvcreate -L1 -n lv1 vg
lvcreate -L1 -n lv2 -s vg/lv1
lvcreate -L1 -n lv3 vg
lvconvert -s vg/lv3 vg/lv1

Internal error: LVs (5) != visible LVs (1) + snapshots (1) + internal LVs (0) in VG vg
2014-03-17 14:31:42 +01:00
Peter Rajnoha
eecf191d3e config: runtime default for activation/mirror_image_fault_policy
The activation/mirror_image_fault_policy default value copies the
value (or default one) used for activation/mirror_device_fault_policy.
2014-03-06 11:16:23 +01:00
Zdenek Kabelac
a920bc1a40 cleanup: indent, drop unneeded braces 2014-02-24 21:13:35 +01:00
Jonathan Brassow
00ce01e52d cache-pool: Change segtype name from cache_pool to cache-pool
Thin pools use "thin-pool" for the segment type name.  To be consistent,
we use "cache-pool" instead of "cache_pool".
2014-02-19 09:26:03 -06:00
Zdenek Kabelac
25cea92338 thin: fix merge of old snaphost
Fix merging of old snapshot into thinvolume origin.
Add also internal error for the error case when
merging requests activation of merged LV.
2014-02-17 22:25:53 +01:00
Jonathan Brassow
0912cf67aa cache: Ability to convert an existing LV into a cached LV
Users now have the ability to convert their existing logical volumes
into cached logical volumes.  A cache pool LV must be specified using
the '--cachepool' argument.  The cachepool is the small, fast LV used
to cache the large, slow LV that is being converted.
2014-02-12 09:55:35 -06:00
Jonathan Brassow
c8b6c4aee9 cachepool: Ability to convert existing LVs to cachepool type
This patch allows users to convert existing logical volumes into
cache pool LVs.  Since cache pool LVs consist of data and metadata
sub-LVs, there is also the '--poolmetadata' (similar to thin_pool)
which allows for the specification of the metadata device.
2014-02-12 09:51:42 -06:00
Jonathan Brassow
8ddc7f641c misc: disambiguate 'update_pool_params'
s/update_pool_params/update_thin_pool_params/ to disambiguate it from
a future 'update_cache_pool_params'.
2014-02-04 09:58:35 -06:00
Zdenek Kabelac
155405b0e1 thin: validate external origin size
Avoid use of external origin with size unaligned/incompatible with
thin pool chunk size, since the last chunk is not correctly provisioned
when it is overwritten.
2014-01-29 14:58:13 +01:00
Zdenek Kabelac
e9d9852c55 thin: more validation of thin name
Avoid starting conversion of the LV to the thin pool and thin volume
at the same time.  Since this is mostly a user mistake, do not try
to just convert to one of those type, since we cannot assume if the
user wanted LV to become thin volume or thin pool.

Before the fix tool reported pretty strange internal error:
Internal error: Referenced LV lvol1_tdata not listed in VG mvg.

Fixed output:
lvconvert --thinpool lvol0 -T mvg/lvol0
Can't use same LV mvg/lvol0 for thin pool and thin volume.
2014-01-28 13:21:39 +01:00
Zdenek Kabelac
74878bc2bc cleanup: gcc can't see the code path
This is a bit to hard for gcc to see the condition can't
be triggered, so make it easier and initialize to 0.
2013-12-05 09:42:50 +01:00
Zdenek Kabelac
91496e0eda thin: enable thin snapshot merge 2013-12-04 14:30:26 +01:00
Zdenek Kabelac
51783676fb cleanup: swap condition logic
Use easier to follow logic of code.
When checking for merging origin, do a merging.
2013-12-04 14:30:25 +01:00
Zdenek Kabelac
6d7a76ccbf cleanup: code move
Move _swap_lv_identifiers() above  _finish_lvconvert_merge()
so it could be used from this function.
2013-12-04 14:30:25 +01:00
Zdenek Kabelac
5a6794a2ce lv_remove_single: add silent arg
Support silence for removal message.
2013-12-04 14:30:25 +01:00
Alasdair G Kergon
7b65363bf7 lvconvert: Implement --splitsnapshot. 2013-12-04 02:09:37 +00:00
Alasdair G Kergon
ff769ecfe7 lvconvert: Fix reload after snapshot conversion.
At the end of lvconvert --snapshot with an active origin, the origin
gets reloaded.

Commit 57c0f72b1d ("lvconvert: use
_reload_lv on more places") accidentally replaced this with a snapshot
LV reload (which does nothing because only the origin is active).
2013-12-04 02:04:29 +00:00
Zdenek Kabelac
50e1fad86a cleanup: use matching signed types 2013-11-28 12:47:51 +01:00
Zdenek Kabelac
8c96afd361 cleanup: use compound literals for wipe_lv
Optimize and cleanup recently introduced new function wipe_lv.
Use compound literals to get nicely initialized wipe_params struct.
Pass in lv as explicit argument for wipe_lv.
Use cmd from lv structure.
Initialize only non-null members so it's easy to see what
is the special arg.
2013-11-28 12:45:52 +01:00
Zdenek Kabelac
8724c0fceb snapshot: move code of old snapshot merge
Move code for merging old snapshot into its own function.
2013-11-28 12:45:28 +01:00
Zdenek Kabelac
79991aa769 snapshot: drop find_merging_snapshot
Drop find_merging_snapshot() function. Use find_snapshot()
called after check for lv_is_merging_origin() which
is the commonly used code path - so we avoid duplicated
tests and potential risk of derefering NULL point
in unhandled error path.
2013-11-28 12:42:43 +01:00
Peter Rajnoha
b6dab4e059 lv_manip: rename set_lv -> wipe_lv and include signature wiping capability
Use common wipe_lv (former set_lv) fn to do zeroing as well as signature
wiping if needed. Provide new struct wipe_lv_params to define the
functionality.

Bind "lvcreate -W/--wipesignatures y" with proper wipe_lv call.

Also, add "yes" and "force" to lvcreate_params so it's possible
to apply them for the prompt: "WARNING: %s detected on %s. Wipe it? [y/n]".
2013-11-27 15:48:15 +01:00
Zdenek Kabelac
4a061a35c7 snapshot: use lv_check_not_in_use
Instead of plain open_count check, try to use 'smarter'
lv_check_not_in_use() function.
2013-11-22 20:58:11 +01:00
Zdenek Kabelac
6d196410fc snapshot: revert and move check to lvconvert
Revert 4777eb6872 which put
target_present check into init_snapshot_merge(). However
this function is also used when parsing metadata. So we would
get this present test performed even when target is not really
needed. So move this target_present test directly into lvconvert.
2013-11-22 20:57:30 +01:00
Peter Rajnoha
f1a42aa8ec lvconvert: use LV_TEMPORARY when necessary during lvconvert to thin pool
This is an addition to original patch for lvcreate - commit 039bdad.
The same principle applies to lvconvert where there are several steps
during which we need to wipe the existing LV that's being converted
to thin pool, making sure there's no other interference from outside (udev).
2013-10-29 13:33:35 +01:00
Zdenek Kabelac
dd3a2f13f1 thin: missed check for thin_pool in last update 2013-10-16 12:47:30 +02:00
Zdenek Kabelac
1b7631101b thin: fix lvconvert for active pool.
Prohibit conversion of pool device with active thin volumes.
Properly restore active states only for active thin pool volume.
Use new LV_NOSCAN when converting volume into thin pool's metadata.
2013-10-16 10:53:01 +02:00
Zdenek Kabelac
ac961087b0 snapshot: disable merging for virtual snaps
Merging into virtual origin is not supposed to work.
2013-10-12 00:15:55 +02:00
Zdenek Kabelac
92bafade60 thin: fix lvconvert in external origin conversion
Patch 562ad293fd introduced code regression
when LV was converted to a thin LV with external origin and at the same time,
conversion of LV to a thin pool has been requested.
(RHBZ: #997704)

data_lv needs to be assigned after test for external conversion find pool.
2013-10-08 13:41:06 +02:00
Alasdair G Kergon
04d9a52684 release 2.02.103
52 files changed, 598 insertions(+), 264 deletions(-)
2013-10-04 14:32:23 +01:00
Jonathan Brassow
098896fb29 mirror/RAID: Honor mirror_segtype_default when converting from linear
1) When converting from an x-way mirror/raid1 to a y-way mirror/raid1,
the default behaviour should be to stay the same segment type.

2) When converting from linear to mirror or raid1, the default behaviour
should honor the mirror_segtype_default.

3) When converting and the '--type' argument is specified, the '--type'
argument should be honored.

catch such conditions, but errors in the tests caused the issue to go
unnoticed.  The code has been fixed to perform #2 properly, the tests
have been corrected to properly test for #2, and a few other tests
were changed to explicitly specify the '--type mirror' when necessary.
2013-09-25 22:25:43 -05:00
Peter Rajnoha
cc9e65c391 thin: use appropriate default value based on allocation/thin_pool_chunk_size_calculation setting
If thin_pool_chunk_size_calculation is set to "default", use 64KiB,
otheriwse 512KiB for "performance".
2013-09-25 16:06:38 +02:00
Jonathan Brassow
82228acfc9 Mirror/Thin: Disallow thinpools on mirror logical volumes
The same corner cases that exist for snapshots on mirrors exist for
any logical volume layered on top of mirror.  (One example is when
a mirror image fails and a non-repair LVM command is the first to
detect it via label reading.  In this case, the LVM command will hang
and prevent the necessary LVM repair command from running.)  When
a better alternative exists, it makes no sense to allow a new target
to stack on mirrors as a new feature.  Since, RAID is now capable of
running EX in a cluster and thin is not active-active aware, it makes
sense to pair these two rather than mirror+thinpool.

As further background, here are some additional comments that I made
when addressing a bug related to mirror+thinpool:
(https://bugzilla.redhat.com/show_bug.cgi?id=919604#c9)
I am going to disallow thin* on top of mirror logical volumes.
Users will have to use the "raid1" segment type if they want this.

This bug has come down to a choice between:
1) Disallowing thin-LVs from being used as PVs.
2) Disallowing thinpools on top of mirrors.

The problem is that the code in dev_manager.c:device_is_usable() is unable
to tell whether there is a mirror device lower in the stack from the device
being checked.  Pretty much anything layered on top of a mirror will suffer
from this problem.  (Snapshots are a good example of this; and option #1
above has been chosen to deal with them.  This can also be seen in
dev_manager.c:device_is_usable().)  When a mirror failure occurs, the
kernel blocks all I/O to it.  If there is an LVM command that comes along
to do the repair (or a different operation that requires label reading), it
would normally avoid the mirror when it sees that it is blocked.  However,
if there is a snapshot or a thin-LV that is on a mirror, the above code
will not detect the mirror underneath and will issue label reading I/O.
This causes the command to hang.

Choosing #1 would mean that thin-LVs could never be used as PVs - even if
they are stacked on something other than mirrors.

Choosing #2 means that thinpools can never be placed on mirrors.  This is
probably better than we think, since it is preferred that people use the
"raid1" segment type in the first place.  However, RAID* cannot currently
be used in a cluster volume group - even in EX-only mode.  Thus, a complete
solution for option #2 must include the ability to activate RAID logical
volumes (and perform RAID operations) in a cluster volume group.  I've
already begun working on this.
2013-09-11 15:58:44 -05:00
Jonathan Brassow
2691f1d764 RAID: Make RAID single-machine-exclusive capable in a cluster
Creation, deletion, [de]activation, repair, conversion, scrubbing
and changing operations are all now available for RAID LVs in a
cluster - provided that they are activated exclusively.

The code has been changed to ensure that no LV or sub-LV activation
is attempted cluster-wide.  This includes the often overlooked
operations of activating metadata areas for the brief time it takes
to clear them.  Additionally, some 'resume_lv' operations were
replaced with 'activate_lv_excl_local' when sub-LVs were promoted
to top-level LVs for removal, clearing or extraction.  This was
necessary because it forces the appropriate renaming actions the
occur via resume in the single-machine case, but won't happen in
a cluster due to the necessity of acquiring a lock first.

The *raid* tests have been updated to allow testing in a cluster.
For the most part, this meant creating devices with '-aey' if they
were to be converted to RAID.  (RAID requires the converting LV to
be EX because it is a condition of activation for the RAID LV in
a cluster.)
2013-09-10 16:33:22 -05:00
Zdenek Kabelac
e583ff3d2c thin: thin pool can't be external origin
Avoid trying to convert thin-pool to external origin.
2013-08-09 23:04:30 +02:00
Jonathan Brassow
b15278c3dc Mirror/RAID1: When up|down-converting default to segtype of current LV
If there is no RAID support in the kernel but the default mirror
segtype is "raid1", converting legacy mirrors can be problematic.
For example, changing the log type or converting a mirror to a linear
LV does not require the RAID modules to be present.  However, because
lp->segtype is set to be RAID1 by the configuration file, the command
fails.

We should only be setting lp->segtype when converting mirrors if it is
going to change (e.g. to linear or between mirror types).
2013-08-07 16:01:45 -05:00
Zdenek Kabelac
139a62fc0b thin: use pipe_open instead of popen
Use new function to directly exec command and read its output.
2013-08-06 16:19:31 +02:00
Peter Rajnoha
e195b5227e thin: apply VG profile if creating a new thin pool
When creating a new thin pool and there's no profile requested
via "lvcreate --profile ...", inherit any VG profile if it's attached.

Currently this applies to these settings:
  allocation/thin_pool_chunk_size
  allocation/thin_pool_discards
  allocation/thin_pool_zero
2013-08-06 11:42:40 +02:00
Zdenek Kabelac
de0cba0e2d thin: initial --repair support for pools
Initial basic support for repair.
It currently takes pool metadata spare volume, which
is used for recovery.  New spare is created if the volume
is successfuly repaired.

After the operation the previous _tmeta volume is moved
into  _tmeta%d volume and if everything is ok, this volume
could be removed.
New _tmeta needs to be pvmoved to proper place and also
converted to i.e. mirror if it should be mirrored.

Later version will try to automate some steps here.
2013-07-31 15:32:36 +02:00
Zdenek Kabelac
da5284a500 thin: lvconvert cannot convert pool to mirror
Suggest to use _tdata and _tmeta devices for that.
This fixes regression from too relaxed change in
f1d5f6ae81

Without this patch there are some empty LVs created before
mirror code recognizes it cannot continue.

(in release fix)
2013-07-24 17:17:19 +02:00
Peter Rajnoha
31de670318 lvconvert: add more checks for lvconvert --type
The --type mirror requires -m/--mirrrors:

  lvconvert --type mirror vg/lvol0
    --type mirror requires -m/--mirrors
    Run `lvconvert --help' for more information.

The --type raid* is allowed (the checks already existed):

  lvconvert --type raid10 vg/lvol0
    Converting the segment type for vg/lvol0 from linear to raid10 is not yet supported.

The --type snapshot is a synonym to -s/--snapshot:

  lvconvert -s vg/lvol0 vg/lvol1
    Logical volume lvol1 converted to snapshot.

  lvconvert --type snapshot vg/lvol0 vg/lvol1
    Logical volume lvol1 converted to snapshot.

All the other segment types are not supported, e.g.:

  lvconvert --type zero vg/lvol0
    Conversion using --type zero is not supported.
    Run `lvconvert --help' for more information.
2013-07-23 17:13:54 +02:00
Zdenek Kabelac
f1d5f6ae81 lvconvert: drop limit on thin pool conversion 2013-07-22 12:41:22 +02:00
Zdenek Kabelac
aab53f46ee thin: add lvconvert pool metadata spare
Support poolmetadataspare when convering volumes into thin pool.
Same rules applied as with lvcreate.
2013-07-18 18:22:44 +02:00
Alasdair G Kergon
9d5bdc91ca tools: remove metadata.h 2013-07-09 02:51:24 +01:00
Zdenek Kabelac
ccf3dd60f2 cleanup: remove tab 2013-07-08 14:01:41 +02:00
Zdenek Kabelac
a0ce432829 lvconvert: fix last commit
Condition needs to check for passed in pool_metadata_lv_name
which needs to be renamed to _tmeta, for !pool_metadata_lv_name
it's already created with correct _tmeta name.
2013-07-04 14:02:27 +02:00
Zdenek Kabelac
969c87fa5b thin: swap if branch
Move shorter if branch in front.
Use buffer for _tmeta and _tdata names so too long name
of LV is earlier detected.
2013-07-04 13:33:41 +02:00
Zdenek Kabelac
f88f5a1ca3 thin: move alloc_pool_metadata
Move function from /tool to /lib to thin_manip.c
Since lvm2api will need to move many things into /lib anyway.
2013-07-04 13:33:41 +02:00
Zdenek Kabelac
eeb164b50f lvconvert: use proper error path
VG needs to be released in this error path
2013-07-03 14:44:51 +02:00
Mike Snitzer
fe09d84668 lvconvert: Rename _swap_lv to _swap_lv_identifiers and move to allow an additional user 2013-07-02 17:02:25 -04:00
Mike Snitzer
f9e0adcce5 snapshot: Rename snapshot segment returning methods from find_*_cow to find_*_snapshot
find_cow -> find_snapshot, find_merging_cow -> find_merging_snapshot.
Will thin snapshot code to reuse these methods without confusion.
2013-07-02 16:26:03 -04:00
Peter Rajnoha
24a84549a8 thin: make selected thinp settings profilable
These settins are customizable by profiles:

	allocation/thin_pool_zero
	allocation/thin_pool_discards
	allocation/thin_pool_chunk_size
	activation/thin_pool_autoextend_threshold
	activation/thin_pool_autoextend_percent
2013-07-02 15:22:11 +02:00
Peter Rajnoha
06dd66af54 config: add profile arg to find_config_tree_str 2013-07-02 15:19:09 +02:00
Zdenek Kabelac
47419d21ac cleanup: stack usage
Shortening code with macros return_0, return_NULL.
Add some missing stack prints in error paths.
2013-07-01 23:11:14 +02:00
Zdenek Kabelac
b90450b8a0 cleanup: introduce return_ECMD_FAILED macro
Use shortening macro for common code sequence
stack;
return ECMD_FAILED;
2013-07-01 23:10:33 +02:00
Jonathan Brassow
a6d13308ec RAID/MIRROR: Honor mirror_segtype_default when upconverting linear LVs
If the user would upconvert a linear LV to a mirror without specifying
the segment type ("--type mirror" vs "--type raid1"), the "mirror"
segment type would be chosen without consulting the 'default_mirror_segtype'
setting in lvm.conf.  This is now used as the basis for determining
which should be used if left unspecified.
2013-06-19 17:50:10 -05:00
Petr Rockai
f65dd341a5 locking: Make it possible to pass down an LV to activation code.
Previously, we have relied on UUIDs alone, and on lvmcache to make getting a
"new copy" of VG metadata fast. If the code which triggers the activation has
the correct VG metadata at hand (the version which is currently on disk), it can
now hand it to the activation code directly.
2013-06-10 17:26:38 +02:00
Jonathan Brassow
06ac797f42 Clean-up: Replace 'lv_is_active' with more correct/specific variants
There are places where 'lv_is_active' was being used where it was
more correct to use 'lv_is_active_locally'.  For example, when checking
for the existance of a kernel instance before asking for its status.
Most of the time these would work correctly.  (RAID is only allowed on
non-clustered VGs at the moment, which means that 'lv_is_active' and
'lv_is_active_locally' would give the same result.)  However, it is
more correct to use the proper variant and it helps with future
scenarios where targets might be allowed exclusively (or clustered) in
a cluster VG.
2013-05-16 10:36:56 -05:00
Peter Rajnoha
4777eb6872 lvconvert: check for snapshot-merge support before merge init 2013-05-16 08:21:57 +02:00
Jonathan Brassow
cbcbb67731 mirror: Fix overly-concerning warning on mirror up-convert failure.
Attempting to up-convert an inactive mirror when there is insufficient
space leads to the following message:
  Unable to allocate extents for mirror(s).
  ABORTING: Failed to remove temporary mirror layer inactive_mimagetmp_3.
  Manual cleanup with vgcfgrestore and dmsetup may be required.
This is caused by a failure to execute the 'deactivate_lv' function in
the error condition.  The deactivate returns an error because the LV is
already inactive.  This patch checks if the LV is activate and calls
deactivate_lv only if it is.  This allows the error cleanup code to work
properly in this condition.

It wasn't that big of a deal anyway, since there was no previous vg_commit
that needed to be reverted.  IOW, no harm was done if the allocation failed.
The message was scary and useless.
2013-04-10 16:47:04 -05:00
Zdenek Kabelac
562ad293fd 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.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
9cf00666b3 thin: cannot use snapshot merge with thinpool 2013-03-13 15:13:54 +01:00
Zdenek Kabelac
0191d99906 thin: assign through structure
Just simplify code.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
f572bf987e thin: read paramaters in front
Fill paramaters into lvconvert_params -
so we could use it independently on args()
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
82eee72019 thin: lvconvert read params sooner
Move code for reading stripesize and readahead to the
_read_params function.
2013-03-13 15:13:54 +01:00
Zdenek Kabelac
f06dd8725a 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.
2013-03-13 15:13:54 +01:00
Peter Rajnoha
386886f71c 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.
2013-03-06 10:14:33 +01:00
Zdenek Kabelac
b73de73151 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.
2013-02-23 10:38:20 +01:00
Zdenek Kabelac
386f3d5a5e 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.
2013-02-23 10:37:01 +01:00
Jonathan Brassow
0e4ffd9d3b 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.
2013-02-20 14:40:17 -06:00
Zdenek Kabelac
15115b61c0 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.
2013-02-05 14:31:34 +01:00
Zdenek Kabelac
be5ad90703 lvconvert: fix accepting second lv name
Do not allow to accept second LV name on lvconvert --thinpool
command line.
2013-02-05 14:31:17 +01:00
Jonathan Brassow
970dfbcd69 RAID: Limit replacement of devices when array is not in-sync.
If a RAID array is not in-sync, replacing devices should not be allowed
as a general rule.  This is because the contents used to populate the
incoming device may be undefined because the devices being read where
not in-sync.  The kernel enforces this rule unless overridden by not
allowing the creation of an array that is not in-sync and includes a
devices that needs to be rebuilt.

Since we cannot know the sync state of an LV if it is inactive, we must
also enforce the rule that an array must be active to replace devices.

That leaves us with the following conditions:
1) never allow replacement or repair of devices if the LV is in-active
2) never allow replacement if the LV is not in-sync
3) allow repair if the LV is not in-sync, but warn that contents may
   not be recoverable.

In the case where a user is performing the repair on the command line via
'lvconvert --repair', the warning is printed before the user is prompted
if they would like to replace the device(s).  If the repair is automated
(i.e. via dmeventd and policy is "allocate"), then the device is replaced
if possible and the warning is printed.
2012-12-18 14:40:42 -06:00
Peter Rajnoha
e8025aa67a lvconvert: also allow --type with --stripes
We can also use this for conversion between different mirror segment
types. Each new segment type converter then needs to check itself
whether the --stripes is applicable.
2012-12-13 11:19:11 +01:00
Peter Rajnoha
cad22be394 lvconvert: allow lvconvert --stripes/stripesize only with -mirrors/--repair/--thinpool
Also, update lvconvert man page to reflect this and make clear that
the --stripes/stripesize is applied to newly allocated space only.
2012-12-11 15:50:25 +01:00
Peter Rajnoha
f942ae4a7a lvconvert: do not ignore -f in lvconvert --repair -y -f 2012-12-11 09:52:54 +01:00
Zdenek Kabelac
99018b37ee thin: lvconvert supports swapping metadata device
Support swapping of metadata device if the thin pool already
exists. This way it's easy to i.e. resize metadata or their
repair operation.

User may create some empty LV, replace existing metadata
or dump and restore them into bigger LV.
2012-12-02 18:01:27 +01:00
Zdenek Kabelac
ade2f47829 thin: deactivate subvolumes
Do not leave active thin data and metadata volumes
if activation of thin pool fails.
2012-12-02 17:56:44 +01:00
Zdenek Kabelac
f0da2842cf thin: shuffle code
Reorder code lines for next patch.
2012-12-02 17:56:44 +01:00
Zdenek Kabelac
0be8a9126f thin: lvconvert update messages 2012-12-02 17:56:44 +01:00
Zdenek Kabelac
c7a7fd0a12 thin: fix attrs for unloaded driver
If the driver is not loaded, set all 'features' ON
instead of all of them being OFF.
2012-11-27 11:29:47 +01:00
Zdenek Kabelac
953080e4fc thin: add more unsupporte options for merge
Hmm, we need some smarter way to detect unsupported command
line options for various commands.
2012-11-26 12:15:32 +01:00
Zdenek Kabelac
b21d3e3592 thin: lvconvert update
Use common function from toollib and support allocation
of metadata LV with give thin pool data LV.
2012-11-19 14:38:17 +01:00
Zdenek Kabelac
cf5242a670 lvconvert: store target attributes
Target tells us its version, and we may allow different set of options
to be supported with different version of driver.

Idea is to provide individual feature flags and later be
able to query for them.
2012-11-19 14:17:10 +01:00
Jonathan Brassow
54c73b7723 mirror: Mirrored log should be fixed before mirror when double fault occurs
This patch is intended to fix bug 825323 - FS turns read-only during a double
fault of a mirror leg and mirrored log's leg at the same time.  It only
affects a 2-way mirror with a mirrored log.  3+-way mirrors and mirrors
without a mirrored log are not affected.

The problem resulted from the fact that the top level mirror was not
using 'noflush' when suspending before its "down-convert".  When a
mirror image fails, the bios are queue until a suspend is recieved.  If
it is a 'noflush' suspend, the bios can be safely requeued in the DM
core.  If 'noflush' is not used, the bios must be pushed through the
target and if a device is failed for a mirror, that means issuing an
error.  When an error is received by a file system, it results in it
turning read-only (depending on the FS).

Part of the problem was is due to the nature of the stacking involved in
using a mirror as a mirror's log.  When an image in each fail, the top
level mirror stalls because it is waiting for a log flush.  The other
stalls waiting for corrective action.  When the repair command is issued,
the entire stacked arrangement is collapsed to a linear LV.  The log
flush then fails (somewhat uncleanly) and the top-level mirror is suspended
without 'noflush' because it is a linear device.

This patch allows the log to be repaired first, which in turn allows the
top-level mirror's log flush to complete cleanly.  The top-level mirror
is then secondarily reduced to a linear device - at which time this mirror
is suspended properly with 'noflush'.
2012-11-14 14:58:47 -06:00
Zdenek Kabelac
f260f99d57 cleanup: switch log_error to log_warn
Use log_warn to print non-fatal warning messages.

Use of log_error would confuse checker for testing
whether proper error has been reported for some real error.
2012-10-17 15:41:35 +02:00
Zdenek Kabelac
5b07bd3f91 lvconvert: disable convertion of thin to mirrors
For now this convertions is not supported, thus disabled.
The only supported conversion for now is to create mirrored thin pools
from mirrored devices.
2012-10-08 12:16:53 +02:00
Zdenek Kabelac
a27650cc98 thin: lvconvert
Update code for lvconvert.
Change the lvconvert user interface a bit - now we require 2 specifiers
--thinpool   takes LV name for data device (and makes the name)
--poolmetadata  takes LV name for metadata device.

Fix type in thin help text -z -> -Z.

Supported is also new flag --discards for thinpools.
2012-10-03 15:13:33 +02:00
Jonathan Brassow
c3eb3a7687 cleanup: Use segtype->ops->name() instead of segtype->name where applicable
When printing a message for the user and the lv_segment pointer is available,
use segtype->ops->name() instead of segtype->name.  This gives a better
user-readable name for the segment.  This is especially true for the
'striped' segment type, which prints "linear" if there is an area_count of
one.
2012-09-05 11:35:54 -05:00
Alasdair G Kergon
438e0050df config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.

When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]

Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 20:35:48 +01:00
Zdenek Kabelac
57c0f72b1d lvconvert: use _reload_lv on more places
Use common subroutine.
2012-08-23 14:38:45 +02:00
Zdenek Kabelac
4698fb0543 lvconvert: move _reload_lv()
Just move in front
2012-08-23 14:37:52 +02:00
Peter Rajnoha
07e4ac7b00 lvconvert: count % upwards when merging a snapshot
Before:
  # lvconvert --merge -i 1 vg/lvol1
  Merging of volume lvol1 started.
  lvol0: Merged: 36.7%
  lvol0: Merged: 21.3%
  lvol0: Merged: 5.8%
  lvol0: Merged: 0.0%
  Merge of snapshot into logical volume lvol0 has finished.
  Logical volume "lvol1" successfully removed

After:
  # lvconvert --merge -i 1 vg/lvol1
  Merging of volume lvol1 started.
  lvol0: Merged: 61.4%
  lvol0: Merged: 73.0%
  lvol0: Merged: 88.4%
  lvol0: Merged: 100.0%
  Merge of snapshot into logical volume lvol0 has finished.
  Logical volume "lvol1" successfully removed
2012-07-10 15:30:18 +02:00
Zdenek Kabelac
6bd3864b41 thin: fix lvconvert error path NULL dereference
For printing the name, use given command line parameter.
2012-06-22 13:50:21 +02:00
Zdenek Kabelac
0a9f894ff0 Initial support for lvconvert for thin pool volumes.
Support has many limitations and lots of FIXMEs inside,
however it makes initial task when user creates a separate LV for
thin pool data and thin metadata already usable, so let's enable
it for testing.

Easiest API:

lvconvert --chunksize XX --thinpool data_lv  metadata_lv

More functionality extensions will follow up.

TODO: Code needs some rework since a lot of same code is getting copied.
2012-05-09 12:17:06 +00:00
Jonathan Earl Brassow
1a53400723 Fix for bug 807776: invalid lvconvert --merge output should mention raid1 now
s/snapshot/mergeable volume/
2012-04-19 21:50:37 +00:00
Peter Rajnoha
543eaed88c Detect VG name being part of the LV name in lvconvert --splitmirrors -n.
Before:
devel/~ # lvconvert --splitmirrors 1 -n vg/splitted_one vg/mirrored_one
  Internal error: LV name vg/splitted_one has invalid form.
  Intermediate VG metadata write failed.

After:
devel/~ # lvconvert --splitmirrors 1 -n vg/splitted_one vg/mirrored_one
  Logical volume mirrored_one converted.

devel/~ # lvconvert --splitmirrors 1 -n abc/splitted_one vg/mirrored_one
  Please use a single volume group name ("vg" or "abc")
  Run `lvconvert --help' for more information.
2012-03-30 08:58:02 +00:00
Zdenek Kabelac
f3c177312f Correct enum type
Using debug_t and some forgetten alloc_policy_t, force_t from past commit.
2012-03-01 21:14:43 +00:00
Zdenek Kabelac
fbf6b89a84 Using enum types for enums
alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
2012-02-28 14:24:57 +00:00
Zdenek Kabelac
980cf7959c Keep same sign for 's' counter 2012-02-23 22:36:56 +00:00
Jonathan Earl Brassow
e8eb64c878 Allow 'lvconvert --repair' to operate on RAID 4/5/6.
The higher level RAIDs should be allowed for repair along with 'mirror' and
'raid1' segment types.
2012-02-22 17:18:49 +00:00
Jonathan Earl Brassow
7a5a5cb06f Add some messages that indicate completion of RAID device replacement.
There were no messages printed upon completiion of RAID device replacement.
This could cause confusion/concern during automated recovery, because the
user sees the failure messages but no other messages indicating correction.
2012-02-22 16:03:55 +00:00
Jonathan Earl Brassow
972282bfbc Fix a bad return code in 'lvconvert_raid'
Functions at this level do return 0 or 1, not ECMD_* values.
2012-02-22 15:20:50 +00:00
Jonathan Earl Brassow
96f82296ae Change confusing message that is printed when a RAID device fails.
s/Issue/Use/, otherwise it is easy to misread "Issue" as "Issuing" - causing
the user confusion as to whether the action was performed automatically or
whether they need to issue the command.
2012-02-13 18:38:36 +00:00
Jonathan Earl Brassow
1456c3b298 Fix possible NULL pointer dereferences when updating mirror log.
'_lv_update_log_type' takes a lvconvert_params argument so that it can pass
down the user's preference of 'region_size' and allocation_policy.  When
'mirror_remove_missing' was introduced (commit ID
95986e42a1) it didn't make sense to pass down
user preferences - so NULL was given instead.  While it may never happen in
practice, static analysis reveals that this argument could be dereferenced.
So, if the user preferences were not passed in, glean the necessary fields
from what is already set in the LV.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

(Not updating WHATSNEW for this simple clean-up.)
2012-02-13 18:36:55 +00:00
Zdenek Kabelac
b39b36eeb5 Cosmetic change use return macro with implicit stack 2012-01-25 22:38:40 +00:00
Mike Snitzer
27e21a4adc Allow removal of an invalid snapshot that was to be merged on next activation.
Don't allow a user to merge an invalid snapshot.
2012-01-20 22:03:48 +00:00
Mike Snitzer
23e34c729b Differentiate between snapshot status of "Invalid" and "Merge failed". 2012-01-20 22:02:04 +00:00
Alasdair Kergon
909bf00ab4 tag uninit var 2011-12-08 18:00:03 +00:00
Jonathan Earl Brassow
d098140177 Add policy based automated repair of RAID logical volumes
The RAID plug-in for dmeventd now calls 'lvconvert --repair' to address failures
of devices in a RAID logical volume.  The action taken can be either to "warn"
or "allocate" a new device from any spares that may be available in the
volume group.  The action is designated by setting 'raid_fault_policy' in
lvm.conf - the default being "warn".
2011-12-06 19:30:15 +00:00
Jonathan Earl Brassow
0c506d9a40 Support the ability to replace specific devices in a RAID array.
RAID is not like traditional LVM mirroring.  LVM mirroring required failed
devices to be removed or the logical volume would simply hang.  RAID arrays can
keep on running with failed devices.  In fact, for RAID types other than RAID1,
removing a device would mean substituting an error target or converting to a
lower level RAID (e.g. RAID6 -> RAID5, or RAID4/5 to RAID0).  Therefore, rather
than removing a failed device unconditionally and potentially allocating a
replacement, RAID allows the user to "replace" a device with a new one.  This
approach is a 1-step solution vs the current 2-step solution.

example> lvconvert --replace <dev_to_remove> vg/lv [possible_replacement_PVs]

'--replace' can be specified more than once.

example> lvconvert --replace /dev/sdb1 --replace /dev/sdc1 vg/lv
2011-11-30 02:02:10 +00:00
Jonathan Earl Brassow
f60175c308 Add the ability to convert LVs of "mirror" segtype to "raid1" segtype.
Example:
~> lvconvert --type raid1 vg/mirror_lv

Steps to convert "mirror" to "raid1"
1) Allocate a RAID metadata LV for each mirror image from the same PVs
   on which they are located.
2) Clear the metadata LVs.  This involves writing LVM metadata, so we don't
   change any aspects of the mirror LV before this so that the user can easily
   remove LVs from the failed convert attempt while retaining the original
   mirror.
3) Remove the mirror log, if it exists.
4) Add metadata LVs to mirror LV
5) Rename mirror sub-lvs (s/mimage/rimage/)
6) Change flags and segtype from mirror to raid1
2011-10-07 14:56:01 +00:00
Jonathan Earl Brassow
d3582e0252 Add the ability to convert linear LVs to RAID1
Example:
~> lvconvert --type raid1 -m 1 vg/lv

The following steps are performed to convert linear to RAID1:
1) Allocate a metadata device from the same PV as the linear device
   to provide the metadata/data LV pair required for all RAID components.
2) Allocate the required number of metadata/data LV pairs for the
   remaining additional images.
3) Clear the metadata LVs.  This performs a LVM metadata update.
4) Create the top-level RAID LV and add the component devices.

We want to make any failure easy to unwind.  This is why we don't create the
top-level LV and add the components until the last step.  Should anything
happen before that, the user could simply remove the unnecessary images.  Also,
we want to ensure that the metadata LVs are cleared before forming the array to
prevent stale information from polluting the new array.

A new macro 'seg_is_linear' was added to allow us to distinguish linear LVs
from striped LVs.
2011-10-07 14:52:26 +00:00
Alasdair Kergon
2ef5b7cca6 Start using 64-bit status flags - most of the code already handles them.
tdata -> tpool
remove commented out definitions from metadata.h
formatting clean-ups
2011-09-06 18:49:31 +00:00
Jonathan Earl Brassow
a2facf4ad4 Add ability to merge back a RAID1 image that has been split w/ --trackchanges
Argument layout is very similar to the merge command for snapshots.
2011-08-18 19:43:08 +00:00
Jonathan Earl Brassow
6d04311efa Add the ability to split an image from the mirror and track changes.
~> lvconvert --splitmirrors 1 --trackchanges vg/lv
The '--trackchanges' option allows a user the ability to use an image of
a RAID1 array for the purposes of temporary read-only access.  The image
can be merged back into the array at a later time and only the blocks that
have changed in the array since the split will be resync'ed.  This
operation can be thought of as a partial split.  The image is never completely
extracted from the array, in that the array reserves the position the device
occupied and tracks the differences between the array and the split image via
a bitmap.  The image itself is rendered read-only and the name (<LV>_rimage_*)
cannot be changed.  The user can complete the split (permanently splitting the
image from the array) by re-issuing the 'lvconvert' command without the
'--trackchanges' argument and specifying the '--name' argument.
	~> lvconvert --splitmirrors 1 --name my_split vg/lv
Merging the tracked image back into the array is done with the '--merge'
option (included in a follow-on patch).
	~> lvconvert --merge vg/lv_rimage_<n>

The internal mechanics of this are relatively simple.  The 'raid' device-
mapper target allows for the specification of an empty slot in an array
via '- -'.  This is what will be used if a partial activation of an array
is ever required.  (It would also be possible to use 'error' targets in
place of the '- -'.)  If a RAID image is found to be both read-only and
visible, then it is considered separate from the array and '- -' is used
to hold it's position in the array.  So, all that needs to be done to
temporarily split an image from the array /and/ cause the kernel target's
bitmap to track (aka "mark") changes made is to make the specified image
visible and read-only.  To merge the device back into the array, the image
needs to be returned to the read/write state of the top-level LV and made
invisible.
2011-08-18 19:38:26 +00:00
Jonathan Earl Brassow
a324baf6a1 Add --splitmirrors support for RAID1 (1 image only)
Users already have the ability to split an image from an LV of "mirror"
segtype.  This patch extends that ability to LVs of "raid1" segtype.

This patch only allows a single image to be split off, however.  (The
"mirror" segtype allows an arbitrary number of images to be split off.
e.g.  4-way => 3-way/linear, 2-way/2-way, linear,3-way)
2011-08-18 19:34:18 +00:00
Jonathan Earl Brassow
4aebd52c4c Add ability to down-convert RAID1 arrays.
Also, add some simple RAID tests to testsuite.
2011-08-11 18:24:40 +00:00
Zdenek Kabelac
077a6755ff Replace free_vg with release_vg
Move the free_vg() to  vg.c  and replace free_vg  with release_vg
and make the _free_vg internal.

Patch is needed for sharing VG in vginfo cache so the release_vg function name
is a better fit here.
2011-08-10 20:25:29 +00:00
Alasdair Kergon
6585b5a197 remove unnecessary lvconvert.h 2011-07-08 19:42:11 +00:00
Jonathan Earl Brassow
63576b1202 Fix error message - the parameter name is '--mirrorlog' not '--log' 2011-06-29 02:06:26 +00:00
Jonathan Earl Brassow
48c9c491b0 Remove unnecesary conditional.
The conditional is not just unnecessary, it would have been wrong.  The code
is suppose to be checking if the 'splitmirrors_ARG' is negative, but it
instead is checking 'mirrors_ARG'.  Rather than changing the argument being
checked, I've pulled the check entirely because 'splitmirrors_ARG' is already
guarenteed to not be negative by virtue of the fact that it is a 'int_arg'.
Negative values will be caught in _process_command_line().
2011-06-28 21:28:35 +00:00
Peter Rajnoha
1fd2dac60b Clarify error message when unable to convert an LV into a snapshot of an LV. 2011-06-01 12:24:15 +00:00
Petr Rockai
b00711e312 Add a new entry point in the mirror lvconvert code, for removing missing mirror
images and/or logs, without attempting any further actions.
2011-05-07 13:56:13 +00:00