summaryrefslogtreecommitdiffstats
path: root/tools/pvscan.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2012-06-27 09:35:11 -0400
committerPeter Rajnoha <prajnoha@redhat.com>2012-06-28 09:44:03 -0400
commitd2df8dddc8c04973a3e23b7a19e9bfbf8c45f79e (patch)
tree7bcca97a3e58c468df6de63e1bb941e844ca27bd /tools/pvscan.c
parent215a314f195ea4af5265e37999502462fcf2a341 (diff)
downloadlvm2-d2df8dddc8c04973a3e23b7a19e9bfbf8c45f79e.tar.gz
lvm2-d2df8dddc8c04973a3e23b7a19e9bfbf8c45f79e.tar.xz
lvm2-d2df8dddc8c04973a3e23b7a19e9bfbf8c45f79e.zip
pvscan: add --activate ay option (autoactivate)
Define auto_activation_handler that activates VGs/LVs automatically based on the activation/auto_activation_volume_list (activating all volumes by default if the list is not defined). The autoactivation is done within the pvscan call in 69-dm-lvmetad.rules that watches for udev events (device appearance/removal). For now, this works for non-clustered and complete VGs only.
Diffstat (limited to 'tools/pvscan.c')
-rw-r--r--tools/pvscan.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/pvscan.c b/tools/pvscan.c
index beba1743..a0408998 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -97,6 +97,20 @@ static void _pvscan_display_single(struct cmd_context *cmd,
pv_pe_size(pv)));
}
+static int _auto_activation_handler(struct volume_group *vg, int partial, int activate)
+{
+ /* TODO: add support for partial and clustered VGs */
+ if (partial || vg_is_clustered(vg))
+ return 1;
+
+ if (!vgchange_activate(vg->cmd, vg, activate)) {
+ log_error("%s: autoactivation failed.", vg->name);
+ return 0;
+ }
+
+ return 1;
+}
+
static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd, activation_handler handler)
{
struct dev_iter *iter;
@@ -136,6 +150,14 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
char *buf;
activation_handler handler = NULL;
+ if (arg_count(cmd, activate_ARG)) {
+ if (arg_uint_value(cmd, activate_ARG, CHANGE_AAY) != CHANGE_AAY) {
+ log_error("Only --activate ay allowed with pvscan.");
+ return 0;
+ }
+ handler = _auto_activation_handler;
+ }
+
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG))
devno_args = 1;
@@ -241,6 +263,11 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, cache_ARG))
return _pvscan_lvmetad(cmd, argc, argv);
+ if (arg_count(cmd, activate_ARG)) {
+ log_error("--activate is only valid with --cache.");
+ return EINVALID_CMD_LINE;
+ }
+
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG)) {
log_error("--major and --minor are only valid with --cache.");
return EINVALID_CMD_LINE;