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))