master - lvchange: reject writemostly/writebehind on raid1 during resync
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8ab072507706fb...
Commit: 8ab072507706fb826eee05eb369429ad0a7a406a
Parent: 3f4ecaf8c2b3146e81bcb32bd4f0321beee1192a
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Feb 23 15:09:29 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Feb 23 15:09:29 2017 +0100
lvchange: reject writemostly/writebehind on raid1 during resync
The MD kernel raid1 personality does no use any writemostly leg as the primary.
In case a previous linear LV holding data gets upconverted to
raid1 it becomes the primary leg of the new raid1 LV and a full
resynchronization is started to update the new legs.
No writemostly and/or writebehind setting may be allowed during
this initial, full synchronization period of this new raid1 LV
(using the lvchange(8) command), because that would change the
primary (i.e the previous linear LV) thus causing data loss.
lvchange has a bug not preventing this scenario.
Fix rejects setting writemostly and/or writebehind on resychronizing raid1 LVs.
Once we have status in the lvm2 metadata about the linear -> raid upconversion,
we may relax this constraint for other types of resynchronization
(e.g. for user requested "lvchange --resync ").
New lvchange-raid1-writemostly.sh test is added to the test suite.
Resolves: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855895
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/metadata/raid_manip.c | 8 +++++-
test/shell/lvchange-raid1-writemostly.sh | 41 ++++++++++++++++++++++++++++++
tools/lvchange.c | 15 +++++++++++
5 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 722b6f6..14109fb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Reject writemostly/writebehind in lvchange during resynchronization.
Deactivate active origin first before removal for improved workflow.
Fix regression of accepting options --type and -m with lvresize (2.02.158).
Add lvconvert --swapmetadata, new specific way to swap pool metadata LVs.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 573c09d..e4d2267 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1232,6 +1232,7 @@ uint32_t raid_rimage_extents(const struct segment_type *segtype,
uint32_t raid_ensure_min_region_size(const struct logical_volume *lv, uint64_t raid_size, uint32_t region_size);
int lv_raid_change_region_size(struct logical_volume *lv,
int yes, int force, uint32_t new_region_size);
+int lv_raid_in_sync(const struct logical_volume *lv);
/* -- metadata/raid_manip.c */
/* ++ metadata/cache_manip.c */
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index cdd7af8..b6215a2 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -238,7 +238,7 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r
* Returns: 1 if in-sync, 0 otherwise.
*/
#define _RAID_IN_SYNC_RETRIES 6
-static int _raid_in_sync(struct logical_volume *lv)
+static int _raid_in_sync(const struct logical_volume *lv)
{
int retries = _RAID_IN_SYNC_RETRIES;
dm_percent_t sync_percent;
@@ -269,6 +269,12 @@ static int _raid_in_sync(struct logical_volume *lv)
return (sync_percent == DM_PERCENT_100) ? 1 : 0;
}
+/* External interface to raid in-sync check */
+int lv_raid_in_sync(const struct logical_volume *lv)
+{
+ return _raid_in_sync(lv);
+}
+
/* Check if RaidLV @lv is synced or any raid legs of @lv are not synced */
static int _raid_devs_sync_healthy(struct logical_volume *lv)
{
diff --git a/test/shell/lvchange-raid1-writemostly.sh b/test/shell/lvchange-raid1-writemostly.sh
new file mode 100644
index 0000000..edf11bd
--- /dev/null
+++ b/test/shell/lvchange-raid1-writemostly.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+which mkfs.ext4 || skip
+aux have_raid 1 3 5 || skip
+
+aux prepare_vg 4
+
+for d in $dev1 $dev2 $dev3 $dev4
+do
+ aux delay_dev $d 1
+done
+
+#
+# Test writemostly prohibited on resyncrhonizing raid1
+#
+
+# Create 4-way striped LV
+lvcreate -aey --ty raid1 -m 3 -L 32M -n $lv1 $vg
+not lvchange -y --writemostly $dev1 $vg/$lv1
+check lv_field $vg/$lv1 segtype "raid1"
+check lv_field $vg/$lv1 stripes 4
+check lv_attr_bit health $vg/${lv1}_rimage_0 "-"
+aux wait_for_sync $vg $lv1
+lvchange -y --writemostly $dev1 $vg/$lv1
+check lv_attr_bit health $vg/${lv1}_rimage_0 "w"
+
+vgremove -ff $vg
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1c00b76..cba0496 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -739,6 +739,21 @@ static int _lvchange_writemostly(struct logical_volume *lv)
struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *raid_seg = first_seg(lv);
+ /*
+ * Prohibit writebehind and writebehind during synchronization.
+ *
+ * FIXME: we can do better once we can distingush between
+ * an initial sync after a linear -> raid1 upconversion
+ * and any later additions of legs, requested resyncs
+ * via lvchange or leg repairs/replacements.
+ */
+ if (!lv_raid_in_sync(lv)) {
+ log_error("Unable to change write%s on %s while it is not in-sync.",
+ arg_is_set(cmd, writemostly_ARG) ? "mostly" : "behind",
+ display_lvname(lv));
+ return 0;
+ }
+
if (arg_is_set(cmd, writebehind_ARG))
raid_seg->writebehind = arg_uint_value(cmd, writebehind_ARG, 0);
7 years, 2 months
master - man/help: improve the style of units indicator
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3f4ecaf8c2b314...
Commit: 3f4ecaf8c2b3146e81bcb32bd4f0321beee1192a
Parent: da634bfc8933619a70284077b499c82802f04ceb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 22 16:50:30 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 22 16:50:30 2017 -0600
man/help: improve the style of units indicator
We use --foo Number[k|Units] to indicate that
the default units of the number is k, but other
units listed below are also accepted.
Capitalize and underline Units so it is consistent
with other variables, and reference it at the end.
Technically, the k should be bold, but this
tends to make the text visually hard to read
because of the excessive highlights scattered
everywhere. So it's left normal text for now
(it's unlikely to confuse anyone.)
---
tools/command.c | 19 +++++++++----------
tools/vals.h | 12 ++++++------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 1a5fbb5..c3c1960 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1786,20 +1786,19 @@ static void print_val_man(const char *str)
int i;
/*
- * The suffix [k|unit] is just printed in plain text.
- * Doing bold k and underlined unit creates a lot of
- * visual "noise" that is choppy and hard to read.
+ * Doing bold k before underlined Unit creates a lot of
+ * visual "noise" that makes the text hard to read.
* The extra markup in this case doesn't add anything
* that isn't already obvious.
*/
- if (!strcmp(str, "Number[k|unit]")) {
- printf("\\fINumber\\fP[k|unit]");
+ if (!strcmp(str, "Number[k|Unit]")) {
+ printf("\\fINumber\\fP[k|\\fIUnit\\fP]");
return;
}
- if (!strcmp(str, "Number[m|unit]")) {
- printf("\\fINumber\\fP[m|unit]");
+ if (!strcmp(str, "Number[m|Unit]")) {
+ printf("\\fINumber\\fP[m|\\fIUnit\\fP]");
return;
}
@@ -2799,13 +2798,13 @@ void print_man_all_positions_desc(struct command_name *cname)
/* Nearly every command uses a number arg somewhere. */
printf("\n.HP\n");
- printf("\\fINumber\\fP");
+ printf("\\fINumber\\fP, \\fIUnit\\fP");
printf("\n");
printf(".br\n");
printf("Input units are always treated as base two values, regardless of unit\n"
"capitalization, e.g. 'k' and 'K' both refer to 1024.\n"
- "The default input unit is specified by letter, followed by |unit which\n"
- "represents other possible input units: bBsSkKmMgGtTpPeE.\n");
+ "The default input unit is specified by letter, followed by |\\fIUnit\\fP\n"
+ "which represents other possible input units: \\fBbBsSkKmMgGtTpPeE\\fP.\n");
printf("\n.HP\n");
printf("Environment");
diff --git a/tools/vals.h b/tools/vals.h
index 4dc3a61..3eb27e9 100644
--- a/tools/vals.h
+++ b/tools/vals.h
@@ -83,10 +83,10 @@
* could be "Number[bBsSkKmMgGtTpPeE]" (with implied |),
* but repeating this full specification produces cluttered
* output, and doesn't indicate which unit is the default.
- * "Number[units]" would be cleaner, as would a subset of
+ * "Number[Units]" would be cleaner, as would a subset of
* common units, e.g. "Number[kmg...]", but neither helps
- * with default. "Number[k|unit]" and "Number[m|unit]" show
- * the default, and "unit" indicates that other units
+ * with default. "Number[k|Unit]" and "Number[m|Unit]" show
+ * the default, and "Unit" indicates that other units
* are possible without listing them all. This also
* suggests using the preferred lower case letters, because
* --size and other option args treat upper/lower letters
@@ -115,9 +115,9 @@ val(activation_VAL, activation_arg, "Active", "y|n|ay")
val(cachemode_VAL, cachemode_arg, "CacheMode", "writethrough|writeback")
val(discards_VAL, discards_arg, "Discards", "passdown|nopassdown|ignore")
val(mirrorlog_VAL, mirrorlog_arg, "MirrorLog", "core|disk")
-val(sizekb_VAL, size_kb_arg, "SizeKB", "Number[k|unit]")
-val(sizemb_VAL, size_mb_arg, "SizeMB", "Number[m|unit]")
-val(regionsize_VAL, regionsize_arg, "RegionSize", "Number[m|unit]")
+val(sizekb_VAL, size_kb_arg, "SizeKB", "Number[k|Unit]")
+val(sizemb_VAL, size_mb_arg, "SizeMB", "Number[m|Unit]")
+val(regionsize_VAL, regionsize_arg, "RegionSize", "Number[m|Unit]")
val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%VG|%PVS|%FREE]")
val(permission_VAL, permission_arg, "Permission", "rw|r")
7 years, 2 months
master - man: indicate repeatable options
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da634bfc893361...
Commit: da634bfc8933619a70284077b499c82802f04ceb
Parent: 1eb1869626cbdacbeca037fbd81d01756f2faa76
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 22 16:38:54 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 22 16:38:54 2017 -0600
man: indicate repeatable options
Print ... after a repeatable option in the OPTIONS section.
An alternative would be to just mention in the text description
that the option is repeatable.
---
tools/command.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index d170eec..1a5fbb5 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -176,8 +176,8 @@ struct opt_name {
char _padding[7];
const char *long_opt; /* --foo */
int val_enum; /* xyz_VAL when --foo takes a val like "--foo xyz" */
- uint32_t unused1;
- uint32_t unused2;
+ uint32_t flags;
+ uint32_t prio;
const char *desc;
};
@@ -2617,7 +2617,6 @@ void print_man_all_options_list(struct command_name *cname)
/*
* All options used for a given command name, along with descriptions.
- * listed in order of:
*/
void print_man_all_options_desc(struct command_name *cname)
@@ -2656,6 +2655,9 @@ void print_man_all_options_desc(struct command_name *cname)
print_val_man(val_names[val_enum].usage);
}
+ if (opt_names[opt_enum].flags & ARG_COUNTABLE)
+ printf(" ...");
+
if (opt_names[opt_enum].desc) {
printf("\n");
printf(".br\n");
7 years, 2 months
master - man: improve writemostly PV arg
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1eb1869626cbda...
Commit: 1eb1869626cbdacbeca037fbd81d01756f2faa76
Parent: aa72caca5a19c67caffefc3f967af630b93ee2f0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 22 15:20:44 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 22 15:20:44 2017 -0600
man: improve writemostly PV arg
---
tools/command.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 0d40af6..d170eec 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1785,16 +1785,6 @@ static void print_val_man(const char *str)
int line_argc;
int i;
- if (!strcmp(str, "Number") ||
- !strcmp(str, "String") ||
- !strncmp(str, "VG", 2) ||
- !strncmp(str, "LV", 2) ||
- !strncmp(str, "PV", 2) ||
- !strcmp(str, "Tag")) {
- printf("\\fI%s\\fP", str);
- return;
- }
-
/*
* The suffix [k|unit] is just printed in plain text.
* Doing bold k and underlined unit creates a lot of
@@ -1823,6 +1813,11 @@ static void print_val_man(const char *str)
return;
}
+ if (!strcmp(str, "PV[:t|n|y]")) {
+ printf("\\fIPV\\fP[\\fB:t\\fP|\\fBn\\fP|\\fBy\\fP]");
+ return;
+ }
+
/*
* I think this bit is almost unnecessary with the specific
* ones checked above.
@@ -1841,6 +1836,16 @@ static void print_val_man(const char *str)
return;
}
+ if (!strcmp(str, "Number") ||
+ !strcmp(str, "String") ||
+ !strncmp(str, "VG", 2) ||
+ !strncmp(str, "LV", 2) ||
+ !strncmp(str, "PV", 2) ||
+ !strcmp(str, "Tag")) {
+ printf("\\fI%s\\fP", str);
+ return;
+ }
+
if (strchr(str, '|')) {
int len = strlen(str);
line = dm_strdup(str);
7 years, 2 months
master - tests: support zero_dev
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aa72caca5a19c6...
Commit: aa72caca5a19c67caffefc3f967af630b93ee2f0
Parent: f44e69f9fc2dc56d1fec02f6303b2a1101cdf47e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 22 15:16:20 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 22 15:40:59 2017 +0100
tests: support zero_dev
When the test would need to try to write some large amount of data
we can give it 'zero' segments - for obvious reason such written data
can't be verified but in some test cases it doesn't really matter.
Usage follows 'error_dev' style.
For now test suite is not supporting any combination of
error/delay/zero segments so only 1 type could be used per PV.
---
test/lib/aux.sh | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 5108a52..9779358 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -866,7 +866,7 @@ common_dev_() {
else
test -z "${offsets[@]}" && offsets="0:"
fi ;;
- error) offsets=${@:3}
+ error|zero) offsets=${@:3}
test -z "${offsets[@]}" && offsets="0:" ;;
esac
@@ -893,8 +893,8 @@ common_dev_() {
case "$tgtype" in
delay)
echo "$from $len delay $pvdev $(($pos + $offset)) $read_ms $pvdev $(($pos + $offset)) $write_ms" ;;
- error)
- echo "$from $len error" ;;
+ error|zero)
+ echo "$from $len $tgtype" ;;
esac
pos=$(($pos + $len))
done > "$name.devtable"
@@ -1013,12 +1013,23 @@ restore_from_devtable() {
#
# Convert device to device with errors
# Takes the list of pairs of error segment from:len
-# Original device table is replace with multiple lines
+# Combination with zero or delay is unsupported
+# Original device table is replaced with multiple lines
# i.e. error_dev "$dev1" 8:32 96:8
error_dev() {
common_dev_ error "$@"
}
+#
+# Convert existing device to a device with zero segments
+# Takes the list of pairs of zero segment from:len
+# Combination with error or delay is unsupported
+# Original device table is replaced with multiple lines
+# i.e. zero_dev "$dev1" 8:32 96:8
+zero_dev() {
+ common_dev_ zero "$@"
+}
+
backup_dev() {
local dev
7 years, 2 months
master - tests: not slowing work with metadata
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f44e69f9fc2dc5...
Commit: f44e69f9fc2dc56d1fec02f6303b2a1101cdf47e
Parent: 9712995edd60220cd525c51b6bab9f7bd3b38b5a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 21 13:06:00 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 22 15:40:28 2017 +0100
tests: not slowing work with metadata
Slows only data extents on a PV.
---
test/shell/pvmove-resume-multiseg.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/pvmove-resume-multiseg.sh b/test/shell/pvmove-resume-multiseg.sh
index a2fbf35..0f4e78d 100644
--- a/test/shell/pvmove-resume-multiseg.sh
+++ b/test/shell/pvmove-resume-multiseg.sh
@@ -33,9 +33,9 @@ test_pvmove_resume() {
# next LV on same VG and differetnt PV (we want to test 2 pvmoves per VG)
lvcreate -an -Zn -l30 -n $lv2 $vg "$dev3"
- aux delay_dev "$dev4" 0 250
+ aux delay_dev "$dev4" 0 250 $(get first_extent_sector "$dev4"):
test -e HAVE_DM_DELAY || { lvremove -f $vg; return 0; }
- aux delay_dev "$dev5" 0 250
+ aux delay_dev "$dev5" 0 250 $(get first_extent_sector "$dev5"):
pvmove -i5 "$dev1" "$dev4" &
PVMOVE=$!
7 years, 2 months
master - snapshot: improve removal of active origin volume
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9712995edd6022...
Commit: 9712995edd60220cd525c51b6bab9f7bd3b38b5a
Parent: 6716f5a2f46f034f24d01918cc1dc78cd7bac9be
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 22 15:12:54 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 22 15:35:04 2017 +0100
snapshot: improve removal of active origin volume
Previously when lvremove tried to remove 'active' origin,
it had been asking for every 'snapshot' LV separately
and doing individual single snapshot removals first.
To be faster it now deactivates origin before removal
all connected snapshots.
This avoids multiple reloads of dm table for origin volume
which were unnecessary as origin was meant to be removed as well.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 17 +++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b0768cd..722b6f6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Deactivate active origin first before removal for improved workflow.
Fix regression of accepting options --type and -m with lvresize (2.02.158).
Add lvconvert --swapmetadata, new specific way to swap pool metadata LVs.
Add lvconvert --startpoll, new specific way to start polling conversions.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d8f869d..78cc30e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6229,12 +6229,21 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
/* Remove snapshot LVs first */
if ((force == PROMPT) &&
/* Active snapshot already needs to confirm each active LV */
- !lv_is_active(lv) &&
- yes_no_prompt("Removing origin %s will also remove %u "
- "snapshots(s). Proceed? [y/n]: ",
- lv->name, lv->origin_count) == 'n')
+ (yes_no_prompt("Do you really want to remove%s "
+ "%sorigin logical volume %s with %u snapshot(s)? [y/n]: ",
+ lv_is_active(lv) ? " active" : "",
+ vg_is_clustered(lv->vg) ? "clustered " : "",
+ display_lvname(lv),
+ lv->origin_count) == 'n'))
goto no_remove;
+ if (!deactivate_lv(cmd, lv)) {
+ stack;
+ goto no_remove;
+ }
+ log_verbose("Removing origin logical volume %s with %u snapshots(s).",
+ display_lvname(lv), lv->origin_count);
+
dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
if (!lv_remove_with_dependencies(cmd, dm_list_struct_base(snh, struct lv_segment,
origin_list)->cow,
7 years, 2 months
master - WHATS_NEW: add entry
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6716f5a2f46f03...
Commit: 6716f5a2f46f034f24d01918cc1dc78cd7bac9be
Parent: 263050bc073e509f84de4c4da160887f412376fc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Feb 22 15:20:23 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Feb 22 15:20:52 2017 +0100
WHATS_NEW: add entry
---
WHATS_NEW | 1 +
tools/toollib.c | 1 -
2 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c8b7fdc..b0768cd 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Fix regression of accepting options --type and -m with lvresize (2.02.158).
Add lvconvert --swapmetadata, new specific way to swap pool metadata LVs.
Add lvconvert --startpoll, new specific way to start polling conversions.
Add lvconvert --mergethin, new specific way to merge thin snapshots.
diff --git a/tools/toollib.c b/tools/toollib.c
index 842f67c..0e45d80 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5755,4 +5755,3 @@ bad:
out:
return 0;
}
-
7 years, 2 months
master - man/help: enclose each option in brackets
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=263050bc073e50...
Commit: 263050bc073e509f84de4c4da160887f412376fc
Parent: c1ce371b59257a236115d2d6a3cb24af17faf55d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 21 14:59:52 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 21 14:59:52 2017 -0600
man/help: enclose each option in brackets
Placing [] around each individual option is the most
common style, and it improves the readability.
---
tools/command.c | 73 +++++++++++++++++++------------------------------------
1 files changed, 25 insertions(+), 48 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index ed38740..0d40af6 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1654,8 +1654,6 @@ void print_usage(struct command *cmd, int longhelp)
goto op_count;
if (cmd->oo_count) {
- first = 1;
-
for (oo = 0; oo < cmd->oo_count; oo++) {
opt_enum = cmd->optional_opt_args[oo].opt;
@@ -1680,24 +1678,18 @@ void print_usage(struct command *cmd, int longhelp)
if ((cname->variants > 1) && cname->common_options[opt_enum])
continue;
- if (first)
- printf("\n\t[");
- else
- printf("\n\t ");
- first = 0;
+ printf("\n\t[");
printf(" %s", opt_names[opt_enum].long_opt);
if (cmd->optional_opt_args[oo].def.val_bits) {
printf(" ");
print_usage_def(&cmd->optional_opt_args[oo].def);
}
+
+ printf(" ]");
}
- if (first)
- printf("\n\t[");
- else
- printf("\n\t ");
- printf(" COMMON_OPTIONS ]");
+ printf("\n\t[ COMMON_OPTIONS ]");
}
op_count:
@@ -1724,33 +1716,29 @@ void print_usage(struct command *cmd, int longhelp)
void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
{
- int oo, opt_enum, first = 1;
+ int oo, opt_enum;
printf(" Common options for lvm:");
for (oo = 0; oo < lvm_all.oo_count; oo++) {
opt_enum = lvm_all.optional_opt_args[oo].opt;
- if (first)
- printf("\n\t[");
- else
- printf("\n\t ");
- first = 0;
+ printf("\n\t[");
printf(" %s", opt_names[opt_enum].long_opt);
if (lvm_all.optional_opt_args[oo].def.val_bits) {
printf(" ");
print_usage_def(&lvm_all.optional_opt_args[oo].def);
}
+ printf(" ]");
}
- printf(" ]");
printf("\n\n");
}
void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
{
- int oo, opt_enum, first = 1;
+ int oo, opt_enum;
/*
* when there's more than one variant, options that
@@ -1769,11 +1757,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (is_lvm_all_opt(opt_enum))
continue;
- if (first)
- printf("\n\t[");
- else
- printf("\n\t ");
- first = 0;
+ printf("\n\t[");
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
@@ -1786,9 +1770,9 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
}
break;
}
+ printf(" ]");
}
- printf(" ]");
printf("\n\n");
}
@@ -2161,7 +2145,6 @@ void print_man_usage(char *lvmname, struct command *cmd)
if (cmd->oo_count) {
printf(".RS 4\n");
- printf("[");
/* print optional options with short opts */
@@ -2179,10 +2162,9 @@ void print_man_usage(char *lvmname, struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
- printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
man_long_opt_name(cmd->name, opt_enum));
@@ -2190,6 +2172,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
}
@@ -2209,11 +2192,10 @@ void print_man_usage(char *lvmname, struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
/* space alignment without short opt */
- printf(" ");
+ printf("[ ");
printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
@@ -2221,17 +2203,16 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
}
if (sep) {
printf("\n.br\n");
- printf(" ");
/* space alignment without short opt */
/* printf(" "); */
}
- printf(" COMMON_OPTIONS");
- printf(" ]\n");
+ printf("[ COMMON_OPTIONS ]\n");
printf(".RE\n");
printf(".br\n");
}
@@ -2290,7 +2271,6 @@ void print_man_usage_common_lvm(struct command *cmd)
sep = 0;
printf(".RS 4\n");
- printf("[");
/* print those with short opts */
for (i = 0; i < ARG_COUNT; i++) {
@@ -2304,14 +2284,13 @@ void print_man_usage_common_lvm(struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
continue;
- printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
man_long_opt_name(cmd->name, opt_enum));
@@ -2319,6 +2298,7 @@ void print_man_usage_common_lvm(struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
break;
}
@@ -2337,7 +2317,6 @@ void print_man_usage_common_lvm(struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
for (oo = 0; oo < cmd->oo_count; oo++) {
@@ -2345,7 +2324,7 @@ void print_man_usage_common_lvm(struct command *cmd)
continue;
/* space alignment without short opt */
- printf(" ");
+ printf("[ ");
printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
@@ -2353,13 +2332,13 @@ void print_man_usage_common_lvm(struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
break;
}
}
- printf(" ]\n");
- printf(".RE\n");
+ printf("\n.RE\n");
return;
}
@@ -2380,7 +2359,6 @@ void print_man_usage_common_cmd(struct command *cmd)
sep = 0;
printf(".RS 4\n");
- printf("[");
/* print those with short opts */
for (i = 0; i < ARG_COUNT; i++) {
@@ -2401,14 +2379,13 @@ void print_man_usage_common_cmd(struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
for (oo = 0; oo < cmd->oo_count; oo++) {
if (cmd->optional_opt_args[oo].opt != opt_enum)
continue;
- printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ printf("[ \\fB-%c\\fP|\\fB%s\\fP",
opt_names[opt_enum].short_opt,
man_long_opt_name(cmd->name, opt_enum));
@@ -2416,6 +2393,7 @@ void print_man_usage_common_cmd(struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
break;
}
@@ -2441,7 +2419,6 @@ void print_man_usage_common_cmd(struct command *cmd)
if (sep) {
printf("\n.br\n");
- printf(" ");
}
for (oo = 0; oo < cmd->oo_count; oo++) {
@@ -2449,7 +2426,7 @@ void print_man_usage_common_cmd(struct command *cmd)
continue;
/* space alignment without short opt */
- printf(" ");
+ printf("[ ");
printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
@@ -2457,13 +2434,13 @@ void print_man_usage_common_cmd(struct command *cmd)
printf(" ");
print_def_man(&cmd->optional_opt_args[oo].def, 1);
}
+ printf(" ]");
sep = 1;
break;
}
}
- printf(" ]\n");
- printf(".RE\n");
+ printf("\n.RE\n");
printf(".br\n");
printf("\n");
return;
7 years, 2 months
master - man/help: use separate common option lists
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c1ce371b59257a...
Commit: c1ce371b59257a236115d2d6a3cb24af17faf55d
Parent: b7ae57c6a6fd69d23cc8c180920ddca372914419
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 21 14:32:54 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 21 14:32:54 2017 -0600
man/help: use separate common option lists
There are two kinds of common options:
1. options common to all variants of a given command name
2. options common to all lvm commands
Previously, both kinds of common options were listed together
under "Common options". Now the first are printed under
"Common options for command" (when needed), and the second
are printed under "Common options for lvm" (always).
---
tools/command-lines.in | 14 ----
tools/command.c | 193 ++++++++++++++++++++++++++++++++++++++----------
tools/command.h | 3 +-
tools/lvmcmdline.c | 7 +-
4 files changed, 160 insertions(+), 57 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 606d2e7..348e7a4 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -191,20 +191,6 @@ OO_ALL: --commandprofile String, --config String, --debug,
--verbose, --version, --yes, --test
#
-# This list only applies to printing the usage text.
-# These common options are displayed once at the end of
-# a given command's usage. This is done to avoid excessive
-# repetition of common options, which may obscure the more
-# interesting and relevant parts of a common prototype.
-# This definition is *only* used when generating the command
-# usage strings, and is the basis for the division between
-# the "usage" and "usage_common" strings. This OO defn does
-# not relate to which optional opts are accepted by commands,
-# which is defined by the OO line.
-#
-OO_USAGE_COMMON: OO_ALL, --force, --noudevsync
-
-#
# options for pvs, lvs, vgs, fullreport
#
OO_REPORT: --aligned, --all, --binary, --configreport ConfigReport, --foreign,
diff --git a/tools/command.c b/tools/command.c
index e7596df..ed38740 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1506,12 +1506,7 @@ int define_commands(char *run_name)
return 0;
}
- /*
- * For usage.
- * Predefined string of options common to all commands
- * (for compact output)
- */
- include_optional_opt_args(&lvm_all, "OO_USAGE_COMMON");
+ include_optional_opt_args(&lvm_all, "OO_ALL");
return 1;
}
@@ -1665,12 +1660,23 @@ void print_usage(struct command *cmd, int longhelp)
opt_enum = cmd->optional_opt_args[oo].opt;
/*
- * Skip common opts in lvm_all and cname->common_options.
+ * Skip common lvm options in lvm_all which
+ * are printed at the end under "Common options for lvm"
+ * see print_common_options_lvm()
*/
if (is_lvm_all_opt(opt_enum))
continue;
+ /*
+ * When there is more than one variant,
+ * skip common command options from
+ * cname->common_options (options common
+ * to all variants), which are printed at
+ * the end under "Common options for command"
+ * see print_common_options_cmd()
+ */
+
if ((cname->variants > 1) && cname->common_options[opt_enum])
continue;
@@ -1716,11 +1722,35 @@ void print_usage(struct command *cmd, int longhelp)
}
-void print_usage_common(struct command_name *cname, struct command *cmd)
+void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
{
int oo, opt_enum, first = 1;
- printf(" Common options:");
+ printf(" Common options for lvm:");
+
+ for (oo = 0; oo < lvm_all.oo_count; oo++) {
+ opt_enum = lvm_all.optional_opt_args[oo].opt;
+
+ if (first)
+ printf("\n\t[");
+ else
+ printf("\n\t ");
+ first = 0;
+
+ printf(" %s", opt_names[opt_enum].long_opt);
+ if (lvm_all.optional_opt_args[oo].def.val_bits) {
+ printf(" ");
+ print_usage_def(&lvm_all.optional_opt_args[oo].def);
+ }
+ }
+
+ printf(" ]");
+ printf("\n\n");
+}
+
+void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
+{
+ int oo, opt_enum, first = 1;
/*
* when there's more than one variant, options that
@@ -1728,7 +1758,9 @@ void print_usage_common(struct command_name *cname, struct command *cmd)
*/
if (cname->variants < 2)
- goto all;
+ return;
+
+ printf(" Common options for command:");
for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
if (!cname->common_options[opt_enum])
@@ -1756,25 +1788,6 @@ void print_usage_common(struct command_name *cname, struct command *cmd)
}
}
- all:
- /* options that are common to all lvm commands */
-
- for (oo = 0; oo < lvm_all.oo_count; oo++) {
- opt_enum = lvm_all.optional_opt_args[oo].opt;
-
- if (first)
- printf("\n\t[");
- else
- printf("\n\t ");
- first = 0;
-
- printf(" %s", opt_names[opt_enum].long_opt);
- if (lvm_all.optional_opt_args[oo].def.val_bits) {
- printf(" ");
- print_usage_def(&lvm_all.optional_opt_args[oo].def);
- }
- }
-
printf(" ]");
printf("\n\n");
}
@@ -2215,7 +2228,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf("\n.br\n");
printf(" ");
/* space alignment without short opt */
- printf(" ");
+ /* printf(" "); */
}
printf(" COMMON_OPTIONS");
printf(" ]\n");
@@ -2263,7 +2276,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
* then options with only long names, alphabetically
*/
-void print_man_usage_common(struct command *cmd)
+void print_man_usage_common_lvm(struct command *cmd)
{
struct command_name *cname;
int i, sep, rp, oo, op, opt_enum;
@@ -2271,6 +2284,99 @@ void print_man_usage_common(struct command *cmd)
if (!(cname = find_command_name(cmd->name)))
return;
+ printf("Common options for lvm:\n");
+ printf(".\n");
+
+ sep = 0;
+
+ printf(".RS 4\n");
+ printf("[");
+
+ /* print those with short opts */
+ for (i = 0; i < ARG_COUNT; i++) {
+ opt_enum = opt_names_alpha[i]->opt_enum;
+
+ if (!opt_names[opt_enum].short_opt)
+ continue;
+
+ if (!is_lvm_all_opt(opt_enum))
+ continue;
+
+ if (sep) {
+ printf("\n.br\n");
+ printf(" ");
+ }
+
+ for (oo = 0; oo < cmd->oo_count; oo++) {
+ if (cmd->optional_opt_args[oo].opt != opt_enum)
+ continue;
+
+ printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ opt_names[opt_enum].short_opt,
+ man_long_opt_name(cmd->name, opt_enum));
+
+ if (cmd->optional_opt_args[oo].def.val_bits) {
+ printf(" ");
+ print_def_man(&cmd->optional_opt_args[oo].def, 1);
+ }
+ sep = 1;
+ break;
+ }
+
+ }
+
+ /* print those without short opts */
+ for (i = 0; i < ARG_COUNT; i++) {
+ opt_enum = opt_names_alpha[i]->opt_enum;
+
+ if (opt_names[opt_enum].short_opt)
+ continue;
+
+ if (!is_lvm_all_opt(opt_enum))
+ continue;
+
+ if (sep) {
+ printf("\n.br\n");
+ printf(" ");
+ }
+
+ for (oo = 0; oo < cmd->oo_count; oo++) {
+ if (cmd->optional_opt_args[oo].opt != opt_enum)
+ continue;
+
+ /* space alignment without short opt */
+ printf(" ");
+
+ printf(" \\fB%s\\fP", man_long_opt_name(cmd->name, opt_enum));
+
+ if (cmd->optional_opt_args[oo].def.val_bits) {
+ printf(" ");
+ print_def_man(&cmd->optional_opt_args[oo].def, 1);
+ }
+ sep = 1;
+ break;
+ }
+ }
+
+ printf(" ]\n");
+ printf(".RE\n");
+ return;
+}
+
+void print_man_usage_common_cmd(struct command *cmd)
+{
+ struct command_name *cname;
+ int i, sep, rp, oo, op, opt_enum;
+
+ if (!(cname = find_command_name(cmd->name)))
+ return;
+
+ if (cname->variants < 2)
+ return;
+
+ printf("Common options for command:\n");
+ printf(".\n");
+
sep = 0;
printf(".RS 4\n");
@@ -2286,7 +2392,11 @@ void print_man_usage_common(struct command *cmd)
if (!opt_names[opt_enum].short_opt)
continue;
- if ((cname->variants < 2) && !is_lvm_all_opt(opt_enum))
+ /* common cmd options only used with variants */
+ if (cname->variants < 2)
+ continue;
+
+ if (is_lvm_all_opt(opt_enum))
continue;
if (sep) {
@@ -2322,7 +2432,11 @@ void print_man_usage_common(struct command *cmd)
if (opt_names[opt_enum].short_opt)
continue;
- if ((cname->variants < 2) && !is_lvm_all_opt(opt_enum))
+ /* common cmd options only used with variants */
+ if (cname->variants < 2)
+ continue;
+
+ if (is_lvm_all_opt(opt_enum))
continue;
if (sep) {
@@ -2349,6 +2463,9 @@ void print_man_usage_common(struct command *cmd)
}
printf(" ]\n");
+ printf(".RE\n");
+ printf(".br\n");
+ printf("\n");
return;
}
@@ -2811,9 +2928,8 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
cmd = &commands[i];
if (prev_cmd && strcmp(prev_cmd->name, cmd->name)) {
- printf("Common options:\n");
- printf(".\n");
- print_man_usage_common(prev_cmd);
+ print_man_usage_common_cmd(prev_cmd);
+ print_man_usage_common_lvm(prev_cmd);
printf("\n");
printf(".SH OPTIONS\n");
@@ -2909,9 +3025,8 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
print_man_usage(lvmname, cmd);
if (i == (COMMAND_COUNT - 1)) {
- printf("Common options:\n");
- printf(".\n");
- print_man_usage_common(cmd);
+ print_man_usage_common_cmd(cmd);
+ print_man_usage_common_lvm(cmd);
printf("\n");
printf(".SH OPTIONS\n");
diff --git a/tools/command.h b/tools/command.h
index 51c4551..c5c801a 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -214,7 +214,8 @@ struct command {
int define_commands(char *run_name);
int command_id_to_enum(const char *str);
void print_usage(struct command *cmd, int longhelp);
-void print_usage_common(struct command_name *cname, struct command *cmd);
+void print_usage_common_cmd(struct command_name *cname, struct command *cmd);
+void print_usage_common_lvm(struct command_name *cname, struct command *cmd);
void factor_common_options(void);
#endif
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index ecb5802..02266c9 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1716,9 +1716,10 @@ static int _usage(const char *name, int longhelp)
}
/* Common options are printed once for all variants of a command name. */
- if (longhelp)
- print_usage_common(cname, cmd);
- else
+ if (longhelp) {
+ print_usage_common_cmd(cname, cmd);
+ print_usage_common_lvm(cname, cmd);
+ } else
log_print("Use --longhelp to show all options.");
return 1;
7 years, 2 months