master - lvmetad: Fix a memory leak introduced in 15fdd5c90dd.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95372a852bbcac...
Commit: 95372a852bbcacc9f194324832b94fcf1493f7c5
Parent: 382fc878d7be5252d7ad93f2740ee25bd500d53e
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Wed Apr 3 13:46:12 2013 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Wed Apr 3 13:46:12 2013 +0200
lvmetad: Fix a memory leak introduced in 15fdd5c90dd.
---
daemons/lvmetad/lvmetad-core.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index a789bad..bbad69c 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -756,6 +756,9 @@ static int update_metadata(lvmetad_state *s, const char *name, const char *_vgid
if (retval && oldname && strcmp(name, oldname))
dm_hash_remove(s->vgname_to_vgid, oldname);
+ if (haveseq >= 0 && haveseq < seq)
+ dm_config_destroy(old);
+
unlock_vgid_to_metadata(s);
if (retval)
11 years
master - lvmetad: Check for reappeared PVs.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=382fc878d7be52...
Commit: 382fc878d7be5252d7ad93f2740ee25bd500d53e
Parent: 00ed6759c8cbf2f4497fa0d5f7df69780159539a
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Apr 3 12:48:28 2013 +0200
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Apr 3 12:48:28 2013 +0200
lvmetad: Check for reappeared PVs.
---
lib/cache/lvmetad.c | 2 ++
lib/metadata/metadata.c | 4 ++--
lib/metadata/metadata.h | 3 +++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index a7354a7..4ea3dbd 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -389,6 +389,8 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
pvl->pv->dev = lvmcache_device(info);
if (!pvl->pv->dev)
pvl->pv->status |= MISSING_PV;
+ else
+ check_reappeared_pv(vg, pvl->pv);
if (!lvmcache_fid_add_mdas_pv(info, fid)) {
vg = NULL;
goto_out; /* FIXME error path */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 911a4c8..bde1cb0 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2836,8 +2836,8 @@ int vg_missing_pv_count(const struct volume_group *vg)
return ret;
}
-static void check_reappeared_pv(struct volume_group *correct_vg,
- struct physical_volume *pv)
+void check_reappeared_pv(struct volume_group *correct_vg,
+ struct physical_volume *pv)
{
struct pv_list *pvl;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 0c13a97..4f504ed 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -491,4 +491,7 @@ int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tags);
+void check_reappeared_pv(struct volume_group *correct_vg,
+ struct physical_volume *pv);
+
#endif
11 years
master - lvmetad: Mark PVs visible to lvmetad but not to us as MISSING.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00ed6759c8cbf2...
Commit: 00ed6759c8cbf2f4497fa0d5f7df69780159539a
Parent: 6ac4cba276e8d7842e4efedc117f4b9aafa90c71
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Apr 3 11:10:52 2013 +0200
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Apr 3 11:40:29 2013 +0200
lvmetad: Mark PVs visible to lvmetad but not to us as MISSING.
---
lib/cache/lvmetad.c | 6 +++++-
test/shell/lvcreate-missing.sh | 19 +++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 3cde71e..a7354a7 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -387,14 +387,18 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if ((info = lvmcache_info_from_pvid((const char *)&pvl->pv->id, 0))) {
pvl->pv->label_sector = lvmcache_get_label(info)->sector;
pvl->pv->dev = lvmcache_device(info);
+ if (!pvl->pv->dev)
+ pvl->pv->status |= MISSING_PV;
if (!lvmcache_fid_add_mdas_pv(info, fid)) {
vg = NULL;
goto_out; /* FIXME error path */
}
- } /* else probably missing */
+ } else
+ pvl->pv->status |= MISSING_PV; /* probably missing */
}
lvmcache_update_vg(vg, 0);
+ vg_mark_partial_lvs(vg, 1);
}
out:
diff --git a/test/shell/lvcreate-missing.sh b/test/shell/lvcreate-missing.sh
new file mode 100644
index 0000000..63471c3
--- /dev/null
+++ b/test/shell/lvcreate-missing.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Copyright (C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/test
+
+aux prepare_vg 2
+init_udev_transaction
+dmsetup remove -f "$dev1" || true
+finish_udev_transaction
+
+not lvcreate -n "foo" $vg -l 1
11 years
master - tests: lvconvert external origin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6ac4cba276e8d7...
Commit: 6ac4cba276e8d7842e4efedc117f4b9aafa90c71
Parent: d24c01a414506f0cdc04b5c8589f61d288b25273
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 5 14:24:05 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 2 15:17:31 2013 +0200
tests: lvconvert external origin
Add tests for thin external origin support
---
test/shell/lvconvert-thin-external.sh | 121 +++++++++++++++++++++++++++++++++
test/shell/lvcreate-thin-external.sh | 86 +++++++++++++++++++++++
2 files changed, 207 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-thin-external.sh b/test/shell/lvconvert-thin-external.sh
new file mode 100644
index 0000000..1bcf0b6
--- /dev/null
+++ b/test/shell/lvconvert-thin-external.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+
+# Copyright (C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Test conversion to thin external origin
+
+. lib/test
+
+which mkfs.ext2 || skip
+which fsck || skip
+
+#
+# Main
+#
+aux have_thin 1 5 0 || skip
+
+aux prepare_pvs 2 64
+
+vgcreate $vg -s 64K $(cat DEVICES)
+
+# create thin pool
+lvcreate -L8M -T $vg/pool
+
+# create plain LV
+lvcreate -L8M -n $lv1 $vg
+
+mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
+mkdir mnt
+mount $DM_DEV_DIR/$vg/$lv1 mnt
+
+dd if=/dev/zero of=mnt/test1 bs=1M count=1
+
+# convert plain LV into thin external snapshot volume
+# during conversion dd above could be still flushed
+
+lvconvert -T --originname extorg --thinpool $vg/pool $vg/$lv1
+
+check active $vg $lv1
+check inactive $vg extorg
+
+touch mnt/test
+umount mnt
+
+fsck -n $DM_DEV_DIR/$vg/$lv1
+
+lvchange -ay $vg/extorg
+lvchange -an $vg/$lv1
+
+check active $vg extorg
+check inactive $vg $lv1
+
+# fsck in read-only mode
+fsck -n $DM_DEV_DIR/$vg/extorg
+
+#not lvresize -l+8 $vg/extorg
+#not lvresize -l-4 $vg/extorg
+#not lvchange -p rw $vg/extorg
+
+#lvresize -L+8M $vg/$lv1
+#lvresize -L-4M $vg/$lv1
+#lvchange -p r $vg/$lv1
+#lvchange -p rw $vg/$lv1
+
+lvchange -ay $vg
+
+lvs -a -o+origin_size,seg_size $vg
+lvconvert --originname extorg1 --thinpool $vg/pool -T $vg/extorg
+
+check inactive $vg extorg1
+
+lvconvert --originname extorglv1 --thinpool $vg/pool -T $vg/extorg1
+
+lvs -a -o+origin_size,seg_size $vg
+
+lvchange -an $vg/extorg
+lvs -a -o+origin_size,seg_size $vg
+check inactive $vg extorglv1
+
+lvchange -ay $vg/extorg1
+lvs -a -o+origin_size,seg_size $vg
+
+lvcreate -l4 -s $vg/$lv1 -n $lv2
+lvcreate -l8 -s $vg/extorg -n $lv3
+lvcreate -l12 -s $vg/extorg1 -n $lv4
+lvcreate -l16 -s $vg/extorglv1 -n $lv5
+
+lvs -a -o+origin_size,seg_size,segtype $vg
+
+# Converting old-snapshot into external origin is not supported
+not lvconvert -T --thinpool $vg/pool --originname lv5origin $vg/$lv4
+
+check lv_field $vg/$lv1 segtype thin
+check lv_field $vg/$lv2 segtype linear
+check lv_field $vg/$lv3 segtype linear
+check lv_field $vg/$lv4 segtype linear
+check lv_field $vg/$lv5 segtype linear
+check lv_field $vg/extorg segtype thin
+check lv_field $vg/extorg1 segtype thin
+check lv_field $vg/extorglv1 segtype linear
+
+vgchange -ay $vg
+
+lvs -a -o+origin_size,seg_size $vg
+
+lvchange -an $vg/extorglv1
+check inactive $vg extorglv1
+
+# Remove all volumes dependent on external origin
+lvremove -f $vg/extorglv1
+# Only pool is left
+check vg_field $vg lv_count 1
+
+vgremove -ff $vg
diff --git a/test/shell/lvcreate-thin-external.sh b/test/shell/lvcreate-thin-external.sh
new file mode 100644
index 0000000..c469265
--- /dev/null
+++ b/test/shell/lvcreate-thin-external.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# Copyright (C) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Test creation of thin snapshots using external origin
+
+. lib/test
+
+which mkfs.ext2 || skip
+which fsck || skip
+
+#
+# Main
+#
+aux have_thin 1 3 0 || skip
+
+aux prepare_pvs 2 64
+
+vgcreate $vg -s 64K $(cat DEVICES)
+
+lvcreate -L10M -V10M -T $vg/pool --name $lv1
+mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
+
+lvcreate -L4M -n $lv2 $vg
+mkfs.ext2 $DM_DEV_DIR/$vg/$lv2
+
+# Fail to create snapshot of rw LV
+not lvcreate -s $vg/$lv2 --thinpool $vg/pool
+
+lvchange -p r $vg/$lv2
+
+# Fail to create snapshot of active r LV
+# FIXME: kernel update needed
+not lvcreate -s $vg/$lv2 --thinpool $vg/pool
+
+# Deactivate LV we want to use as external origin
+# once kernel will ensure read-only this condition may go away
+lvchange -an $vg/$lv2
+
+lvcreate -s $vg/$lv2 --thinpool $vg/pool
+
+# Fail with --thin and --snapshot
+not lvcreate -s $vg/$lv5 --name $vg/$lv7 -T $vg/newpool
+
+# Fail to create already existing pool
+not lvcreate -s $vg/$lv2 -L10 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --chunksize 64 --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --zero y --thinpool $vg/pool
+not lvcreate -s $vg/$lv2 --poolmetadata $vg/$lv1 --thinpool $vg/pool
+
+# Fail with nonexistent pool
+not lvcreate -s $vg/$lv2 --thinpool $vg/newpool
+
+# Create pool and snap
+lvcreate -s $vg/$lv2 --name $vg/$lv3 -L20 --chunksize 128 --thinpool $vg/newpool
+lvcreate -s $vg/$lv3 --name $vg/$lv4
+lvcreate -s $vg/$lv2 --name $vg/$lv5 --thinpool $vg/newpool
+# Make normal thin snapshot
+lvcreate -s $vg/$lv5 --name $vg/$lv6
+# We do not need to specify thinpool when doing thin snap, but it should work
+lvcreate -s $vg/$lv5 --name $vg/$lv7 --thinpool $vg/newpool
+
+check inactive $vg $lv2
+lvchange -ay $vg/$lv2
+lvcreate -s $vg/$lv2 --name $vg/$lv8 --thinpool $vg/newpool
+
+lvs -o+chunksize $vg
+
+check active $vg $lv3
+check active $vg $lv4
+check active $vg $lv5
+check active $vg $lv6
+check active $vg $lv7
+
+fsck -n $DM_DEV_DIR/$vg/$lv1
+fsck -n $DM_DEV_DIR/$vg/$lv7
+
+vgremove -ff $vg
11 years
master - thin: lvcreate external origin snapshot support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d24c01a414506f...
Commit: d24c01a414506f0cdc04b5c8589f61d288b25273
Parent: 435e0bb60895b3831840a10a5deb68a51936f3e9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 2 14:53:58 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 2 15:17:31 2013 +0200
thin: lvcreate external origin snapshot support
---
lib/metadata/lv_manip.c | 49 +++++++++++++++++----
tools/lvcreate.c | 107 +++++++++++++++++++++++++++--------------------
2 files changed, 102 insertions(+), 54 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ad8160e..10331c3 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -324,10 +324,14 @@ struct lv_segment *alloc_lv_segment(const struct segment_type *segtype,
/* Use the same external origin */
if (!attach_thin_external_origin(seg, first_seg(thin_pool_lv)->external_lv))
return_NULL;
- } else {
+ } else if (lv_is_thin_pool(thin_pool_lv)) {
seg->transaction_id = first_seg(thin_pool_lv)->transaction_id;
if (!attach_pool_lv(seg, thin_pool_lv, NULL))
return_NULL;
+ } else {
+ log_error(INTERNAL_ERROR "Volume %s is not thin volume or thin pool",
+ thin_pool_lv->name);
+ return NULL;
}
}
@@ -4302,6 +4306,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
struct logical_volume *pool_lv;
struct lv_list *lvl;
int origin_active = 0;
+ const char *thin_name = NULL;
if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) {
log_error("Logical volume \"%s\" already exists in "
@@ -4364,7 +4369,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
status |= lp->permission | VISIBLE_LV;
- if (lp->snapshot && lp->thin) {
+ if (seg_is_thin(lp) && lp->snapshot) {
if (!(org = find_lv(vg, lp->origin))) {
log_error("Couldn't find origin volume '%s'.",
lp->origin);
@@ -4454,7 +4459,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
return NULL;
}
- if (lp->snapshot && !lp->thin && ((uint64_t)lp->extents * vg->extent_size < 2 * lp->chunk_size)) {
+ if (lp->snapshot && !seg_is_thin(lp) && ((uint64_t)lp->extents * vg->extent_size < 2 * lp->chunk_size)) {
log_error("Unable to create a snapshot smaller than 2 chunks.");
return NULL;
}
@@ -4493,7 +4498,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
}
/* The snapshot segment gets created later */
- if (lp->snapshot && !lp->thin &&
+ if (lp->snapshot && !seg_is_thin(lp) &&
!(lp->segtype = get_segtype_from_string(cmd, "striped")))
return_NULL;
@@ -4571,12 +4576,21 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
dm_list_splice(&lv->tags, &lp->tags);
+ if (seg_is_thin_volume(lp)) {
+ /* For thin snapshot we must have matching pool */
+ if (org && lv_is_thin_volume(org) && (!lp->pool ||
+ (strcmp(first_seg(org)->pool_lv->name, lp->pool) == 0)))
+ thin_name = org->name;
+ else
+ thin_name = lp->pool;
+ }
+
if (!lv_extend(lv, lp->segtype,
lp->stripes, lp->stripe_size,
lp->mirrors,
seg_is_thin_pool(lp) ? lp->poolmetadataextents : lp->region_size,
seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents,
- seg_is_thin_volume(lp) ? (org ? org->name : lp->pool) : NULL, lp->pvh, lp->alloc))
+ thin_name, lp->pvh, lp->alloc))
return_NULL;
if (seg_is_thin_pool(lp)) {
@@ -4587,12 +4601,29 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
first_seg(lv)->low_water_mark = 0;
} else if (seg_is_thin_volume(lp)) {
pool_lv = first_seg(lv)->pool_lv;
-
if (!(first_seg(lv)->device_id =
get_free_pool_device_id(first_seg(pool_lv)))) {
stack;
goto revert_new_lv;
}
+ /*
+ * Check if using 'external origin' or the 'normal' snapshot
+ * within the same thin pool
+ */
+ if (lp->snapshot && (first_seg(org)->pool_lv != pool_lv)) {
+ if (org->status & LVM_WRITE) {
+ log_error("Cannot use writable LV as the external origin.");
+ return 0; // TODO conversion for inactive
+ }
+ if (lv_is_active(org) && !lv_is_external_origin(org)) {
+ log_error("Cannot use active LV for the external origin.");
+ return 0; // We can't be sure device it is read-only
+ }
+ if (!attach_thin_external_origin(first_seg(lv), org)) {
+ stack;
+ goto revert_new_lv;
+ }
+ }
if (!attach_pool_message(first_seg(pool_lv),
DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0)) {
@@ -4634,7 +4665,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
if (seg_is_thin(lp)) {
/* For snapshot, suspend active thin origin first */
- if (org && lv_is_active(org)) {
+ if (org && lv_is_active(org) && lv_is_thin_volume(org)) {
if (!pool_below_threshold(first_seg(first_seg(org)->pool_lv))) {
log_error("Cannot create thin snapshot. Pool %s/%s is filled "
"over the autoextend threshold.",
@@ -4699,7 +4730,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
goto deactivate_and_revert_new_lv;
}
- if (lp->snapshot && !lp->thin) {
+ if (lp->snapshot && !seg_is_thin(lp)) {
/* Reset permission after zeroing */
if (!(lp->permission & LVM_WRITE))
lv->status &= ~LVM_WRITE;
@@ -4788,7 +4819,7 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool)))
return_0;
- if (!lp->thin)
+ if (!lp->thin && !lp->snapshot)
goto out;
lp->pool = lv->name;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index aa75636..df05cbb 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -207,12 +207,17 @@ static int _determine_snapshot_type(struct volume_group *vg,
}
if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
+ if (seg_is_thin(lp)) {
+ if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
+ return_0;
+ return 1;
+ }
+
if (!lv_is_thin_volume(lvl->lv)) {
log_error("Please specify either size or extents with snapshots.");
return 0;
}
- lp->thin = 1;
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
return_0;
@@ -355,7 +360,7 @@ static int _read_size_params(struct lvcreate_params *lp,
}
/* If size/extents given with thin, then we are creating a thin pool */
- if (lp->thin && (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG)))
+ if (seg_is_thin(lp) && (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG)))
lp->create_thin_pool = 1;
if (arg_count(cmd, poolmetadatasize_ARG) && !seg_is_thin(lp)) {
@@ -380,8 +385,9 @@ static int _read_size_params(struct lvcreate_params *lp,
return 0;
}
} else {
- /* No virtual size given, so no thin LV to create. */
- if (seg_is_thin_volume(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin-pool")))
+ /* No virtual size given and no snapshot, so no thin LV to create. */
+ if (seg_is_thin_volume(lp) && !lp->snapshot &&
+ !(lp->segtype = get_segtype_from_string(cmd, "thin-pool")))
return_0;
lp->thin = 0;
@@ -651,6 +657,7 @@ static int _lvcreate_params(struct lvcreate_params *lp,
struct arg_value_group_list *current_group;
const char *segtype_str;
const char *tag;
+ unsigned i;
memset(lp, 0, sizeof(*lp));
memset(lcp, 0, sizeof(*lcp));
@@ -660,7 +667,6 @@ static int _lvcreate_params(struct lvcreate_params *lp,
/*
* Check selected options are compatible and determine segtype
*/
-// FIXME -m0 implies *striped*
if ((arg_count(cmd, thin_ARG) || arg_count(cmd, thinpool_ARG)) &&
arg_count(cmd,mirrors_ARG)) {
log_error("--thin,--thinpool and --mirrors are incompatible.");
@@ -692,6 +698,12 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
+ if ((arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp)) &&
+ arg_count(cmd, thin_ARG)) {
+ log_error("--thin and --snapshot are incompatible.");
+ return 0;
+ }
+
if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) ||
(!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG)))
lp->snapshot = 1;
@@ -802,37 +814,43 @@ static int _lvcreate_params(struct lvcreate_params *lp,
!_read_raid_params(lp, cmd))
return_0;
- if (!lp->create_thin_pool && arg_count(cmd, discards_ARG)) {
- log_error("--discards is only available for thin pool creation.");
- return 0;
- }
+ if (!lp->create_thin_pool) {
+ if (seg_is_thin(lp)) {
+ static const int _argname[] = {
+ chunksize_ARG, discards_ARG, poolmetadatasize_ARG, zero_ARG
+ };
+ for (i = 0; i < sizeof(_argname)/sizeof(_argname[0]); ++i) {
+ if (arg_count(cmd, _argname[i])) {
+ log_error("%s is only available for thin pool creation.",
+ arg_long_option_name(_argname[i]));
+ return 0;
+ }
+ }
+ } else if (lp->snapshot) {
+ if (arg_count(cmd, zero_ARG)) {
+ log_error("-Z is incompatible with snapshots.");
+ return 0;
+ }
+ if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
+ log_error("Negative chunk size is invalid.");
+ return 0;
+ }
+ 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))) {
+ log_error("Chunk size must be a power of 2 in the "
+ "range 4K to 512K.");
+ return 0;
+ }
+ log_verbose("Setting chunksize to %s.", display_size(cmd, lp->chunk_size));
- if (lp->snapshot && lp->thin && arg_count(cmd, chunksize_ARG))
- log_warn("WARNING: Ignoring --chunksize with thin snapshots.");
- else if (lp->thin && !lp->create_thin_pool) {
- if (arg_count(cmd, chunksize_ARG))
- log_warn("WARNING: Ignoring --chunksize when using an existing pool.");
- } else if (lp->snapshot) {
- if (arg_sign_value(cmd, chunksize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Negative chunk size is invalid");
- return 0;
- }
- 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))) {
- log_error("Chunk size must be a power of 2 in the "
- "range 4K to 512K");
+ if (!(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
+ return_0;
+ } else if (arg_count(cmd, chunksize_ARG)) {
+ log_error("--chunksize is only available with snapshots and thin pools.");
return 0;
}
- log_verbose("Setting chunksize to %s.", display_size(cmd, lp->chunk_size));
-
- if (!lp->thin && lp->snapshot && !(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
- return_0;
- } else if (arg_count(cmd, chunksize_ARG) && !lp->create_thin_pool) {
- log_error("-c is only available with snapshots and thin pools");
- return 0;
}
-
if (lp->mirrors > DEFAULT_MIRROR_MAX_IMAGES) {
log_error("Only up to %d images in mirror supported currently.",
DEFAULT_MIRROR_MAX_IMAGES);
@@ -879,11 +897,16 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
{
struct lv_list *lvl;
- if (!lp->thin && !lp->create_thin_pool) {
+ if (!lp->thin && !lp->create_thin_pool && !lp->snapshot) {
log_error("Please specify device size(s).");
return 0;
}
+ if (lp->thin && lp->snapshot) {
+ log_error("Please either creater snapshot or thin volume.");
+ return 0;
+ }
+
if (lp->thin && !lp->create_thin_pool) {
if (arg_count(vg->cmd, chunksize_ARG)) {
log_error("Only specify --chunksize when originally creating the thin pool.");
@@ -945,12 +968,11 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 0;
}
- if (!lp->thin && lp->lv_name) {
- log_error("--name may only be given when creating a new thin Logical volume or snapshot.");
- return 0;
- }
-
- if (!lp->thin) {
+ if (!lp->thin && !lp->snapshot) {
+ if (lp->lv_name) {
+ log_error("--name may only be given when creating a new thin Logical volume or snapshot.");
+ return 0;
+ }
if (arg_count(vg->cmd, readahead_ARG)) {
log_error("--readhead may only be given when creating a new thin Logical volume or snapshot.");
return 0;
@@ -994,12 +1016,7 @@ static int _validate_internal_thin_processing(const struct lvcreate_params *lp)
r = 0;
}
- if (lp->snapshot && (lp->create_thin_pool || !lp->thin)) {
- log_error(INTERNAL_ERROR "Inconsistent thin and snapshot parameters identified.");
- r = 0;
- }
-
- if (!lp->thin && !lp->create_thin_pool) {
+ if (!lp->thin && !lp->create_thin_pool && !lp->snapshot) {
log_error(INTERNAL_ERROR "Failed to identify what type of thin target to use.");
r = 0;
}
11 years
master - cleanup: indent line
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=435e0bb60895b3...
Commit: 435e0bb60895b3831840a10a5deb68a51936f3e9
Parent: b57b394ebbb4b4078d532318110cff60e38035d3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Mar 27 11:49:10 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 2 15:17:05 2013 +0200
cleanup: indent line
---
lib/metadata/segtype.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index d3ad2b2..1a23658 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -47,7 +47,7 @@ struct dev_manager;
#define seg_is_replicator(seg) ((seg)->segtype->flags & SEG_REPLICATOR ? 1 : 0)
#define seg_is_replicator_dev(seg) ((seg)->segtype->flags & SEG_REPLICATOR_DEV ? 1 : 0)
#define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
-#define seg_is_linear(seg) (seg_is_striped(seg) && ((seg)->area_count == 1))
+#define seg_is_linear(seg) (seg_is_striped(seg) && ((seg)->area_count == 1))
#define seg_is_snapshot(seg) ((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
#define seg_is_virtual(seg) ((seg)->segtype->flags & SEG_VIRTUAL ? 1 : 0)
#define seg_is_raid(seg) ((seg)->segtype->flags & SEG_RAID ? 1 : 0)
11 years
master - cmdline: add arg_long_option_name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b57b394ebbb4b4...
Commit: b57b394ebbb4b4078d532318110cff60e38035d3
Parent: 2edf488b3844a067bcdfe8f8efdf1a086c52a5cf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Mar 22 20:20:33 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 2 15:16:53 2013 +0200
cmdline: add arg_long_option_name
Add simple function to return long_name string option for given arg.
---
tools/lvmcmdline.c | 5 +++++
tools/tools.h | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c7820e0..c69d20d 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -73,6 +73,11 @@ unsigned grouped_arg_is_set(const struct arg_values *av, int a)
return grouped_arg_count(av, a) ? 1 : 0;
}
+const char *arg_long_option_name(int a)
+{
+ return _cmdline.arg_props[a].long_arg;
+}
+
const char *arg_value(struct cmd_context *cmd, int a)
{
return cmd->arg_values[a].value;
diff --git a/tools/tools.h b/tools/tools.h
index 673e40b..15d1f84 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -163,6 +163,7 @@ int major_minor_valid(const struct cmd_context * cmd, const struct format_type *
/* we use the enums to access the switches */
unsigned arg_count(const struct cmd_context *cmd, int a);
unsigned arg_is_set(const struct cmd_context *cmd, int a);
+const char *arg_long_option_name(int a);
const char *arg_value(struct cmd_context *cmd, int a);
const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
11 years
master - log: reenable abort
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2edf488b3844a0...
Commit: 2edf488b3844a067bcdfe8f8efdf1a086c52a5cf
Parent: 5c93f3997b11b33742c562b39d60949bf7e6c01d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 28 13:33:20 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 2 15:16:04 2013 +0200
log: reenable abort
abort_on_internal_error got ignored with the new class logging commit.j
Put this check back in this return path, so the check is not skipped.
---
lib/log/log.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/log/log.c b/lib/log/log.c
index 3b038f5..06e053f 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -346,11 +346,12 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
va_end(ap);
}
- if (level > debug_level())
- return;
-
- if (level >= _LOG_DEBUG && !debug_class_is_logged(dm_errno_or_class))
+ if ((level > debug_level()) ||
+ (level >= _LOG_DEBUG && !debug_class_is_logged(dm_errno_or_class))) {
+ if (fatal_internal_error)
+ abort();
return;
+ }
if (_log_to_file && (_log_while_suspended || !critical_section())) {
fprintf(_log_file, "%s:%d %s%s", file, line, log_command_name(),
11 years