master - fix man page generation
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9f5e46965bd3e967de8...
Commit: 9f5e46965bd3e967de8c3b6741f2b7f178192a53
Parent: a4dbbefaff74b6507c82dc1b938b0312c2dda576
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jun 14 09:26:08 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jun 14 09:26:08 2019 -0500
fix man page generation
The man page generation for pvchange/lvchange/vgchange was
incorrect (leaving out some option listings) as a result of
commit e225bf5 "fix command definition for pvchange -a"
---
tools/command.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index 246d181..bdd18d6 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1292,7 +1292,7 @@ void factor_common_options(void)
if (strcmp(cmd->name, command_names[cn].name))
continue;
- if (cmd->ro_count)
+ if (cmd->ro_count || cmd->any_ro_count)
command_names[cn].variant_has_ro = 1;
if (cmd->rp_count)
command_names[cn].variant_has_rp = 1;
@@ -1301,7 +1301,7 @@ void factor_common_options(void)
if (cmd->op_count)
command_names[cn].variant_has_op = 1;
- for (ro = 0; ro < cmd->ro_count; ro++) {
+ for (ro = 0; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
command_names[cn].all_options[cmd->required_opt_args[ro].opt] = 1;
if ((cmd->required_opt_args[ro].opt == size_ARG) && !strncmp(cmd->name, "lv", 2))
4 years, 10 months
master - WHATS_NEW for recent changes
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a4dbbefaff74b6507c8...
Commit: a4dbbefaff74b6507c82dc1b938b0312c2dda576
Parent: 208a09745db480d77120d0cd83743732fc216918
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 13 17:44:14 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 13 17:44:14 2019 -0500
WHATS_NEW for recent changes
---
WHATS_NEW | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 81cfdd3..60e5128 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,12 @@
Version 2.03.05 -
================================
+ Fix command definition for pvchange -a.
+ Add vgck --updatemetadata command that will repair metadata problems.
+ Improve VG reading to work if one good copy of metadata is found.
+ Report/display/scan commands that read VGs will no longer write/repair.
+ Move metadata repairs from VG reading to VG writing.
+ Add config setting md_component_checks to control MD component checks.
+ Add end of device MD component checks when dev has no udev info.
Version 2.03.04 - 10th June 2019
================================
4 years, 10 months
master - tests: aux have_writecache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=208a09745db480d7712...
Commit: 208a09745db480d77120d0cd83743732fc216918
Parent: 7eaa3adedf4977352f93d8558dd0f1a0eb2c9921
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 13 11:36:18 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 13 11:36:18 2019 -0500
tests: aux have_writecache
function was never defined, causing writecache.sh to be skipped
---
test/lib/aux.sh | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 040c8f2..09ef9ed 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1478,6 +1478,14 @@ have_vdo() {
target_at_least dm-vdo "$@"
}
+have_writecache() {
+ lvm segtypes 2>/dev/null | grep -q writecache$ || {
+ echo "writecache is not built-in." >&2
+ return 1
+ }
+ target_at_least dm-writecache "$@"
+}
+
have_raid() {
target_at_least dm-raid "$@"
4 years, 10 months
master - vgchange: change debug message level
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7eaa3adedf4977352f9...
Commit: 7eaa3adedf4977352f93d8558dd0f1a0eb2c9921
Parent: 4bb7d3da0e7472804361f639c6da5e2798b4e0d2
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 11 16:14:07 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 11 16:14:07 2019 -0500
vgchange: change debug message level
A debug message was mistakely left visible.
---
tools/vgchange.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/vgchange.c b/tools/vgchange.c
index a662be3..d6d4f91 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -407,8 +407,8 @@ static int _vgchange_metadata_copies(struct cmd_context *cmd,
{
uint32_t mda_copies = arg_uint_value(cmd, vgmetadatacopies_ARG, DEFAULT_VGMETADATACOPIES);
- log_warn("vgchange_metadata_copies new %u vg_mda_copies %u D %u",
- mda_copies, vg_mda_copies(vg), DEFAULT_VGMETADATACOPIES);
+ log_debug("vgchange_metadata_copies new %u vg_mda_copies %u D %u",
+ mda_copies, vg_mda_copies(vg), DEFAULT_VGMETADATACOPIES);
if (mda_copies == vg_mda_copies(vg)) {
if (vg_mda_copies(vg) == VGMETADATACOPIES_UNMANAGED)
4 years, 10 months
master - lvmcache: remove wrapper around lvmcache_get_vgnameids
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4bb7d3da0e747280436...
Commit: 4bb7d3da0e7472804361f639c6da5e2798b4e0d2
Parent: 0f350ba890f02eb73d6cdebe29420a709e2b5ae6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 11 14:09:13 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 11 14:10:14 2019 -0500
lvmcache: remove wrapper around lvmcache_get_vgnameids
This was left over from when there was an lvmetad
version of the function.
---
lib/cache/lvmcache.c | 18 ++++++++++++++++--
lib/cache/lvmcache.h | 6 ++++--
lib/metadata/metadata-exported.h | 3 ---
lib/metadata/metadata.c | 22 ----------------------
tools/toollib.c | 6 +++---
tools/vgimportclone.c | 2 +-
6 files changed, 24 insertions(+), 33 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index e45764a..1d92e01 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -947,12 +947,26 @@ int lvmcache_label_scan(struct cmd_context *cmd)
return r;
}
-int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
- struct dm_list *vgnameids)
+int lvmcache_get_vgnameids(struct cmd_context *cmd,
+ struct dm_list *vgnameids,
+ const char *only_this_vgname,
+ int include_internal)
{
struct vgnameid_list *vgnl;
struct lvmcache_vginfo *vginfo;
+ if (only_this_vgname) {
+ if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
+ log_error("vgnameid_list allocation failed.");
+ return 0;
+ }
+
+ vgnl->vg_name = dm_pool_strdup(cmd->mem, only_this_vgname);
+ vgnl->vgid = NULL;
+ dm_list_add(vgnameids, &vgnl->list);
+ return 1;
+ }
+
dm_list_iterate_items(vginfo, &_vginfos) {
if (!include_internal && is_orphan_vg(vginfo->vgname))
continue;
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 22c2c1f..5b78d7a 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -103,8 +103,10 @@ struct device *lvmcache_device_from_pvid(struct cmd_context *cmd, const struct i
const char *lvmcache_vgname_from_info(struct lvmcache_info *info);
const struct format_type *lvmcache_fmt_from_info(struct lvmcache_info *info);
-int lvmcache_get_vgnameids(struct cmd_context *cmd, int include_internal,
- struct dm_list *vgnameids);
+int lvmcache_get_vgnameids(struct cmd_context *cmd,
+ struct dm_list *vgnameids,
+ const char *only_this_vgname,
+ int include_internal);
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted);
void lvmcache_commit_metadata(const char *vgname);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 10593a0..9029d3f 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -696,9 +696,6 @@ int unlink_lv_from_vg(struct logical_volume *lv);
void lv_set_visible(struct logical_volume *lv);
void lv_set_hidden(struct logical_volume *lv);
-int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
- const char *only_this_vgname, int include_internal);
-
int pv_write(struct cmd_context *cmd, struct physical_volume *pv, int allow_non_orphan);
int move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
const char *pv_name);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index aceac5a..039a7d6 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3566,28 +3566,6 @@ void set_pv_devices(struct format_instance *fid, struct volume_group *vg)
_set_pv_device(fid, vg, pvl->pv);
}
-int get_vgnameids(struct cmd_context *cmd, struct dm_list *vgnameids,
- const char *only_this_vgname, int include_internal)
-{
- struct vgnameid_list *vgnl;
-
- if (only_this_vgname) {
- if (!(vgnl = dm_pool_alloc(cmd->mem, sizeof(*vgnl)))) {
- log_error("vgnameid_list allocation failed.");
- return 0;
- }
-
- vgnl->vg_name = dm_pool_strdup(cmd->mem, only_this_vgname);
- vgnl->vgid = NULL;
- dm_list_add(vgnameids, &vgnl->list);
- return 1;
- }
-
- lvmcache_get_vgnameids(cmd, include_internal, vgnameids);
-
- return 1;
-}
-
int pv_write(struct cmd_context *cmd,
struct physical_volume *pv, int allow_non_orphan)
{
diff --git a/tools/toollib.c b/tools/toollib.c
index a3b5fea..506ad2d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2262,7 +2262,7 @@ int process_each_vg(struct cmd_context *cmd,
*/
log_very_verbose("Obtaining the complete list of VGs to process");
- if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, include_internal)) {
+ if (!lvmcache_get_vgnameids(cmd, &vgnameids_on_system, NULL, include_internal)) {
ret_max = ECMD_FAILED;
goto_out;
}
@@ -3807,7 +3807,7 @@ int process_each_lv(struct cmd_context *cmd,
*/
log_very_verbose("Obtaining the complete list of VGs before processing their LVs");
- if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) {
+ if (!lvmcache_get_vgnameids(cmd, &vgnameids_on_system, NULL, 0)) {
ret_max = ECMD_FAILED;
goto_out;
}
@@ -4479,7 +4479,7 @@ int process_each_pv(struct cmd_context *cmd,
if (!(read_flags & PROCESS_SKIP_SCAN))
lvmcache_label_scan(cmd);
- if (!get_vgnameids(cmd, &all_vgnameids, only_this_vgname, 1)) {
+ if (!lvmcache_get_vgnameids(cmd, &all_vgnameids, only_this_vgname, 1)) {
ret_max = ret;
goto_out;
}
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index f7b1c0b..a3af841 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -296,7 +296,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
vgname_count = 1;
}
- if (!get_vgnameids(cmd, &vgnameids_on_system, NULL, 0))
+ if (!lvmcache_get_vgnameids(cmd, &vgnameids_on_system, NULL, 0))
goto_out;
retry_name:
4 years, 10 months
master - remove unused trustcache option
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0f350ba890f02eb73d6...
Commit: 0f350ba890f02eb73d6cdebe29420a709e2b5ae6
Parent: c9203a6106c7f9d66d7872e5709f5e02d246c0e3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 11 11:42:49 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 11 11:42:49 2019 -0500
remove unused trustcache option
---
lib/misc/lvm-globals.c | 11 -----------
lib/misc/lvm-globals.h | 2 --
tools/args.h | 3 +--
tools/command-lines.in | 10 +++++-----
tools/lvmcmdline.c | 11 -----------
5 files changed, 6 insertions(+), 31 deletions(-)
diff --git a/lib/misc/lvm-globals.c b/lib/misc/lvm-globals.c
index 6d3bf02..eb99cf5 100644
--- a/lib/misc/lvm-globals.c
+++ b/lib/misc/lvm-globals.c
@@ -31,7 +31,6 @@ static int _fwraid_filtering = 0;
static int _pvmove = 0;
static int _obtain_device_list_from_udev = DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV;
static enum dev_ext_e _external_device_info_source = DEV_EXT_NONE;
-static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
static int _debug_level = 0;
static int _debug_classes_logged = 0;
static int _security_level = SECURITY_LEVEL;
@@ -107,11 +106,6 @@ void init_external_device_info_source(enum dev_ext_e src)
_external_device_info_source = src;
}
-void init_trust_cache(int trustcache)
-{
- _trust_cache = trustcache;
-}
-
void init_security_level(int level)
{
_security_level = level;
@@ -285,11 +279,6 @@ enum dev_ext_e external_device_info_source(void)
return _external_device_info_source;
}
-int trust_cache(void)
-{
- return _trust_cache;
-}
-
int background_polling(void)
{
return _background_polling;
diff --git a/lib/misc/lvm-globals.h b/lib/misc/lvm-globals.h
index 944b822..921ae7e 100644
--- a/lib/misc/lvm-globals.h
+++ b/lib/misc/lvm-globals.h
@@ -32,7 +32,6 @@ void init_fwraid_filtering(int level);
void init_pvmove(int level);
void init_external_device_info_source(enum dev_ext_e src);
void init_obtain_device_list_from_udev(int device_list_from_udev);
-void init_trust_cache(int trustcache);
void init_debug(int level);
void init_debug_classes_logged(int classes);
void init_cmd_name(int status);
@@ -65,7 +64,6 @@ int fwraid_filtering(void);
int pvmove_mode(void);
int obtain_device_list_from_udev(void);
enum dev_ext_e external_device_info_source(void);
-int trust_cache(void);
int verbose_level(void);
int silent_mode(void);
int debug_level(void);
diff --git a/tools/args.h b/tools/args.h
index e972c7d..bd07aa3 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -713,9 +713,8 @@ arg(trackchanges_ARG, '\0', "trackchanges", 0, 0, 0,
"merging the split image (see --mergemirrors) or permanently splitting\n"
"the image (see --splitmirrors with --name.\n")
-/* TODO: hide this? */
arg(trustcache_ARG, '\0', "trustcache", 0, 0, 0,
- "Avoids certain device scanning during command processing. Do not use.\n")
+ "No longer used.\n")
arg(type_ARG, '\0', "type", segtype_VAL, 0, 0,
"The LV type, also known as \"segment type\" or \"segtype\".\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index c9d4fd6..73a1e64 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -198,7 +198,7 @@ OO_REPORT: --aligned, --all, --binary, --configreport ConfigReport, --foreign,
--nameprefixes, --noheadings, --nosuffix,
--options String, --readonly, --reportformat ReportFmt, --rows,
--select String, --separator String, --shared, --sort String,
---trustcache, --unbuffered, --units Units, --unquoted
+--unbuffered, --units Units, --unquoted
#
# options for config, dumpconfig, lvmconfig
@@ -1384,7 +1384,7 @@ DESC: Resize a pool metadata SubLV by a specified size.
lvs
OO: --history, --segments, OO_REPORT
OP: VG|LV|Tag ...
-IO: --partial, --ignoreskippedcluster
+IO: --partial, --ignoreskippedcluster, --trustcache
ID: lvs_general
---
@@ -1486,7 +1486,7 @@ ID: pvremove_general
pvs
OO: --segments, OO_REPORT
OP: PV|Tag ...
-IO: --partial, --ignoreskippedcluster
+IO: --partial, --ignoreskippedcluster, --trustcache
ID: pvs_general
---
@@ -1752,7 +1752,7 @@ DESC: Rename a VG by specifying the VG UUID.
vgs
OO: OO_REPORT
OP: VG|Tag ...
-IO: --partial, --ignoreskippedcluster
+IO: --partial, --ignoreskippedcluster, --trustcache
ID: vgs_general
---
@@ -1807,7 +1807,7 @@ ID: devtypes_general
fullreport
OO: OO_REPORT
OP: VG ...
-IO: --partial, --ignoreskippedcluster
+IO: --partial, --ignoreskippedcluster, --trustcache
ID: fullreport_general
lastlog
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 922c52d..3fec702 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2396,17 +2396,6 @@ static int _get_current_settings(struct cmd_context *cmd)
if (arg_is_set(cmd, binary_ARG))
cmd->report_binary_values_as_numeric = 1;
- if (arg_is_set(cmd, trustcache_ARG)) {
- if (arg_is_set(cmd, all_ARG)) {
- log_error("--trustcache is incompatible with --all");
- return EINVALID_CMD_LINE;
- }
- init_trust_cache(1);
- log_warn("WARNING: Cache file of PVs will be trusted. "
- "New devices holding PVs may get ignored.");
- } else
- init_trust_cache(0);
-
if (arg_is_set(cmd, noudevsync_ARG))
cmd->current_settings.udev_sync = 0;
4 years, 10 months
master - tests: correct checked target name
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c9203a6106c7f9d66d7...
Commit: c9203a6106c7f9d66d7872e5709f5e02d246c0e3
Parent: e225bf59ffdad0de1bb976ffdb65d77979cb5381
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 11 16:40:44 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 11 16:43:14 2019 +0200
tests: correct checked target name
So when the target name happened to be a suffix of another one,
the grep was filtering incorrect line
(i.e. dm-cache && dm-writecache) - so do a line head matching.
---
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 b178ab7..040c8f2 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -1421,7 +1421,7 @@ target_at_least() {
fi
local version
- version=$(dmsetup targets 2>/dev/null | grep "${1##dm-} " 2>/dev/null)
+ version=$(dmsetup targets 2>/dev/null | grep "^${1##dm-} " 2>/dev/null)
version=${version##* v}
version_at_least "$version" "${@:2}" || {
4 years, 10 months
master - fix command definition for pvchange -a
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e225bf59ffdad0de1bb...
Commit: e225bf59ffdad0de1bb976ffdb65d77979cb5381
Parent: b7850faba72a50e49783a3b01e6833fc1a99873b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 10 11:35:26 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 10 13:43:20 2019 -0500
fix command definition for pvchange -a
The -a was being included in the set of "one or more"
options instead of an actual required option. Even
though the cmd def was not implementing the restrictions
correctly, the command internally was.
Adjust the cmd def code which did not support a command
with some real required options and a set of "one or more"
options.
---
tools/command-lines.in | 2 +-
tools/command.c | 93 ++++++++++++++++++++++++++++++++++++++---------
tools/command.h | 12 ++++++-
tools/lvchange.c | 4 +-
tools/lvmcmdline.c | 30 ++++++++--------
5 files changed, 104 insertions(+), 37 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 4601239..c9d4fd6 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1404,7 +1404,7 @@ OO_PVCHANGE: --autobackup Bool, --force, --reportformat ReportFmt, --uuid
OO_PVCHANGE_META: --allocatable Bool, --addtag Tag, --deltag Tag,
--uuid, --metadataignore Bool
-pvchange OO_PVCHANGE_META --all
+pvchange --all OO_PVCHANGE_META
OO: OO_PVCHANGE
IO: --ignoreskippedcluster
ID: pvchange_properties_all
diff --git a/tools/command.c b/tools/command.c
index bf2879f..246d181 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1070,7 +1070,7 @@ static void _add_required_opt_line(struct cmd_context *cmdtool, struct command *
* (This is the special case of vgchange/lvchange where one
* optional option is required, and others are then optional.)
* The set of options from OO_FOO are saved in required_opt_args,
- * and flag CMD_FLAG_ONE_REQUIRED_OPT is set on the cmd indicating
+ * and flag CMD_FLAG_ANY_REQUIRED_OPT is set on the cmd indicating
* this special case.
*/
@@ -1104,6 +1104,7 @@ static void _add_required_line(struct cmd_context *cmdtool, struct command *cmd,
int i;
int takes_arg;
int prev_was_opt = 0, prev_was_pos = 0;
+ int orig_ro_count = 0;
/* argv[0] is command name */
@@ -1128,10 +1129,20 @@ static void _add_required_line(struct cmd_context *cmdtool, struct command *cmd,
prev_was_pos = 1;
} else if (!strncmp(argv[i], "OO_", 3)) {
- /* one required_opt_arg is required, special case lv/vgchange */
- cmd->cmd_flags |= CMD_FLAG_ONE_REQUIRED_OPT;
+ /*
+ * the first ro_count entries in required_opt_arg required,
+ * after which one or more of the next any_ro_count entries
+ * in required_opt_arg are required. required_opt_arg
+ * has a total of ro_count+any_ro_count entries.
+ */
+ cmd->cmd_flags |= CMD_FLAG_ANY_REQUIRED_OPT;
+ orig_ro_count = cmd->ro_count;
+
_include_required_opt_args(cmdtool, cmd, argv[i]);
+ cmd->any_ro_count = cmd->ro_count - orig_ro_count;
+ cmd->ro_count = orig_ro_count;
+
} else if (prev_was_pos) {
/* set property for previous required_pos_arg */
_update_prev_pos_arg(cmd, argv[i], REQUIRED);
@@ -1773,7 +1784,7 @@ static void _print_usage_def(struct command *cmd, int opt_enum, struct arg_def *
void print_usage(struct command *cmd, int longhelp, int desc_first)
{
struct command_name *cname = _find_command_name(cmd->name);
- int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
+ int any_req = (cmd->cmd_flags & CMD_FLAG_ANY_REQUIRED_OPT) ? 1 : 0;
int include_extents = 0;
int ro, rp, oo, op, opt_enum, first;
@@ -1788,20 +1799,31 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
printf(" %s", cmd->name);
- if (onereq && cmd->ro_count) {
+ if (any_req) {
+ for (ro = 0; ro < cmd->ro_count; ro++) {
+ opt_enum = cmd->required_opt_args[ro].opt;
+
+ if (opt_names[opt_enum].short_opt)
+ printf(" -%c|%s", opt_names[opt_enum].short_opt, opt_names[opt_enum].long_opt);
+ else
+ printf(" %s", opt_names[opt_enum].long_opt);
+
+ if (cmd->required_opt_args[ro].def.val_bits) {
+ printf(" ");
+ _print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
+ }
+ }
+
/* one required option in a set */
first = 1;
/* options with short and long */
- for (ro = 0; ro < cmd->ro_count; ro++) {
+ for (ro = cmd->ro_count; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
opt_enum = cmd->required_opt_args[ro].opt;
if (!opt_names[opt_enum].short_opt)
continue;
- if ((opt_enum == size_ARG) && command_has_alternate_extents(cmd->name))
- include_extents = 1;
-
if (first)
printf("\n\t(");
else
@@ -1817,7 +1839,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
}
/* options with only long */
- for (ro = 0; ro < cmd->ro_count; ro++) {
+ for (ro = cmd->ro_count; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
opt_enum = cmd->required_opt_args[ro].opt;
if (opt_names[opt_enum].short_opt)
@@ -1843,7 +1865,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
printf(" )\n");
}
- if (!onereq && cmd->ro_count) {
+ if (!any_req && cmd->ro_count) {
for (ro = 0; ro < cmd->ro_count; ro++) {
opt_enum = cmd->required_opt_args[ro].opt;
@@ -1863,7 +1885,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
}
if (cmd->rp_count) {
- if (onereq)
+ if (any_req)
printf("\t");
for (rp = 0; rp < cmd->rp_count; rp++) {
if (cmd->required_pos_args[rp].def.val_bits) {
@@ -2403,7 +2425,7 @@ static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
static void _print_man_usage(char *lvmname, struct command *cmd)
{
struct command_name *cname;
- int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
+ int any_req = (cmd->cmd_flags & CMD_FLAG_ANY_REQUIRED_OPT) ? 1 : 0;
int sep, ro, rp, oo, op, opt_enum;
int need_ro_indent_end = 0;
int include_extents = 0;
@@ -2413,10 +2435,45 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
printf("\\fB%s\\fP", lvmname);
- if (!onereq)
+ if (!any_req)
goto ro_normal;
/*
+ * required options that follow command name, all required
+ */
+ if (cmd->ro_count) {
+ sep = 0;
+
+ for (ro = 0; ro < cmd->ro_count; ro++) {
+
+ /* avoid long line wrapping */
+ if ((cmd->ro_count > 2) && (sep == 2)) {
+ printf("\n.RS 5\n");
+ need_ro_indent_end = 1;
+ }
+
+ opt_enum = cmd->required_opt_args[ro].opt;
+
+ if ((opt_enum == size_ARG) && command_has_alternate_extents(cmd->name))
+ include_extents = 1;
+
+ if (opt_names[opt_enum].short_opt) {
+ printf(" \\fB-%c\\fP|\\fB%s\\fP",
+ opt_names[opt_enum].short_opt,
+ _man_long_opt_name(cmd->name, opt_enum));
+ } else
+ printf(" \\fB%s\\fP", opt_names[cmd->required_opt_args[ro].opt].long_opt);
+
+ if (cmd->required_opt_args[ro].def.val_bits) {
+ printf(" ");
+ _print_def_man(cname, opt_enum, &cmd->required_opt_args[ro].def, 1);
+ }
+
+ sep++;
+ }
+ }
+
+ /*
* one required option in a set, print as:
* ( -a|--a,
* -b|--b,
@@ -2427,7 +2484,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
* and the second loop prints those without short opts.
*/
- if (cmd->ro_count) {
+ if (cmd->any_ro_count) {
printf("\n");
printf(".RS 4\n");
printf("(");
@@ -2435,7 +2492,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
sep = 0;
/* print required options with a short opt */
- for (ro = 0; ro < cmd->ro_count; ro++) {
+ for (ro = cmd->ro_count; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
opt_enum = cmd->required_opt_args[ro].opt;
if (!opt_names[opt_enum].short_opt)
@@ -2467,7 +2524,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
}
/* print required options without a short opt */
- for (ro = 0; ro < cmd->ro_count; ro++) {
+ for (ro = cmd->ro_count; ro < cmd->ro_count + cmd->any_ro_count; ro++) {
opt_enum = cmd->required_opt_args[ro].opt;
if (opt_names[opt_enum].short_opt)
@@ -2497,7 +2554,7 @@ static void _print_man_usage(char *lvmname, struct command *cmd)
printf(".RE\n");
}
- /* print required position args on a new line after the onereq set */
+ /* print required position args on a new line after the any_req set */
if (cmd->rp_count) {
printf(".RS 4\n");
for (rp = 0; rp < cmd->rp_count; rp++) {
diff --git a/tools/command.h b/tools/command.h
index c2e3e6a..dae3d05 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -164,8 +164,16 @@ struct cmd_rule {
/*
* one or more from required_opt_args is required,
* then the rest are optional.
+ *
+ * CMD_FLAG_ANY_REQUIRED_OPT: for lvchange/vgchange special case.
+ * The first ro_count entries of required_opt_args must be met
+ * (ro_count may be 0.) After this, one or more options must be
+ * set from the remaining required_opt_args. So, the first
+ * ro_count options in required_opt_args must match, and after
+ * that one or more of the remaining options in required_opt_args
+ * must match.
*/
-#define CMD_FLAG_ONE_REQUIRED_OPT 1 /* lvchange/vgchage require one item from required_opt_args */
+#define CMD_FLAG_ANY_REQUIRED_OPT 1
#define CMD_FLAG_SECONDARY_SYNTAX 2 /* allows syntax variants to be suppressed in certain output */
#define CMD_FLAG_PREVIOUS_SYNTAX 4 /* allows syntax variants to not be advertised in output */
#define CMD_FLAG_PARSE_ERROR 8 /* error parsing command-lines.in def */
@@ -202,6 +210,8 @@ struct command {
struct cmd_rule rules[CMD_MAX_RULES];
+ int any_ro_count;
+
int ro_count;
int oo_count;
int rp_count;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index ad5abdd..7bdf997 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1084,7 +1084,7 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
*/
/* First group of options which allow for one metadata commit/update for the whole group */
- for (i = 0; i < cmd->command->ro_count; i++) {
+ for (i = 0; i < cmd->command->ro_count + cmd->command->any_ro_count; i++) {
opt_enum = cmd->command->required_opt_args[i].opt;
if (!arg_is_set(cmd, opt_enum))
@@ -1206,7 +1206,7 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
return_ECMD_FAILED;
/* Second group of options which need per option metadata commit+reload(s) */
- for (i = 0; i < cmd->command->ro_count; i++) {
+ for (i = 0; i < cmd->command->ro_count + cmd->command->any_ro_count; i++) {
opt_enum = cmd->command->required_opt_args[i].opt;
if (!arg_is_set(cmd, opt_enum))
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 94e527c..922c52d 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1192,7 +1192,7 @@ static void _set_valid_args_for_command_name(int ci)
if (strcmp(commands[i].name, command_names[ci].name))
continue;
- for (ro = 0; ro < commands[i].ro_count; ro++) {
+ for (ro = 0; ro < (commands[i].ro_count + commands[i].any_ro_count); ro++) {
opt_enum = commands[i].required_opt_args[ro].opt;
all_args[opt_enum] = 1;
@@ -1533,7 +1533,7 @@ static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp
* For each command[i], check how many required opt/pos args cmd matches.
* Save the command[i] that matches the most.
*
- * commands[i].cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT means
+ * commands[i].cmd_flags & CMD_FLAG_ANY_REQUIRED_OPT means
* any one item from commands[i].required_opt_args needs to be
* set to match.
*
@@ -1551,7 +1551,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
const char *name;
char opts_msg[MAX_OPTS_MSG];
char check_opts_msg[MAX_OPTS_MSG];
- int match_required, match_ro, match_rp, match_type, match_unused, mismatch_required;
+ int match_required, match_ro, match_rp, match_any_ro, match_type, match_unused, mismatch_required;
int best_i = 0, best_required = 0, best_type = 0, best_unused = 0;
int close_i = 0, close_ro = 0, close_type = 0;
int only_i = 0;
@@ -1600,6 +1600,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
match_required = 0; /* required parameters that match */
match_ro = 0; /* required opt_args that match */
match_rp = 0; /* required pos_args that match */
+ match_any_ro = 0;
match_type = 0; /* type arg matches */
match_unused = 0; /* options set that are not accepted by command */
mismatch_required = 0; /* required parameters that do not match */
@@ -1628,20 +1629,19 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
}
}
- /*
- * Special case where missing required_opt_arg's does not matter
- * if one required_opt_arg did match.
- */
- if (commands[i].cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) {
- if (match_ro) {
- /* one or more of the required_opt_args is used */
- mismatch_required = 0;
- } else {
- /* not even one of the required_opt_args is used */
- mismatch_required = 1;
+ for (ro = commands[i].ro_count; ro < commands[i].ro_count + commands[i].any_ro_count; ro++) {
+ if (_command_required_opt_matches(cmd, i, ro)) {
+ /* log_warn("match %d any ro opt %d", i, commands[i].required_opt_args[ro].opt); */
+ match_any_ro++;
}
}
+ if ((commands[i].cmd_flags & CMD_FLAG_ANY_REQUIRED_OPT) && !match_any_ro) {
+ /* not even one of the any ro is used */
+ /* log_warn("match %d not one from any", i); */
+ mismatch_required = 1;
+ }
+
/* match required_pos_args */
for (rp = 0; rp < commands[i].rp_count; rp++) {
@@ -1697,7 +1697,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
accepted = 0;
/* NB in some cases required_opt_args are optional */
- for (j = 0; j < commands[i].ro_count; j++) {
+ for (j = 0; j < commands[i].ro_count + commands[i].any_ro_count; j++) {
if (commands[i].required_opt_args[j].opt == opt_enum) {
accepted = 1;
break;
4 years, 10 months
master - locking: fix repeated convert to ex
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b7850faba72a50e4978...
Commit: b7850faba72a50e49783a3b01e6833fc1a99873b
Parent: 49b884656725a39a33a5e27dd6377443e7e177e4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 10 12:04:49 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 10 13:37:03 2019 -0500
locking: fix repeated convert to ex
Some uncommon commands like pvchange -a -u may
call convert to ex multiple times.
---
lib/locking/locking.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index c3ea536..3058a8b 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -384,6 +384,10 @@ int lockf_global(struct cmd_context *cmd, const char *mode)
int lockf_global_convert(struct cmd_context *cmd, const char *mode)
{
+ /* some uncommon cases like pvchange -a can call this multiple times */
+ if (cmd->lockf_global_ex && !strcmp(mode, "ex"))
+ return 1;
+
return _lockf_global(cmd, mode, 1);
}
4 years, 10 months
master - lvmcache: remove unused function
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=49b884656725a39a33a...
Commit: 49b884656725a39a33a5e27dd6377443e7e177e4
Parent: 550536474f2b2ad3ac58f1f91aa2325022df53b9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jun 7 14:39:32 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 10 10:38:32 2019 -0500
lvmcache: remove unused function
Drop lvmcache_fmt_from_vgname(), the way it was called made
it identical to the existing lvmcache_vginfo_from_vgname().
---
lib/cache/lvmcache.c | 54 --------------------------------------------------
lib/cache/lvmcache.h | 1 -
tools/vgcreate.c | 4 +-
3 files changed, 2 insertions(+), 57 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 857a953..e45764a 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -278,60 +278,6 @@ struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname, const ch
return vginfo;
}
-const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd,
- const char *vgname, const char *vgid,
- unsigned revalidate_labels)
-{
- struct lvmcache_vginfo *vginfo;
- struct lvmcache_info *info;
- struct dm_list *devh, *tmp;
- struct dm_list devs;
- struct device_list *devl;
- char vgid_found[ID_LEN + 1] __attribute__((aligned(8)));
-
- if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid))) {
- stack;
- return NULL;
- }
-
- /*
- * If this function is called repeatedly, only the first one needs to revalidate.
- */
- if (!revalidate_labels)
- goto out;
-
- /*
- * This function is normally called before reading metadata so
- * we check cached labels here. Unfortunately vginfo is volatile.
- */
- dm_list_init(&devs);
- dm_list_iterate_items(info, &vginfo->infos) {
- if (!(devl = malloc(sizeof(*devl)))) {
- log_error("device_list element allocation failed");
- return NULL;
- }
- devl->dev = info->dev;
- dm_list_add(&devs, &devl->list);
- }
-
- memcpy(vgid_found, vginfo->vgid, sizeof(vgid_found));
-
- dm_list_iterate_safe(devh, tmp, &devs) {
- devl = dm_list_item(devh, struct device_list);
- label_read(devl->dev);
- dm_list_del(&devl->list);
- free(devl);
- }
-
- /* If vginfo changed, caller needs to rescan */
- if (!(vginfo = lvmcache_vginfo_from_vgname(vgname, vgid_found)) ||
- strncmp(vginfo->vgid, vgid_found, ID_LEN))
- return NULL;
-
-out:
- return vginfo->fmt;
-}
-
struct lvmcache_vginfo *lvmcache_vginfo_from_vgid(const char *vgid)
{
struct lvmcache_vginfo *vginfo;
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 379cc9d..22c2c1f 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -91,7 +91,6 @@ void lvmcache_lock_vgname(const char *vgname, int read_only);
void lvmcache_unlock_vgname(const char *vgname);
/* Queries */
-const struct format_type *lvmcache_fmt_from_vgname(struct cmd_context *cmd, const char *vgname, const char *vgid, unsigned revalidate_labels);
int lvmcache_lookup_mda(struct lvmcache_vgsummary *vgsummary);
struct lvmcache_vginfo *lvmcache_vginfo_from_vgname(const char *vgname,
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 6640b8e..d594ec1 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -71,7 +71,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
* then do the initial label scan which reads all devices and
* populates lvmcache with any VG name it finds. If the VG name
* we want to use exists, then the label scan will find it,
- * and the fmt_from_vgname call (used to check if the name exists)
+ * and the vginfo_from_vgname call (used to check if the name exists)
* will return non-NULL.
*/
@@ -82,7 +82,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
lvmcache_label_scan(cmd);
- if (lvmcache_fmt_from_vgname(cmd, vp_new.vg_name, NULL, 0)) {
+ if (lvmcache_vginfo_from_vgname(vp_new.vg_name, NULL)) {
unlock_vg(cmd, NULL, vp_new.vg_name);
log_error("A volume group called %s already exists.", vp_new.vg_name);
return ECMD_FAILED;
4 years, 10 months