master - test: lvm2api thin data_percent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f4f7f70ce94e9...
Commit: 7f4f7f70ce94e9692b84a3568aedfceb13466ece
Parent: 39f3c9de0babbe54cecb4cee5b163bf72eab61f4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 5 10:33:41 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 5 10:37:41 2012 +0200
test: lvm2api thin data_percent
---
test/api/Makefile.in | 18 +++++++++++--
test/api/thin_percent.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++
test/api/thin_percent.sh | 37 ++++++++++++++++++++++++++++
3 files changed, 112 insertions(+), 3 deletions(-)
diff --git a/test/api/Makefile.in b/test/api/Makefile.in
index 58d0a23..7ad6743 100644
--- a/test/api/Makefile.in
+++ b/test/api/Makefile.in
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2009-2012 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -20,8 +20,20 @@ ifeq ("@APPLIB@", "yes")
TARGETS += test
SOURCES = test.c
-TARGETS += vgtest.t percent.t pe_start.t lvtest.t
-SOURCES2 = vgtest.c percent.c pe_start.c lvtest.c
+TARGETS += \
+ lvtest.t \
+ percent.t \
+ pe_start.t \
+ thin_percent.t \
+ vgtest.t
+
+SOURCES2 = \
+ lvtest.c \
+ percent.c \
+ pe_start.c \
+ thin_percent.c \
+ vgtest.c
+
endif
include $(top_builddir)/make.tmpl
diff --git a/test/api/thin_percent.c b/test/api/thin_percent.c
new file mode 100644
index 0000000..952346f
--- /dev/null
+++ b/test/api/thin_percent.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * 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 Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#undef NDEBUG
+
+#include "lvm2app.h"
+#include "assert.h"
+
+int main(int argc, char *argv[])
+{
+ lvm_t handle;
+ vg_t vg;
+ lv_t lv;
+ struct lvm_property_value v;
+
+ handle = lvm_init(NULL);
+ assert(handle);
+
+ vg = lvm_vg_open(handle, argv[1], "r", 0);
+ assert(vg);
+
+ lv = lvm_lv_from_name(vg, "pool");
+ assert(lv);
+
+ v = lvm_lv_get_property(lv, "data_percent");
+ assert(v.is_valid);
+ assert(v.value.integer == 25 * PERCENT_1);
+
+
+ lv = lvm_lv_from_name(vg, "thin");
+ assert(lv);
+
+ v = lvm_lv_get_property(lv, "data_percent");
+ assert(v.is_valid);
+ assert(v.value.integer == 50 * PERCENT_1);
+
+
+ lv = lvm_lv_from_name(vg, "snap");
+ assert(lv);
+
+ v = lvm_lv_get_property(lv, "data_percent");
+ assert(v.is_valid);
+ assert(v.value.integer == 75 * PERCENT_1);
+
+ lvm_vg_close(vg);
+ lvm_quit(handle);
+
+ return 0;
+}
diff --git a/test/api/thin_percent.sh b/test/api/thin_percent.sh
new file mode 100644
index 0000000..bba33ba
--- /dev/null
+++ b/test/api/thin_percent.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+aux target_at_least dm-thin-pool 1 0 0 || skip
+
+# disable thin_check if not present in system
+which thin_check || aux lvmconf 'global/thin_check_executable = ""'
+
+aux prepare_devs 2
+
+vgcreate -s 64k $vg $(cat DEVICES)
+
+lvcreate -L5M -T $vg/pool
+
+lvcreate -V1M -T $vg/pool -n thin
+dd if=/dev/urandom of="$DM_DEV_DIR/$vg/thin" count=2 bs=256K
+
+lvcreate -s $vg/thin -n snap
+dd if=/dev/urandom of="$DM_DEV_DIR/$vg/snap" count=3 bs=256K
+
+lvs $vg
+
+aux apitest thin_percent $vg
+
+vgremove -ff $vg
11 years, 7 months
master - test: check data_percent is equal to snap_percent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=39f3c9de0babbe...
Commit: 39f3c9de0babbe54cecb4cee5b163bf72eab61f4
Parent: 1da6c1495aea539ccd869b157162aaff9f96b385
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 5 10:32:49 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 5 10:37:41 2012 +0200
test: check data_percent is equal to snap_percent
---
test/api/percent.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/test/api/percent.c b/test/api/percent.c
index db686d7..c5fa434 100644
--- a/test/api/percent.c
+++ b/test/api/percent.c
@@ -23,6 +23,7 @@ int main(int argc, char *argv[])
vg_t vg = NULL;
lv_t lv;
struct lvm_property_value v;
+ struct lvm_property_value d;
handle = lvm_init(NULL);
assert(handle);
@@ -51,6 +52,10 @@ int main(int argc, char *argv[])
assert(v.is_valid);
assert(v.value.integer == 50 * PERCENT_1);
+ d = lvm_lv_get_property(lv, "data_percent");
+ assert(d.is_valid);
+ assert(d.value.integer == v.value.integer);
+
lvm_vg_close(vg);
lvm_quit(handle);
11 years, 7 months
master - lvm2api: fix data percent reporting for thin, snap
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1da6c1495aea53...
Commit: 1da6c1495aea539ccd869b157162aaff9f96b385
Parent: 9efd3fb604ae34803bb2d4c94080c57d3efdba81
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 5 09:56:50 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Oct 5 10:37:09 2012 +0200
lvm2api: fix data percent reporting for thin, snap
Use same logic for lvm2api as we use lvs reporting.
data_percent is meant to be superset for snap_percent.
---
WHATS_NEW | 1 +
lib/report/properties.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 18e860c..44682a6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Fix lvm2api data_percent reporting for thin volumes.
Do not allow RAID LVs in a clustered volume group.
Update lvconvert to support stacking of devs for thin meta/data devs.
Support changes of permissions for thin snapshot volumes.
diff --git a/lib/report/properties.c b/lib/report/properties.c
index d2eac5e..4129b01 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -104,6 +104,12 @@ static percent_t _data_percent(const struct logical_volume *lv)
{
percent_t perc;
+ if (lv_is_cow(lv))
+ return _snap_percent(lv);
+
+ if (lv_is_thin_volume(lv))
+ return lv_thin_percent(lv, 0, &perc) ? perc : PERCENT_INVALID;
+
return lv_thin_pool_percent(lv, 0, &perc) ? perc : PERCENT_INVALID;
}
11 years, 7 months
master - RAID: Do not allow RAID LVs in a cluster volume group.
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9efd3fb604ae34...
Commit: 9efd3fb604ae34803bb2d4c94080c57d3efdba81
Parent: a27650cc983d54767316998e1df472325d169617
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Oct 3 15:52:54 2012 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Oct 3 15:52:54 2012 -0500
RAID: Do not allow RAID LVs in a cluster volume group.
It would be possible to activate a RAID LV exclusively in a cluster
volume group, but for now we do not allow RAID LVs to exist in a
clustered volume group at all. This has two components:
1) Do not allow RAID LVs to be created in a clustered VG
2) Do not allow changing a VG from single-machine to clustered
if there are RAID LVs present.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 19 +++++++++++++++++--
lib/metadata/vg.c | 13 ++++++++++++-
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cd325b9..18e860c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Do not allow RAID LVs in a clustered volume group.
Update lvconvert to support stacking of devs for thin meta/data devs.
Support changes of permissions for thin snapshot volumes.
Enhance insert_layer_for_lv() with recursive rename for _tdata LVs.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 4f86d14..d469fe8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4438,10 +4438,25 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
if (!(lvl = find_lv_in_vg(vg, lp->pool))) {
log_error("Unable to find existing pool LV %s in VG %s.",
lp->pool, vg->name);
- return 0;
+ return NULL;
}
if (!update_pool_lv(lvl->lv, 1))
- return_0;
+ return_NULL;
+ }
+
+ if (vg_is_clustered(vg) && segtype_is_raid(lp->segtype)) {
+ /*
+ * FIXME:
+ * We could allow a RAID LV to be created as long as it
+ * is activated exclusively. Any subsequent activations
+ * would have to be enforced as exclusive also.
+ *
+ * For now, we disallow the existence of RAID LVs in a
+ * cluster VG
+ */
+ log_error("Unable to create a %s logical volume in a cluster.",
+ lp->segtype->name);
+ return NULL;
}
if (segtype_is_mirrored(lp->segtype) || segtype_is_raid(lp->segtype)) {
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 29e9aa4..2897d42 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -514,9 +514,20 @@ int vg_set_clustered(struct volume_group *vg, int clustered)
/*
* We do not currently support switching the cluster attribute
- * on active mirrors or snapshots.
+ * on active mirrors, snapshots or RAID logical volumes.
*/
dm_list_iterate_items(lvl, &vg->lvs) {
+ /*
+ * FIXME:
+ * We could allow exclusive activation of RAID LVs, but
+ * for now we disallow them in a cluster VG at all.
+ */
+ if (lv_is_raid_type(lvl->lv)) {
+ log_error("RAID logical volumes are not allowed "
+ "in a cluster volume group.");
+ return 0;
+ }
+
if (lv_is_active(lvl->lv) &&
(lv_is_mirrored(lvl->lv) || lv_is_raid_type(lvl->lv))) {
log_error("%s logical volumes must be inactive "
11 years, 7 months
master - thin: lvconvert
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a27650cc983d54...
Commit: a27650cc983d54767316998e1df472325d169617
Parent: e9f83147d5da3120604c67354b4d6f027ac10ed0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon May 14 13:57:30 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:13:33 2012 +0200
thin: lvconvert
Update code for lvconvert.
Change the lvconvert user interface a bit - now we require 2 specifiers
--thinpool takes LV name for data device (and makes the name)
--poolmetadata takes LV name for metadata device.
Fix type in thin help text -z -> -Z.
Supported is also new flag --discards for thinpools.
---
WHATS_NEW | 1 +
man/lvconvert.8.in | 10 +--
tools/args.h | 1 +
tools/commands.h | 7 +-
tools/lvconvert.c | 176 ++++++++++++++++++++++++++++++++-------------------
5 files changed, 119 insertions(+), 76 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0927c49..cd325b9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Update lvconvert to support stacking of devs for thin meta/data devs.
Support changes of permissions for thin snapshot volumes.
Enhance insert_layer_for_lv() with recursive rename for _tdata LVs.
Skip building dm tree for thin pool when called with origin_only flag.
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 2a47da8..2659719 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -63,16 +63,12 @@ lvconvert \- convert a logical volume from linear to mirror or snapshot
.IR ThinPoolLogicalVolume { Name | Path }
.RB [ \-c | \-\-chunksize
.IR ChunkSize ]
-.RB [[ \-\-poolmetadatasize
-.IR MetadataSize [ bBsSkKmMgG ]
-.RI [ PhysicalVolume [ Path ][ :PE [ -PE ]]...]]
-|
-.IR ThinMetadataLogicalVolume { Name | Path }]
-.RB [ \-Z | \-\-zero
-.RI { y | n }]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-v | \-\-verbose ]
.RB [ \-\-version ]
+.RB [ \-Z | \-\-zero
+.RI { y | n }]
+.IR ThinMetadataLogicalVolume { Name | Path }
.sp
.B lvconvert \-\-repair
.RB [ \-h | \-? | \-\-help ]
diff --git a/tools/args.h b/tools/args.h
index d436db4..0d9605a 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -70,6 +70,7 @@ arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0)
arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0)
arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
+arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0)
arg(discards_ARG, '\0', "discards", discards_arg, 0)
arg(stripes_long_ARG, '\0', "stripes", int_arg, 0)
diff --git a/tools/commands.h b/tools/commands.h
index 602fe81..6415d34 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -146,15 +146,16 @@ xx(lvconvert,
"lvconvert "
"--thinpool ThinPoolLogicalVolume[Path]\n"
"\t[--chunksize size]\n"
- "\t[[--poolmetadatasize size] | ThinMetadataLogicalVolume[Path]]\n"
- "\t[-z|--zero {y|n}]\n"
+ "\t[--discards {ignore|nopassdown|passdown}]\n"
+ "\t[[--poolmetadatasize size] | --poolmetadata ThinMetadataLogicalVolume[Path]]\n"
+ "\t[-Z|--zero {y|n}]\n"
"\t[-d|--debug] [-h|-?|--help] [-v|--verbose]\n",
alloc_ARG, background_ARG, chunksize_ARG, corelog_ARG, interval_ARG,
merge_ARG, mirrorlog_ARG, mirrors_ARG, name_ARG, noudevsync_ARG,
regionsize_ARG, repair_ARG, replace_ARG, snapshot_ARG, splitmirrors_ARG,
trackchanges_ARG, type_ARG, stripes_long_ARG, stripesize_ARG, test_ARG,
- chunksize_ARG, poolmetadatasize_ARG, thinpool_ARG,
+ chunksize_ARG, discards_ARG, poolmetadata_ARG, poolmetadatasize_ARG, thinpool_ARG,
use_policies_ARG, yes_ARG, force_ARG, zero_ARG)
xx(lvcreate,
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 7b284f0..41bc585 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -54,9 +54,10 @@ struct lvconvert_params {
struct logical_volume *lv_to_poll;
- uint64_t poolmetadata_size; /* thin pool */
+ uint64_t poolmetadata_size;
const char *pool_data_lv_name;
- /* pool_metadata_lv_name is lv_name */
+ const char *pool_metadata_lv_name;
+ thin_discards_t discards;
};
static int _lvconvert_name_params(struct lvconvert_params *lp,
@@ -125,7 +126,10 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
if ((ptr = strrchr(lp->lv_name_full, '/')))
lp->lv_name = ptr + 1;
- if (!lp->merge_mirror && !apply_lvname_restrictions(lp->lv_name))
+ if (!lp->merge_mirror &&
+ !strstr(lp->lv_name, "_tdata") &&
+ !strstr(lp->lv_name, "_tmeta") &&
+ !apply_lvname_restrictions(lp->lv_name))
return_0;
if (*pargc && lp->snapshot) {
@@ -198,6 +202,10 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
log_error("--thinpool and --splitmirrors are mutually exlusive.");
return 0;
}
+ lp->discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_PASSDOWN);
+ } else if (arg_count(cmd, discards_ARG)) {
+ log_error("--discards is only valid with --thinpool.");
+ return 0;
}
/*
@@ -327,7 +335,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
- if (arg_count(cmd, poolmetadatasize_ARG)) {
+ if (arg_count(cmd, poolmetadata_ARG)) {
+ lp->pool_metadata_lv_name = arg_str_value(cmd, poolmetadata_ARG, "");
+ } else if (arg_count(cmd, poolmetadatasize_ARG)) {
if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
log_error("Negative pool metadata size is invalid.");
return 0;
@@ -365,6 +375,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
}
} else
lp->chunk_size = DM_THIN_MIN_DATA_BLOCK_SIZE;
+
log_verbose("Setting pool metadata chunk size to %u sectors.",
lp->chunk_size);
@@ -385,12 +396,12 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
} else { /* Mirrors (and some RAID functions) */
if (arg_count(cmd, chunksize_ARG)) {
log_error("--chunksize is only available with "
- "snapshots");
+ "snapshots or thin pools.");
return 0;
}
if (arg_count(cmd, zero_ARG)) {
- log_error("--zero is only available with snapshots");
+ log_error("--zero is only available with snapshots or thin pools.");
return 0;
}
@@ -1796,68 +1807,109 @@ out:
return r;
}
+/*
+ * Thin lvconvert version which
+ * rename metadata
+ * convert/layers thinpool over data
+ * attach metadata
+ */
static int _lvconvert_thinpool(struct cmd_context *cmd,
- struct logical_volume *metadata_lv,
+ struct logical_volume *pool_lv,
struct lvconvert_params *lp)
{
int r = 0;
char *name;
int len;
- int was_active;
struct lv_segment *seg;
struct logical_volume *data_lv;
- struct logical_volume *pool_lv =
- (lp->pool_data_lv_name == lp->lv_name) ?
- metadata_lv : find_lv(metadata_lv->vg,
- lp->pool_data_lv_name);
+ struct logical_volume *metadata_lv;
+
+ if (lv_is_thin_type(pool_lv)) {
+ log_error("Can't use thin logical volume %s/%s for thin pool data.",
+ pool_lv->vg->name, pool_lv->name);
+ return 0;
+ }
- if (!pool_lv) {
- log_error("Can't find pool logical volume %s.", lp->lv_name);
+ /* We are changing target type, so deactivate first */
+ if (!deactivate_lv(cmd, pool_lv)) {
+ log_error("Can't deactivate logical volume %s/%s.",
+ pool_lv->vg->name, pool_lv->name);
return 0;
}
- if ((pool_lv != metadata_lv)) {
- if (!lv_is_visible(metadata_lv)) {
- log_error("Can't use hidden logical volume %s/%s for thin pool metadata.",
- metadata_lv->vg->name, metadata_lv->name);
- goto out;
+ if (lp->pool_metadata_lv_name) {
+ metadata_lv = find_lv(pool_lv->vg, lp->pool_metadata_lv_name);
+ if (!metadata_lv) {
+ log_error("Unknown metadata LV %s", lp->pool_metadata_lv_name);
+ return 0;
}
- if (lv_is_thin_pool(metadata_lv)) {
- log_error("Can't use thin pool logical volume %s/%s for thin pool metadata.",
- metadata_lv->vg->name, metadata_lv->name);
- goto out;
+ if (metadata_lv == pool_lv) {
+ log_error("Can't use same LV for thin data and metadata LV %s",
+ lp->pool_metadata_lv_name);
+ return 0;
}
- /* FIXME: any more types prohibited here ? */
- if (!deactivate_lv(cmd, metadata_lv)) {
- log_error("Can't deactivate logical volume %s/%s.",
+ if (lv_is_thin_type(metadata_lv)) {
+ log_error("Can't use thin pool logical volume %s/%s "
+ "for thin pool metadata.",
metadata_lv->vg->name, metadata_lv->name);
- goto out;
+ return 0;
}
- /* FIXME: initialize metadata LV! */
+ } else if (arg_count(cmd, poolmetadatasize_ARG)) {
+ /* FIXME: allocate metadata LV! */
+ metadata_lv = NULL;
+ log_error("Uncreated metadata.");
+ return 0;
} else {
- /* FIXME: add creation of metadata LV */
+ log_error("Uknown metadata.");
+ return 0;
}
- if (!lv_is_visible(pool_lv)) {
- log_error("Can't use hidden logical volume %s/%s for thin pool data.",
- metadata_lv->vg->name, metadata_lv->name);
- goto out;
- }
- if (lv_is_thin_pool(pool_lv)) {
- log_error("Can't use thin pool logical volume %s/%s for thin pool data.",
- metadata_lv->vg->name, metadata_lv->name);
- goto out;
+ len = strlen(pool_lv->name) + 16;
+ if (!(name = dm_pool_alloc(pool_lv->vg->vgmem, len))) {
+ log_error("Cannot allocate new name.");
+ return 0;
}
- /* FIXME: any more types prohibited here ? */
- if ((was_active = lv_is_active(pool_lv))) {
- if (!deactivate_lv(cmd, pool_lv)) {
+
+ if (!lv_is_active(metadata_lv)) {
+ if (!deactivate_lv(cmd, metadata_lv)) {
log_error("Can't deactivate logical volume %s/%s.",
- pool_lv->vg->name, pool_lv->name);
- goto out;
+ metadata_lv->vg->name, metadata_lv->name);
+ return 0;
+ }
+ if (!activate_lv_local(cmd, metadata_lv)) {
+ log_error("Aborting. Failed to activate thin metadata lv.");
+ return 0;
}
}
+ if (!set_lv(cmd, metadata_lv, UINT64_C(0), 0)) {
+ log_error("Aborting. Failed to wipe thin metadata lv.");
+ return 0;
+ }
+
+ if (!deactivate_lv(cmd, metadata_lv)) {
+ log_error("Aborting. Failed to deactivate thin metadata lv. "
+ "Manual intervention required.");
+ return 0;
+ }
+
+ if (dm_snprintf(name, len, "%s_tmeta", pool_lv->name) < 0)
+ return_0;
+
+ /* Rename deactivated metadata LV to have _tmeta suffix */
+ /* Implicit checks if metadata_lv is visible */
+ if (!lv_rename_update(cmd, metadata_lv, name, 0))
+ return_0;
+
+ /*
+ * Since we wish to have underlaying dev, to match _tdata
+ * rename data LV first, also checks for visible LV
+ */
+ /* FIXME: any more types prohibited here? */
+ /* FIXME: revert renamed LVs in fail path? */
+
/* FIXME: common code with metadata/thin_manip.c extend_pool() */
+ /* Create layer _tdata */
if (!(data_lv = insert_layer_for_lv(pool_lv->vg->cmd, pool_lv,
pool_lv->status, "_tdata")))
return_0;
@@ -1868,17 +1920,9 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
seg->chunk_size = lp->chunk_size;
seg->zero_new_blocks = lp->zero ? 1 : 0;
+ seg->discards = lp->discards;
seg->low_water_mark = 0;
-
- len = strlen(pool_lv->name) + 16;
- if (!(name = dm_pool_alloc(pool_lv->vg->vgmem, len))) {
- log_error("Cannot allocate new name.");
- return 0;
- }
-
- if (dm_snprintf(name, len, "%s_tmeta", pool_lv->name) < 0)
- return_0;
- metadata_lv->name = name;
+ seg->transaction_id = 0;
if (!attach_pool_metadata_lv(seg, metadata_lv))
return_0;
@@ -1888,18 +1932,18 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
if (!attach_pool_data_lv(seg, data_lv))
return_0;
- /* store vg on disk(s) */
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
return_0;
- log_print_unless_silent("Converted %s/%s to thin pool.",
- pool_lv->vg->name, pool_lv->name);
- if (was_active && !activate_lv(cmd, pool_lv)) {
+ if (!activate_lv_excl(cmd, pool_lv)) {
log_error("Failed to activate pool logical volume %s/%s.",
pool_lv->vg->name, pool_lv->name);
goto out;
}
+ log_print_unless_silent("Converted %s/%s to thin pool.",
+ pool_lv->vg->name, pool_lv->name);
+
r = 1;
out:
backup(pool_lv->vg);
@@ -1975,6 +2019,15 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
stack;
return ECMD_FAILED;
}
+ } else if (arg_count(cmd, thinpool_ARG)) {
+ if (!archive(lv->vg)) {
+ stack;
+ return ECMD_FAILED;
+ }
+ if (!_lvconvert_thinpool(cmd, lv, lp)) {
+ stack;
+ return ECMD_FAILED;
+ }
} else if (segtype_is_raid(lp->segtype) ||
(lv->status & RAID) || lp->merge_mirror) {
if (!archive(lv->vg)) {
@@ -2014,15 +2067,6 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
/* If repairing and using policies, remove missing PVs from VG */
if (arg_count(cmd, repair_ARG) && arg_count(cmd, use_policies_ARG))
_remove_missing_empty_pv(lv->vg, failed_pvs);
- } else if (arg_count(cmd, thinpool_ARG)) {
- if (!archive(lv->vg)) {
- stack;
- return ECMD_FAILED;
- }
- if (!_lvconvert_thinpool(cmd, lv, lp)) {
- stack;
- return ECMD_FAILED;
- }
}
return ECMD_PROCESSED;
11 years, 7 months
master - thin: lvchange allows to change perms of thin snap
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e9f83147d5da31...
Commit: e9f83147d5da3120604c67354b4d6f027ac10ed0
Parent: d442c3ef0cec424db797714704859fbc2154f000
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 19 14:55:34 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:13:32 2012 +0200
thin: lvchange allows to change perms of thin snap
Thin snapshots are individual thin volumes so they can have its own
control for rw permissions.
---
WHATS_NEW | 1 +
tools/lvchange.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index dce8241..0927c49 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Support changes of permissions for thin snapshot volumes.
Enhance insert_layer_for_lv() with recursive rename for _tdata LVs.
Skip building dm tree for thin pool when called with origin_only flag.
Add internal lv_rename_update() to rename LV without updating mda.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index d1cb4cf..b2c1fe4 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -722,7 +722,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return EINVALID_CMD_LINE;
}
- if (lv_is_origin(lv) &&
+ if (lv_is_origin(lv) && !lv_is_thin_volume(lv) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
arg_count(cmd, alloc_ARG))) {
11 years, 7 months
master - liblvm: insert layer with subvolume renames
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d442c3ef0cec42...
Commit: d442c3ef0cec424db797714704859fbc2154f000
Parent: 4648d33d0704de23876582f35786023ebc954fe9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 6 15:21:18 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:13:32 2012 +0200
liblvm: insert layer with subvolume renames
Rename also subvolumes if we are inserting _tdata layer.
(Currently it breaks mirrors if it would be generic, needs fixing).
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8050db8..dce8241 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Enhance insert_layer_for_lv() with recursive rename for _tdata LVs.
Skip building dm tree for thin pool when called with origin_only flag.
Add internal lv_rename_update() to rename LV without updating mda.
Ensure descriptors 0,1,2 are always available.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index eb5794c..4f86d14 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3795,6 +3795,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
struct logical_volume *layer_lv;
struct segment_type *segtype;
struct lv_segment *mapseg;
+ struct lv_names lv_names;
unsigned exclusive = 0;
/* create an empty layer LV */
@@ -3891,6 +3892,18 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
lv_where->le_count = layer_lv->le_count;
lv_where->size = (uint64_t) lv_where->le_count * lv_where->vg->extent_size;
+ /*
+ * recuresively rename sub LVs
+ * currently supported only for thin data layer
+ * FIXME: without strcmp it breaks mirrors....
+ */
+ if (strcmp(layer_suffix, "_tdata") == 0) {
+ lv_names.old = lv_where->name;
+ lv_names.new = layer_lv->name;
+ if (!for_each_sub_lv(cmd, layer_lv, _rename_cb, (void *) &lv_names))
+ return 0;
+ }
+
return layer_lv;
}
11 years, 7 months
master - cleanup: add proper cast for force_t
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4648d33d0704de...
Commit: 4648d33d0704de23876582f35786023ebc954fe9
Parent: cf8e1a00937a7ef5eebf363898e237fd4a8dc392
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Sep 19 15:13:21 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:06:17 2012 +0200
cleanup: add proper cast for force_t
---
tools/lvremove.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 0252149..54094b1 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -26,7 +26,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
lv = origin;
- if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG), 0)) {
+ if (!lv_remove_with_dependencies(cmd, lv, (force_t) arg_count(cmd, force_ARG), 0)) {
stack;
return ECMD_FAILED;
}
11 years, 7 months
master - thin: origin only suspend
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf8e1a00937a7e...
Commit: cf8e1a00937a7ef5eebf363898e237fd4a8dc392
Parent: 1946a453297535829d3d698dfa51733d8a223400
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 5 11:28:01 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:05:55 2012 +0200
thin: origin only suspend
Skip tree creating when used with origin_only flag.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bc0c778..8050db8 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Skip building dm tree for thin pool when called with origin_only flag.
Add internal lv_rename_update() to rename LV without updating mda.
Ensure descriptors 0,1,2 are always available.
Use /proc/self/fd for closing openned descriptors.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index c8a1e35..31c1c27 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1369,7 +1369,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
seg = first_seg(lv);
}
- if (lv_is_thin_pool(lv)) {
+ if (!origin_only && lv_is_thin_pool(lv)) {
if (!_add_lv_to_dtree(dm, dtree, seg->metadata_lv, 0))
return_0;
/* FIXME code from _create_partial_dtree() should be moved here */
11 years, 7 months
master - libdm: reset delay flag for devs used by thin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1946a453297535...
Commit: 1946a453297535829d3d698dfa51733d8a223400
Parent: 21c401006c3c12b75354736db9a2f75e7993f489
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 27 16:57:14 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:04:41 2012 +0200
libdm: reset delay flag for devs used by thin
Patch clears the flag if thin pool is stacked over mirror.
Since thin pool could be used to stack device over mirrors,
it needs resume properly i.e. mirrors with corelog which are otherwise
unconditionally skipped (for pvmove functionality).
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 6 +++++-
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index c46db61..338cfaf 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.77 -
=================================
+ Always reset delay_resume_if_new flag when stacking thin pool.
Don't create value for dm_config_node and require dm_config_create_value call.
Check for existing new_name for dmsetup rename.
Fix memory leak in dmsetup _get_split_name() error path.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index f675d0d..096eba2 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -3107,6 +3107,10 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
if (!_link_tree_nodes(node, seg->pool))
return_0;
+ /* Clean flag delay_resume_if_new - so corelog gets resumed */
+ seg->metadata->props.delay_resume_if_new = 0;
+ seg->pool->props.delay_resume_if_new = 0;
+
node->props.send_messages = 1;
seg->transaction_id = transaction_id;
seg->low_water_mark = low_water_mark;
11 years, 7 months