master - Revert a previous change
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f5a205668b9965...
Commit: f5a205668b9965a7a2471d9e7cbcd3db49a495c7
Parent: cb9256111a8635b354c5b0ac3f3ab8fdab6068e3
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Jul 24 14:18:07 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Jul 24 14:18:07 2013 -0500
Revert a previous change
commit d00d45a8b609d50302c94a0fff20849f0cc13a48 introduced changes
that are causing cluster mirror tests to fail. Ultimately, I think
the change was right, but a proper clean-up will have to wait.
The portion of the commit we are reverting correlates to the
following commit comment:
2) lib/metadata/mirror.c:_delete_lv() - should have been calling
_activate_lv_like_model() with 'mirror_lv'. This is because
'mirror_lv' is the LV that the overall operation is being
performed on. We need to use this LV as the basis for
determining whether to activate locally, or across the
cluster, etc.
It appears that when legs or logs are removed from a mirror, they
are being activated before they are deleted in order to make them
top-level LVs that can be acted upon. When doing this, it appears
they are not activated based on the characteristics of the mirror
from which they came. IOW, if the mirror was exclusively active,
the sub-LVs are activated globally. This is a no-no. This then
made it impossible to activate_lv_like_model if the model was
"mirror_lv" instead of "lv" in _delete_lv(). Thus, at some point
this change should probably be put back and those location where
the sub-LVs are being improperly activated "shared" instead of
EX should be corrected.
---
lib/metadata/mirror.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 8748d89..24c9786 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -434,7 +434,8 @@ static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *l
}
}
- if (!_activate_lv_like_model(mirror_lv, lv))
+ /* FIXME: the 'model' should be 'mirror_lv' not 'lv', I think. */
+ if (!_activate_lv_like_model(lv, lv))
return_0;
/* FIXME Is this superfluous now? */
10 years, 8 months
master - libdm: move new added field to structure end
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb9256111a8635...
Commit: cb9256111a8635b354c5b0ac3f3ab8fdab6068e3
Parent: da5284a500338b458ade34c1a88d461acde52b71
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 24 16:49:48 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 24 17:17:37 2013 +0200
libdm: move new added field to structure end
For backwared compatibility add new struct field to the end.
(in release fix)
---
libdm/libdevmapper.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 66396ce..0c415c6 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1581,10 +1581,10 @@ struct dm_config_value {
};
struct dm_config_node {
- int id;
const char *key;
struct dm_config_node *parent, *sib, *child;
struct dm_config_value *v;
+ int id;
};
struct dm_config_tree {
10 years, 8 months
master - thin: lvconvert cannot convert pool to mirror
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da5284a500338b...
Commit: da5284a500338b458ade34c1a88d461acde52b71
Parent: 7dc21c1597fe57cf7401e074feb8c507cf66aabc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 24 15:25:22 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 24 17:17:19 2013 +0200
thin: lvconvert cannot convert pool to mirror
Suggest to use _tdata and _tmeta devices for that.
This fixes regression from too relaxed change in
f1d5f6ae81f4723e6aeb2f04bd68cba59cd65403
Without this patch there are some empty LVs created before
mirror code recognizes it cannot continue.
(in release fix)
---
test/shell/lvconvert-thin.sh | 3 +++
tools/lvconvert.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvconvert-thin.sh b/test/shell/lvconvert-thin.sh
index a84c1d1..3cbfd2c 100644
--- a/test/shell/lvconvert-thin.sh
+++ b/test/shell/lvconvert-thin.sh
@@ -95,4 +95,7 @@ grep "WARNING: Chunk size is too small" err
#lvs -a -o+chunk_size,stripe_size,seg_pe_ranges
+# Convertions of pool to mirror is unsupported
+not lvconvert -m1 $vg/$lv1
+
vgremove -ff $vg
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 62334d8..bd07497 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1553,6 +1553,27 @@ static int _lvconvert_mirrors_repair(struct cmd_context *cmd,
return 1;
}
+static int _lvconvert_validate_thin(struct logical_volume *lv,
+ struct lvconvert_params *lp)
+{
+ if (!lv_is_thin_pool(lv) && !lv_is_thin_volume(lv))
+ return 1;
+
+ log_error("Converting thin%s segment type for \"%s/%s\" to %s is not supported.",
+ lv_is_thin_pool(lv) ? " pool" : "",
+ lv->vg->name, lv->name, lp->segtype->name);
+
+ if (lv_is_thin_volume(lv))
+ return 0;
+
+ /* Give advice for thin pool conversion */
+ log_error("For pool data volume conversion use \"%s/%s\".",
+ lv->vg->name, seg_lv(first_seg(lv), 0)->name);
+ log_error("For pool metadata volume conversion use \"%s/%s\".",
+ lv->vg->name, first_seg(lv)->metadata_lv->name);
+ return 0;
+}
+
/*
* _lvconvert_mirrors
*
@@ -1575,6 +1596,9 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
return 0;
}
+ if (!_lvconvert_validate_thin(lv, lp))
+ return_0;
+
/* Adjust mimage and/or log count */
if (!_lvconvert_mirrors_parse_params(cmd, lv, lp,
&old_mimage_count, &old_log_count,
@@ -1676,6 +1700,9 @@ static int lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp
return 0;
}
+ if (!_lvconvert_validate_thin(lv, lp))
+ return_0;
+
if (!is_valid_raid_conversion(seg->segtype, lp->segtype)) {
log_error("Unable to convert %s/%s from %s to %s",
lv->vg->name, lv->name,
10 years, 8 months
master - python: make clean removes build dir
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7dc21c1597fe57...
Commit: 7dc21c1597fe57cf7401e074feb8c507cf66aabc
Parent: a03609dee4770f2453b1f5cb851e2169c539b1e4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 24 13:57:49 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 24 17:14:10 2013 +0200
python: make clean removes build dir
Cleanning compiled objects for clean: target.
---
python/Makefile.in | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/python/Makefile.in b/python/Makefile.in
index 9f9046b..fd529b8 100644
--- a/python/Makefile.in
+++ b/python/Makefile.in
@@ -33,7 +33,9 @@ install_lvm2: install_python_bindings
install: install_lvm2
+clean:
+ $(RM) -r build
+
CLEAN_TARGETS += .liblvm_built liblvm_python.c
-DISTCLEAN_DIRS += build
DISTCLEAN_TARGETS += setup.py
10 years, 8 months
master - systemd: udevadm settle for lvm2-activation-net.service
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a03609dee4770f...
Commit: a03609dee4770f2453b1f5cb851e2169c539b1e4
Parent: cf09cf0cd398d97e41f406aee5fa6b07c23a563b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jul 24 11:06:28 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jul 24 11:06:38 2013 +0200
systemd: udevadm settle for lvm2-activation-net.service
In case lvmetad is not used, we need to wait for udev to complete
after net-attached storage is initialized (after iscsi/fcoe service).
N.B. This also requires the storage to be attached synchronously
in the kernel itself.
---
.../lvm2_activation_generator_systemd_red_hat.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index d257479..17bc71a 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -135,20 +135,22 @@ static int generate_unit(const char *dir, int unit)
if (unit == UNIT_NET) {
fputs("After=iscsi.service fcoe.service\n"
- "Before=remote-fs.target shutdown.target\n", f);
+ "Before=remote-fs.target shutdown.target\n\n"
+ "[Service]\n"
+ "ExecStartPre=/usr/bin/udevadm settle\n", f);
} else {
if (unit == UNIT_EARLY) {
- fputs("After=systemd-udev-settle.service\n", f);
- fputs("Before=cryptsetup.target\n", f);
+ fputs("After=systemd-udev-settle.service\n"
+ "Before=cryptsetup.target\n", f);
} else
fputs("After=lvm2-activation-early.service cryptsetup.target\n", f);
fputs("Before=local-fs.target shutdown.target\n"
- "Wants=systemd-udev-settle.service\n\n", f);
+ "Wants=systemd-udev-settle.service\n\n"
+ "[Service]\n", f);
}
- fputs("[Service]\n"
- "ExecStart=/usr/sbin/lvm vgchange -aay --sysinit\n"
+ fputs("ExecStart=/usr/sbin/lvm vgchange -aay --sysinit\n"
"Type=oneshot\n", f);
if (fclose(f) < 0) {
10 years, 8 months
master - Revert "lvm2app: lvm_vg_list_lvs filter hidden LVs"
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cf09cf0cd398d9...
Commit: cf09cf0cd398d97e41f406aee5fa6b07c23a563b
Parent: 5597dc3652babd9a27064e001d654d5df7297ca7
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jul 24 01:49:18 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jul 24 01:49:18 2013 +0100
Revert "lvm2app: lvm_vg_list_lvs filter hidden LVs"
This reverts commit a2b51476007aae91acfc121a7fd2ce04f3b08781.
The function has behaved like this for a long time so let's
not change this part of the API.
---
liblvm/lvm_vg.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index f0da83b..3f4968e 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -250,15 +250,13 @@ struct dm_list *lvm_vg_list_lvs(vg_t vg)
dm_list_init(list);
dm_list_iterate_items(lvl, &vg->lvs) {
- if (lv_is_visible(lvl->lv)) {
- if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
- log_errno(ENOMEM,
- "Memory allocation fail for lvm_lv_list.");
- return NULL;
- }
- lvs->lv = lvl->lv;
- dm_list_add(list, &lvs->list);
+ if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
+ log_errno(ENOMEM,
+ "Memory allocation fail for lvm_lv_list.");
+ return NULL;
}
+ lvs->lv = lvl->lv;
+ dm_list_add(list, &lvs->list);
}
return list;
}
10 years, 8 months
master - thin: not zeroing for non-zeroed thin pool snaps
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5597dc3652babd...
Commit: 5597dc3652babd9a27064e001d654d5df7297ca7
Parent: d00d45a8b609d50302c94a0fff20849f0cc13a48
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 24 01:11:15 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 24 01:15:31 2013 +0200
thin: not zeroing for non-zeroed thin pool snaps
Do not zero initial 4KB of thin snapshot volume for thin pool with
disabled zeroing.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 2 +-
test/shell/lvcreate-thin-snap.sh | 7 +++++++
3 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 36d9f93..fd44fb1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Do not zero init 4KB of thin snapshot for non-zeroing thin pool (2.02.94).
Issue an error msg if lvconvert --type used incorrectly with other options.
Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
Support ARG_GROUPABLE with merge_synonym (for --raidwritemostly).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8fea33d..088c05d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5829,7 +5829,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
if (!seg_is_thin(lp) && !lp->zero && !lp->snapshot)
log_warn("WARNING: \"%s\" not zeroed", lv->name);
else if ((!seg_is_thin(lp) ||
- (lv_is_thin_volume(lv) &&
+ (lv_is_thin_volume(lv) && !lp->snapshot &&
!first_seg(first_seg(lv)->pool_lv)->zero_new_blocks)) &&
!set_lv(cmd, lv, UINT64_C(0), 0)) {
log_error("Aborting. Failed to wipe %s.",
diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh
index 701bb08..a223469 100644
--- a/test/shell/lvcreate-thin-snap.sh
+++ b/test/shell/lvcreate-thin-snap.sh
@@ -54,4 +54,11 @@ lvcreate -K -s --name sn2 $vg/sn1
lvcreate -K -s --name sn3 $vg/sn2
lvcreate -K -s --name sn4 $vg/sn3
+lvremove -ff $vg
+
+lvcreate -L10M --zero n -T $vg/pool -V10M --name $lv1
+mkfs.ext4 $DM_DEV_DIR/$vg/$lv1
+lvcreate -K -s $vg/$lv1 --name snap
+fsck -p $DM_DEV_DIR/$vg/snap
+
vgremove -ff $vg
10 years, 8 months
master - Clean-up: Addressing a few FIXME's
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d00d45a8b609d5...
Commit: d00d45a8b609d50302c94a0fff20849f0cc13a48
Parent: a2b51476007aae91acfc121a7fd2ce04f3b08781
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Jul 23 14:46:22 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Jul 23 14:46:22 2013 -0500
Clean-up: Addressing a few FIXME's
Three fixme's addressed in this commit:
1) lib/metadata/lv_manip.c:_calc_area_multiple() - this could be
safely changed to a comment explaining that currently because
RAID10 can only have a 2-way mirror, we don't need to know the
number of stripes. However, we will need to know that in the
future if RAID10 is to support more than 2-way mirroring.
2) lib/metadata/mirror.c:_delete_lv() - should have been calling
_activate_lv_like_model() with 'mirror_lv'. This is because
'mirror_lv' is the LV that the overall operation is being
performed on. We need to use this LV as the basis for
determining whether to activate locally, or across the
cluster, etc.
3) tools/lvcreate.c:_lvcreate_params() - Minor clean-up. If
'-m 0' is given, treat it as though the mirroring argument
was not given (i.e. as though the requested segment type
was 'stripe' and not mirror).
---
lib/metadata/lv_manip.c | 11 ++++++++---
lib/metadata/mirror.c | 3 +--
tools/lvcreate.c | 7 +++----
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9284c7b..8fea33d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -846,7 +846,8 @@ struct alloc_handle {
};
static uint32_t _calc_area_multiple(const struct segment_type *segtype,
- const uint32_t area_count, const uint32_t stripes)
+ const uint32_t area_count,
+ const uint32_t stripes)
{
if (!area_count)
return 1;
@@ -868,9 +869,13 @@ static uint32_t _calc_area_multiple(const struct segment_type *segtype,
return area_count - segtype->parity_devs;
}
- /* RAID10 - only has 2-way mirror right now */
+ /*
+ * RAID10 - only has 2-way mirror right now.
+ * If we are to move beyond 2-way RAID10, then
+ * the 'stripes' argument will always need to
+ * be given.
+ */
if (!strcmp(segtype->name, "raid10")) {
- // FIXME: I'd like the 'stripes' arg always given
if (!stripes)
return area_count / 2;
return stripes;
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 4f36e0d..8748d89 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -434,8 +434,7 @@ static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *l
}
}
- // FIXME: shouldn't the activation type be based on mirror_lv, not lv?
- if (!_activate_lv_like_model(lv, lv))
+ if (!_activate_lv_like_model(mirror_lv, lv))
return_0;
/* FIXME Is this superfluous now? */
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2e8c65f..8564613 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -735,10 +735,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
-// FIXME -m0 implies *striped*
-
- /* Set default segtype */
- if (arg_count(cmd, mirrors_ARG))
+ /* Set default segtype - remember, '-m 0' implies stripe. */
+ if (arg_count(cmd, mirrors_ARG) &&
+ arg_uint_value(cmd, mirrors_ARG, 0))
if (arg_uint_value(cmd, arg_count(cmd, stripes_long_ARG) ?
stripes_long_ARG : stripes_ARG, 1) > 1) {
segtype_str = find_config_tree_str(cmd, global_raid10_segtype_default_CFG, NULL);;
10 years, 8 months
master - lvm2app: lvm_vg_list_lvs filter hidden LVs
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2b51476007aae...
Commit: a2b51476007aae91acfc121a7fd2ce04f3b08781
Parent: 31de670318c9794690601468def392cd7e4eb0fc
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Jul 23 14:57:53 2013 -0400
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Tue Jul 23 14:01:20 2013 -0500
lvm2app: lvm_vg_list_lvs filter hidden LVs
The function lvm_vg_list_lvs was returning all logical
volumes, including *_tmeta and *_tdata. Added check
to verify that LV is visible before including in list
of returned logical volumes.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
liblvm/lvm_vg.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index 3f4968e..f0da83b 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -250,13 +250,15 @@ struct dm_list *lvm_vg_list_lvs(vg_t vg)
dm_list_init(list);
dm_list_iterate_items(lvl, &vg->lvs) {
- if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
- log_errno(ENOMEM,
- "Memory allocation fail for lvm_lv_list.");
- return NULL;
+ if (lv_is_visible(lvl->lv)) {
+ if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
+ log_errno(ENOMEM,
+ "Memory allocation fail for lvm_lv_list.");
+ return NULL;
+ }
+ lvs->lv = lvl->lv;
+ dm_list_add(list, &lvs->list);
}
- lvs->lv = lvl->lv;
- dm_list_add(list, &lvs->list);
}
return list;
}
10 years, 8 months
master - lvconvert: add more checks for lvconvert --type
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=31de670318c979...
Commit: 31de670318c9794690601468def392cd7e4eb0fc
Parent: 373f95a921223c1e4d36ae975ac685227369cf5b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jul 23 17:04:43 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jul 23 17:13:54 2013 +0200
lvconvert: add more checks for lvconvert --type
The --type mirror requires -m/--mirrrors:
lvconvert --type mirror vg/lvol0
--type mirror requires -m/--mirrors
Run `lvconvert --help' for more information.
The --type raid* is allowed (the checks already existed):
lvconvert --type raid10 vg/lvol0
Converting the segment type for vg/lvol0 from linear to raid10 is not yet supported.
The --type snapshot is a synonym to -s/--snapshot:
lvconvert -s vg/lvol0 vg/lvol1
Logical volume lvol1 converted to snapshot.
lvconvert --type snapshot vg/lvol0 vg/lvol1
Logical volume lvol1 converted to snapshot.
All the other segment types are not supported, e.g.:
lvconvert --type zero vg/lvol0
Conversion using --type zero is not supported.
Run `lvconvert --help' for more information.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 66 ++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0269839..36d9f93 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Issue an error msg if lvconvert --type used incorrectly with other options.
Use LOG_DEBUG/ERR msg severity instead default for lvm2-activation-generator.
Support ARG_GROUPABLE with merge_synonym (for --raidwritemostly).
Fix segfault when reporting raid_syncaction for older kernels.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ce28947..62334d8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -177,6 +177,35 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
return 1;
}
+static int _check_conversion_type(struct cmd_context *cmd, const char *type_str)
+{
+ if (!type_str || !*type_str)
+ return 1;
+
+ if (!strcmp(type_str, "mirror")) {
+ if (!arg_count(cmd, mirrors_ARG)) {
+ log_error("--type mirror requires -m/--mirrors");
+ return 0;
+ }
+ return 1;
+ }
+
+ /* FIXME: Check thin-pool and thin more thoroughly! */
+ if (!strcmp(type_str, "snapshot") || !strncmp(type_str, "raid", 4) ||
+ !strcmp(type_str, "thin-pool") || !strcmp(type_str, "thin"))
+ return 1;
+
+ log_error("Conversion using --type %s is not supported.", type_str);
+ return 0;
+}
+
+/* -s/--snapshot and --type snapshot are synonyms */
+#define snapshot_type_requested(cmd,type_str) (arg_count(cmd, snapshot_ARG) || \
+ !strcmp(type_str, "snapshot"))
+/* mirror/raid* (1,10,4,5,6 and their variants) reshape */
+#define mirror_or_raid_type_requested(cmd,type_str) (arg_count(cmd, mirrors_ARG) || \
+ !strncmp(type_str, "raid", 4))
+
static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
@@ -185,40 +214,45 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
struct arg_value_group_list *group;
int region_size;
int pagesize = lvm_getpagesize();
+ const char *type_str = arg_str_value(cmd, type_ARG, "");
memset(lp, 0, sizeof(*lp));
lp->target_attr = ~0;
- if ((arg_count(cmd, snapshot_ARG) || arg_count(cmd, merge_ARG)) &&
- (arg_count(cmd, mirrorlog_ARG) || arg_count(cmd, mirrors_ARG) ||
+ if (!_check_conversion_type(cmd, type_str))
+ return_0;
+
+ if ((snapshot_type_requested(cmd, type_str) || arg_count(cmd, merge_ARG)) &&
+ (arg_count(cmd, mirrorlog_ARG) || mirror_or_raid_type_requested(cmd, type_str) ||
arg_count(cmd, repair_ARG) || arg_count(cmd, thinpool_ARG))) {
- log_error("--snapshot or --merge argument cannot be mixed "
- "with --mirrors, --mirrorlog, --repair "
- "or --thinpool.");
+ log_error("--snapshot/--type snapshot or --merge argument "
+ "cannot be mixed with --mirrors/--type mirror/--type raid*, "
+ "--mirrorlog, --repair or --thinpool.");
return 0;
}
if ((arg_count(cmd, stripes_long_ARG) || arg_count(cmd, stripesize_ARG)) &&
- !(arg_count(cmd, mirrors_ARG) || arg_count(cmd, repair_ARG) ||
- arg_count(cmd, thinpool_ARG) || arg_count(cmd, type_ARG))) {
+ !(mirror_or_raid_type_requested(cmd, type_str) ||
+ arg_count(cmd, repair_ARG) ||
+ arg_count(cmd, thinpool_ARG))) {
log_error("--stripes or --stripesize argument is only valid "
- "with --mirrors, --repair, --thinpool or --type");
+ "with --mirrors/--type mirror/--type raid*, --repair and --thinpool");
return 0;
}
if (!arg_count(cmd, background_ARG))
lp->wait_completion = 1;
- if (arg_count(cmd, snapshot_ARG))
+ if (snapshot_type_requested(cmd, type_str))
lp->snapshot = 1;
- if (arg_count(cmd, snapshot_ARG) && arg_count(cmd, merge_ARG)) {
+ if (snapshot_type_requested(cmd, type_str) && arg_count(cmd, merge_ARG)) {
log_error("--snapshot and --merge are mutually exclusive");
return 0;
}
- if (arg_count(cmd, splitmirrors_ARG) && arg_count(cmd, mirrors_ARG)) {
- log_error("--mirrors and --splitmirrors are "
+ if (arg_count(cmd, splitmirrors_ARG) && mirror_or_raid_type_requested(cmd, type_str)) {
+ log_error("--mirrors/--type mirror/--type raid* and --splitmirrors are "
"mutually exclusive");
return 0;
}
@@ -231,16 +265,16 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
log_error("--thinpool and --merge are mutually exlusive.");
return 0;
}
- if (arg_count(cmd, mirrors_ARG)) {
- log_error("--thinpool and --mirrors are mutually exlusive.");
+ if (mirror_or_raid_type_requested(cmd, type_str)) {
+ log_error("--thinpool and --mirrors/--type mirror/--type raid* are mutually exlusive.");
return 0;
}
if (arg_count(cmd, repair_ARG)) {
log_error("--thinpool and --repair are mutually exlusive.");
return 0;
}
- if (arg_count(cmd, snapshot_ARG)) {
- log_error("--thinpool and --snapshot are mutually exlusive.");
+ if (snapshot_type_requested(cmd, type_str)) {
+ log_error("--thinpool and --snapshot/--type snapshot are mutually exlusive.");
return 0;
}
if (arg_count(cmd, splitmirrors_ARG)) {
10 years, 8 months