Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b0d8a524a2c1d9cc…
Commit: b0d8a524a2c1d9ccf191392bf47a2023087ae362
Parent: 37a33d7414b85e4ce69a2ab6727522faba8a86eb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 30 16:21:03 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:49 2016 +0200
tests: test foreign users of thin-pool
Note: dmeventd should not need any notification and automatically
try to resize again when there is some metadata change.
---
test/shell/thin-foreign-dmeventd.sh | 104 +++++++++++++++++++++++++++++++++++
1 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/test/shell/thin-foreign-dmeventd.sh b/test/shell/thin-foreign-dmeventd.sh
new file mode 100644
index 0000000..a96b206
--- /dev/null
+++ b/test/shell/thin-foreign-dmeventd.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+
+# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# test foreing user of thin-pool
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+MOUNT_DIR=mnt
+
+cleanup_mounted_and_teardown()
+{
+ umount "$MOUNT_DIR" || true
+ dmsetup remove $THIN
+ vgremove -ff $vg
+ aux teardown
+}
+
+percent_() {
+ get lv_field $vg/pool data_percent | cut -d. -f1
+}
+
+#
+# Main
+#
+aux have_thin 1 0 0 || skip
+which mkfs.ext4 || skip
+
+aux prepare_dmeventd
+aux prepare_pvs 2 64
+
+vgcreate $vg -s 64K $(cat DEVICES)
+
+# Create named pool only
+lvcreate --errorwhenfull y -L2100K -T $vg/pool
+
+POOL="$vg-pool"
+THIN="${PREFIX}_thin"
+
+# Foreing user is using own ioctl command to create thin devices
+dmsetup message $POOL 0 "create_thin 0"
+dmsetup message $POOL 0 "set_transaction_id 0 1"
+
+dmsetup status
+# Once the transaction id has changed, lvm2 shall not be able to create thinLV
+fail lvcreate -V10 $vg/pool
+
+trap 'cleanup_mounted_and_teardown' EXIT
+
+# 20M thin device
+dmsetup create $THIN --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
+
+dmsetup table
+dmsetup info -c
+
+mkdir "$MOUNT_DIR"
+# This mkfs fills 2.2MB pool over 95%
+# no autoresize is configured
+mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
+test $(percent_) -gt 95
+mount "$DM_DEV_DIR/mapper/$THIN" "$MOUNT_DIR"
+
+pvchange -x n "$dev1" "$dev2"
+
+test $(percent_) -gt 95
+# Configure autoresize
+aux lvmconf 'activation/thin_pool_autoextend_percent = 10' \
+ 'activation/thin_pool_autoextend_threshold = 75'
+
+# Give it some time to left dmeventd do some work
+sleep 20
+
+# And check foreign thin device is still mounted
+mount | grep "$MOUNT_DIR" | grep "$THIN"
+test $(percent_) -gt 95
+
+pvchange -x y "$dev1" "$dev2"
+
+# FIXME: ATM tell dmeventd explicitely we've changed metadata
+# however dmeventd shall be aware of any metadata change
+# and automagically retry resize operation after that.
+lvchange --refresh $vg/pool
+
+# Give it some time and let dmeventd do some work
+for i in $(seq 1 15) ; do
+ test $(percent_) -ge 75 || break
+ sleep 1
+done
+
+test $(percent_) -lt 75
+
+# And check foreign thin device is still mounted
+mount | grep "$MOUNT_DIR" | grep "$THIN"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=458918b31953943a…
Commit: 458918b31953943a3cc44976388f008ca850c124
Parent: 2f638e07e814617152d617a2ca7c8acdae41968a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 30 15:54:27 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:46 2016 +0200
thin: fix link validation for unused thin-pool
This patch fixes link validation for used thin-pool.
Udev rules correctly creates symlinks only for unused new thin-pool.
Such thin-pool can be used by foreing apps (like Docker) thus
has /dev/vg/lv link.
However when thin-pool becomes used by thinLV - this link is no
longer exposed to user - but internal verfication missed this
and caused messages like this to be printed upon 'vgchange -ay':
The link /dev/vg/pool should have been created by udev but it was not
found. Falling back to direct link creation.
And same with 'vgchange -an':
The link /dev/vg/pool should have been removed by udev but it is still
present. Falling back to direct link removal.
This patch ensures only unused thin-pool has this link.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 10 ++++++++--
test/shell/thin-overprovisioning.sh | 4 ++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a73744e..4d71ea8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.159 -
=================================
+ Fix created link for a used pool for vgmknode.
Introduce and use is_power_of_2 macro.
Support conversions between striped and raid0 segment types.
Add infrastructure for raid takeover lvconvert options.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 51f1a9a..233a216 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1599,6 +1599,12 @@ static int _dev_manager_lv_rmnodes(const struct logical_volume *lv)
return fs_del_lv(lv);
}
+static int _lv_has_mknode(const struct logical_volume *lv)
+{
+ return (lv_is_visible(lv) &&
+ (!lv_is_thin_pool(lv) || lv_is_new_thin_pool(lv)));
+}
+
int dev_manager_mknodes(const struct logical_volume *lv)
{
struct dm_info dminfo;
@@ -1610,7 +1616,7 @@ int dev_manager_mknodes(const struct logical_volume *lv)
if ((r = _info_run(MKNODES, name, NULL, &dminfo, NULL, NULL, 0, 0, 0, 0))) {
if (dminfo.exists) {
- if (lv_is_visible(lv))
+ if (_lv_has_mknode(lv))
r = _dev_manager_lv_mknodes(lv);
} else
r = _dev_manager_lv_rmnodes(lv);
@@ -2993,7 +2999,7 @@ static int _create_lv_symlinks(struct dev_manager *dm, struct dm_tree_node *root
r = 0;
continue;
}
- if (lv_is_visible(lvlayer->lv)) {
+ if (_lv_has_mknode(lvlayer->lv)) {
if (!_dev_manager_lv_mknodes(lvlayer->lv))
r = 0;
continue;
diff --git a/test/shell/thin-overprovisioning.sh b/test/shell/thin-overprovisioning.sh
index 8a396b6..07c74cc 100644
--- a/test/shell/thin-overprovisioning.sh
+++ b/test/shell/thin-overprovisioning.sh
@@ -24,6 +24,8 @@ aux have_thin 1 3 0 || skip
aux prepare_vg 2 33
lvcreate -L32 -T $vg/pool
+# check there is link node for UNUSED thin-pool
+test -e "$DM_DEV_DIR/$vg/pool"
# leave 12M free space
lvcreate -an -n $lv1 -L16 $vg 2>&1 | tee out
@@ -31,6 +33,8 @@ vgs $vg
lvcreate -n thin1 -V30 $vg/pool 2>&1 | tee out
not grep "WARNING: Sum" out
+# check again link node is now gone for a USED thin-pool
+test ! -e "$DM_DEV_DIR/$vg/pool"
# Pool gets overprovisioned
lvcreate -an -n thin2 -V4 $vg/pool 2>&1 | tee out
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=103c188681fce748…
Commit: 103c188681fce748ef193115c126bfbbc65fbab9
Parent: aed8bc8ae7b2f1c20a84470b033daababfb7c166
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 30 12:02:43 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 30 17:08:50 2016 -0500
lvconvert: add comments describing conversions
---
tools/lvconvert.c | 387 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 352 insertions(+), 35 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3b98116..795deef 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -18,6 +18,25 @@
#include "lv_alloc.h"
#include "lvconvert_poll.h"
+/*
+ * Guidelines for mapping options to operations.
+ *
+ * There should be a clear and unique correspondence between an option
+ * name and the operation to be performed.
+ *
+ * An option with a given name should always perform the same operation.
+ * If the same operation applies to two types of LV, then the same option
+ * name can be used with both LV types. But, a given option name should
+ * not be used to perform different operations depending on the LV type it
+ * is used with.
+ *
+ * --merge and --split are examples where a single option name has been
+ * overloaded with different operations. The case of --split has been
+ * corrected with the clear and unique variations --splitcache,
+ * --splitsnapshot, --splitmirror, which should allow --split to be
+ * deprecated. (The same is still needed for --merge.)
+ */
+
struct lvconvert_params {
/* Exactly one of these options is chosen */
int merge; /* Either merge_snapshot or merge_mirror is also set */
@@ -3295,24 +3314,44 @@ static int _lvconvert_cache(struct cmd_context *cmd,
* moved into the _convert_lvtype_operation() functions below.
*/
+/*
+ * Separate a COW snapshot LV from its origin.
+ * lvconvert --splitsnapshot LV
+ */
+
static int _convert_cow_snapshot_splitsnapshot(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_splitsnapshot(cmd, lv, lp);
}
+/*
+ * Merge a COW snapshot LV into its origin.
+ * lvconvert --merge LV
+ */
+
static int _convert_cow_snapshot_merge(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_merge_old_snapshot(cmd, lv, lp);
}
+/*
+ * Merge a snapshot thin LV into its origin.
+ * lvconvert --merge LV
+ */
+
static int _convert_thin_volume_merge(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_merge_thin_snapshot(cmd, lv, lp);
}
+/*
+ * Split and preserve a cache pool from the data portion of a thin pool LV.
+ * lvconvert --splitcache LV
+ */
+
static int _convert_thin_pool_splitcache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3328,6 +3367,11 @@ static int _convert_thin_pool_splitcache(struct cmd_context *cmd, struct logical
return _lvconvert_split_cached(cmd, sublv1);
}
+/*
+ * Split and remove a cache pool from the data portion of a thin pool LV.
+ * lvconvert --uncache LV
+ */
+
static int _convert_thin_pool_uncache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3343,16 +3387,35 @@ static int _convert_thin_pool_uncache(struct cmd_context *cmd, struct logical_vo
return _lvconvert_uncache(cmd, sublv1, lp);
}
+/*
+ * Repair a thin pool LV.
+ * lvconvert --repair LV
+ */
+
static int _convert_thin_pool_repair(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_thin_pool_repair(cmd, lv, lp);
}
+/*
+ * Convert the data portion of a thin pool LV to a cache LV.
+ * lvconvert --type cache LV
+ *
+ * Required options:
+ * --cachepool LV
+ *
+ * Auxiliary operation:
+ * Converts the --cachepool arg to a cache pool if it is not already.
+ *
+ * Alternate syntax:
+ * lvconvert --cache LV
+ */
+
static int _convert_thin_pool_cache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
- /* lvconvert --cache includes an implicit conversion of the cachepool arg to type cache-pool. */
+ /* lvconvert --type cache includes an implicit conversion of the cachepool arg to type cache-pool. */
if (!_lvconvert_pool(cmd, lv, lp)) {
log_error("Implicit conversion of --cachepool arg to type cache-pool failed.");
return 0;
@@ -3363,24 +3426,49 @@ static int _convert_thin_pool_cache(struct cmd_context *cmd, struct logical_volu
return _lvconvert_cache(cmd, lv, lp);
}
+/*
+ * Replace the metadata LV in a thin pool LV.
+ * lvconvert --poolmetadata NewLV --thinpool LV
+ * FIXME: this will change so --swap-poolmetadata defines the operation.
+ * FIXME: should be lvconvert --swap-poolmetadata NewLV LV
+ */
+
static int _convert_thin_pool_swapmetadata(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Split and preserve a cache pool from a cache LV.
+ * lvconvert --splitcache LV
+ */
+
static int _convert_cache_volume_splitcache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_split_cached(cmd, lv);
}
+/*
+ * Split and remove a cache pool from a cache LV.
+ * lvconvert --uncache LV
+ */
+
static int _convert_cache_volume_uncache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_uncache(cmd, lv, lp);
}
+/*
+ * Split images from the raid1|mirror origin of a cache LV and use them to create a new LV.
+ * lvconvert --splitmirrors Number LV
+ *
+ * Required options:
+ * --trackchanges | --name Name
+ */
+
static int _convert_cache_volume_splitmirrors(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3398,12 +3486,26 @@ static int _convert_cache_volume_splitmirrors(struct cmd_context *cmd, struct lo
return 0;
}
+/*
+ * Convert a cache LV to a thin pool (using the cache LV for thin pool data).
+ * lvconvert --type thin-pool LV
+ *
+ * Alternate syntax:
+ * This is equivalent to above, but not preferred because it's ambiguous and inconsistent.
+ * lvconvert --thinpool LV
+ */
+
static int _convert_cache_volume_thin_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Split a cache volume from a cache pool LV.
+ * lvconvert --splitcache LV
+ */
+
static int _convert_cache_pool_splitcache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3429,30 +3531,63 @@ static int _convert_cache_pool_splitcache(struct cmd_context *cmd, struct logica
return _lvconvert_split_cached(cmd, sublv1);
}
+/*
+ * Replace the metadata LV in a cache pool LV.
+ * lvconvert --poolmetadata NewLV --cachepool LV
+ * FIXME: this will change so --swap-poolmetadata defines the operation.
+ * FIXME: should be lvconvert --swap-poolmetadata NewLV LV
+ */
+
static int _convert_cache_pool_swapmetadata(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Change the number of images in a mirror LV.
+ * lvconvert --mirrors Number LV
+ */
+
static int _convert_mirror_number(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_mirrors(cmd, lv, lp);
}
+/*
+ * Split images from a mirror LV and use them to create a new LV.
+ * lvconvert --splitmirrors Number LV
+ *
+ * Required options:
+ * --name Name
+ */
+
static int _convert_mirror_splitmirrors(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_mirrors(cmd, lv, lp);
}
+/*
+ * Change the type of log used by a mirror LV.
+ * lvconvert --mirrorlog Type LV
+ */
+
static int _convert_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_mirrors(cmd, lv, lp);
}
+/*
+ * Replace failed PVs in a mirror LV.
+ * lvconvert --repair LV
+ *
+ * Auxiliary operation:
+ * Removes missing, empty PVs from the VG, like vgreduce.
+ */
+
static int _convert_mirror_repair(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3469,18 +3604,38 @@ static int _convert_mirror_repair(struct cmd_context *cmd, struct logical_volume
return ret;
}
+/*
+ * Convert mirror LV to raid1 LV.
+ * lvconvert --type raid1 LV
+ *
+ * FIXME: this is not yet implemented in the raid code.
+ */
+
static int _convert_mirror_raid(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_raid(lv, lp);
}
+/*
+ * Change the number of images in a raid1 LV.
+ * lvconvert --mirrors Number LV
+ */
+
static int _convert_raid_number(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_raid(lv, lp);
}
+/*
+ * Split images from a raid1 LV and use them to create a new LV.
+ * lvconvert --splitmirrors Number LV
+ *
+ * Required options:
+ * --trackchanges | --name Name
+ */
+
static int _convert_raid_splitmirrors(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3488,6 +3643,12 @@ static int _convert_raid_splitmirrors(struct cmd_context *cmd, struct logical_vo
return _lvconvert_raid(lv, lp);
}
+/*
+ * Merge a raid1 LV into originalLV if the raid1 LV was
+ * previously split from the originalLV using --trackchanges.
+ * lvconvert --merge LV
+ */
+
static int _convert_raid_merge(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3495,6 +3656,14 @@ static int _convert_raid_merge(struct cmd_context *cmd, struct logical_volume *l
return _lvconvert_raid(lv, lp);
}
+/*
+ * Replace failed PVs in a raid* LV.
+ * lvconvert --repair LV
+ *
+ * Auxiliary operation:
+ * Removes missing, empty PVs from the VG, like vgreduce.
+ */
+
static int _convert_raid_repair(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3512,6 +3681,11 @@ static int _convert_raid_repair(struct cmd_context *cmd, struct logical_volume *
return ret;
}
+/*
+ * Replace a specific PV in a raid* LV with another PV.
+ * lvconvert --replace PV LV
+ */
+
static int _convert_raid_replace(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3519,12 +3693,35 @@ static int _convert_raid_replace(struct cmd_context *cmd, struct logical_volume
return _lvconvert_raid(lv, lp);
}
+/*
+ * Combine a raid* LV with a snapshot LV that was previously
+ * split from the raid* LV using --splitsnapshot.
+ * lvconvert --type snapshot LV SnapshotLV
+ *
+ * Alternate syntax:
+ * lvconvert --snapshot LV SnapshotLV
+ */
+
static int _convert_raid_snapshot(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_snapshot(cmd, lv, lp);
}
+/*
+ * Convert a raid* LV to a thin LV with an external origin.
+ * lvconvert --type thin LV
+ *
+ * Required options:
+ * --thinpool LV
+ *
+ * Auxiliary operation:
+ * Converts the --thinpool arg to a thin pool if it is not already.
+ *
+ * Alternate syntax:
+ * lvconvert --thin LV
+ */
+
static int _convert_raid_thin(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3537,10 +3734,24 @@ static int _convert_raid_thin(struct cmd_context *cmd, struct logical_volume *lv
return _lvconvert_thin(cmd, lv, lp);
}
+/*
+ * Convert a raid* LV to a cache LV.
+ * lvconvert --type cache LV
+ *
+ * Required options:
+ * --cachepool LV
+ *
+ * Auxiliary operation:
+ * Converts the --cachepool arg to a cache pool if it is not already.
+ *
+ * Alternate syntax:
+ * lvconvert --cache LV
+ */
+
static int _convert_raid_cache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
- /* lvconvert --cache includes an implicit conversion of the cachepool arg to type cache-pool. */
+ /* lvconvert --type cache includes an implicit conversion of the cachepool arg to type cache-pool. */
if (!_lvconvert_pool(cmd, lv, lp)) {
log_error("Implicit conversion of --cachepool arg to type cache-pool failed.");
return 0;
@@ -3549,41 +3760,74 @@ static int _convert_raid_cache(struct cmd_context *cmd, struct logical_volume *l
return _lvconvert_cache(cmd, lv, lp);
}
+/*
+ * Convert a raid* LV to a thin-pool LV.
+ * lvconvert --type thin-pool LV
+ *
+ * Alternate syntax:
+ * This is equivalent to above, but not preferred because it's ambiguous and inconsistent.
+ * lvconvert --thinpool LV
+ */
+
static int _convert_raid_thin_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Convert a raid* LV to cache-pool LV.
+ * lvconvert --type cache-pool LV
+ */
+
static int _convert_raid_cache_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Convert a raid* LV to use a different raid level.
+ * lvconvert --type raid* LV
+ */
+
static int _convert_raid_raid(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_raid(lv, lp);
}
+/*
+ * Convert a raid* LV to a striped LV.
+ * lvconvert --type striped LV
+ *
+ * FIXME: this is not yet implemented in the raid code.
+ */
+
static int _convert_raid_striped(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_raid(lv, lp);
}
+/*
+ * Convert a raid* LV to a linear LV.
+ * lvconvert --type linear LV
+ *
+ * FIXME: this is not yet implemented in the raid code.
+ */
+
static int _convert_raid_linear(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_raid(lv, lp);
}
-static int _convert_striped_snapshot(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvconvert_params *lp)
-{
- return _lvconvert_snapshot(cmd, lv, lp);
-}
+/*
+ * Merge a striped/linear LV into a raid1 LV if the striped/linear LV was
+ * previously split from the raid1 LV using --trackchanges.
+ * lvconvert --merge LV
+ */
static int _convert_striped_merge(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
@@ -3591,6 +3835,35 @@ static int _convert_striped_merge(struct cmd_context *cmd, struct logical_volume
return _lvconvert_raid(lv, lp);
}
+/*
+ * Combine a linear/striped LV with a snapshot LV that was previously
+ * split from the linear/striped LV using --splitsnapshot.
+ * lvconvert --type snapshot LV SnapshotLV
+ *
+ * Alternate syntax:
+ * lvconvert --snapshot LV SnapshotLV
+ */
+
+static int _convert_striped_snapshot(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvconvert_params *lp)
+{
+ return _lvconvert_snapshot(cmd, lv, lp);
+}
+
+/*
+ * Convert a striped/linear LV to a thin LV with an external origin.
+ * lvconvert --type thin LV
+ *
+ * Required options:
+ * --thinpool LV
+ *
+ * Auxiliary operation:
+ * Converts the --thinpool arg to a thin pool if it is not already.
+ *
+ * Alternate syntax:
+ * lvconvert --thin LV
+ */
+
static int _convert_striped_thin(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3603,6 +3876,20 @@ static int _convert_striped_thin(struct cmd_context *cmd, struct logical_volume
return _lvconvert_thin(cmd, lv, lp);
}
+/*
+ * Convert a striped/linear LV to a cache LV.
+ * lvconvert --type cache LV
+ *
+ * Required options:
+ * --cachepool LV
+ *
+ * Auxiliary operation:
+ * Converts the --cachepool arg to a cache pool if it is not already.
+ *
+ * Alternate syntax:
+ * lvconvert --cache LV
+ */
+
static int _convert_striped_cache(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3615,24 +3902,62 @@ static int _convert_striped_cache(struct cmd_context *cmd, struct logical_volume
return _lvconvert_cache(cmd, lv, lp);
}
+/*
+ * Convert a striped/linear LV to a thin-pool LV.
+ * lvconvert --type thin-pool LV
+ *
+ * Alternate syntax:
+ * This is equivalent to above, but not preferred because it's ambiguous and inconsistent.
+ * lvconvert --thinpool LV
+ */
+
static int _convert_striped_thin_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Convert a striped/linear LV to a cache-pool LV.
+ * lvconvert --type cache-pool LV
+ */
+
static int _convert_striped_cache_pool(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_pool(cmd, lv, lp);
}
+/*
+ * Convert a striped/linear LV to a mirror LV.
+ * lvconvert --type mirror LV
+ *
+ * Required options:
+ * --mirrors Number
+ *
+ * Alternate syntax:
+ * This is equivalent to above when global/mirror_segtype_default="mirror".
+ * lvconvert --mirrors Number LV
+ */
+
static int _convert_striped_mirror(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
return _lvconvert_mirrors(cmd, lv, lp);
}
+/*
+ * Convert a striped/linear LV to a raid* LV.
+ * lvconvert --type raid* LV
+ *
+ * Required options:
+ * --mirrors Number
+ *
+ * Alternate syntax:
+ * This is equivalent to above when global/mirror_segtype_default="raid1".
+ * lvconvert --mirrors Number LV
+ */
+
static int _convert_striped_raid(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
@@ -3696,9 +4021,9 @@ static int _convert_thin_pool(struct cmd_context *cmd, struct logical_volume *lv
log_error("Operation not permitted on thin pool LV %s", display_lvname(lv));
log_error("Operations permitted on a thin pool LV are:\n"
- " --splitcache (operates on cache sub LV)\n"
- " --uncache (operates on cache sub LV)\n"
- " --cache (operates on data sub LV)\n"
+ " --splitcache (operates on cache sub LV)\n"
+ " --uncache (operates on cache sub LV)\n"
+ " --type cache | --cache (operates on data sub LV)\n"
" --repair\n");
return 0;
}
@@ -3718,12 +4043,12 @@ static int _convert_cache_volume(struct cmd_context *cmd, struct logical_volume
if (arg_is_set(cmd, splitmirrors_ARG))
return _convert_cache_volume_splitmirrors(cmd, lv, lp);
- /* The --thinpool alias is ambiguous and not preferred. */
+ /* Using --thinpool is ambiguous and not preferred. */
if ((new_type && !strcmp(new_type, "thin-pool")) || arg_is_set(cmd, thinpool_ARG))
return _convert_cache_volume_thin_pool(cmd, lv, lp);
- /* The --thinpool alias for --type thin-pool is not preferred, so not shown. */
+ /* The --thinpool alternative for --type thin-pool is not preferred, so not shown. */
log_error("Operation not permitted on cache LV %s", display_lvname(lv));
log_error("Operations permitted on a cache LV are:\n"
@@ -3782,6 +4107,7 @@ static int _convert_mirror(struct cmd_context *cmd, struct logical_volume *lv,
* explicit option should be added to enable this case,
* rather than making it the result of an ambiguous
* "lvconvert vg/lv" command.
+ * Add 'lvconvert --poll-mirror vg/lv' for this case.
*
* Old behavior was described as:
* "Collapsing a stack of mirrors.
@@ -3837,7 +4163,7 @@ static int _convert_raid(struct cmd_context *cmd, struct logical_volume *lv,
if (lp->cache)
return _convert_raid_cache(cmd, lv, lp);
- /* The --thinpool alias is ambiguous and not preferred. */
+ /* Using --thinpool is ambiguous and not preferred. */
if ((new_type && !strcmp(new_type, "thin-pool")) || arg_is_set(cmd, thinpool_ARG))
return _convert_raid_thin_pool(cmd, lv, lp);
@@ -3854,7 +4180,7 @@ static int _convert_raid(struct cmd_context *cmd, struct logical_volume *lv,
if (new_type && !strcmp(new_type, "linear"))
return _convert_raid_linear(cmd, lv, lp);
- /* The --thinpool alias for --type thin-pool is not preferred, so not shown. */
+ /* The --thinpool alternative for --type thin-pool is not preferred, so not shown. */
log_error("Operation not permitted on raid LV %s", display_lvname(lv));
log_error("Operations permitted on a raid LV are:\n"
@@ -3863,9 +4189,9 @@ static int _convert_raid(struct cmd_context *cmd, struct logical_volume *lv,
" --merge\n"
" --repair\n"
" --replace\n"
- " --snapshot\n"
- " --thin\n"
- " --cache\n"
+ " --type snapshot | --snapshot\n"
+ " --type thin | --thin\n"
+ " --type cache | --cache\n"
" --type thin-pool\n"
" --type cache-pool\n"
" --type raid*\n"
@@ -3884,20 +4210,20 @@ static int _convert_striped(struct cmd_context *cmd, struct logical_volume *lv,
if (new_type)
new_segtype = get_segtype_from_string(cmd, new_type);
- if (lp->snapshot)
- return _convert_striped_snapshot(cmd, lv, lp);
-
/* FIXME: add a new option to make this case more clear, e.g. --merge-splitmirror */
if (lp->merge)
return _convert_striped_merge(cmd, lv, lp);
+ if (lp->snapshot)
+ return _convert_striped_snapshot(cmd, lv, lp);
+
if (lp->thin)
return _convert_striped_thin(cmd, lv, lp);
if (lp->cache)
return _convert_striped_cache(cmd, lv, lp);
- /* The --thinpool alias is ambiguous and not preferred. */
+ /* Using --thinpool is ambiguous and not preferred. */
if ((new_type && !strcmp(new_type, "thin-pool")) || arg_is_set(cmd, thinpool_ARG))
return _convert_striped_thin_pool(cmd, lv, lp);
@@ -3919,14 +4245,14 @@ static int _convert_striped(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_is_set(cmd, mirrors_ARG) && mirrors_type && !strcmp(mirrors_type, "raid1"))
return _convert_striped_raid(cmd, lv, lp);
- /* The --thinpool alias for --type thin-pool is not preferred, so not shown. */
+ /* The --thinpool alternative for --type thin-pool is not preferred, so not shown. */
log_error("Operation not permitted on striped or linear LV %s", display_lvname(lv));
log_error("Operations permitted on a striped or linear LV are:\n"
- " --snapshot\n"
" --merge\n"
- " --thin\n"
- " --cache\n"
+ " --type snapshot | --snapshot\n"
+ " --type thin | --thin\n"
+ " --type cache | --cache\n"
" --type thin-pool\n"
" --type cache-pool\n"
" --type mirror | --mirrors\n"
@@ -3949,6 +4275,7 @@ static int _convert_striped(struct cmd_context *cmd, struct logical_volume *lv,
* _convert_lvtype();
* for each lp->operation
* _convert_lvtype_operation();
+ *
*/
static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
@@ -3957,12 +4284,6 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
struct lv_segment *lv_seg = first_seg(lv);
int ret = 0;
- log_debug("lvconvert lv %s is type %s status %llx to type %s",
- display_lvname(lv),
- lv_seg->segtype->name,
- (unsigned long long)lv->status,
- arg_str_value(cmd, type_ARG, ""));
-
/*
* Check some conditions that can never be processed.
*/
@@ -4048,10 +4369,6 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv,
}
/*
- * Check for LV types that cannot be converted and print an error.
- */
-
- /*
* The intention is to explicitly check all cases above and never
* reach here, but this covers anything that was missed.
*/
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8e39530efdffc42…
Commit: a8e39530efdffc42d21e9bc968ab3966b719876a
Parent: 802ed9d4597443e21086b392d9ee160f6d99dde9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 30 10:09:54 2016 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 30 10:09:54 2016 -0500
lvconvert: add missing alias for a thin-pool conversion
The case of converting a cache volume to a thin pool missed
recognizing the --thinpool alias for --type thin-pool.
---
tools/lvconvert.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4808090..8ceb1c7 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3718,9 +3718,13 @@ static int _convert_cache_volume(struct cmd_context *cmd, struct logical_volume
if (arg_is_set(cmd, splitmirrors_ARG))
return _convert_cache_volume_splitmirrors(cmd, lv, lp);
- if (new_type && !strcmp(new_type, "thin-pool"))
+ /* The --thinpool alias is ambiguous and not preferred. */
+
+ if ((new_type && !strcmp(new_type, "thin-pool")) || arg_is_set(cmd, thinpool_ARG))
return _convert_cache_volume_thin_pool(cmd, lv, lp);
+ /* The --thinpool alias for --type thin-pool is not preferred, so not shown. */
+
log_error("Operation not permitted on cache LV %s", display_lvname(lv));
log_error("Operations permitted on a cache LV are:\n"
" --splitcache\n"