master - lvchange: fix missing return value
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6fdc391baec1129d0c7...
Commit: 6fdc391baec1129d0c70913f116c04f928d083fa
Parent: 448bf9491a10715650569d5eeceb1026941d70ae
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Apr 5 10:08:01 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Apr 5 10:08:01 2017 -0500
lvchange: fix missing return value
A return value from lvchange_persistent_cmd() was missed
in commit 1c41898c07ad750820fb39770355fded8e9b030a
---
tools/lvchange.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 60a37a9..1778b52 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1618,6 +1618,8 @@ int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
} else if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG)) {
ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
}
+
+ return ret;
}
int lvchange(struct cmd_context *cmd, int argc, char **argv)
7 years
master - lvmconf: fix systemd unit existence check for lvmconf --services --startstopservices
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=448bf9491a107156505...
Commit: 448bf9491a10715650569d5eeceb1026941d70ae
Parent: afa844817a716f054f1e56612fa19522225797f4
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Apr 5 11:06:56 2017 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Apr 5 11:06:56 2017 +0200
lvmconf: fix systemd unit existence check for lvmconf --services --startstopservices
We have to unset the LoadState variable from previous use when we check
for systemd unit state. We use this variable to check if systemd services
are loaded or not and if it is loaded, we issue systemctl commands to
enable/disable and start/stop the service. We don't issue these commands
if the unit is not loaded to avoid error messages which may confuse users.
---
WHATS_NEW | 1 +
scripts/lvmconf.sh | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index abff1c8..57e01d4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.170 -
==================================
+ Fix systemd unit existence check for lvmconf --services --startstopservices.
Check and use PATH_MAX buffers when creating vgrename device paths.
Version 2.02.169 - 28th March 2017
diff --git a/scripts/lvmconf.sh b/scripts/lvmconf.sh
index a86036d..caf7fae 100644
--- a/scripts/lvmconf.sh
+++ b/scripts/lvmconf.sh
@@ -361,7 +361,8 @@ function set_service {
if [ "$type" = "systemd" ]; then
if [ "$action" = "activate" ]; then
for i in $@; do
- eval $($SYSTEMCTL_BIN show $i -p LoadState)
+ unset LoadState
+ eval $($SYSTEMCTL_BIN show $i -p LoadState 2>/dev/null)
test "$LoadState" = "loaded" || continue
$SYSTEMCTL_BIN enable $i
if [ "$START_STOP_SERVICES" = "1" ]; then
@@ -370,7 +371,8 @@ function set_service {
done
elif [ "$action" = "deactivate" ]; then
for i in $@; do
- eval $($SYSTEMCTL_BIN show $i -p LoadState)
+ unset LoadState
+ eval $($SYSTEMCTL_BIN show $i -p LoadState 2>/dev/null)
test "$LoadState" = "loaded" || continue
$SYSTEMCTL_BIN disable $i
if [ "$START_STOP_SERVICES" = "1" ]; then
7 years
master - commands: fix misspelling of option value
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=afa844817a716f054f1...
Commit: afa844817a716f054f1e56612fa19522225797f4
Parent: a7d4156a9aba1454249c945d07ebbfc366d86eaf
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 4 17:09:35 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 4 17:09:35 2017 -0500
commands: fix misspelling of option value
(The cmd def parser really needs to catch mistakes
like this as it did when it was external.)
---
tools/command-lines.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 20a9e79..5a3b520 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -297,7 +297,7 @@ ID: lvchange_poll
DESC: Start or stop processing an LV conversion.
lvchange --persistent y --minor Number LV
-OO: --major Number, --activate Activate, --poll Bool, --monitor Bool, OO_LVCHANGE
+OO: --major Number, --activate Active, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_persistent
DESC: Make the minor device number persistent for an LV.
RULE: all not LV_thinpool LV_cachepool
7 years
master - lvchange: fix --poll value when set from option
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a7d4156a9aba1454249...
Commit: a7d4156a9aba1454249c945d07ebbfc366d86eaf
Parent: 1c41898c07ad750820fb39770355fded8e9b030a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 4 15:32:08 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 4 17:04:45 2017 -0500
lvchange: fix --poll value when set from option
The actual value specified by the --poll y|n option was not
being used. The way the --poll value is used is hidden
through an indirection where the value is stored in a
global variable at the start of the command, and then the
value is read from there later. Setting the global
variable early in the command had been lost with the
cmd def changes.
---
tools/lvchange.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index d80095d..60a37a9 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -142,8 +142,9 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
}
/*
- * The --monitor y|n value is taken indirectly from dmeventd_monitor_mode()
- * whose value was set via init_dmeventd_monitor().
+ * The --monitor y|n value is read from dmeventd_monitor_mode(),
+ * which was set by the init_dmeventd_monitor() /
+ * get_activation_monitoring_mode() / arg_int_value(monitor_ARG).
*/
static int _lvchange_monitoring(struct cmd_context *cmd,
@@ -158,7 +159,10 @@ static int _lvchange_monitoring(struct cmd_context *cmd,
}
if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
- log_verbose("Monitoring LV %s", display_lvname(lv));
+ if (dmeventd_monitor_mode())
+ log_verbose("Monitoring LV %s", display_lvname(lv));
+ else
+ log_verbose("Unmonitoring LV %s", display_lvname(lv));
if (!monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
return_0;
}
@@ -167,8 +171,8 @@ static int _lvchange_monitoring(struct cmd_context *cmd,
}
/*
- * The --poll y|n value is taken indirectly from background_polling(),
- * whose value was set via init_background_polling().
+ * The --poll y|n value is read from background_polling(),
+ * which was set by init_background_polling(arg_int_value(poll_ARG)).
*/
static int _lvchange_background_polling(struct cmd_context *cmd,
@@ -1236,6 +1240,7 @@ int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv)
* A command def rule allows only some options when LV is partial,
* so handles_missing_pvs will only affect those.
*/
+ init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
NULL, &_lvchange_properties_check, &_lvchange_properties_single);
@@ -1340,6 +1345,7 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
+ init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
@@ -1406,6 +1412,7 @@ static int _lvchange_refresh_check(struct cmd_context *cmd,
int lvchange_refresh_cmd(struct cmd_context *cmd, int argc, char **argv)
{
+ init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
@@ -1555,6 +1562,7 @@ static int _lvchange_monitor_poll_check(struct cmd_context *cmd,
int lvchange_monitor_poll_cmd(struct cmd_context *cmd, int argc, char **argv)
{
+ init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_monitor_poll_check, &_lvchange_monitor_poll_single);
@@ -1593,6 +1601,7 @@ int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
+ init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
7 years
master - vgchange/lvchange: fix poll and monitor use
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1c41898c07ad750820f...
Commit: 1c41898c07ad750820fb39770355fded8e9b030a
Parent: a12b3af033d8086e0399e5433a3307ebb05b9d0b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 4 12:52:29 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 4 17:04:45 2017 -0500
vgchange/lvchange: fix poll and monitor use
Fill in some gaps where old versions of lvm allowed
--poll and --monitor in combination with other operations,
but those combinations had been lost since the cmd def work.
(The new cmd def code also added some combinations that
had been missed by the old code.)
Changes:
lvchange --activate: add poll and monitor options, and
add calls to them in implementation.
lvchange --refresh: add monitor option (poll already there),
and call to monitor in implementation.
lvchange <metadata ops>: add poll and monitor options, and
add calls to them in implementation.
vgchange <metadata ops>: add poll option (call to poll
already in implementation).
vgchange --refresh: remove monitor option (not used by code)
lvchange --persistent y: add poll and monitor options, and
add calls to them, and to activate
in the implementation. (Making it
match the main lvchange metadata
command.)
Summary of current usage:
lvchange --activate: monitor, poll
vgchange --activate: monitor, poll
lvchange --refresh: monitor, poll
vgchange --refresh: poll
lvchange --monitor: ok
lvchange --poll: ok
lvchange --monitor --poll: ok
vgchange --monitor: ok
vgchange --poll: ok
vgchange --monitor --poll: ok
lvchange <metadata ops>: monitor, poll
vgchange <metadata ops>: poll
---
tools/command-lines.in | 16 ++++++------
tools/lvchange.c | 62 +++++++++++++++++++++++++++++++++++++++++------
2 files changed, 62 insertions(+), 16 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index fe98cc6..20a9e79 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -234,7 +234,7 @@ OO_LVCHANGE_META: --addtag Tag, --deltag Tag,
# in combination with unrelated metadata changes.
lvchange OO_LVCHANGE_META VG|LV|Tag|Select ...
-OO: --activate Active, OO_LVCHANGE
+OO: --activate Active, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_properties
DESC: Change a general LV attribute.
DESC: For options listed in parentheses, any one is
@@ -275,18 +275,18 @@ DESC: Reconstruct data on specific PVs of a raid LV.
RULE: all not LV_raid0
lvchange --activate Active VG|LV|Tag|Select ...
-OO: --activationmode ActivationMode, --partial, --ignoreactivationskip,
---ignorelockingfailure, --sysinit, OO_LVCHANGE
+OO: --activationmode ActivationMode, --partial, --poll Bool, --monitor Bool,
+--ignoreactivationskip, --ignorelockingfailure, --sysinit, OO_LVCHANGE
ID: lvchange_activate
DESC: Activate or deactivate an LV.
lvchange --refresh VG|LV|Tag|Select ...
-OO: --activationmode ActivationMode, --partial, --poll Bool, OO_LVCHANGE
+OO: --activationmode ActivationMode, --partial, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_refresh
DESC: Reactivate an LV using the latest metadata.
lvchange --monitor Bool VG|LV|Tag|Select ...
-OO: --poll Bool, OO_LVCHANGE
+OO: OO_LVCHANGE
ID: lvchange_monitor
DESC: Start or stop monitoring an LV from dmeventd.
RULE: all not lv_is_pvmove
@@ -297,7 +297,7 @@ ID: lvchange_poll
DESC: Start or stop processing an LV conversion.
lvchange --persistent y --minor Number LV
-OO: --major Number, --activate Activate, OO_LVCHANGE
+OO: --major Number, --activate Activate, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_persistent
DESC: Make the minor device number persistent for an LV.
RULE: all not LV_thinpool LV_cachepool
@@ -1470,7 +1470,7 @@ OO_VGCHANGE_META: --addtag Tag, --deltag Tag,
--profile String, --detachprofile, --metadataprofile String
vgchange OO_VGCHANGE_META
-OO: OO_VGCHANGE
+OO: --poll Bool, OO_VGCHANGE
OP: VG|Tag|Select ...
ID: vgchange_properties
DESC: Change a general VG attribute.
@@ -1497,7 +1497,7 @@ ID: vgchange_activate
DESC: Activate or deactivate LVs.
vgchange --refresh
-OO: --sysinit, --ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE
+OO: --sysinit, --ignorelockingfailure, --poll Bool, OO_VGCHANGE
OP: VG|Tag|Select ...
ID: vgchange_refresh
DESC: Reactivate LVs using the latest metadata.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index c68ea98..d80095d 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -141,6 +141,11 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
return 1;
}
+/*
+ * The --monitor y|n value is taken indirectly from dmeventd_monitor_mode()
+ * whose value was set via init_dmeventd_monitor().
+ */
+
static int _lvchange_monitoring(struct cmd_context *cmd,
struct logical_volume *lv)
{
@@ -152,13 +157,20 @@ static int _lvchange_monitoring(struct cmd_context *cmd,
return 0;
}
- if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) &&
- !monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
- return_0;
+ if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
+ log_verbose("Monitoring LV %s", display_lvname(lv));
+ if (!monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
+ return_0;
+ }
return 1;
}
+/*
+ * The --poll y|n value is taken indirectly from background_polling(),
+ * whose value was set via init_background_polling().
+ */
+
static int _lvchange_background_polling(struct cmd_context *cmd,
struct logical_volume *lv)
{
@@ -169,8 +181,10 @@ static int _lvchange_background_polling(struct cmd_context *cmd,
return 0;
}
- if (background_polling())
+ if (background_polling()) {
+ log_verbose("Polling LV %s", display_lvname(lv));
lv_spawn_background_polling(cmd, lv);
+ }
return 1;
}
@@ -1246,6 +1260,9 @@ int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, activate_ARG)) {
log_warn("WARNING: Combining activation change with other commands is not advised.");
ret = lvchange_activate_cmd(cmd, argc, argv);
+
+ } else if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG)) {
+ ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
}
return ret;
@@ -1321,6 +1338,8 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
{
+ int ret;
+
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
@@ -1335,8 +1354,16 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
cmd->lockd_vg_enforce_sh = 1;
- return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
- NULL, &_lvchange_activate_check, &_lvchange_activate_single);
+ ret = process_each_lv(cmd, argc, argv, NULL, NULL, 0,
+ NULL, &_lvchange_activate_check, &_lvchange_activate_single);
+
+ if (ret != ECMD_PROCESSED)
+ return ret;
+
+ if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG))
+ ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
+
+ return ret;
}
static int _lvchange_refresh_single(struct cmd_context *cmd,
@@ -1356,6 +1383,10 @@ static int _lvchange_refresh_single(struct cmd_context *cmd,
!_lvchange_background_polling(cmd, lv))
return_ECMD_FAILED;
+ if (arg_is_set(cmd, monitor_ARG) &&
+ !_lvchange_monitoring(cmd, lv))
+ return_ECMD_FAILED;
+
return ECMD_PROCESSED;
}
@@ -1560,9 +1591,24 @@ static int _lvchange_persistent_check(struct cmd_context *cmd,
int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
{
+ int ret;
+
cmd->handles_missing_pvs = 1;
- return process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
- NULL, &_lvchange_persistent_check, &_lvchange_persistent_single);
+
+ ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
+ NULL, &_lvchange_persistent_check, &_lvchange_persistent_single);
+
+ if (ret != ECMD_PROCESSED)
+ return ret;
+
+ /* See comment in lvchange_properties about needing to allow these. */
+ if (arg_is_set(cmd, activate_ARG)) {
+ log_warn("WARNING: Combining activation change with other commands is not advised.");
+ ret = lvchange_activate_cmd(cmd, argc, argv);
+
+ } else if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG)) {
+ ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
+ }
}
int lvchange(struct cmd_context *cmd, int argc, char **argv)
7 years
master - lvchange: enhance avoiding multiple metadata updates/reloads/backups
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a12b3af033d8086e039...
Commit: a12b3af033d8086e0399e5433a3307ebb05b9d0b
Parent: e7ec9aab8a9a546e1b6ef7dc49e8012373691c3b
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Apr 4 23:53:55 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Apr 4 23:53:55 2017 +0200
lvchange: enhance avoiding multiple metadata updates/reloads/backups
Enhance commit 25b5915c9b5260c59d627bd1f6db8220bd4ad61e
to process options requiring immediate metadata commits
and reloads after those we can group together doing just
one commit and an optional reload for the whole group.
Backup metadata after processing options successfully.
Related: rhbz1437611
---
tools/lvchange.c | 247 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 179 insertions(+), 68 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 27b5184..c68ea98 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -19,21 +19,18 @@
/*
* Passed back from callee to request caller to
- * commit / update and reload / backup metadata.
+ * commit and optionally reload metadata.
*
* This allows for one metadata update per command run
* (unless mandatory interim ones in callee).
*/
-enum metadata_request {
- MR_COMMIT = 0x1,
- MR_UPDATE_RELOAD = 0x2,
- MR_BACKUP = 0x4
-};
+#define MR_COMMIT 0x1 /* Commit metadata, don't reload table(s) */
+#define MR_RELOAD 0x2 /* Commit metadata _and_ reload table(s) */
static int _vg_write_commit(const struct logical_volume *lv, const char *what)
{
- log_very_verbose("Updating %slogical volume %s on disk(s).",
- what ? : "", display_lvname(lv));
+ log_very_verbose("Updating %s%slogical volume %s on disk(s).",
+ what ? : "", what ? " " : "", display_lvname(lv));
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update %smetadata of %s on disk.",
what ? : "", display_lvname(lv));
@@ -45,7 +42,7 @@ static int _vg_write_commit(const struct logical_volume *lv, const char *what)
static int _lvchange_permission(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
uint32_t lv_access;
struct lvinfo info;
@@ -94,15 +91,15 @@ static int _lvchange_permission(struct cmd_context *cmd,
display_lvname(lv));
}
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
return 1;
}
static int _lvchange_pool_update(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
int update = 0;
unsigned val;
@@ -138,7 +135,9 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
if (!update)
return 0;
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
+
return 1;
}
@@ -464,7 +463,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
static int _lvchange_alloc(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
int want_contiguous = arg_int_value(cmd, contiguous_ARG, 0);
alloc_policy_t alloc = (alloc_policy_t)
@@ -488,15 +487,15 @@ static int _lvchange_alloc(struct cmd_context *cmd,
/* No need to suspend LV for this change */
- /* Request caller to commit+backuo metadata */
- *mr |= (MR_COMMIT | MR_BACKUP);
+ /* Request caller to commit metadata */
+ *mr |= MR_COMMIT;
return 1;
}
static int _lvchange_errorwhenfull(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
unsigned ewf = arg_int_value(cmd, errorwhenfull_ARG, 0);
@@ -511,15 +510,15 @@ static int _lvchange_errorwhenfull(struct cmd_context *cmd,
else
lv->status &= ~LV_ERROR_WHEN_FULL;
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
return 1;
}
static int _lvchange_readahead(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
unsigned read_ahead = 0;
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
@@ -558,15 +557,15 @@ static int _lvchange_readahead(struct cmd_context *cmd,
log_verbose("Setting read ahead to %u for %s.",
read_ahead, display_lvname(lv));
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
return 1;
}
static int _lvchange_persistent(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
enum activation_change activate = CHANGE_AN;
@@ -634,15 +633,12 @@ static int _lvchange_persistent(struct cmd_context *cmd,
}
}
- /* Request caller to backup metadata */
- *mr |= MR_BACKUP;
-
return 1;
}
static int _lvchange_cache(struct cmd_context *cmd,
struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
cache_metadata_format_t format;
cache_mode_t mode;
@@ -677,8 +673,8 @@ static int _lvchange_cache(struct cmd_context *cmd,
!cache_set_policy(first_seg(lv), name, settings))
goto_out;
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
r = 1;
out:
@@ -689,7 +685,7 @@ out:
}
static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
- int arg, enum metadata_request *mr)
+ int arg, uint32_t *mr)
{
if (!change_tag(cmd, NULL, lv, NULL, arg))
return_0;
@@ -697,8 +693,9 @@ static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
log_very_verbose("Updating logical volume %s on disk(s).", display_lvname(lv));
/* No need to suspend LV for this change */
- /* Request caller to commit+backup metadata */
- *mr |= (MR_COMMIT | MR_BACKUP);
+
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_COMMIT;
return 1;
}
@@ -752,7 +749,7 @@ static int _lvchange_rebuild(struct logical_volume *lv)
}
static int _lvchange_writemostly(struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
int pv_count, i = 0;
uint32_t s, writemostly;
@@ -869,14 +866,14 @@ static int _lvchange_writemostly(struct logical_volume *lv,
}
}
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
return 1;
}
static int _lvchange_recovery_rate(struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *raid_seg = first_seg(lv);
@@ -894,14 +891,14 @@ static int _lvchange_recovery_rate(struct logical_volume *lv,
return 0;
}
- /* Request caller to update and reload metadata */
- *mr |= MR_UPDATE_RELOAD;
+ /* Request caller to commit and reload metadata */
+ *mr |= MR_RELOAD;
return 1;
}
static int _lvchange_profile(struct logical_volume *lv,
- enum metadata_request *mr)
+ uint32_t *mr)
{
const char *old_profile_name, *new_profile_name;
struct profile *new_profile;
@@ -924,13 +921,13 @@ static int _lvchange_profile(struct logical_volume *lv,
log_verbose("Changing configuration profile for LV %s: %s -> %s.",
display_lvname(lv), old_profile_name, new_profile_name);
- /* Request caller to commit+backup metadata */
- *mr |= (MR_COMMIT | MR_BACKUP);
+ /* Request caller to commit metadata */
+ *mr |= MR_COMMIT;
return 1;
}
-static int _lvchange_activation_skip(struct logical_volume *lv, enum metadata_request *mr)
+static int _lvchange_activation_skip(struct logical_volume *lv, uint32_t *mr)
{
int skip = arg_int_value(lv->vg->cmd, setactivationskip_ARG, 0);
@@ -940,16 +937,15 @@ static int _lvchange_activation_skip(struct logical_volume *lv, enum metadata_re
display_lvname(lv), skip ? "enabled" : "disabled");
/* Request caller to commit+backup metadata */
- *mr |= (MR_COMMIT | MR_BACKUP);
+ *mr |= MR_COMMIT;
return 1;
}
/* Update and reload or commit and/or backup metadata for @lv as requested by @mr */
-static int _commit_update_backup(struct logical_volume *lv,
- const enum metadata_request mr)
+static int _commit_reload(struct logical_volume *lv, uint32_t mr)
{
- if (mr & MR_UPDATE_RELOAD) {
+ if (mr & MR_RELOAD) {
if (!lv_update_and_reload(lv))
return_0;
@@ -957,9 +953,6 @@ static int _commit_update_backup(struct logical_volume *lv,
!_vg_write_commit(lv, NULL))
return 0;
- if (mr & MR_BACKUP)
- backup(lv->vg);
-
return 1;
}
@@ -976,13 +969,22 @@ static int _commit_update_backup(struct logical_volume *lv,
* . (or all the code could live in the _single fn)
*/
+/*
+ * Process 2 types of options differently
+ * minimizing metadata commits and table reloads:
+ *
+ * 1. process group of options not requiring metadata commit(, reload)
+ * for each option and commit(, reload) metadata for the whole group
+ *
+ * 2. process the options requiring metadata commit+reload per option
+ */
static int _lvchange_properties_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
- int doit = 0, docmds = 0;
+ int docmds = 0, doit = 0, doit_total = 0, change_msg = 1, second_group = 0;
int i, opt_enum;
- enum metadata_request mr = 0;
+ uint32_t mr = 0;
/*
* If a persistent lv lock already exists from activation
@@ -995,90 +997,199 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
return ECMD_FAILED;
}
+ /* First group of options which allow for one metadata commit/update for the whole group */
for (i = 0; i < cmd->command->ro_count; i++) {
opt_enum = cmd->command->required_opt_args[i].opt;
if (!arg_is_set(cmd, opt_enum))
continue;
- /* Archive will only happen once per run */
+ switch (opt_enum) {
+ /*
+ * Skip options requiring per option commit/reload
+ * to process them in the second step.
+ */
+ case discards_ARG:
+ case zero_ARG:
+ case cachemode_ARG:
+ case cachepolicy_ARG:
+ case cachesettings_ARG:
+ second_group++;
+ continue;
+ default:
+ break;
+ }
+
+ /* Archive will only happen once per run. */
if (!archive(lv->vg))
return_ECMD_FAILED;
- docmds++;
-
+ /*
+ * Process the following options and to a single
+ * metadata commit/reload for the whole group.
+ */
switch (opt_enum) {
case permission_ARG:
+ docmds++;
doit += _lvchange_permission(cmd, lv, &mr);
break;
case alloc_ARG:
case contiguous_ARG:
+ docmds++;
doit += _lvchange_alloc(cmd, lv, &mr);
break;
case errorwhenfull_ARG:
+ docmds++;
doit += _lvchange_errorwhenfull(cmd, lv, &mr);
break;
case readahead_ARG:
+ docmds++;
doit += _lvchange_readahead(cmd, lv, &mr);
break;
case persistent_ARG:
+ docmds++;
doit += _lvchange_persistent(cmd, lv, &mr);
break;
- case discards_ARG:
- case zero_ARG:
- doit += _lvchange_pool_update(cmd, lv, &mr);
- break;
-
case addtag_ARG:
case deltag_ARG:
+ docmds++;
doit += _lvchange_tag(cmd, lv, opt_enum, &mr);
break;
case writemostly_ARG:
case writebehind_ARG:
+ docmds++;
doit += _lvchange_writemostly(lv, &mr);
break;
case minrecoveryrate_ARG:
case maxrecoveryrate_ARG:
+ docmds++;
doit += _lvchange_recovery_rate(lv, &mr);
break;
case profile_ARG:
case metadataprofile_ARG:
case detachprofile_ARG:
+ docmds++;
doit += _lvchange_profile(lv, &mr);
break;
case setactivationskip_ARG:
+ docmds++;
doit += _lvchange_activation_skip(lv, &mr);
break;
+ default:
+ log_error(INTERNAL_ERROR "Failed to check for option %s",
+ arg_long_option_name(i));
+ }
+ }
+
+ /* Any options of the first group processed? */
+ if (docmds) {
+ doit_total = doit;
+ doit = 0;
+
+ /* Display any logical volume change */
+ if (doit_total) {
+ log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
+ change_msg = 0;
+
+ /* Commit(, reload) metadata once for whole processed group of options */
+ if (!_commit_reload(lv, mr))
+ return_ECMD_FAILED;
+ }
+
+ /* Bail out if any processing of an option in the first group failed */
+ if (docmds != doit_total)
+ return_ECMD_FAILED;
+
+ /* Do backup if processing the first group of options went ok */
+ backup(lv->vg);
+
+ } else if (!second_group)
+ return_ECMD_FAILED;
+
+ /* Second group of options which need per option metadata commit+reload(s) */
+ for (i = 0; i < cmd->command->ro_count; i++) {
+ opt_enum = cmd->command->required_opt_args[i].opt;
+
+ if (!arg_is_set(cmd, opt_enum))
+ continue;
+
+ switch (opt_enum) {
+ /* Skip any of the already processed options */
+ case permission_ARG:
+ case alloc_ARG:
+ case contiguous_ARG:
+ case errorwhenfull_ARG:
+ case readahead_ARG:
+ case persistent_ARG:
+ case addtag_ARG:
+ case deltag_ARG:
+ case writemostly_ARG:
+ case writebehind_ARG:
+ case minrecoveryrate_ARG:
+ case maxrecoveryrate_ARG:
+ case profile_ARG:
+ case metadataprofile_ARG:
+ case detachprofile_ARG:
+ case setactivationskip_ARG:
+ continue;
+ default:
+ break;
+ }
+
+ /* Archive will only happen once per run */
+ if (!archive(lv->vg))
+ return_ECMD_FAILED;
+
+ mr = 0;
+
+ switch (opt_enum) {
+ /* Process the following options which need per option metadata commit and reload */
+ case discards_ARG:
+ case zero_ARG:
+ docmds++;
+ doit += _lvchange_pool_update(cmd, lv, &mr);
+ break;
+
case cachemode_ARG:
case cachepolicy_ARG:
case cachesettings_ARG:
+ docmds++;
doit += _lvchange_cache(cmd, lv, &mr);
break;
default:
- log_error(INTERNAL_ERROR "Failed to check for option %s",
- arg_long_option_name(i));
+ break;
}
+
+ /* Display any logical volume change unless already displayed in step 1. */
+ if (doit && change_msg) {
+ log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
+ change_msg = 0;
+ }
+
+ /* Commit(,reload) metadata per processed option */
+ if (!_commit_reload(lv, mr))
+ return_ECMD_FAILED;
}
- if (doit)
- log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
+ doit_total += doit;
- if (doit != docmds)
+ /* Bail out if no options wwre found or any processing of an option in the second group failed */
+ if (!docmds || docmds != doit_total)
return_ECMD_FAILED;
- if (!_commit_update_backup(lv, mr))
- return_ECMD_FAILED;
+ /* Do backup if processing the second group of options went ok */
+ backup(lv->vg);
return ECMD_PROCESSED;
}
@@ -1422,12 +1533,12 @@ static int _lvchange_persistent_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
- enum metadata_request mr = 0;
+ uint32_t mr = 0;
if (!_lvchange_persistent(cmd, lv, &mr))
return_ECMD_FAILED;
- if (!_commit_update_backup(lv, mr))
+ if (!_commit_reload(lv, mr))
return_ECMD_FAILED;
return ECMD_PROCESSED;
7 years
master - man: '-pool' regexp
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e7ec9aab8a9a546e1b6...
Commit: e7ec9aab8a9a546e1b6ef7dc49e8012373691c3b
Parent: 76b70d5058cbbe41b60b99f11cda5e698b3c62e9
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Apr 4 23:53:28 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Apr 4 23:53:28 2017 +0200
man: '-pool' regexp
---
man/Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/man/Makefile.in b/man/Makefile.in
index defa9b3..25b1c95 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -216,6 +216,7 @@ $(SED) -i -e "s+\([ [:alpha:]]\)-\{7\}+\1\\\-\\\-\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([[:alnum:]]\{2,\}\)\\\-\([[:alnum:]]\{2,\}\)+\1-\2+g" \
-e "s+\(\\\-\\\-[[:alnum:]]\{2,\}\)-+\1\\\-+g" \
-e "s+\(lvm2\-activation\)+lvm2\\\-activation+" \
+ -e "s+\([^\\]\)-pool+\1\\\-pool+g" \
-e "s+\([[:digit:]]\)-\([[:digit:]]\)+\1\\\-\2+g" \
-e "s+\\\-git+\-git+g" \
-e "s+\(vg.*\)\-lv+\1\\\-lv+g" \
7 years
master - lvconvert: fix converting hidden lv to pool
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=76b70d5058cbbe41b60...
Commit: 76b70d5058cbbe41b60b99f11cda5e698b3c62e9
Parent: b951d0433765d3ed7b0507906dec1894053cef4f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 4 16:47:47 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 4 16:47:47 2017 -0500
lvconvert: fix converting hidden lv to pool
A hidden LV can not be converted to a thin pool or cache pool.
---
tools/command-lines.in | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index b2682fa..fe98cc6 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -495,6 +495,7 @@ ID: lvconvert_to_thinpool_or_swap_metadata
DESC: Convert LV to type thin-pool (variant, use \\-\\-type thin-pool).
DESC: Swap metadata LV in a thin pool (variant, use \\-\\-swapmetadata).
FLAGS: PREVIOUS_SYNTAX
+RULE: all and lv_is_visible
---
@@ -533,6 +534,7 @@ ID: lvconvert_to_cachepool_or_swap_metadata
DESC: Convert LV to type cache-pool (variant, use \\-\\-type cache-pool).
DESC: Swap metadata LV in a cache pool (variant, use \\-\\-swapmetadata).
FLAGS: PREVIOUS_SYNTAX
+RULE: all and lv_is_visible
---
7 years
master - help: print all options in abbreviated help output
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b951d0433765d3ed7b0...
Commit: b951d0433765d3ed7b0507906dec1894053cef4f
Parent: 29161a145e9c1c50157dca30c17957e4699826d6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 3 16:36:04 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Apr 3 16:36:04 2017 -0500
help: print all options in abbreviated help output
Don't abbreviate the --help output quite as much
when there are many command defs. Print all the
options in the cmd defs that are shown. --longhelp
output is unchanged and includes everything.
---
tools/lvmcmdline.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index bb107d4..280a052 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1835,15 +1835,13 @@ static int _usage(const char *name, int longhelp, int skip_notes)
_cmdline.commands[i].command_enum,
_cmdline.commands[i].command_id);
- print_usage(&_cmdline.commands[i], show_full, 1);
+ print_usage(&_cmdline.commands[i], 1, 1);
cmd = &_cmdline.commands[i];
}
/* Common options are printed once for all variants of a command name. */
- if (show_full) {
- print_usage_common_cmd(cname, cmd);
- print_usage_common_lvm(cname, cmd);
- }
+ print_usage_common_cmd(cname, cmd);
+ print_usage_common_lvm(cname, cmd);
if (skip_notes)
return 1;
7 years
master - commands: missing comma in cmd def option list
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=29161a145e9c1c50157...
Commit: 29161a145e9c1c50157dca30c17957e4699826d6
Parent: db579b9e936df14edb9c06830c21e5b5aef666a4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 3 16:20:55 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Apr 3 16:20:55 2017 -0500
commands: missing comma in cmd def option list
Does not affect parsing, but keep it consistent.
---
tools/command-lines.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index a83fb43..b2682fa 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -297,7 +297,7 @@ ID: lvchange_poll
DESC: Start or stop processing an LV conversion.
lvchange --persistent y --minor Number LV
-OO: --major Number, --activate Activate OO_LVCHANGE
+OO: --major Number, --activate Activate, OO_LVCHANGE
ID: lvchange_persistent
DESC: Make the minor device number persistent for an LV.
RULE: all not LV_thinpool LV_cachepool
7 years