summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-07-24 12:29:19 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2015-07-24 15:00:07 +0200
commit2cba93e2828583d1065c031bd493bc2ec9d7c82c (patch)
tree602b6da25268d6b55aa6d4f9fbbaadd91dc638fa
parent54960dc29b8ae820420dfc753c854fce0e44d717 (diff)
downloadlvm2-dev-prajnoha-avoid-some-init-for-simple-commands.tar.gz
commands: add NO_METADATA_PROCESSING command flagdev-prajnoha-avoid-some-init-for-simple-commands
Mark commands that do not handle LVM metadata with the new NO_METADATA_PROCESSING flag: - lvmconfig (config, dumpconfig) - devtypes - formats - segtypes - systemid - tags - version Recognize this flag during command/context initialization and skip init for lvmetad, lvmpolld, lvmlockd and switch to using "no locking" (locking_type=0) for such commands.
-rw-r--r--lib/locking/locking.c5
-rw-r--r--tools/commands.h20
-rw-r--r--tools/lvmcmdline.c13
-rw-r--r--tools/tools.h2
4 files changed, 25 insertions, 15 deletions
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index c88a85b82..22e83d2b1 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -119,8 +119,9 @@ int init_locking(int type, struct cmd_context *cmd, int suppress_messages)
switch (type) {
case 0:
init_no_locking(&_locking, cmd, suppress_messages);
- log_warn("WARNING: Locking disabled. Be careful! "
- "This could corrupt your metadata.");
+ log_warn_suppress(suppress_messages,
+ "WARNING: Locking disabled. Be careful! "
+ "This could corrupt your metadata.");
return 1;
case 1:
diff --git a/tools/commands.h b/tools/commands.h
index 7f4b4e274..0ab578d4b 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -30,7 +30,7 @@ xx(e2fsadm,
xx(config,
"Display and manipulate configuration information",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"config\n"
"\t[-f|--file filename]\n"
"\t[--type {current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
@@ -60,7 +60,7 @@ xx(config,
xx(devtypes,
"Display recognised built-in block device types",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"devtypes\n"
"\t[--aligned]\n"
"\t[--binary]\n"
@@ -86,7 +86,7 @@ xx(devtypes,
xx(dumpconfig,
"Display and manipulate configuration information",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"dumpconfig\n"
"\t[-f|--file filename]\n"
"\t[--type {current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
@@ -116,12 +116,12 @@ xx(dumpconfig,
xx(formats,
"List available metadata formats",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"formats\n")
xx(help,
"Display help for commands",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"help <command>\n")
/*********
@@ -491,7 +491,7 @@ xx(lvmchange,
xx(lvmconfig,
"Display and manipulate configuration information",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"lvmconfig\n"
"\t[-f|--file filename]\n"
"\t[--type {current|default|diff|full|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
@@ -979,17 +979,17 @@ xx(pvscan,
xx(segtypes,
"List available segment types",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"segtypes\n")
xx(systemid,
"Display the system ID, if any, currently set on this host",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"systemid\n")
xx(tags,
"List tags defined on this host",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"tags\n")
xx(vgcfgbackup,
@@ -1409,5 +1409,5 @@ xx(vgsplit,
xx(version,
"Display software and driver version information",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | NO_METADATA_PROCESSING,
"version\n")
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 7fb52a199..9844411d6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1463,6 +1463,11 @@ static int _init_lvmlockd(struct cmd_context *cmd)
return 1;
}
+static int _cmd_no_meta_proc(struct cmd_context *cmd)
+{
+ return cmd->command->flags & NO_METADATA_PROCESSING;
+}
+
int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
struct dm_config_tree *config_string_cft;
@@ -1584,7 +1589,9 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
- if (arg_count(cmd, readonly_ARG)) {
+ if (_cmd_no_meta_proc(cmd))
+ locking_type = 0;
+ else if (arg_count(cmd, readonly_ARG)) {
if (find_config_tree_bool(cmd, global_use_lvmlockd_CFG, NULL)) {
/*
* FIXME: we could use locking_type 5 here if that didn't
@@ -1607,12 +1614,12 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
else
locking_type = -1;
- if (!init_locking(locking_type, cmd, arg_count(cmd, sysinit_ARG))) {
+ if (!init_locking(locking_type, cmd, _cmd_no_meta_proc(cmd) || arg_count(cmd, sysinit_ARG))) {
ret = ECMD_FAILED;
goto_out;
}
- if (!_init_lvmlockd(cmd)) {
+ if (!_cmd_no_meta_proc(cmd) && !_init_lvmlockd(cmd)) {
ret = ECMD_FAILED;
goto_out;
}
diff --git a/tools/tools.h b/tools/tools.h
index 5ee5786d2..4ed893fc4 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -103,6 +103,8 @@ struct arg_value_group_list {
#define ONE_VGNAME_ARG 0x00000010
/* Command needs a shared lock on a VG; it only reads the VG. */
#define LOCKD_VG_SH 0x00000020
+/* Command does not process any metadata. */
+#define NO_METADATA_PROCESSING 0x00000040
/* a register of the lvm commands */
struct command {