master - tests: test foreign users of thin-pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b0d8a524a2c1d9...
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"
7 years, 3 months
master - cleanup: warns from older gcc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=37a33d7414b85e...
Commit: 37a33d7414b85e4ce69a2ab6727522faba8a86eb
Parent: 3fd458488649c27f18f1ddb993ba9360f259d47b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 27 11:13:43 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:48 2016 +0200
cleanup: warns from older gcc
---
lib/cache/lvmcache.c | 3 +--
lib/display/display.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 9d89b80..6ce778d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -2137,7 +2137,6 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller,
char pvid_s[ID_LEN + 1] __attribute__((aligned(8)));
char uuid[64] __attribute__((aligned(8)));
struct lvmcache_vgsummary vgsummary = { 0 };
- const struct format_type *fmt = labeller->fmt;
struct lvmcache_info *info;
struct lvmcache_info *info_lookup;
struct device_list *devl;
@@ -2178,7 +2177,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller,
if (!_found_duplicate_pvs && lvmetad_used()) {
log_warn("WARNING: Disabling lvmetad cache which does not support duplicate PVs.");
- lvmetad_set_disabled(fmt->cmd, LVMETAD_DISABLE_REASON_DUPLICATES);
+ lvmetad_set_disabled(labeller->fmt->cmd, LVMETAD_DISABLE_REASON_DUPLICATES);
}
_found_duplicate_pvs = 1;
diff --git a/lib/display/display.c b/lib/display/display.c
index 19421e7..f8dd338 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -843,7 +843,7 @@ char yes_no_prompt(const char *prompt, ...)
static const char _no[] = "no";
const char *answer = NULL;
int c = silent_mode() ? EOF : 0;
- int i, ret = 0, sig = 0;
+ int i = 0, ret = 0, sig = 0;
char buf[12];
va_list ap;
7 years, 3 months
master - cleanup: lvchange uses display_lvname
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3fd458488649c2...
Commit: 3fd458488649c27f18f1ddb993ba9360f259d47b
Parent: b9d3e8c8a8cd5faf23e30336303f6aeef5c32804
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 30 10:45:58 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:48 2016 +0200
cleanup: lvchange uses display_lvname
Convert messages to report vg/lv name consistently.
Also drop unneeded 'info_obtaned' variable since the
obtained info is not reused in any code path.
---
tools/lvchange.c | 212 +++++++++++++++++++++++++++---------------------------
1 files changed, 107 insertions(+), 105 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index b9944f7..c5461f9 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2014 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -22,72 +22,69 @@ static int _lvchange_permission(struct cmd_context *cmd,
{
uint32_t lv_access;
struct lvinfo info;
- unsigned info_obtained = 0;
lv_access = arg_uint_value(cmd, permission_ARG, 0);
if (lv_is_external_origin(lv)) {
- log_error("Cannot change permissions of external origin "
- "\"%s\".", lv->name);
+ log_error("Cannot change permissions of external origin %s.",
+ display_lvname(lv));
return 0;
}
if (!(lv_access & LVM_WRITE) && !(lv->status & LVM_WRITE)) {
/* Refresh if it's read-only in metadata but read-write in kernel */
- if (lv_info(cmd, lv, 0, &info, 0, 0) &&
- (info_obtained = 1, info.exists) && !info.read_only) {
- log_print_unless_silent("Logical volume \"%s\" is already read-only. Refreshing kernel state.",
- lv->name);
+ if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists && !info.read_only) {
+ log_print_unless_silent("Logical volume %s is already read-only. Refreshing kernel state.",
+ display_lvname(lv));
return lv_refresh(cmd, lv);
}
- log_error("Logical volume \"%s\" is already read only",
- lv->name);
+ log_error("Logical volume \"%s\" is already read only.",
+ display_lvname(lv));
return 0;
}
if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
/* Refresh if it's read-write in metadata but read-only in kernel */
- if (lv_info(cmd, lv, 0, &info, 0, 0) &&
- (info_obtained = 1, info.exists) && info.read_only) {
- log_print_unless_silent("Logical volume \"%s\" is already writable. Refreshing kernel state.",
- lv->name);
+ if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists && info.read_only) {
+ log_print_unless_silent("Logical volume %s is already writable. Refreshing kernel state.",
+ display_lvname(lv));
return lv_refresh(cmd, lv);
}
- log_error("Logical volume \"%s\" is already writable",
- lv->name);
+ log_error("Logical volume %s is already writable.",
+ display_lvname(lv));
return 0;
}
if (lv_is_mirrored(lv) && vg_is_clustered(lv->vg) &&
- (info_obtained || lv_info(cmd, lv, 0, &info, 0, 0)) && info.exists) {
- log_error("Cannot change permissions of mirror \"%s\" "
- "while active.", lv->name);
+ lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
+ log_error("Cannot change permissions of mirror %s while active.",
+ display_lvname(lv));
return 0;
}
/* Not allowed to change permissions on RAID sub-LVs directly */
if (lv_is_raid_metadata(lv) || lv_is_raid_image(lv)) {
- log_error("Cannot change permissions of RAID %s \"%s\"",
- lv_is_raid_image(lv) ? "image" :
- "metadata area", lv->name);
+ log_error("Cannot change permissions of RAID %s %s.",
+ lv_is_raid_image(lv) ? "image" : "metadata area",
+ display_lvname(lv));
return 0;
}
if (!(lv_access & LVM_WRITE) && lv_is_thin_pool(lv)) {
- log_error("Change permissions of thin pool \"%s\" not "
- "yet supported.", lv->name);
+ log_error("Change permissions of thin pool %s not yet supported.",
+ display_lvname(lv));
return 0;
}
if (lv_access & LVM_WRITE) {
lv->status |= LVM_WRITE;
- log_verbose("Setting logical volume \"%s\" read/write",
- lv->name);
+ log_verbose("Setting logical volume %s read/write.",
+ display_lvname(lv));
} else {
lv->status &= ~LVM_WRITE;
- log_verbose("Setting logical volume \"%s\" read-only",
- lv->name);
+ log_verbose("Setting logical volume %s read-only.",
+ display_lvname(lv));
}
if (!lv_update_and_reload(lv))
@@ -104,7 +101,8 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
thin_discards_t discards;
if (!lv_is_thin_pool(lv)) {
- log_error("Logical volume \"%s\" is not a thin pool.", lv->name);
+ log_error("Logical volume %s is not a thin pool.",
+ display_lvname(lv));
return 0;
}
@@ -114,14 +112,15 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
if (((discards == THIN_DISCARDS_IGNORE) ||
(first_seg(lv)->discards == THIN_DISCARDS_IGNORE)) &&
pool_is_active(lv))
- log_error("Cannot change support for discards while pool volume \"%s\" is active.", lv->name);
+ log_error("Cannot change support for discards while pool volume %s is active.",
+ display_lvname(lv));
else {
first_seg(lv)->discards = discards;
update++;
}
} else
- log_error("Logical volume \"%s\" already uses --discards %s.",
- lv->name, get_pool_discards_name(discards));
+ log_error("Logical volume %s already uses --discards %s.",
+ display_lvname(lv), get_pool_discards_name(discards));
}
if (arg_is_set(cmd, zero_ARG)) {
@@ -130,8 +129,8 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
first_seg(lv)->zero_new_blocks = val;
update++;
} else
- log_error("Logical volume \"%s\" already %szero new blocks.",
- lv->name, val ? "" : "does not ");
+ log_error("Logical volume %s already %szero new blocks.",
+ display_lvname(lv), val ? "" : "does not ");
}
if (!update)
@@ -150,7 +149,7 @@ static int _lvchange_monitoring(struct cmd_context *cmd,
if (!lv_info(cmd, lv, lv_is_thin_pool(lv) ? 1 : 0,
&info, 0, 0) || !info.exists) {
- log_error("Logical volume, %s, is not active", lv->name);
+ log_error("Logical volume %s is not active.", display_lvname(lv));
return 0;
}
@@ -171,7 +170,7 @@ static int _lvchange_background_polling(struct cmd_context *cmd,
struct lvinfo info;
if (!lv_info(cmd, lv, 0, &info, 0, 0) || !info.exists) {
- log_error("Logical volume, %s, is not active", lv->name);
+ log_error("Logical volume %s is not active.", display_lvname(lv));
return 0;
}
@@ -290,7 +289,7 @@ static int attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
*/
static int _lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
{
- log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name);
+ log_verbose("Refreshing logical volume %s (if active).", display_lvname(lv));
return lv_refresh(cmd, lv);
}
@@ -329,33 +328,33 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
if (!seg_is_mirror(seg) && !seg_is_raid(seg)) {
log_error("Unable to resync %s. It is not RAID or mirrored.",
- lv->name);
+ display_lvname(lv));
return 0;
}
if (lv_is_pvmove(lv)) {
- log_error("Unable to resync pvmove volume %s", lv->name);
+ log_error("Unable to resync pvmove volume %s.", display_lvname(lv));
return 0;
}
if (lv_is_locked(lv)) {
- log_error("Unable to resync locked volume %s", lv->name);
+ log_error("Unable to resync locked volume %s.", display_lvname(lv));
return 0;
}
if (lv_is_active_locally(lv)) {
if (!lv_check_not_in_use(lv, 1)) {
- log_error("Can't resync open logical volume \"%s\"",
- lv->name);
+ log_error("Can't resync open logical volume %s.",
+ display_lvname(lv));
return 0;
}
if (!arg_is_set(cmd, yes_ARG) &&
yes_no_prompt("Do you really want to deactivate "
"logical volume %s to resync it? [y/n]: ",
- lv->name) == 'n') {
- log_error("Logical volume \"%s\" not resynced",
- lv->name);
+ display_lvname(lv)) == 'n') {
+ log_error("Logical volume %s not resynced.",
+ display_lvname(lv));
return 0;
}
@@ -365,8 +364,8 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
}
if (seg_is_raid(seg) && active && !exclusive) {
- log_error("RAID logical volume %s/%s cannot be active remotely.",
- lv->vg->name, lv->name);
+ log_error("RAID logical volume %s cannot be active remotely.",
+ display_lvname(lv));
return 0;
}
@@ -376,13 +375,13 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
init_dmeventd_monitor(0);
if (!deactivate_lv(cmd, lv)) {
- log_error("Unable to deactivate %s for resync", lv->name);
+ log_error("Unable to deactivate %s for resync.", display_lvname(lv));
return 0;
}
if (vg_is_clustered(lv->vg) && lv_is_active(lv)) {
- log_error("Can't get exclusive access to clustered volume %s",
- lv->name);
+ log_error("Can't get exclusive access to clustered volume %s.",
+ display_lvname(lv));
return 0;
}
@@ -390,12 +389,12 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
init_dmeventd_monitor(monitored);
init_mirror_in_sync(0);
- log_very_verbose("Starting resync of %s%s%s%s \"%s\"",
+ log_very_verbose("Starting resync of %s%s%s%s %s.",
(active) ? "active " : "",
vg_is_clustered(lv->vg) ? "clustered " : "",
(seg->log_lv) ? "disk-logged " :
seg_is_raid(seg) ? "" : "core-logged ",
- lvseg_name(seg), lv->name);
+ lvseg_name(seg), display_lvname(lv));
/*
* If this mirror has a core log (i.e. !seg->log_lv),
@@ -406,8 +405,8 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
if (!seg_is_raid(seg) && !seg->log_lv) {
if (lv->status & LV_NOTSYNCED) {
lv->status &= ~LV_NOTSYNCED;
- log_very_verbose("Updating logical volume \"%s\""
- " on disk(s)", lv->name);
+ log_very_verbose("Updating logical volume %s on disk(s).",
+ display_lvname(lv));
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");
return 0;
@@ -415,8 +414,8 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
}
if (!_reactivate_lv(lv, active, exclusive)) {
- log_error("Failed to reactivate %s to resynchronize "
- "mirror", lv->name);
+ log_error("Failed to reactivate %s to resynchronize mirror.",
+ display_lvname(lv));
return 0;
}
@@ -430,9 +429,9 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
/* Separate mirror log or metadata devices so we can clear them */
if (!detach_metadata_devices(seg, &device_list)) {
- log_error("Failed to clear %s %s for %s",
+ log_error("Failed to clear %s %s for %s.",
seg->segtype->name, seg_is_raid(seg) ?
- "metadata area" : "mirror log", lv->name);
+ "metadata area" : "mirror log", display_lvname(lv));
return 0;
}
@@ -448,16 +447,16 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
dm_list_iterate_items(lvl, &device_list) {
if (!activate_lv_excl_local(cmd, lvl->lv)) {
- log_error("Unable to activate %s for %s clearing",
- lvl->lv->name, (seg_is_raid(seg)) ?
+ log_error("Unable to activate %s for %s clearing.",
+ display_lvname(lvl->lv), (seg_is_raid(seg)) ?
"metadata area" : "mirror log");
return 0;
}
if (!wipe_lv(lvl->lv, (struct wipe_params)
{ .do_zero = 1, .zero_sectors = lvl->lv->size })) {
- log_error("Unable to reset sync status for %s",
- lv->name);
+ log_error("Unable to reset sync status for %s.",
+ display_lvname(lv));
if (!deactivate_lv(cmd, lvl->lv))
log_error("Failed to deactivate log LV after "
"wiping failed");
@@ -466,36 +465,37 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
if (!deactivate_lv(cmd, lvl->lv)) {
log_error("Unable to deactivate %s LV %s "
- "after wiping for resync",
+ "after wiping for resync.",
(seg_is_raid(seg)) ? "metadata" : "log",
- lvl->lv->name);
+ display_lvname(lvl->lv));
return 0;
}
}
/* Wait until devices are away */
if (!sync_local_dev_names(lv->vg->cmd)) {
- log_error("Failed to sync local devices after updating %s",
+ log_error("Failed to sync local devices after updating %s.",
display_lvname(lv));
return 0;
}
/* Put metadata sub-LVs back in place */
if (!attach_metadata_devices(seg, &device_list)) {
- log_error("Failed to reattach %s device after clearing",
+ log_error("Failed to reattach %s device after clearing.",
(seg_is_raid(seg)) ? "metadata" : "log");
return 0;
}
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
- log_error("Failed to update metadata on disk.");
+ log_error("Failed to update metadata on disk for %s.",
+ display_lvname(lv));
return 0;
}
if (!_reactivate_lv(lv, active, exclusive)) {
backup(lv->vg);
- log_error("Failed to reactivate %s after resync",
- lv->name);
+ log_error("Failed to reactivate %s after resync.",
+ display_lvname(lv));
return 0;
}
@@ -512,8 +512,8 @@ static int _lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
? ALLOC_CONTIGUOUS : ALLOC_INHERIT);
if (alloc == lv->alloc) {
- log_error("Allocation policy of logical volume \"%s\" is "
- "already %s", lv->name, get_alloc_string(alloc));
+ log_error("Allocation policy of logical volume %s is already %s.",
+ display_lvname(lv), get_alloc_string(alloc));
return 0;
}
@@ -521,10 +521,10 @@ static int _lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
/* FIXME If contiguous, check existing extents already are */
- log_verbose("Setting contiguous allocation policy for \"%s\" to %s",
- lv->name, get_alloc_string(alloc));
+ log_verbose("Setting contiguous allocation policy for %s to %s.",
+ display_lvname(lv), get_alloc_string(alloc));
- log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
+ log_very_verbose("Updating logical volume %s on disk(s).", display_lvname(lv));
/* No need to suspend LV for this change */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
@@ -584,17 +584,18 @@ static int _lvchange_readahead(struct cmd_context *cmd,
if (lv->read_ahead == read_ahead) {
if (read_ahead == DM_READ_AHEAD_AUTO)
- log_error("Read ahead is already auto for \"%s\"", lv->name);
+ log_error("Read ahead is already auto for %s.",
+ display_lvname(lv));
else
- log_error("Read ahead is already %u for \"%s\"",
- read_ahead, lv->name);
+ log_error("Read ahead is already %u for %s.",
+ read_ahead, display_lvname(lv));
return 0;
}
lv->read_ahead = read_ahead;
- log_verbose("Setting read ahead to %u for \"%s\"", read_ahead,
- lv->name);
+ log_verbose("Setting read ahead to %u for %s.",
+ read_ahead, display_lvname(lv));
if (!lv_update_and_reload(lv))
return_0;
@@ -629,7 +630,8 @@ static int _lvchange_persistent(struct cmd_context *cmd,
!arg_is_set(cmd, yes_ARG) &&
yes_no_prompt("Logical volume %s will be "
"deactivated temporarily. "
- "Continue? [y/n]: ", lv->name) == 'n') {
+ "Continue? [y/n]: ",
+ display_lvname(lv)) == 'n') {
log_error("%s device number not changed.",
display_lvname(lv));
return 0;
@@ -665,9 +667,9 @@ static int _lvchange_persistent(struct cmd_context *cmd,
return_0;
if (activate != CHANGE_AN) {
- log_verbose("Re-activating logical volume %s", display_lvname(lv));
+ log_verbose("Re-activating logical volume %s.", display_lvname(lv));
if (!lv_active_change(cmd, lv, activate, 0)) {
- log_error("%s: reactivation failed", display_lvname(lv));
+ log_error("%s: reactivation failed.", display_lvname(lv));
backup(lv->vg);
return 0;
}
@@ -736,7 +738,7 @@ static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int
if (!change_tag(cmd, NULL, lv, NULL, arg))
return_0;
- log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
+ log_very_verbose("Updating logical volume %s on disk(s).", display_lvname(lv));
/* No need to suspend LV for this change */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
@@ -759,7 +761,7 @@ static int _lvchange_writemostly(struct logical_volume *lv)
struct lv_segment *raid_seg = first_seg(lv);
if (!seg_is_raid1(raid_seg)) {
- log_error("--write%s can only be used with 'raid1' segment type",
+ log_error("--write%s can only be used with 'raid1' segment type.",
arg_is_set(cmd, writemostly_ARG) ? "mostly" : "behind");
return 0;
}
@@ -853,8 +855,8 @@ static int _lvchange_recovery_rate(struct logical_volume *lv)
struct lv_segment *raid_seg = first_seg(lv);
if (!seg_is_raid(raid_seg)) {
- log_error("Unable to change the recovery rate of non-RAID"
- " logical volume.");
+ log_error("Unable to change the recovery rate of non-RAID "
+ "logical volume %s.", display_lvname(lv));
return 0;
}
@@ -867,8 +869,7 @@ static int _lvchange_recovery_rate(struct logical_volume *lv)
if (raid_seg->max_recovery_rate &&
(raid_seg->max_recovery_rate < raid_seg->min_recovery_rate)) {
- log_error("Minumum recovery rate cannot"
- " be higher than maximum.");
+ log_error("Minimum recovery rate cannot be higher than maximum.");
return 0;
}
@@ -899,7 +900,7 @@ static int _lvchange_profile(struct logical_volume *lv)
}
log_verbose("Changing configuration profile for LV %s: %s -> %s.",
- lv->name, old_profile_name, new_profile_name);
+ display_lvname(lv), old_profile_name, new_profile_name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
@@ -916,7 +917,7 @@ static int _lvchange_activation_skip(struct logical_volume *lv)
lv_set_activation_skip(lv, 1, skip);
log_verbose("Changing activation skip flag to %s for LV %s.",
- lv->name, skip ? "enabled" : "disabled");
+ display_lvname(lv), skip ? "enabled" : "disabled");
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
@@ -949,8 +950,8 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
readahead_ARG,
zero_ARG,
-1)) {
- log_error("Only -a permitted with read-only volume "
- "group \"%s\"", lv->vg->name);
+ log_error("Only -a permitted with read-only volume group %s.",
+ lv->vg->name);
return ECMD_FAILED;
}
@@ -964,26 +965,27 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
profile_ARG,
readahead_ARG,
-1)) {
- log_error("Can't change logical volume \"%s\" under snapshot",
- lv->name);
+ log_error("Can't change logical volume %s under snapshot.",
+ display_lvname(lv));
return ECMD_FAILED;
}
if (lv_is_pvmove(lv)) {
- log_error("Unable to change pvmove LV %s", lv->name);
+ log_error("Unable to change pvmove LV %s.", display_lvname(lv));
if (arg_is_set(cmd, activate_ARG))
log_error("Use 'pvmove --abort' to abandon a pvmove");
return ECMD_FAILED;
}
if (lv_is_mirror_log(lv)) {
- log_error("Unable to change mirror log LV %s directly", lv->name);
+ log_error("Unable to change mirror log LV %s directly.",
+ display_lvname(lv));
return ECMD_FAILED;
}
if (lv_is_mirror_image(lv)) {
- log_error("Unable to change mirror image LV %s directly",
- lv->name);
+ log_error("Unable to change mirror image LV %s directly.",
+ display_lvname(lv));
return ECMD_FAILED;
}
@@ -1000,8 +1002,8 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
/* Rest can be changed for stacked thin pool meta/data volumes */
;
else if (!lv_is_visible(lv) && !lv_is_virtual_origin(lv)) {
- log_error("Unable to change internal LV %s directly",
- lv->name);
+ log_error("Unable to change internal LV %s directly.",
+ display_lvname(lv));
return ECMD_FAILED;
}
@@ -1278,22 +1280,22 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
if ((arg_is_set(cmd, minor_ARG) || arg_is_set(cmd, major_ARG)) &&
!arg_is_set(cmd, persistent_ARG)) {
- log_error("--major and --minor require -My");
+ log_error("--major and --minor require -My.");
return EINVALID_CMD_LINE;
}
if (arg_is_set(cmd, minor_ARG) && argc != 1) {
- log_error("Only give one logical volume when specifying minor");
+ log_error("Only give one logical volume when specifying minor.");
return EINVALID_CMD_LINE;
}
if (arg_is_set(cmd, contiguous_ARG) && arg_is_set(cmd, alloc_ARG)) {
- log_error("Only one of --alloc and --contiguous permitted");
+ log_error("Only one of --alloc and --contiguous permitted.");
return EINVALID_CMD_LINE;
}
if (arg_is_set(cmd, poll_ARG) && arg_is_set(cmd, sysinit_ARG)) {
- log_error("Only one of --poll and --sysinit permitted");
+ log_error("Only one of --poll and --sysinit permitted.");
return EINVALID_CMD_LINE;
}
@@ -1306,7 +1308,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
*/
if (arg_is_set(cmd, sysinit_ARG) && (arg_uint_value(cmd, activate_ARG, 0) == CHANGE_AAY)) {
if (lvmetad_used()) {
- log_warn("WARNING: lvmetad is active, skipping direct activation during sysinit");
+ log_warn("WARNING: lvmetad is active, skipping direct activation during sysinit.");
return ECMD_PROCESSED;
}
}
7 years, 3 months
master - cleanup: drop unused assignments
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b9d3e8c8a8cd5f...
Commit: b9d3e8c8a8cd5faf23e30336303f6aeef5c32804
Parent: 1e3411aa3724ee9ee32f5cb4378526b9c355854d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 30 10:45:52 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:48 2016 +0200
cleanup: drop unused assignments
In all code paths we set a value for these variables, so drop
their initial unused assign.
---
daemons/lvmetad/lvmetad-core.c | 2 +-
daemons/lvmpolld/lvmpolld-cmd-utils.c | 2 +-
lib/cache/lvmetad.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 1ec9e3b..31d0933 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -2646,7 +2646,7 @@ static response dump(lvmetad_state *s)
static response handler(daemon_state s, client_handle h, request r)
{
- response res = { 0 };
+ response res;
lvmetad_state *state = s.private;
char prev_token[128] = { 0 };
const char *rq;
diff --git a/daemons/lvmpolld/lvmpolld-cmd-utils.c b/daemons/lvmpolld/lvmpolld-cmd-utils.c
index 86f5000..f70fd0d 100644
--- a/daemons/lvmpolld/lvmpolld-cmd-utils.c
+++ b/daemons/lvmpolld/lvmpolld-cmd-utils.c
@@ -31,7 +31,7 @@ const char *polling_op(enum poll_type type)
static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind)
{
- const char **newargv = *cmdargv;
+ const char **newargv;
if (*ind && !(*ind % MIN_ARGV_SIZE)) {
newargv = dm_realloc(*cmdargv, (*ind / MIN_ARGV_SIZE + 1) * MIN_ARGV_SIZE * sizeof(char *));
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 94059dd..476448d 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -955,7 +955,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
{
struct volume_group *vg = NULL;
struct volume_group *vg2 = NULL;
- daemon_reply reply = { 0 };
+ daemon_reply reply;
int found;
char uuid[64];
struct format_instance *fid = NULL;
7 years, 3 months
master - cleanup: add extra test for argc==0
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e3411aa3724ee...
Commit: 1e3411aa3724ee9ee32f5cb4378526b9c355854d
Parent: 458918b31953943a3cc44976388f008ca850c124
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 30 10:27:10 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:44:48 2016 +0200
cleanup: add extra test for argc==0
Cleaup some compiler warning about posibility to allocate 0 size.
---
daemons/cmirrord/functions.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index e9d3c09..757d8e8 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -573,6 +573,12 @@ static int clog_ctr(struct dm_ulog_request *rq)
for (argc = 0, p = rq->data; (p = strstr(p, " ")); p++, argc++)
*p = '\0';
+ if (!argc) {
+ LOG_ERROR("Received constructor request with bad data %s",
+ rq->data);
+ return -EINVAL;
+ }
+
argv = malloc(argc * sizeof(char *));
if (!argv)
return -ENOMEM;
7 years, 3 months
master - thin: fix link validation for unused thin-pool
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=458918b3195394...
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
7 years, 3 months
master - dmeventd: thin plugin umount over 95%
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2f638e07e81461...
Commit: 2f638e07e814617152d617a2ca7c8acdae41968a
Parent: 103c188681fce748ef193115c126bfbbc65fbab9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 29 15:56:29 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jul 1 00:43:45 2016 +0200
dmeventd: thin plugin umount over 95%
Run umount code only when either thin data or metadata are
above 95% - so if there are resize failures with 60%.
system fill keep running.
Also umount will only be tried with lvm2 LVs.
Foreign users are ATM unsuppored.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 99 ++++++++++++++++++++++---
2 files changed, 89 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 5043c23..30d6d82 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.129 -
=================================
+ Thin dmeventd plugin umounts lvm2 volume only when pool is 95% or more.
Version 1.02.128 - 25th June 2016
=================================
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 0cef168..c27cf50 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -30,6 +30,9 @@
/* First warning when thin data or metadata is 80% full. */
#define WARNING_THRESH (DM_PERCENT_1 * 80)
+/* Umount thin LVs when thin data or metadata LV is >=
+ * and lvextend --use-policies has failed. */
+#define UMOUNT_THRESH (DM_PERCENT_1 * 95)
/* Run a check every 5%. */
#define CHECK_STEP (DM_PERCENT_1 * 5)
/* Do not bother checking thin data or metadata is less than 50% full. */
@@ -53,6 +56,53 @@ struct dso_state {
DM_EVENT_LOG_FN("thin")
+#define UUID_PREFIX "LVM-"
+
+/* Figure out device UUID has LVM- prefix and is OPEN */
+static int _has_unmountable_prefix(int major, int minor)
+{
+ struct dm_task *dmt;
+ struct dm_info info;
+ const char *uuid;
+ int r = 0;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
+ return_0;
+
+ if (!dm_task_set_major_minor(dmt, major, minor, 1))
+ goto_out;
+
+ if (!dm_task_no_flush(dmt))
+ stack;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!dm_task_get_info(dmt, &info))
+ goto out;
+
+ if (!info.exists || !info.open_count)
+ goto out; /* Not open -> not mounted */
+
+ if (!(uuid = dm_task_get_uuid(dmt)))
+ goto out;
+
+ /* Check it's public mountable LV
+ * has prefix LVM- and UUID size is 68 chars */
+ if (memcmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1) ||
+ strlen(uuid) != 68)
+ goto out;
+
+#if THIN_DEBUG
+ log_debug("Found LV (%u:%u) %s.", major, minor, uuid);
+#endif
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
/* Get dependencies for device, and try to find matching device */
static int _has_deps(const char *name, int tp_major, int tp_minor, int *dev_minor)
{
@@ -90,6 +140,9 @@ static int _has_deps(const char *name, int tp_major, int tp_minor, int *dev_mino
*dev_minor = info.minor;
+ if (!_has_unmountable_prefix(major, info.minor))
+ goto out;
+
#if THIN_DEBUG
{
char dev_name[PATH_MAX];
@@ -206,7 +259,7 @@ static int _umount_device(char *buffer, unsigned major, unsigned minor,
}
/*
- * Find all thin pool users and try to umount them.
+ * Find all thin pool LV users and try to umount them.
* TODO: work with read-only thin pool support
*/
static void _umount(struct dm_task *dmt)
@@ -240,7 +293,7 @@ out:
dm_bitset_destroy(data.minors);
}
-static void _use_policy(struct dm_task *dmt, struct dso_state *state)
+static int _use_policy(struct dm_task *dmt, struct dso_state *state)
{
#if THIN_DEBUG
log_info("dmeventd executes: %s.", state->cmd_str);
@@ -248,10 +301,12 @@ static void _use_policy(struct dm_task *dmt, struct dso_state *state)
if (!dmeventd_lvm2_run_with_lock(state->cmd_str)) {
log_error("Failed to extend thin pool %s.",
dm_task_get_name(dmt));
- _umount(dmt);
state->fails++;
- } else
- state->fails = 0;
+ return 0;
+ }
+
+ state->fails = 0;
+ return 1;
}
void process_event(struct dm_task *dmt,
@@ -267,6 +322,13 @@ void process_event(struct dm_task *dmt,
char *target_type = NULL;
char *params;
int needs_policy = 0;
+ int needs_umount = 0;
+
+#if THIN_DEBUG
+ log_debug("Watch for tp-data:%.2f%% tp-metadata:%.2f%%.",
+ dm_percent_to_float(state->data_percent_check),
+ dm_percent_to_float(state->metadata_percent_check));
+#endif
#if 0
/* No longer monitoring, waiting for remove */
@@ -275,8 +337,10 @@ void process_event(struct dm_task *dmt,
#endif
if (event & DM_EVENT_DEVICE_ERROR) {
/* Error -> no need to check and do instant resize */
- _use_policy(dmt, state);
- goto out;
+ if (_use_policy(dmt, state))
+ goto out;
+
+ stack;
}
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
@@ -288,7 +352,7 @@ void process_event(struct dm_task *dmt,
if (!dm_get_status_thin_pool(state->mem, params, &tps)) {
log_error("Failed to parse status.");
- _umount(dmt);
+ needs_umount = 1;
goto out;
}
@@ -323,6 +387,9 @@ void process_event(struct dm_task *dmt,
log_warn("WARNING: Thin pool %s metadata is now %.2f%% full.",
device, dm_percent_to_float(percent));
needs_policy = 1;
+
+ if (percent >= UMOUNT_THRESH)
+ needs_umount = 1;
}
percent = dm_make_percent(tps->used_data_blocks, tps->total_data_blocks);
@@ -337,11 +404,21 @@ void process_event(struct dm_task *dmt,
log_warn("WARNING: Thin pool %s data is now %.2f%% full.",
device, dm_percent_to_float(percent));
needs_policy = 1;
+
+ if (percent >= UMOUNT_THRESH)
+ needs_umount = 1;
}
- if (needs_policy)
- _use_policy(dmt, state);
+ if (needs_policy &&
+ _use_policy(dmt, state))
+ needs_umount = 0; /* No umount when command was successful */
out:
+ if (needs_umount) {
+ _umount(dmt);
+ /* Until something changes, do not retry any more actions */
+ state->data_percent_check = state->metadata_percent_check = (DM_PERCENT_1 * 101);
+ }
+
if (tps)
dm_pool_free(state->mem, tps);
7 years, 3 months
master - lvconvert: add comments describing conversions
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=103c188681fce7...
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.
*/
7 years, 3 months
master - macros: Use is_power_of_2.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aed8bc8ae7b2f1...
Commit: aed8bc8ae7b2f1c20a84470b033daababfb7c166
Parent: a8e39530efdffc42d21e9bc968ab3966b719876a
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Jun 30 17:59:44 2016 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Jun 30 17:59:44 2016 +0100
macros: Use is_power_of_2.
---
WHATS_NEW | 1 +
lib/format_pool/import_export.c | 2 +-
lib/metadata/lv_manip.c | 4 ++--
lib/metadata/thin_manip.c | 2 +-
lib/metadata/vg.c | 4 ++--
lib/thin/thin.c | 4 ++--
tools/lvconvert.c | 4 ++--
tools/lvcreate.c | 4 ++--
tools/toollib.c | 2 +-
9 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 619c64d..a73744e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.159 -
=================================
+ 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/format_pool/import_export.c b/lib/format_pool/import_export.c
index 39b33ba..1529df5 100644
--- a/lib/format_pool/import_export.c
+++ b/lib/format_pool/import_export.c
@@ -181,7 +181,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
unsigned j;
uint32_t area_len;
- if (usp->striping & (usp->striping - 1)) {
+ if (!is_power_of_2(usp->striping)) {
log_error("Stripe size must be a power of 2");
return 0;
}
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index db71939..a706578 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -712,7 +712,7 @@ int get_default_region_size(struct cmd_context *cmd)
{
int region_size = _get_default_region_size(cmd);
- if (region_size & (region_size - 1)) {
+ if (!is_power_of_2(region_size)) {
region_size = _round_down_pow2(region_size);
log_verbose("Reducing region size to %u kiB (power of 2).",
region_size / 2);
@@ -4329,7 +4329,7 @@ static int _validate_stripesize(const struct volume_group *vg,
lp->stripe_size = vg->extent_size;
}
- if (lp->stripe_size & (lp->stripe_size - 1)) {
+ if (!is_power_of_2(lp->stripe_size)) {
log_error("Stripe size must be power of 2.");
return 0;
}
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 06d4242..3b92909 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -588,7 +588,7 @@ int update_thin_pool_params(const struct segment_type *segtype,
*zero = find_config_tree_bool(cmd, allocation_thin_pool_zero_CFG, profile);
if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
- (*chunk_size & (*chunk_size - 1))) {
+ !is_power_of_2(*chunk_size)) {
log_error("Chunk size must be a power of 2 for this thin target version.");
return 0;
}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 01dcad9..9f48a9b 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -379,7 +379,7 @@ int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_
}
if ((fmt->features & FMT_NON_POWER2_EXTENTS)) {
- if ((new_extent_size & (new_extent_size - 1)) &&
+ if (!is_power_of_2(new_extent_size) &&
(new_extent_size % MIN_NON_POWER2_EXTENT_SIZE)) {
log_error("Physical Extent size must be a multiple of %s when not a power of 2.",
display_size(fmt->cmd, (uint64_t) MIN_NON_POWER2_EXTENT_SIZE));
@@ -389,7 +389,7 @@ int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_
}
/* Apply original format1 restrictions */
- if ((new_extent_size & (new_extent_size - 1))) {
+ if (!is_power_of_2(new_extent_size)) {
log_error("Metadata format only supports Physical Extent sizes that are powers of 2.");
return 0;
}
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index a850757..1e29566 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -271,7 +271,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
}
if (!(attr & THIN_FEATURE_BLOCK_SIZE) &&
- (seg->chunk_size & (seg->chunk_size - 1))) {
+ !is_power_of_2(seg->chunk_size)) {
log_error("Thin pool target does not support %s chunk size (needs"
" kernel >= 3.6).", display_size(cmd, seg->chunk_size));
return 0;
@@ -311,7 +311,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
/* Use ignore for discards ignore or non-power-of-2 chunk_size and <1.5 target */
/* FIXME: Check whether underlying dev supports discards */
if (((!(attr & THIN_FEATURE_DISCARDS_NON_POWER_2) &&
- (seg->chunk_size & (seg->chunk_size - 1))) ||
+ !is_power_of_2(seg->chunk_size)) ||
(seg->discards == THIN_DISCARDS_IGNORE))) {
if (!dm_tree_node_set_thin_pool_discard(node, 1, 0))
return_0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8ceb1c7..3b98116 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -650,7 +650,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
- (lp->chunk_size & (lp->chunk_size - 1))) {
+ !is_power_of_2(lp->chunk_size)) {
log_error("Chunk size must be a power of 2 in the "
"range 4K to 512K");
return 0;
@@ -724,7 +724,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
return 0;
}
- if (lp->region_size & (lp->region_size - 1)) {
+ if (!is_power_of_2(lp->region_size)) {
log_error("Region size (%" PRIu32
") must be a power of 2", lp->region_size);
return 0;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 6b99717..8db68c1 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -555,7 +555,7 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
return 0;
}
- if (lp->region_size & (lp->region_size - 1)) {
+ if (!is_power_of_2(lp->region_size)) {
log_error("Region size (%" PRIu32 ") must be a power of 2",
lp->region_size);
return 0;
@@ -1036,7 +1036,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
if (lp->snapshot && (lp->extents || lcp->size)) {
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
- (lp->chunk_size & (lp->chunk_size - 1))) {
+ !is_power_of_2(lp->chunk_size)) {
log_error("Chunk size must be a power of 2 in the "
"range 4K to 512K.");
return 0;
diff --git a/tools/toollib.c b/tools/toollib.c
index 35b687b..a76599c 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1294,7 +1294,7 @@ static int _validate_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
}
if (*stripes > 1 && (*stripe_size < STRIPE_SIZE_MIN ||
- *stripe_size & (*stripe_size - 1))) {
+ !is_power_of_2(*stripe_size))) {
log_error("Invalid stripe size %s.",
display_size(cmd, (uint64_t) *stripe_size));
return 0;
7 years, 3 months
master - lvconvert: add missing alias for a thin-pool conversion
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8e39530efdffc...
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"
7 years, 3 months