summaryrefslogtreecommitdiff
path: root/tools/pvscan.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-11-03 12:03:29 -0500
committerDavid Teigland <teigland@redhat.com>2021-11-04 11:08:38 -0500
commitd558b3ad7e6086480075b3bf750eba0ee66c78ec (patch)
tree1185d7297ed58381889384e037e4f112b7fb5f49 /tools/pvscan.c
parent594f6ca97024fa23dfa852b6cc9da272877e1ced (diff)
downloadlvm2-d558b3ad7e6086480075b3bf750eba0ee66c78ec.tar.gz
vgchange -aay: optimize device scan using pvs_online files
Port the old pvscan -aay scanning optimization to vgchange -aay. The optimization uses pvs_online files created by pvscan --cache to derive a list of devices to use when activating a VG. This allows autoactivation of a VG to avoid scanning all devices, and only scan the devices used by the VG itself. The optimization is applied internally using the device hints interface. The new option "--autoactivation event" is given to pvscan and vgchange commands that are called by event activation. This informs the command that it is being used for event activation, so that it can apply checks and optimizations that are specific to event activation. Those include: - skipping the command if lvm.conf event_activation=0 - checking that a VG is complete before activating it - using pvs_online files to limit device scanning
Diffstat (limited to 'tools/pvscan.c')
-rw-r--r--tools/pvscan.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 4f97e211c..d9607fdb6 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -750,7 +750,7 @@ static int _pvscan_aa_single(struct cmd_context *cmd, const char *vg_name,
log_debug("pvscan autoactivating VG %s.", vg_name);
- if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
+ if (!vgchange_activate(cmd, vg, CHANGE_AAY, 1)) {
log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@@ -1038,7 +1038,7 @@ static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp
log_debug("pvscan autoactivating VG %s.", vgname);
- if (!vgchange_activate(cmd, vg, CHANGE_AAY)) {
+ if (!vgchange_activate(cmd, vg, CHANGE_AAY, 1)) {
log_error_pvscan(cmd, "%s: autoactivation failed.", vg->name);
pp->activate_errors++;
}
@@ -1869,12 +1869,35 @@ static int _pvscan_cache_args(struct cmd_context *cmd, int argc, char **argv,
return ret;
}
+static int _get_autoactivation(struct cmd_context *cmd, int event_activation, int *skip_command)
+{
+ const char *aa_str;
+
+ if (!(aa_str = arg_str_value(cmd, autoactivation_ARG, NULL)))
+ return 1;
+
+ if (strcmp(aa_str, "event")) {
+ log_print_pvscan(cmd, "Skip pvscan for unknown autoactivation value.");
+ *skip_command = 1;
+ return 1;
+ }
+
+ if (!event_activation) {
+ log_print_pvscan(cmd, "Skip pvscan for event with event_activation=0.");
+ *skip_command = 1;
+ return 1;
+ }
+
+ return 1;
+}
+
int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct pvscan_aa_params pp = { 0 };
struct dm_list complete_vgnames;
int do_activate = arg_is_set(cmd, activate_ARG);
int event_activation;
+ int skip_command = 0;
int devno_args = 0;
int do_all;
int ret;
@@ -1946,6 +1969,13 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
log_verbose("Ignoring pvscan --cache because event_activation is disabled.");
return ECMD_PROCESSED;
}
+
+ if (!_get_autoactivation(cmd, event_activation, &skip_command))
+ return_ECMD_FAILED;
+
+ if (skip_command)
+ return ECMD_PROCESSED;
+
if (!_pvscan_cache_args(cmd, argc, argv, &complete_vgnames))
return ECMD_FAILED;
}