summaryrefslogtreecommitdiffstats
path: root/tools/lvchange.c
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2010-01-05 20:56:51 +0000
committerMike Snitzer <snitzer@redhat.com>2010-01-05 20:56:51 +0000
commit7a8fa6aaab54a9da7289637e016eef553168bfe2 (patch)
treea93b1467523d000261cb4a23e493d7bf087d98f5 /tools/lvchange.c
parent0e06c92fdf1973bf8a8e0096b7beaf6fc687f10e (diff)
downloadlvm2-7a8fa6aaab54a9da7289637e016eef553168bfe2.tar.gz
lvm2-7a8fa6aaab54a9da7289637e016eef553168bfe2.tar.xz
lvm2-7a8fa6aaab54a9da7289637e016eef553168bfe2.zip
Add a [--poll {y|n}] flag to vgchange and lvchange to control whether
the background polldaemon is allowed to start. It can be used standalone or in conjunction with --refresh or --available y. Control over when the background polldaemon starts will be particularly important for snapshot-merge of a root filesystem. Dracut will be updated to activate all LVs with: --poll n The lvm2-monitor initscript will start polling with: --poll y NOTE: Because we currently have no way of knowing if a background polldaemon is active for a given LV the following limitations exist and have been deemed acceptable: 1) it is not possible to stop an active polldaemon; so the lvm2-monitor initscript doesn't stop running polldaemon(s) 2) redundant polldaemon instances will be started for all specified LVs if vgchange or lvchange are repeatedly used with '--poll y' Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'tools/lvchange.c')
-rw-r--r--tools/lvchange.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c
index f43b07af..f01d560a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -101,6 +101,22 @@ static int lvchange_monitoring(struct cmd_context *cmd,
return 1;
}
+static int lvchange_background_polling(struct cmd_context *cmd,
+ struct logical_volume *lv)
+{
+ struct lvinfo info;
+
+ if (!lv_info(cmd, lv, &info, 0, 0) || !info.exists) {
+ log_error("Logical volume, %s, is not active", lv->name);
+ return 0;
+ }
+
+ if (background_polling())
+ lv_spawn_background_polling(cmd, lv);
+
+ return 1;
+}
+
static int lvchange_availability(struct cmd_context *cmd,
struct logical_volume *lv)
{
@@ -135,7 +151,8 @@ static int lvchange_availability(struct cmd_context *cmd,
return_0;
}
- lv_spawn_background_polling(cmd, lv);
+ if (background_polling())
+ lv_spawn_background_polling(cmd, lv);
}
return 1;
@@ -577,6 +594,9 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
(is_static() || arg_count(cmd, ignoremonitoring_ARG)) ?
DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR));
+ init_background_polling(arg_int_value(cmd, poll_ARG,
+ DEFAULT_BACKGROUND_POLLING));
+
/* access permission change */
if (arg_count(cmd, permission_ARG)) {
if (!archive(lv->vg)) {
@@ -679,6 +699,15 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
+ if (!arg_count(cmd, available_ARG) &&
+ !arg_count(cmd, refresh_ARG) &&
+ arg_count(cmd, poll_ARG)) {
+ if (!lvchange_background_polling(cmd, lv)) {
+ stack;
+ return ECMD_FAILED;
+ }
+ }
+
if (doit != docmds) {
stack;
return ECMD_FAILED;
@@ -695,10 +724,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
&& !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG)
&& !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)
&& !arg_count(cmd, alloc_ARG) && !arg_count(cmd, monitor_ARG)
- && !arg_count(cmd, resync_ARG)) {
+ && !arg_count(cmd, poll_ARG) && !arg_count(cmd, resync_ARG)) {
log_error("Need 1 or more of -a, -C, -j, -m, -M, -p, -r, "
- "--resync, --refresh, --alloc, --addtag, --deltag "
- "or --monitor");
+ "--resync, --refresh, --alloc, --addtag, --deltag, "
+ "--monitor or --poll");
return EINVALID_CMD_LINE;
}