Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 282811 Details for
Bug 178979
request for "full snapshot" warnings
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
snapshot-dso.diff
snapshot-dso.diff (text/plain), 20.46 KB, created by
Petr Rockai
on 2007-12-10 14:19:29 UTC
(
hide
)
Description:
snapshot-dso.diff
Filename:
MIME Type:
Creator:
Petr Rockai
Created:
2007-12-10 14:19:29 UTC
Size:
20.46 KB
patch
obsolete
>Tue Nov 27 16:30:02 CET 2007 me@mornfall.net > * resolve conflicts >Tue Nov 27 16:22:56 CET 2007 me@mornfall.net > * Milan's snapshot monitoring DSO >diff -rN -u old-snapshot-dmeventd-rebased/configure new-snapshot-dmeventd-rebased/configure >--- old-snapshot-dmeventd-rebased/configure 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/configure 2007-12-10 15:15:06.417801356 +0100 >@@ -11597,8 +11597,7 @@ > > > ################################################################################ >-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile test/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile" >- >+ ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile" > cat >confcache <<\_ACEOF > # This file is a shell script that caches the results of configure > # tests run on this system so they can be shared between configure >@@ -12185,30 +12184,34 @@ > # Handling of arguments. > for ac_config_target in $ac_config_targets > do >- case $ac_config_target in >- "lib/misc/configure.h") CONFIG_HEADERS="$CONFIG_HEADERS lib/misc/configure.h" ;; >- "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; >- "make.tmpl") CONFIG_FILES="$CONFIG_FILES make.tmpl" ;; >- "daemons/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/Makefile" ;; >- "daemons/clvmd/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/clvmd/Makefile" ;; >- "dmeventd/Makefile") CONFIG_FILES="$CONFIG_FILES dmeventd/Makefile" ;; >- "dmeventd/mirror/Makefile") CONFIG_FILES="$CONFIG_FILES dmeventd/mirror/Makefile" ;; >- "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; >- "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; >- "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; >- "lib/format1/Makefile") CONFIG_FILES="$CONFIG_FILES lib/format1/Makefile" ;; >- "lib/format_pool/Makefile") CONFIG_FILES="$CONFIG_FILES lib/format_pool/Makefile" ;; >- "lib/locking/Makefile") CONFIG_FILES="$CONFIG_FILES lib/locking/Makefile" ;; >- "lib/mirror/Makefile") CONFIG_FILES="$CONFIG_FILES lib/mirror/Makefile" ;; >- "lib/snapshot/Makefile") CONFIG_FILES="$CONFIG_FILES lib/snapshot/Makefile" ;; >- "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; >- "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; >- "po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; >- "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; >- "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; >- "tools/version.h") CONFIG_FILES="$CONFIG_FILES tools/version.h" ;; >- "tools/fsadm/Makefile") CONFIG_FILES="$CONFIG_FILES tools/fsadm/Makefile" ;; >- >+ case "$ac_config_target" in >+ # Handling of arguments. >+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; >+ "make.tmpl" ) CONFIG_FILES="$CONFIG_FILES make.tmpl" ;; >+ "daemons/Makefile" ) CONFIG_FILES="$CONFIG_FILES daemons/Makefile" ;; >+ "daemons/clvmd/Makefile" ) CONFIG_FILES="$CONFIG_FILES daemons/clvmd/Makefile" ;; >+ "dmeventd/Makefile" ) CONFIG_FILES="$CONFIG_FILES dmeventd/Makefile" ;; >+ "dmeventd/mirror/Makefile" ) CONFIG_FILES="$CONFIG_FILES dmeventd/mirror/Makefile" ;; >+ "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; >+ "include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; >+ "lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; >+ "lib/format1/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/format1/Makefile" ;; >+ "lib/format_pool/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/format_pool/Makefile" ;; >+ "lib/locking/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/locking/Makefile" ;; >+ "lib/mirror/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/mirror/Makefile" ;; >+ "lib/snapshot/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/snapshot/Makefile" ;; >+ "man/Makefile" ) CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; >+ "po/Makefile" ) CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; >+ "scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; >+ "tools/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; >+ "tools/version.h" ) CONFIG_FILES="$CONFIG_FILES tools/version.h" ;; >+ "tools/fsadm/Makefile" ) CONFIG_FILES="$CONFIG_FILES tools/fsadm/Makefile" ;; >+ "test/mm/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/mm/Makefile" ;; >+ "test/device/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/device/Makefile" ;; >+ "test/format1/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/format1/Makefile" ;; >+ "test/regex/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/regex/Makefile" ;; >+ "test/filters/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/filters/Makefile" ;; >+ "lib/misc/configure.h" ) CONFIG_HEADERS="$CONFIG_HEADERS lib/misc/configure.h" ;; > *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 > $as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} > { (exit 1); exit 1; }; };; >diff -rN -u old-snapshot-dmeventd-rebased/configure.in new-snapshot-dmeventd-rebased/configure.in >--- old-snapshot-dmeventd-rebased/configure.in 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/configure.in 2007-12-10 15:15:06.417801356 +0100 >@@ -647,6 +647,7 @@ > daemons/clvmd/Makefile > dmeventd/Makefile > dmeventd/mirror/Makefile >+dmeventd/snapshot/Makefile > doc/Makefile > include/Makefile > lib/Makefile >diff -rN -u old-snapshot-dmeventd-rebased/dmeventd/Makefile.in new-snapshot-dmeventd-rebased/dmeventd/Makefile.in >--- old-snapshot-dmeventd-rebased/dmeventd/Makefile.in 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/dmeventd/Makefile.in 2007-12-10 15:15:06.417801356 +0100 >@@ -16,7 +16,7 @@ > top_srcdir = @top_srcdir@ > VPATH = @srcdir@ > >-SUBDIRS += mirror >+SUBDIRS += mirror snapshot > > include $(top_srcdir)/make.tmpl > >diff -rN -u old-snapshot-dmeventd-rebased/dmeventd/snapshot/dmeventd_snapshot.c new-snapshot-dmeventd-rebased/dmeventd/snapshot/dmeventd_snapshot.c >--- old-snapshot-dmeventd-rebased/dmeventd/snapshot/dmeventd_snapshot.c 1970-01-01 01:00:00.000000000 +0100 >+++ new-snapshot-dmeventd-rebased/dmeventd/snapshot/dmeventd_snapshot.c 2007-12-10 15:15:06.417801356 +0100 >@@ -0,0 +1,206 @@ >+/* >+ * Copyright (C) 2007 Red Hat, Inc. All rights reserved. >+ * >+ * This file is part of LVM2. >+ * >+ * 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 Lesser General Public License v.2.1. >+ * >+ * You should have received a copy of the GNU Lesser 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 >+ */ >+ >+#include "libdevmapper.h" >+#include "libdevmapper-event.h" >+#include "lvm2cmd.h" >+#include "lvm-string.h" >+ >+#include <errno.h> >+#include <signal.h> >+#include <string.h> >+#include <stdio.h> >+#include <stdlib.h> >+#include <pthread.h> >+#include <unistd.h> >+ >+#include <syslog.h> /* FIXME Replace syslog with multilog */ >+/* FIXME Missing openlog? */ >+ >+static pthread_mutex_t _register_mutex = PTHREAD_MUTEX_INITIALIZER; >+ >+/* >+ * Number of active registrations. >+ */ >+static int _register_count = 0; >+ >+static struct dm_pool *_mem_pool = NULL; >+static void *_lvm_handle = NULL; >+ >+struct snap_status { >+ int invalid; >+ int f; >+ int f_max; >+ >+}; >+ >+/* >+ * Currently only one event can be processed at a time. >+ */ >+static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER; >+ >+static void _temporary_log_fn(int level, const char *file, >+ int line, const char *format) >+{ >+ if (!strncmp(format, "WARNING: ", 9) && (level < 5)) >+ syslog(LOG_CRIT, "%s", format); >+ else >+ syslog(LOG_DEBUG, "%s", format); >+} >+ >+static void _parse_snapshot_params(char *params, struct snap_status *stat) >+{ >+ char *p; >+ /* xx/xx -- fractions used/max >+ * Invalid -- snapshot invalidated >+ * Unknown -- status unknown >+ */ >+ stat->f = stat->f_max = 0; >+ >+ if (!strncmp(params, "Invalid", 7)) { >+ stat->invalid = 1; >+ return; >+ } >+ >+ if (!strncmp(params, "Unknown", 7)) >+ return; >+ >+ if (!(p = strstr(params, "/"))) >+ return; >+ >+ *p = '\0'; p++; >+ stat->f = atoi(params); >+ stat->f_max = atoi(p); >+} >+ >+/* send unregister command to itself */ >+static void _unregister_itself(struct dm_task *dmt) >+{ >+ const char *name = dm_task_get_name(dmt); >+ struct dm_event_handler *dmevh; >+ >+ if (!(dmevh = dm_event_handler_create())) >+ return; >+ >+ if (dm_event_handler_set_dev_name(dmevh, name)) >+ goto fail; >+ >+ dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS|DM_EVENT_TIMEOUT); >+ dm_event_unregister_handler(dmevh); >+fail: >+ dm_event_handler_destroy(dmevh); >+} >+ >+void process_event(struct dm_task *dmt, enum dm_event_mask event, >+ void **private) >+{ >+ void *next = NULL; >+ uint64_t start, length; >+ char *target_type = NULL; >+ char *params; >+ struct snap_status stat = {0}; >+ const char *device = dm_task_get_name(dmt); >+ int p, *pwarning = (int*)private; >+ >+ /* No longer monitoring, waiting for remove */ >+ if (!*pwarning) >+ return; >+ >+ if (pthread_mutex_trylock(&_event_mutex)) { >+ syslog(LOG_NOTICE, "Another thread is handling an event. Waiting..."); >+ pthread_mutex_lock(&_event_mutex); >+ } >+ >+ dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms); >+ if (!target_type) >+ goto out; >+ >+ _parse_snapshot_params(params, &stat); >+ if (stat.invalid || !stat.f_max) { >+ syslog(LOG_ERR, "Snapshot %s changed state to: %s\n", device, params); >+ _unregister_itself(dmt); >+ *pwarning = 0; >+ goto out; >+ } >+ >+ p = 100 * stat.f / stat.f_max; >+ if (p >= *pwarning) { >+ syslog(LOG_WARNING, "Snapshot %s is now %i%% full.\n", device, p); >+ *pwarning = (p / 5) * 5 + 5; >+ } >+out: >+ pthread_mutex_unlock(&_event_mutex); >+} >+ >+int register_device(const char *device, const char *uuid, int major, int minor, >+ void **private) >+{ >+ int r = 0; >+ int *pwarning = (int*)private; >+ >+ pthread_mutex_lock(&_register_mutex); >+ >+ /* >+ * Need some space for allocations. 1024 should be more >+ * than enough for what we need (device mapper name splitting) >+ */ >+ if (!_mem_pool && !(_mem_pool = dm_pool_create("snapshot_dso", 1024))) >+ goto out; >+ >+ /* FIXME: make this configurable */ >+ *pwarning = 80; /* Print warning if snapshot is full */ >+ >+ if (!_lvm_handle) { >+ lvm2_log_fn(_temporary_log_fn); >+ if (!(_lvm_handle = lvm2_init())) { >+ dm_pool_destroy(_mem_pool); >+ _mem_pool = NULL; >+ goto out; >+ } >+ lvm2_log_level(_lvm_handle, LVM2_LOG_SUPPRESS); >+ /* FIXME Temporary: move to dmeventd core */ >+ lvm2_run(_lvm_handle, "_memlock_inc"); >+ } >+ >+ syslog(LOG_INFO, "Monitoring snapshot %s\n", device); >+ >+ _register_count++; >+ r = 1; >+ >+out: >+ pthread_mutex_unlock(&_register_mutex); >+ >+ return r; >+} >+ >+int unregister_device(const char *device, const char *uuid, int major, int minor, >+ void **unused __attribute((unused))) >+{ >+ pthread_mutex_lock(&_register_mutex); >+ >+ syslog(LOG_INFO, "No longer monitoring snapshot %s\n", >+ device); >+ >+ if (!--_register_count) { >+ dm_pool_destroy(_mem_pool); >+ _mem_pool = NULL; >+ lvm2_run(_lvm_handle, "_memlock_dec"); >+ lvm2_exit(_lvm_handle); >+ _lvm_handle = NULL; >+ } >+ >+ pthread_mutex_unlock(&_register_mutex); >+ >+ return 1; >+} >diff -rN -u old-snapshot-dmeventd-rebased/dmeventd/snapshot/.exported_symbols new-snapshot-dmeventd-rebased/dmeventd/snapshot/.exported_symbols >--- old-snapshot-dmeventd-rebased/dmeventd/snapshot/.exported_symbols 1970-01-01 01:00:00.000000000 +0100 >+++ new-snapshot-dmeventd-rebased/dmeventd/snapshot/.exported_symbols 2007-12-10 15:15:06.417801356 +0100 >@@ -0,0 +1,3 @@ >+process_event >+register_device >+unregister_device >diff -rN -u old-snapshot-dmeventd-rebased/dmeventd/snapshot/Makefile.in new-snapshot-dmeventd-rebased/dmeventd/snapshot/Makefile.in >--- old-snapshot-dmeventd-rebased/dmeventd/snapshot/Makefile.in 1970-01-01 01:00:00.000000000 +0100 >+++ new-snapshot-dmeventd-rebased/dmeventd/snapshot/Makefile.in 2007-12-10 15:15:06.417801356 +0100 >@@ -0,0 +1,36 @@ >+# >+# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. >+# Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. >+# >+# This file is part of the LVM2. >+# >+# 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 >+ >+srcdir = @srcdir@ >+top_srcdir = @top_srcdir@ >+VPATH = @srcdir@ >+ >+INCLUDES += -I${top_srcdir}/tools >+CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd >+ >+SOURCES = dmeventd_snapshot.c >+ >+ifeq ("@LIB_SUFFIX@","dylib") >+ LIB_SHARED = libdevmapper-event-lvm2snapshot.dylib >+else >+ LIB_SHARED = libdevmapper-event-lvm2snapshot.so >+endif >+ >+include $(top_srcdir)/make.tmpl >+ >+install: libdevmapper-event-lvm2snapshot.$(LIB_SUFFIX) >+ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ >+ $(libdir)/$<.$(LIB_VERSION) >+ $(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$< >+ >diff -rN -u old-snapshot-dmeventd-rebased/lib/metadata/lv_manip.c new-snapshot-dmeventd-rebased/lib/metadata/lv_manip.c >--- old-snapshot-dmeventd-rebased/lib/metadata/lv_manip.c 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/lib/metadata/lv_manip.c 2007-12-10 15:15:05.917531023 +0100 >@@ -1855,6 +1855,12 @@ > if (!archive(vg)) > return 0; > >+/* FIXME: ugly hack, cannot call in vg_remove_snapshot, because it is deactivated already */ >+#ifdef DMEVENTD >+ if (lv_is_cow(lv)) >+ monitor_dev_for_events(cmd, lv->snapshot->lv, 0); >+#endif >+ > /* FIXME Snapshot commit out of sequence if it fails after here? */ > if (!deactivate_lv(cmd, lv)) { > log_error("Unable to deactivate logical volume \"%s\"", >diff -rN -u old-snapshot-dmeventd-rebased/lib/metadata/snapshot_manip.c new-snapshot-dmeventd-rebased/lib/metadata/snapshot_manip.c >--- old-snapshot-dmeventd-rebased/lib/metadata/snapshot_manip.c 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/lib/metadata/snapshot_manip.c 2007-12-10 15:15:05.917531023 +0100 >@@ -17,6 +17,8 @@ > #include "metadata.h" > #include "toolcontext.h" > #include "lv_alloc.h" >+#include "activate.h" >+#include "segtype.h" > > int lv_is_origin(const struct logical_volume *lv) > { >@@ -93,7 +95,6 @@ > cow->snapshot = seg; > > cow->status &= ~VISIBLE_LV; >- > list_add(&origin->snapshot_segs, &seg->origin_list); > > return 1; >diff -rN -u old-snapshot-dmeventd-rebased/lib/snapshot/snapshot.c new-snapshot-dmeventd-rebased/lib/snapshot/snapshot.c >--- old-snapshot-dmeventd-rebased/lib/snapshot/snapshot.c 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/lib/snapshot/snapshot.c 2007-12-10 15:15:05.917531023 +0100 >@@ -21,6 +21,10 @@ > #include "config.h" > #include "activate.h" > #include "str_list.h" >+#ifdef DMEVENTD >+# include "sharedlib.h" >+# include <libdevmapper-event.h> >+#endif > > static const char *_snap_name(const struct lv_segment *seg) > { >@@ -125,6 +129,133 @@ > > return _snap_present; > } >+ >+#ifdef DMEVENTD >+static int _get_snapshot_dso_path(struct cmd_context *cmd, char **dso) >+{ >+ char *path; >+ const char *libpath; >+ >+ if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) { >+ log_error("Failed to allocate dmeventd library path."); >+ return 0; >+ } >+ >+ libpath = find_config_tree_str(cmd, "dmeventd/snapshot_library", NULL); >+ if (!libpath) >+ return 0; >+ >+ get_shared_library_path(cmd, libpath, path, PATH_MAX); >+ >+ *dso = path; >+ >+ return 1; >+} >+ >+static struct dm_event_handler *_create_dm_event_handler(const char *dmname, >+ const char *dso, >+ const int timeout, >+ enum dm_event_mask mask) >+{ >+ struct dm_event_handler *dmevh; >+ >+ if (!(dmevh = dm_event_handler_create())) >+ return_0; >+ >+ if (dm_event_handler_set_dso(dmevh, dso)) >+ goto fail; >+ >+ if (dm_event_handler_set_dev_name(dmevh, dmname)) >+ goto fail; >+ >+ dm_event_handler_set_timeout(dmevh, timeout); >+ dm_event_handler_set_event_mask(dmevh, mask); >+ return dmevh; >+ >+fail: >+ dm_event_handler_destroy(dmevh); >+ return NULL; >+} >+ >+static int _target_registered(struct lv_segment *seg, int *pending) >+{ >+ char *dso, *name; >+ struct logical_volume *lv; >+ struct volume_group *vg; >+ enum dm_event_mask evmask = 0; >+ struct dm_event_handler *dmevh; >+ >+ lv = seg->lv; >+ vg = lv->vg; >+ >+ *pending = 0; >+ if (!_get_snapshot_dso_path(vg->cmd, &dso)) >+ return_0; >+ >+ if (!(name = build_dm_name(vg->cmd->mem, vg->name, seg->cow->name, NULL))) >+ return_0; >+ >+ if (!(dmevh = _create_dm_event_handler(name, dso, 0, DM_EVENT_ALL_ERRORS))) >+ return_0; >+ >+ if (dm_event_get_registered_device(dmevh, 0)) { >+ dm_event_handler_destroy(dmevh); >+ return 0; >+ } >+ >+ evmask = dm_event_handler_get_event_mask(dmevh); >+ if (evmask & DM_EVENT_REGISTRATION_PENDING) { >+ *pending = 1; >+ evmask &= ~DM_EVENT_REGISTRATION_PENDING; >+ } >+ >+ dm_event_handler_destroy(dmevh); >+ >+ return evmask; >+} >+ >+/* FIXME This gets run while suspended and performs banned operations. */ >+static int _target_set_events(struct lv_segment *seg, int events, int set) >+{ >+ char *dso, *name; >+ struct volume_group *vg = seg->lv->vg; >+ struct dm_event_handler *dmevh; >+ int r; >+ >+ if (!_get_snapshot_dso_path(vg->cmd, &dso)) >+ return_0; >+ >+ if (!(name = build_dm_name(vg->cmd->mem, vg->name, seg->cow->name, NULL))) >+ return_0; >+ >+ /* FIXME: make timeout configurable */ >+ if (!(dmevh = _create_dm_event_handler(name, dso, 10, >+ DM_EVENT_ALL_ERRORS|DM_EVENT_TIMEOUT))) >+ return_0; >+ >+ r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh); >+ dm_event_handler_destroy(dmevh); >+ if (!r) >+ return_0; >+ >+ log_info("%s %s for events", set ? "Registered" : "Unregistered", name); >+ >+ return 1; >+} >+ >+static int _target_register_events(struct lv_segment *seg, >+ int events) >+{ >+ return _target_set_events(seg, events, 1); >+} >+ >+static int _target_unregister_events(struct lv_segment *seg, >+ int events) >+{ >+ return _target_set_events(seg, events, 0); >+} >+ >+#endif /* DMEVENTD */ > #endif > > static int _snap_modules_needed(struct dm_pool *mem, >@@ -151,6 +282,11 @@ > #ifdef DEVMAPPER_SUPPORT > .target_percent = _snap_target_percent, > .target_present = _snap_target_present, >+#ifdef DMEVENTD >+ .target_monitored = _target_registered, >+ .target_monitor_events = _target_register_events, >+ .target_unmonitor_events = _target_unregister_events, >+#endif > #endif > .modules_needed = _snap_modules_needed, > .destroy = _snap_destroy, >@@ -164,6 +300,7 @@ > #endif > { > struct segment_type *segtype = dm_malloc(sizeof(*segtype)); >+ char *dso; > > if (!segtype) { > stack; >@@ -176,6 +313,11 @@ > segtype->private = NULL; > segtype->flags = SEG_SNAPSHOT; > >+/* FIXME: SEG_MONITORED must depend on lvm.conf setting of dmeventd library */ >+#ifdef DMEVENTD >+ if (_get_snapshot_dso_path(cmd, &dso)) >+ segtype->flags |= SEG_MONITORED; >+#endif > log_very_verbose("Initialised segtype: %s", segtype->name); > > return segtype; >diff -rN -u old-snapshot-dmeventd-rebased/tools/lvconvert.c new-snapshot-dmeventd-rebased/tools/lvconvert.c >--- old-snapshot-dmeventd-rebased/tools/lvconvert.c 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/tools/lvconvert.c 2007-12-10 15:15:06.417801356 +0100 >@@ -544,6 +544,11 @@ > > log_print("Logical volume %s converted to snapshot.", lv->name); > >+/* FIXME: this is ugly hack */ >+#ifdef DMEVENTD >+ monitor_dev_for_events(cmd, lv->snapshot->lv, 1); >+#endif >+ > return 1; > } > >diff -rN -u old-snapshot-dmeventd-rebased/tools/lvcreate.c new-snapshot-dmeventd-rebased/tools/lvcreate.c >--- old-snapshot-dmeventd-rebased/tools/lvcreate.c 2007-12-10 15:15:05.917531023 +0100 >+++ new-snapshot-dmeventd-rebased/tools/lvcreate.c 2007-12-10 15:15:05.917531023 +0100 >@@ -877,6 +877,10 @@ > log_error("Problem reactivating origin %s", org->name); > return 0; > } >+/* FIXME: this is ugly hack */ >+#ifdef DMEVENTD >+ monitor_dev_for_events(cmd, lv->snapshot->lv, 1); >+#endif > } > /* FIXME out of sequence */ > backup(vg); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 178979
:
146727
| 282811