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-15 12:59:03 -0500
commit4f1957ee50c9898460fdea9c894616e7fa9b09d7 (patch)
tree83003f46023dd54a451ddec18c11e7bf1aedf218
parentbf87b8354d07dbddc520e8b61543128e2b2f1924 (diff)
downloadlvm2-4f1957ee50c9898460fdea9c894616e7fa9b09d7.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 8e2611361..90866c4fc 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))