From 20db8ffcaef468b884f1cbf1193bc38a2d4f9f05 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 24 Jan 2007 23:43:27 +0000 Subject: [PATCH] lvm.static no longer interacts with dmeventd unless explicitly asked to. --- WHATS_NEW | 1 + lib/activate/activate.c | 4 ++ lib/log/log.h | 2 + scripts/lvm2_monitoring_init_rhel4 | 98 ++++++++++++++++++++++++++++++ tools/lvchange.c | 7 ++- tools/vgchange.c | 19 +++--- 6 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 scripts/lvm2_monitoring_init_rhel4 diff --git a/WHATS_NEW b/WHATS_NEW index 86c3ef46c..e3f6c156c 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + lvm.static no longer interacts with dmeventd unless explicitly asked to. Add field definitions to report help text. Remove unnecessary cmd arg from target_*monitor_events(). Add private variable to dmeventd shared library interface. diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 3299f8d55..11a6d949d 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -653,6 +653,10 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct lv_segment *seg; int (*monitor_fn) (struct lv_segment *s, int e); + /* skip dmeventd code altogether */ + if (dmeventd_monitor_mode() == DMEVENTD_MONITOR_IGNORE) + return 1; + /* * Nothing to do if dmeventd configured not to be used. */ diff --git a/lib/log/log.h b/lib/log/log.h index 867efc2ef..4ff6ff544 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -90,6 +90,8 @@ int ignorelockingfailure(void); int lockingfailed(void); int security_level(void); int mirror_in_sync(void); + +#define DMEVENTD_MONITOR_IGNORE -1 int dmeventd_monitor_mode(void); /* Suppress messages to stdout/stderr (1) or everywhere (2) */ diff --git a/scripts/lvm2_monitoring_init_rhel4 b/scripts/lvm2_monitoring_init_rhel4 new file mode 100644 index 000000000..3f2360d75 --- /dev/null +++ b/scripts/lvm2_monitoring_init_rhel4 @@ -0,0 +1,98 @@ +#!/bin/bash +# +# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# This file is part of LVM2. +# It is required for the proper handling of failures of LVM2 mirror +# devices that were created using the -m option of lvcreate. +# +# +# chkconfig: 12345 02 99 +# description: Starts and stops dmeventd monitoring for lvm2 +# +### BEGIN INIT INFO +# Provides: +### END INIT INFO + +. /etc/init.d/functions + +VGCHANGE="/usr/sbin/vgchange" + +start() +{ + for ret in 0 + do + # TODO do we want to separate out already active groups only? + VGS=`vgs --noheadings -o name` + for vg in $VGS + do + if ! action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg + then + ret=$? + fi + done + + done + + return $ret +} + + +stop() +{ + for ret in 0 + do + # TODO do we want to separate out already active groups only? + VGS=`vgs --noheadings -o name` + for vg in $VGS + do + if ! action "Starting monitoring for VG $vg:" $VGCHANGE --monitor n $vg + then + ret=$? + fi + done + + done + +} + +ret=1 + +# See how we were called. +case "$1" in + start) + start + ret=$? + ;; + + stop) + stop + ret=$? + ;; + + restart) + if stop + then + start + fi + ret=$? + ;; + + status) + # TODO anyone with an idea how to dump monitored volumes? + ;; + + *) + echo $"Usage: $0 {start|stop|restart|status}" + ;; +esac + +exit $ret diff --git a/tools/lvchange.c b/tools/lvchange.c index e94d9d61c..4f046bc95 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -94,7 +94,8 @@ static int lvchange_monitoring(struct cmd_context *cmd, if (lv->status & PVMOVE) return 1; - if (!monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode())) + if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) && + !monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode())) stack; return 1; @@ -591,7 +592,9 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, return ECMD_FAILED; } - init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, + cmd->is_static ? + DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR)); /* access permission change */ if (arg_count(cmd, permission_ARG)) { diff --git a/tools/vgchange.c b/tools/vgchange.c index dca130608..0660409f7 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -105,7 +105,8 @@ static int _vgchange_monitoring(struct cmd_context *cmd, struct volume_group *vg { int active, monitored; - if ((active = lvs_in_vg_activated(vg))) { + if ((active = lvs_in_vg_activated(vg)) && + dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) { monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); log_print("%d logical volume(s) in volume group " "\"%s\" %smonitored", @@ -146,11 +147,13 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg) if (activate && (active = lvs_in_vg_activated(vg))) { log_verbose("%d logical volume(s) in volume group \"%s\" " "already active", active, vg->name); - monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); - log_verbose("%d existing logical volume(s) in volume " - "group \"%s\" %smonitored", - monitored, vg->name, - dmeventd_monitor_mode() ? "" : "un"); + if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) { + monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); + log_verbose("%d existing logical volume(s) in volume " + "group \"%s\" %smonitored", + monitored, vg->name, + dmeventd_monitor_mode() ? "" : "un"); + } } if (activate && _activate_lvs_in_vg(cmd, vg, available)) @@ -532,7 +535,9 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name, return ECMD_FAILED; } - init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, + cmd->is_static ? + DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR)); if (arg_count(cmd, available_ARG)) r = _vgchange_available(cmd, vg);