summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-09-02 15:15:46 -0500
committerDavid Teigland <teigland@redhat.com>2021-10-07 12:45:14 -0500
commit240db28214a3ebb8e22b7d42904775333e6b96c1 (patch)
tree209ca94cab8541caab9ed975841bbb4d5ef3e7f8
parentca38251b1043c49f5453c2c571876b12aad6b450 (diff)
downloadlvm2-240db28214a3ebb8e22b7d42904775333e6b96c1.tar.gz
vgchange: add vgonline option
Using --vgonline with vgchange -aay makes vgchange use /run/lvm/vgs_online/ files in the same way as pvscan. If the online file for the vg does not exist and the command is able to exclusively create it, then it will activate the VG. If the online file exists or the create fails, then the VG will not be activated.
-rw-r--r--tools/command-lines.in2
-rw-r--r--tools/pvscan.c10
-rw-r--r--tools/tools.h2
-rw-r--r--tools/vgchange.c8
4 files changed, 16 insertions, 6 deletions
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 10b23e75d..23ea33e6d 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1747,7 +1747,7 @@ DESC: Start or stop processing LV conversions.
vgchange --activate Active
OO: --activationmode ActivationMode, --ignoreactivationskip, --partial, --sysinit,
---readonly, --ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE
+--readonly, --ignorelockingfailure, --monitor Bool, --poll Bool, --vgonline, OO_VGCHANGE
OP: VG|Tag|Select ...
IO: --ignoreskippedcluster
ID: vgchange_activate
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 75a08d325..ada1f07fe 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -660,7 +660,7 @@ static int _count_pvid_files_from_lookup_file(struct cmd_context *cmd, struct de
return (vgname) ? 1 : 0;
}
-static void _online_dir_setup(struct cmd_context *cmd)
+void online_dir_setup(struct cmd_context *cmd)
{
struct stat st;
int rv;
@@ -756,7 +756,7 @@ static int _pvscan_aa_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_PROCESSED;
}
-static int _online_vg_file_create(struct cmd_context *cmd, const char *vgname)
+int online_vg_file_create(struct cmd_context *cmd, const char *vgname)
{
char path[PATH_MAX];
int fd;
@@ -1060,7 +1060,7 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
* to run the activation. The first to create the file will do it.
*/
dm_list_iterate_items_safe(sl, sl2, vgnames) {
- if (!_online_vg_file_create(cmd, sl->str)) {
+ if (!online_vg_file_create(cmd, sl->str)) {
log_print_pvscan(cmd, "VG %s skip autoactivation.", sl->str);
str_list_del(vgnames, sl->str);
continue;
@@ -1497,7 +1497,7 @@ static int _online_devs(struct cmd_context *cmd, int do_all, struct dm_list *pvs
} else if (!do_check_complete) {
log_print("VG %s", vgname);
} else if (vg_complete) {
- if (do_vgonline && !_online_vg_file_create(cmd, vgname)) {
+ if (do_vgonline && !online_vg_file_create(cmd, vgname)) {
log_print("VG %s finished", vgname);
} else {
/*
@@ -1919,7 +1919,7 @@ int pvscan_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
do_all = !argc && !devno_args;
- _online_dir_setup(cmd);
+ online_dir_setup(cmd);
if (do_all) {
if (!_pvscan_cache_all(cmd, argc, argv, &complete_vgnames))
diff --git a/tools/tools.h b/tools/tools.h
index bc98fcb09..e2661f272 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -296,5 +296,7 @@ int lvconvert_cachevol_attach_single(struct cmd_context *cmd,
struct processing_handle *handle);
void online_vg_file_remove(const char *vgname);
+int online_vg_file_create(struct cmd_context *cmd, const char *vgname);
+void online_dir_setup(struct cmd_context *cmd);
#endif
diff --git a/tools/vgchange.c b/tools/vgchange.c
index e4b57dbd2..985907a02 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -262,6 +262,11 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
}
}
+ if (arg_is_set(cmd, vgonline_ARG) && !online_vg_file_create(cmd, vg->name)) {
+ log_print("VG %s finished", vg->name);
+ return 1;
+ }
+
if (!_activate_lvs_in_vg(cmd, vg, activate)) {
stack;
r = 0;
@@ -699,6 +704,9 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
}
+ if (arg_is_set(cmd, vgonline_ARG))
+ online_dir_setup(cmd);
+
if (arg_is_set(cmd, activate_ARG)) {
activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, 0);
if (!vgchange_activate(cmd, vg, activate))