master - cleanup: avoid using double __ in extracted image name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6db5b91231ce7a...
Commit: 6db5b91231ce7ac84fafd4190bb3b4a079db1f49
Parent: 1bdcb01f63f849950f381a0a33a046f01f3d6f2a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 8 16:21:25 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
cleanup: avoid using double __ in extracted image name
---
lib/metadata/raid_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 4d3d63f..b88ddcc 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1056,10 +1056,10 @@ static int _extract_image_components(struct lv_segment *seg, uint32_t idx,
seg_metatype(seg, idx) = AREA_UNASSIGNED;
/* FIXME Remove duplicated prefix? */
- if (!(data_lv->name = _generate_raid_name(data_lv, "_extracted", -1)))
+ if (!(data_lv->name = _generate_raid_name(data_lv, "extracted", -1)))
return_0;
- if (!(meta_lv->name = _generate_raid_name(meta_lv, "_extracted", -1)))
+ if (!(meta_lv->name = _generate_raid_name(meta_lv, "extracted", -1)))
return_0;
*extracted_rmeta = meta_lv;
6 years, 7 months
master - cleanup: add dots to debug messages
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1bdcb01f63f849...
Commit: 1bdcb01f63f849950f381a0a33a046f01f3d6f2a
Parent: b38564b8dc8a1e26f1937158dc7fc2d7c0b0804c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 11 16:38:04 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
cleanup: add dots to debug messages
---
lib/activate/dev_manager.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index dcea359..da66374 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2283,7 +2283,7 @@ static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *d
seg->lv->name, errid)))
return_NULL;
- log_debug_activation("Getting device info for %s [%s]", name, dlid);
+ log_debug_activation("Getting device info for %s [%s].", name, dlid);
if (!_info(dm->cmd, dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
@@ -2303,7 +2303,7 @@ static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *d
} else {
/* Already exists */
if (!dm_tree_add_dev(dtree, info.major, info.minor)) {
- log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree",
+ log_error("Failed to add device (%" PRIu32 ":%" PRIu32") to dtree.",
info.major, info.minor);
return_NULL;
}
6 years, 7 months
master - tests: do not set zero interval in aux lvm.conf
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b38564b8dc8a1e...
Commit: b38564b8dc8a1e26f1937158dc7fc2d7c0b0804c
Parent: de3d054f7803bad12e395cb0bd099c0c9c396668
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 11 15:57:00 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
tests: do not set zero interval in aux lvm.conf
0 interval leads as of now to a busy loop with lvmetad and command.
Avoid testing this patological case.
TODO: Code should possibly translate zero interval into some small
sleep. With lvmpolld it's already 1/10s
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 7187975..e4c3780 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1063,7 +1063,7 @@ generate_config() {
cat > "$config_values" <<-EOF
activation/checks = 1
activation/monitoring = 0
-activation/polling_interval = 0
+activation/polling_interval = 1
activation/retry_deactivation = 1
activation/snapshot_autoextend_percent = 50
activation/snapshot_autoextend_threshold = 50
6 years, 7 months
master - tests: avoid using polling
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=de3d054f7803ba...
Commit: de3d054f7803bad12e395cb0bd099c0c9c396668
Parent: 4a2250f9cea300598fff8dbfee8700ac7aa81f89
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 11 15:56:11 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
tests: avoid using polling
---
test/shell/snapshot-merge-stack.sh | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/test/shell/snapshot-merge-stack.sh b/test/shell/snapshot-merge-stack.sh
index 6ed9c95..3ee9eaa 100644
--- a/test/shell/snapshot-merge-stack.sh
+++ b/test/shell/snapshot-merge-stack.sh
@@ -40,13 +40,14 @@ snap_and_merge() {
kill $SLEEP_PID
aux delay_dev "$dev1" 0 200 $(get first_extent_sector "$dev1"):
- lvchange --refresh $vg/$lv1
+ lvchange --poll n --refresh $vg/$lv1
dmsetup table
lvs -a -o+lv_merging,lv_merge_failed $vg
sleep 1
check lv_attr_bit state $vg/$lv1 "a"
check lv_attr_bit state $vg/$lv2 "a"
aux error_dev "$dev2" $(get first_extent_sector "$dev2"):
+ aux enable_dev "$dev1"
# delay to let snapshot merge 'discover' failing COW device
sleep 1
sync
@@ -56,7 +57,7 @@ snap_and_merge() {
check lv_attr_bit state $vg/$lv2 "m"
# device OK and running in full speed
- aux enable_dev "$dev1" "$dev2"
+ aux enable_dev "$dev2"
# reactivate so merge can finish
lvchange -an $vg
6 years, 7 months
master - tests: update make targets
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4a2250f9cea300...
Commit: 4a2250f9cea300598fff8dbfee8700ac7aa81f89
Parent: d8fc4d093ee125e3667046b892c14e4a920a8da0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 17 11:13:43 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:20 2016 +0100
tests: update make targets
Add new targets:
make check_lvmpolld
make check_cluster_lvmpolld
make check_lvmetad_lvmpolld
make check_all_lvmpolld
So check_lvmetad runs only base lvmetad test - to much
logic of remaining targets.
Previous behavior is available via check_all_lvmpolld.
---
test/Makefile.in | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 94b3105..bc501d1 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -77,6 +77,9 @@ help:
@echo " check_cluster Run tests with cluster daemon."
@echo " check_lvmetad Run tests with lvmetad daemon."
@echo " check_lvmpolld Run tests with lvmpolld daemon."
+ @echo " check_cluster_lvmpolld Run tests with clvmd and lvmpolld daemon."
+ @echo " check_lvmetad_lvmpolld Run tests with lvmetad and lvmpolld daemon."
+ @echo " check_all_lvmpolld Run all tests with lvmpolld daemon."
@echo " check_lvmlockd_sanlock Run tests with lvmlockd and sanlock."
@echo " check_lvmlockd_dlm Run tests with lvmlockd and dlm."
@echo " check_lvmlockd_test Run tests with lvmlockd --test."
@@ -146,6 +149,21 @@ ifeq ("@BUILD_LVMPOLLD@", "yes")
check_lvmpolld: .tests-stamp
VERBOSE=$(VERBOSE) ./lib/runner \
--testdir . --outdir results \
+ --flavours ndev-lvmpolld --only $(T) --skip $(S)
+
+check_cluster_lvmpolld: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours ndev-cluster-lvmpolld --only $(T) --skip $(S)
+
+check_lvmetad_lvmpolld: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --flavours ndev-lvmetad-lvmpolld --only $(T) --skip $(S)
+
+check_all_lvmpolld: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
--flavours ndev-lvmpolld,ndev-cluster-lvmpolld,ndev-lvmetad-lvmpolld --only $(T) --skip $(S)
endif
6 years, 7 months
master - conf: support zero for missing_stripe_filler
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8fc4d093ee125...
Commit: d8fc4d093ee125e3667046b892c14e4a920a8da0
Parent: e54cce245f2829107e1ed09221bca7ff7921d98b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 18 12:58:22 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:58:16 2016 +0100
conf: support zero for missing_stripe_filler
Make it easier to replace missing segments with 'zero' returning
target - otherwise user would have to create some extra target
to provide zeros as /dev/zero can't be used (not a block device).
Also break code loop when segment is found and make it an INTERNAL_ERROR
where it's missing.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 24 ++++++++++++++++--------
lib/commands/toolcontext.c | 3 ++-
lib/config/config_settings.h | 3 ++-
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2af2992..57c382f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.168 -
====================================
+ Missing stripe filler now could be also 'zero'.
lvconvert --repair accepts --interval and --background option.
More efficiently prepare _rmeta devices when creating a new raid LV.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 2dc0fd8..dcea359 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2250,8 +2250,8 @@ bad:
return NULL;
}
-static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
- struct lv_segment *seg, int s)
+static char *_add_error_or_zero_device(struct dev_manager *dm, struct dm_tree *dtree,
+ struct lv_segment *seg, int s, int use_zero)
{
char *dlid, *name;
char errid[32];
@@ -2262,13 +2262,15 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
uint64_t size = (uint64_t) seg->len * seg->lv->vg->extent_size;
dm_list_iterate_items(seg_i, &seg->lv->segments) {
- if (seg == seg_i)
+ if (seg == seg_i) {
segno = i;
+ break;
+ }
++i;
}
if (segno < 0) {
- log_error("_add_error_device called with bad segment");
+ log_error(INTERNAL_ERROR "_add_error_or_zero_device called with bad segment.");
return NULL;
}
@@ -2291,8 +2293,13 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
/* Create new node */
if (!(node = dm_tree_add_new_dev(dtree, name, dlid, 0, 0, 0, 0, 0)))
return_NULL;
- if (!dm_tree_node_add_error_target(node, size))
- return_NULL;
+
+ if (use_zero) {
+ if (!dm_tree_node_add_zero_target(node, size))
+ return_NULL;
+ } else
+ if (!dm_tree_node_add_error_target(node, size))
+ return_NULL;
} else {
/* Already exists */
if (!dm_tree_add_dev(dtree, info.major, info.minor)) {
@@ -2310,14 +2317,15 @@ static int _add_error_area(struct dev_manager *dm, struct dm_tree_node *node,
{
char *dlid;
uint64_t extent_size = seg->lv->vg->extent_size;
+ int use_zero = !strcmp(dm->cmd->stripe_filler, TARGET_NAME_ZERO) ? 1 : 0;
- if (!strcmp(dm->cmd->stripe_filler, TARGET_NAME_ERROR)) {
+ if (!strcmp(dm->cmd->stripe_filler, TARGET_NAME_ERROR) || use_zero) {
/*
* FIXME, the tree pointer is first field of dm_tree_node, but
* we don't have the struct definition available.
*/
struct dm_tree **tree = (struct dm_tree **) node;
- if (!(dlid = _add_error_device(dm, *tree, seg, s)))
+ if (!(dlid = _add_error_or_zero_device(dm, *tree, seg, s, use_zero)))
return_0;
if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_le(seg, s)))
return_0;
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 002af05..bfb7c1b 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -640,7 +640,8 @@ static int _process_config(struct cmd_context *cmd)
if (!strcmp(cmd->stripe_filler, "/dev/ioerror") &&
stat(cmd->stripe_filler, &st))
cmd->stripe_filler = "error";
- else if (strcmp(cmd->stripe_filler, "error")) {
+ else if (strcmp(cmd->stripe_filler, "error") &&
+ strcmp(cmd->stripe_filler, "zero")) {
if (stat(cmd->stripe_filler, &st)) {
log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
"is invalid,", cmd->stripe_filler);
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 9eed969..e0770b6 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1111,7 +1111,8 @@ cfg(activation_retry_deactivation_CFG, "retry_deactivation", activation_CFG_SECT
cfg(activation_missing_stripe_filler_CFG, "missing_stripe_filler", activation_CFG_SECTION, CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_STRIPE_FILLER, vsn(1, 0, 0), NULL, 0, NULL,
"Method to fill missing stripes when activating an incomplete LV.\n"
"Using 'error' will make inaccessible parts of the device return I/O\n"
- "errors on access. You can instead use a device path, in which case,\n"
+ "errors on access. Using 'zero' will return success (and zero) on I/O\n"
+ "You can instead use a device path, in which case,\n"
"that device will be used in place of missing stripes. Using anything\n"
"other than 'error' with mirrored or snapshotted volumes is likely to\n"
"result in data corruption.\n")
6 years, 7 months
master - cleanup: skip checking for just assigned string
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e54cce245f2829...
Commit: e54cce245f2829107e1ed09221bca7ff7921d98b
Parent: 59b29716e5fd0f490d28d2457cdebfc68eb9940e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 18 11:18:02 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:52:24 2016 +0100
cleanup: skip checking for just assigned string
When 'stripe_filler' has been just set to 'error',
do not check it again for not being 'error'.
---
lib/commands/toolcontext.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c416575..002af05 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -640,8 +640,7 @@ static int _process_config(struct cmd_context *cmd)
if (!strcmp(cmd->stripe_filler, "/dev/ioerror") &&
stat(cmd->stripe_filler, &st))
cmd->stripe_filler = "error";
-
- if (strcmp(cmd->stripe_filler, "error")) {
+ else if (strcmp(cmd->stripe_filler, "error")) {
if (stat(cmd->stripe_filler, &st)) {
log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
"is invalid,", cmd->stripe_filler);
6 years, 7 months
master - lvconvert: repair accepts interval and background
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=59b29716e5fd0f...
Commit: 59b29716e5fd0f490d28d2457cdebfc68eb9940e
Parent: f8b3b0bc9a5758ab3cacf0de79ee48bb851b07a6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 17 11:16:16 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Nov 11 16:51:33 2016 +0100
lvconvert: repair accepts interval and background
For mirror and raid we expose --interval and --background on
command line (instead of using just always using compiled-in defaults).
---
WHATS_NEW | 1 +
man/lvconvert.8.in | 6 ++++++
tools/lvconvert.c | 1 +
3 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 17fbdc0..2af2992 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.168 -
====================================
+ lvconvert --repair accepts --interval and --background option.
More efficiently prepare _rmeta devices when creating a new raid LV.
Version 2.02.167 - 5th November 2016
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index bc4af80..0becc8a 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -365,6 +365,9 @@ See corresponding operation --splitmirrors.
VG/RaidLV
.br
\[bu]
+Options \-\-background, \-\-interval.
+.br
+\[bu]
Replace failed PVs in RaidLV.
.B lvconvert \-\-replace
@@ -502,6 +505,9 @@ Change the type of log used by MirrorLV.
VG/MirrorLV
.br
\[bu]
+Options \-\-background, \-\-interval.
+.br
+\[bu]
Replace failed PVs in MirrorLV.
.B lvconvert \-\-type linear
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 4563ade..d6824d8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -534,6 +534,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
if (arg_outside_list_is_set(cmd, "cannot be used with --repair",
repair_ARG,
alloc_ARG, usepolicies_ARG,
+ background_ARG, interval_ARG,
force_ARG, noudevsync_ARG, test_ARG,
-1))
return_0;
6 years, 7 months
master - lvconvert: Introduce enum to separate cases.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f8b3b0bc9a5758...
Commit: f8b3b0bc9a5758ab3cacf0de79ee48bb851b07a6
Parent: b11f4f93d70d307b997290713607c0742c3ea29e
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Nov 11 00:27:01 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Nov 11 00:27:01 2016 +0000
lvconvert: Introduce enum to separate cases.
Start to separate out the different things that lvconvert does by using
an enum to identify 12 distinct cases.
---
tools/lvconvert.c | 283 ++++++++++++++++++++++++++++++++---------------------
1 files changed, 170 insertions(+), 113 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 8376565..4563ade 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -37,19 +37,72 @@
* deprecated. (The same is still needed for --merge.)
*/
+typedef enum {
+ /* Merge:
+ * If merge_snapshot is also set:
+ * merge thin snapshot LV into its origin
+ * merge old snapshot COW into its origin
+ * or if merge_mirror is also set
+ * merge LV previously split from mirror back into mirror
+ */
+ CONV_MERGE = 1,
+
+ /* Split:
+ * For a snapshot, split it apart into COW and origin for future recombination
+ * For a cached LV, split it apart into the cached LV and its pool
+ * For a mirrored or raid LV, split mirror into two mirrors, optionally tracking
+ * future changes to the main mirror to allow future recombination.
+ */
+ CONV_SPLIT = 2,
+ CONV_SPLIT_SNAPSHOT = 3,
+ CONV_SPLIT_CACHE = 4,
+ CONV_SPLIT_MIRRORS = 5,
+
+ /* Start to cache an LV */
+ CONV_CACHE = 6,
+
+ /* Destroy the cache attached to a cached LV */
+ CONV_UNCACHE = 7,
+
+ /* Reconstruct a snapshot from its origin and COW */
+ CONV_SNAPSHOT = 8,
+
+ /* Replace devices in a raid LV with alternatives */
+ CONV_REPLACE = 9,
+
+ /* Repair a mirror, raid or thin LV */
+ CONV_REPAIR = 10,
+
+ /* Convert normal LV into one in a thin pool */
+ CONV_THIN = 11,
+
+ /* Every other segment type or mirror log conversion we haven't separated out */
+ CONV_OTHER = 12,
+} conversion_type_t;
+
struct lvconvert_params {
/* Exactly one of these 12 command categories is determined */
- int merge; /* Either merge_snapshot or merge_mirror is also set */
- int cache;
- int keep_mimages; /* --splitmirrors */
- int repair;
- int replace;
- int snapshot;
- int split;
- int splitcache;
- int splitsnapshot;
- int thin;
- int uncache;
+ int merge; /* 1 */
+ int split; /* 2 */
+ int splitsnapshot; /* 3 */
+ int splitcache; /* 4 */
+ int keep_mimages; /* 5 */ /* --splitmirrors */
+ int cache; /* 6 */
+ int uncache; /* 7 */
+ int snapshot; /* 8 */
+ int replace; /* 9 */
+ int repair; /* 10 */
+ int thin; /* 11 */
+ /* other */ /* 12 */
+
+ /* FIXME Eliminate all cases where more than one of the above are set then use conv_type instead */
+ conversion_type_t conv_type;
+
+ int merge_snapshot; /* CONV_MERGE is set */
+ int merge_mirror; /* CONV_MERGE is set */
+
+ int track_changes; /* CONV_SPLIT_MIRRORS is set */
+
int corelog; /* Equivalent to --mirrorlog core */
int mirrorlog; /* Only one of corelog and mirrorlog may be set */
@@ -59,11 +112,6 @@ struct lvconvert_params {
const struct segment_type *segtype; /* Holds what segment type you will get */
- int merge_snapshot; /* merge is also set */
- int merge_mirror; /* merge is also set */
-
- int track_changes; /* keep_mimages is also set (--splitmirrors) */
-
int poolmetadataspare;
int force;
int yes;
@@ -124,6 +172,15 @@ struct convert_poll_id_list {
unsigned is_merging_origin_thin:1;
};
+/* FIXME Temporary function until the enum replaces the separate variables */
+static void _set_conv_type(struct lvconvert_params *lp, int conv_type)
+{
+ if (lp->conv_type != CONV_OTHER)
+ log_error(INTERNAL_ERROR "Changing conv_type from %d to %d.", lp->conv_type, conv_type);
+
+ lp->conv_type = conv_type;
+}
+
static int _lvconvert_validate_names(struct lvconvert_params *lp)
{
unsigned i, j;
@@ -472,10 +529,8 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
-1))
return_0;
lp->merge = 1;
- }
-
- /* If --repair, check for incompatible args. */
- if (arg_is_set(cmd, repair_ARG)) {
+ _set_conv_type(lp, CONV_MERGE);
+ } else if (arg_is_set(cmd, repair_ARG)) {
if (arg_outside_list_is_set(cmd, "cannot be used with --repair",
repair_ARG,
alloc_ARG, usepolicies_ARG,
@@ -483,12 +538,8 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
-1))
return_0;
lp->repair = 1;
- }
-
- if (arg_is_set(cmd, replace_ARG))
- lp->replace = 1;
-
- if (arg_is_set(cmd, split_ARG)) {
+ _set_conv_type(lp, CONV_REPAIR);
+ } else if (arg_is_set(cmd, split_ARG)) {
if (arg_outside_list_is_set(cmd, "cannot be used with --split",
split_ARG,
name_ARG,
@@ -496,40 +547,40 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
-1))
return_0;
lp->split = 1;
- }
-
- if (arg_is_set(cmd, splitcache_ARG)) {
+ _set_conv_type(lp, CONV_SPLIT);
+ } else if (arg_is_set(cmd, splitcache_ARG)) {
if (arg_outside_list_is_set(cmd, "cannot be used with --splitcache",
splitcache_ARG,
force_ARG, noudevsync_ARG, test_ARG,
-1))
return_0;
lp->splitcache = 1;
- }
-
- if (arg_is_set(cmd, splitsnapshot_ARG)) {
+ _set_conv_type(lp, CONV_SPLIT_CACHE);
+ } else if (arg_is_set(cmd, splitsnapshot_ARG)) {
if (arg_outside_list_is_set(cmd, "cannot be used with --splitsnapshot",
splitsnapshot_ARG,
force_ARG, noudevsync_ARG, test_ARG,
-1))
return_0;
lp->splitsnapshot = 1;
- }
-
- if (arg_is_set(cmd, trackchanges_ARG))
- lp->track_changes = 1;
-
- if (arg_is_set(cmd, uncache_ARG)) {
+ _set_conv_type(lp, CONV_SPLIT_SNAPSHOT);
+ } else if (arg_is_set(cmd, uncache_ARG)) {
if (arg_outside_list_is_set(cmd, "cannot be used with --uncache",
uncache_ARG,
force_ARG, noudevsync_ARG, test_ARG,
-1))
return_0;
lp->uncache = 1;
+ _set_conv_type(lp, CONV_UNCACHE);
+ } else if (arg_is_set(cmd, replace_ARG)) {
+ lp->replace = 1;
+ _set_conv_type(lp, CONV_REPLACE);
}
- if (arg_is_set(cmd, cache_ARG))
+ if (arg_is_set(cmd, cache_ARG)) {
lp->cache = 1;
+ _set_conv_type(lp, CONV_CACHE);
+ }
if (!strcmp(lp->type_str, SEG_TYPE_NAME_CACHE))
lp->cache = 1;
@@ -541,8 +592,10 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
lp->type_str = SEG_TYPE_NAME_CACHE;
}
- if (arg_is_set(cmd, thin_ARG))
+ if (arg_is_set(cmd, thin_ARG)) {
lp->thin = 1;
+ _set_conv_type(lp, CONV_THIN);
+ }
if (!strcmp(lp->type_str, SEG_TYPE_NAME_THIN))
lp->thin = 1;
@@ -554,6 +607,9 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
lp->type_str = SEG_TYPE_NAME_THIN;
}
+ if (arg_is_set(cmd, trackchanges_ARG))
+ lp->track_changes = 1;
+
if (!_read_pool_params(cmd, &argc, &argv, lp))
return_0;
@@ -563,6 +619,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
return 0;
}
lp->snapshot = 1;
+ _set_conv_type(lp, CONV_SNAPSHOT);
}
if (lp->split) {
@@ -588,6 +645,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
lp->lv_split_name = arg_str_value(cmd, name_ARG, NULL);
lp->keep_mimages = 1;
+ _set_conv_type(lp, CONV_SPLIT_MIRRORS);
lp->mirrors = arg_uint_value(cmd, splitmirrors_ARG, 0);
lp->mirrors_sign = SIGN_MINUS;
} else {
@@ -642,6 +700,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
return 0;
}
+
/*
* Final checking of each case:
* lp->merge
@@ -658,23 +717,18 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
* --type mirror|raid lp->mirrorlog lp->corelog
* --type raid0|striped
*/
- if (lp->merge) /* Snapshot or mirror merge */
- ;
- else if (lp->splitsnapshot) /* Destroy snapshot retaining cow as separate LV */
- ;
- else if (lp->splitcache)
- ;
- else if (lp->split)
- ;
- else if (lp->uncache)
- ;
- else if (lp->cache)
- ;
- else if (lp->thin)
- ;
- else if (lp->keep_mimages) /* --splitmirrors */
- ;
- else if (lp->snapshot) { /* Snapshot creation from pre-existing cow */
+ switch(lp->conv_type) {
+ case CONV_MERGE: /* Snapshot or mirror merge */
+ case CONV_SPLIT:
+ case CONV_SPLIT_CACHE:
+ case CONV_SPLIT_MIRRORS:
+ case CONV_SPLIT_SNAPSHOT: /* Destroy snapshot retaining cow as separate LV */
+ case CONV_CACHE:
+ case CONV_UNCACHE:
+ case CONV_THIN:
+ case CONV_REPAIR:
+ break;
+ case CONV_SNAPSHOT: /* Snapshot creation from pre-existing cow */
if (!argc) {
log_error("Please provide logical volume path for snapshot origin.");
return 0;
@@ -708,8 +762,9 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
log_verbose("Setting chunk size to %s.", display_size(cmd, lp->chunk_size));
lp->type_str = SEG_TYPE_NAME_SNAPSHOT;
+ break;
- } else if (lp->replace) { /* RAID device replacement */
+ case CONV_REPLACE: /* RAID device replacement */
lp->replace_pv_count = arg_count(cmd, replace_ARG);
lp->replace_pvs = dm_pool_alloc(cmd->mem, sizeof(char *) * lp->replace_pv_count);
if (!lp->replace_pvs)
@@ -729,72 +784,73 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
tmp_str)))
return_0;
}
- } else if (lp->repair)
- ;
- else if (_mirror_or_raid_type_requested(cmd, lp->type_str) ||
- lp->mirrorlog || lp->corelog) { /* Mirrors (and some RAID functions) */
- if (arg_is_set(cmd, chunksize_ARG)) {
- log_error("--chunksize is only available with snapshots or pools.");
- return 0;
- }
+ break;
- if (arg_is_set(cmd, zero_ARG)) {
- log_error("--zero is only available with snapshots or thin pools.");
- return 0;
- }
-
- /*
- * --regionsize is only valid if converting an LV into a mirror.
- * Checked when we know the state of the LV being converted.
- */
- if (arg_is_set(cmd, regionsize_ARG)) {
- if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) ==
- SIGN_MINUS) {
- log_error("Negative regionsize is invalid.");
+ case CONV_OTHER:
+ if (_mirror_or_raid_type_requested(cmd, lp->type_str) ||
+ lp->mirrorlog || lp->corelog) { /* Mirrors (and some RAID functions) */
+ if (arg_is_set(cmd, chunksize_ARG)) {
+ log_error("--chunksize is only available with snapshots or pools.");
return 0;
}
- lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
- } else {
- region_size = get_default_region_size(cmd);
- if (region_size < 0) {
- log_error("Negative regionsize in "
- "configuration file is invalid.");
+
+ if (arg_is_set(cmd, zero_ARG)) {
+ log_error("--zero is only available with snapshots or thin pools.");
return 0;
}
- lp->region_size = region_size;
- }
- if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
- log_error("Region size (%" PRIu32 ") must be "
- "a multiple of machine memory "
- "page size (%d).",
- lp->region_size, pagesize >> SECTOR_SHIFT);
- return 0;
- }
+ /*
+ * --regionsize is only valid if converting an LV into a mirror.
+ * Checked when we know the state of the LV being converted.
+ */
+ if (arg_is_set(cmd, regionsize_ARG)) {
+ if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) ==
+ SIGN_MINUS) {
+ log_error("Negative regionsize is invalid.");
+ return 0;
+ }
+ lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
+ } else {
+ region_size = get_default_region_size(cmd);
+ if (region_size < 0) {
+ log_error("Negative regionsize in "
+ "configuration file is invalid.");
+ return 0;
+ }
+ lp->region_size = region_size;
+ }
- if (!is_power_of_2(lp->region_size)) {
- log_error("Region size (%" PRIu32
- ") must be a power of 2.", lp->region_size);
- return 0;
- }
+ if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
+ log_error("Region size (%" PRIu32 ") must be "
+ "a multiple of machine memory "
+ "page size (%d).",
+ lp->region_size, pagesize >> SECTOR_SHIFT);
+ return 0;
+ }
- if (!lp->region_size) {
- log_error("Non-zero region size must be supplied.");
- return 0;
- }
+ if (!is_power_of_2(lp->region_size)) {
+ log_error("Region size (%" PRIu32
+ ") must be a power of 2.", lp->region_size);
+ return 0;
+ }
- /* FIXME man page says in one place that --type and --mirrors can't be mixed */
- if (lp->mirrors_supplied && !lp->mirrors)
- /* down-converting to linear/stripe? */
- lp->type_str = SEG_TYPE_NAME_STRIPED;
+ if (!lp->region_size) {
+ log_error("Non-zero region size must be supplied.");
+ return 0;
+ }
- } else if (_raid0_type_requested(lp->type_str) || _striped_type_requested(lp->type_str)) { /* striped or linear or raid0 */
- if (arg_from_list_is_set(cmd, "cannot be used with --type raid0 or --type striped or --type linear",
- chunksize_ARG, corelog_ARG, mirrors_ARG, mirrorlog_ARG, regionsize_ARG, zero_ARG,
- -1))
- return_0;
+ /* FIXME man page says in one place that --type and --mirrors can't be mixed */
+ if (lp->mirrors_supplied && !lp->mirrors)
+ /* down-converting to linear/stripe? */
+ lp->type_str = SEG_TYPE_NAME_STRIPED;
- } /* else segtype will default to current type */
+ } else if (_raid0_type_requested(lp->type_str) || _striped_type_requested(lp->type_str)) { /* striped or linear or raid0 */
+ if (arg_from_list_is_set(cmd, "cannot be used with --type raid0 or --type striped or --type linear",
+ chunksize_ARG, corelog_ARG, mirrors_ARG, mirrorlog_ARG, regionsize_ARG, zero_ARG,
+ -1))
+ return_0;
+ } /* else segtype will default to current type */
+ }
lp->force = arg_count(cmd, force_ARG);
lp->yes = arg_count(cmd, yes_ARG);
@@ -4693,6 +4749,7 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
int poll_ret, ret;
struct convert_poll_id_list *idl;
struct lvconvert_params lp = {
+ .conv_type = CONV_OTHER,
.target_attr = ~0,
.idls = DM_LIST_HEAD_INIT(lp.idls),
};
6 years, 7 months
master - dmsetup: [v2] return 0 for [--]{version,help}
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b11f4f93d70d30...
Commit: b11f4f93d70d307b997290713607c0742c3ea29e
Parent: 0b1c796420610f015f65530ab68ade6d8119487d
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Nov 10 18:09:37 2016 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Nov 10 18:09:37 2016 +0100
dmsetup: [v2] return 0 for [--]{version,help}
Leverage 0b1c79642061 to cope with "dmsetup SubCommand --{help,version}"
and bail out directly when _report_init() fails.
Related: rhbz1393692
---
tools/dmsetup.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 371c0f8..e48f0a6 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -6798,7 +6798,7 @@ unknown:
if (_switches[COLS_ARG]) {
if (!_report_init(cmd, subcommand))
ret = 1;
- if (!_report)
+ if (ret || !_report)
goto_out;
}
@@ -6852,7 +6852,6 @@ doit:
}
} while (--_count);
- ret = 0;
out:
if (_report)
dm_report_free(_report);
@@ -6865,5 +6864,5 @@ out:
if (_initial_timestamp)
dm_timestamp_destroy(_initial_timestamp);
- return ret;
+ return (_switches[HELP_ARG] || _switches[VERSION_ARG]) ? 0 : ret;
}
6 years, 7 months