master - tests: start logging dmeventd output
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c4cc5eabfe722d...
Commit: c4cc5eabfe722daf88d19b60d58c616c31e57edd
Parent: 8cc21354c2b4cb58223950b7e089eb28e602f0e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 09:44:08 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:21 2015 +0200
tests: start logging dmeventd output
Log dmeventd output from test - keep output logging in test
and avoid sending messages to syslog.
---
test/lib/aux.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 56316f7..8a25d87 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -70,7 +70,7 @@ prepare_dmeventd() {
local run_valgrind=
test "${LVM_VALGRIND_DMEVENTD:-0}" -eq 0 || run_valgrind="run_valgrind"
- LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -f "$@" &
+ LVM_LOG_FILE_EPOCH=DMEVENTD $run_valgrind dmeventd -fddddl "$@" >debug.log_DMEVENTD_out 2>&1 &
echo $! > LOCAL_DMEVENTD
# FIXME wait for pipe in /var/run instead
8 years, 6 months
master - tests: better regex check
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8cc21354c2b4cb...
Commit: 8cc21354c2b4cb58223950b7e089eb28e602f0e8
Parent: 2cb1f6eafeb72dcd49a7ed941d9c5400540284fa
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 9 21:30:37 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:20 2015 +0200
tests: better regex check
Enhance check for matching prefix.
---
test/lib/inittest.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 4ed8d20..28bc4e8 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -30,7 +30,7 @@ COMMON_PREFIX="LVMTEST"
PREFIX="${COMMON_PREFIX}$$"
# Check we are not conflickting with some exiting setup
-dmsetup table | not grep "$PREFIX" || die "DM table already has devices with prefix $PREFIX!"
+dmsetup table | not grep "${PREFIX}[^0-9]" || die "DM table already has devices with prefix $PREFIX!"
if test -z "$LVM_TEST_DIR"; then LVM_TEST_DIR=$TMPDIR; fi
TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-/tmp}" "$PREFIX.XXXXXXXXXX") || \
8 years, 6 months
master - tests: show status in in_sync
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2cb1f6eafeb72d...
Commit: 2cb1f6eafeb72dcd49a7ed941d9c5400540284fa
Parent: 93229184066a9b7726e3b572bca3f612ed2815fb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 7 15:07:15 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:20 2015 +0200
tests: show status in in_sync
Make visible actual status line when returing 'raid' is in sync.
Useful to prove when kernel is wrong.
---
test/lib/check.sh | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index b47bc8b..74a6eb6 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -189,16 +189,17 @@ in_sync() {
local lvm_name="$1/$2"
local dm_name=$(echo $lvm_name | sed s:-:--: | sed s:/:-:)
- if ! a=(`dmsetup status $dm_name`); then
+ a=( $(dmsetup status $dm_name) ) || \
die "Unable to get sync status of $1"
- elif [ ${a[2]} = "snapshot-origin" ]; then
- if ! a=(`dmsetup status ${dm_name}-real`); then
+
+ if [ ${a[2]} = "snapshot-origin" ]; then
+ a=( $(dmsetup status ${dm_name}-real) ) || \
die "Unable to get sync status of $1"
- fi
snap=": under snapshot"
fi
- if [ ${a[2]} = "raid" ]; then
+ case ${a[2]} in
+ "raid")
# 6th argument is the sync ratio for RAID
idx=6
type=${a[3]}
@@ -206,13 +207,16 @@ in_sync() {
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
- elif [ ${a[2]} = "mirror" ]; then
+ ;;
+ "mirror")
# 4th Arg tells us how far to the sync ratio
idx=$((${a[3]} + 4))
type=${a[2]}
- else
+ ;;
+ *)
die "Unable to get sync ratio for target type '${a[2]}'"
- fi
+ ;;
+ esac
b=( $(echo ${a[$idx]} | sed s:/:' ':) )
@@ -221,11 +225,10 @@ in_sync() {
return 1
fi
- if [[ ${a[$(($idx - 1))]} =~ a ]]; then
+ [[ ${a[$(($idx - 1))]} =~ a ]] && \
die "$lvm_name ($type$snap) in-sync, but 'a' characters in health status"
- fi
- echo "$lvm_name ($type$snap) is in-sync"
+ echo "$lvm_name ($type$snap) is in-sync \"${a[@]}\""
}
active() {
8 years, 6 months
master - makefiles: src dirs have depth 5
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=93229184066a9b...
Commit: 93229184066a9b7726e3b572bca3f612ed2815fb
Parent: 83f00e91567d387caf02da9cd3791c3fef85c80d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 12 00:10:37 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:20 2015 +0200
makefiles: src dirs have depth 5
For tags generation scan depth 5.
---
Makefile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 68fbc79..e4d9937 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -234,7 +234,7 @@ ifneq ($(shell which ctags),)
.PHONY: tags
tags:
test -z "$(shell find $(top_srcdir) -type f -name '*.[ch]' -newer tags 2>/dev/null | head -1)" || $(RM) tags
- test -f tags || find $(top_srcdir) -maxdepth 4 -type f -name '*.[ch]' -exec ctags -a '{}' +
+ test -f tags || find $(top_srcdir) -maxdepth 5 -type f -name '*.[ch]' -exec ctags -a '{}' +
CLEAN_TARGETS += tags
endif
8 years, 6 months
master - makefiles: drop explicit linking
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=83f00e91567d38...
Commit: 83f00e91567d387caf02da9cd3791c3fef85c80d
Parent: 4f9e7f692ea1dc6370ee9978b34c4255d28b3c3c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 9 21:33:59 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:20 2015 +0200
makefiles: drop explicit linking
Nothing in /sscripts needs devmapper-event library so drop its linking.
---
scripts/Makefile.in | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index dabe2ee..f7f672d 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -28,11 +28,6 @@ ifeq ("@APPLIB@", "yes")
LVMLIBS = @LVM2APP_LIB@ -ldevmapper
endif
-ifeq ("@DMEVENTD@", "yes")
- DEPLIBS += $(top_builddir)/daemons/dmeventd/libdevmapper-event.so
- LVMLIBS += -ldevmapper-event
-endif
-
LVM_SCRIPTS = lvmdump.sh lvmconf.sh vgimportclone.sh
DM_SCRIPTS =
8 years, 6 months
master - makefiles: generate Local
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4f9e7f692ea1dc...
Commit: 4f9e7f692ea1dc6370ee9978b34c4255d28b3c3c
Parent: 4b586ad3c26be5eaaeff38d767d5f2421ee1151b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 9 21:31:41 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:20 2015 +0200
makefiles: generate Local
Use same exported symbols list for other generated symfile
as it appeared to be the right way for libdm.
Local {
local:
*;
};
---
make.tmpl.in | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index 1217278..f1d4fad 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -497,7 +497,9 @@ EXPORTED_SYMBOLS := $(wildcard $(srcdir)/.exported_symbols.Base $(srcdir)/.expor
ifeq (,$(firstword $(EXPORTED_SYMBOLS)))
set -e; (echo "Base {"; echo " global:";\
$(SED) "s/^/ /;s/$$/;/" $<;\
- echo " local:"; echo " *;"; echo "};") > $@
+ echo "};";\
+ echo "Local {"; echo " local:"; echo " *;"; echo "};";\
+ ) > $@
else
set -e;\
R=$$(sort $^ | uniq -u);\
8 years, 6 months
master - dmeventd: rework raid plugin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b586ad3c26be5...
Commit: 4b586ad3c26be5eaaeff38d767d5f2421ee1151b
Parent: 256e432e78b720b929a285f5809b1d875b01861a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 11:37:14 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:19 2015 +0200
dmeventd: rework raid plugin
Switch to per-thread mem-pool and lock only for lvm2 calls.
Use libdm parser for raid status line.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 116 ++++++-------------------
2 files changed, 29 insertions(+), 88 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 30ce2cd..dffcd34 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Use libdm status parsing and local mem raid dmeventd plugin.
Use local mem pool and lock only lvm2 execution for mirror dmeventd plugin.
Lock protect only lvm2 execution for snapshot and thin dmeventd plugin.
Use local mempool for raid and mirror plugins.
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 714832b..f00ffa4 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -27,112 +27,54 @@ DM_EVENT_LOG_FN("raid")
/* FIXME Reformat to 80 char lines. */
-/*
- * run_repair is a close copy to
- * plugins/mirror/dmeventd_mirror.c:_remove_failed_devices()
- */
-static int run_repair(const char *device)
+static int _process_raid_event(struct dso_state *state, char *params, const char *device)
{
- int r;
-#define CMD_SIZE 256 /* FIXME Use system restriction */
- char cmd_str[CMD_SIZE];
-
- if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
- "lvscan --cache", device))
- return -1;
-
- r = dmeventd_lvm2_run(cmd_str);
-
- if (!r)
- log_info("Re-scan of RAID device %s failed.", device);
-
- if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
- "lvconvert --config devices{ignore_suspended_devices=1} "
- "--repair --use-policies", device))
- return -1;
-
- /* if repair goes OK, report success even if lvscan has failed */
- r = dmeventd_lvm2_run(cmd_str);
-
- if (!r)
- log_info("Repair of RAID device %s failed.", device);
-
- return (r) ? 0 : -1;
-}
+ struct dm_status_raid *status;
+ const char *d;
-static int _process_raid_event(char *params, const char *device)
-{
- int i, n, failure = 0;
- char *p, *a[4];
- char *raid_type;
- char *num_devices;
- char *health_chars;
- char *resync_ratio;
-
- /*
- * RAID parms: <raid_type> <#raid_disks> \
- * <health chars> <resync ratio>
- */
- if (!dm_split_words(params, 4, 0, a)) {
+ if (!dm_get_status_raid(state->mem, params, &status)) {
log_error("Failed to process status line for %s.", device);
- return -EINVAL;
- }
- raid_type = a[0];
- num_devices = a[1];
- health_chars = a[2];
- resync_ratio = a[3];
-
- if (!(n = atoi(num_devices))) {
- log_error("Failed to parse number of devices for %s: %s.",
- device, num_devices);
- return -EINVAL;
+ return 0;
}
- for (i = 0; i < n; i++) {
- switch (health_chars[i]) {
- case 'A':
- /* Device is 'A'live and well */
- case 'a':
- /* Device is 'a'live, but not yet in-sync */
- break;
- case 'D':
- log_error("Device #%d of %s array, %s, has failed.",
- i, raid_type, device);
- failure++;
- break;
- default:
- /* Unhandled character returned from kernel */
- break;
+ if ((d = strchr(status->dev_health, 'D')) && !state->failed) {
+ log_error("Device #%d of %s array, %s, has failed.",
+ (int)(d - status->dev_health),
+ status->raid_type, device);
+
+ state->failed = 1;
+ if (!dmeventd_lvm2_run_with_lock(state->cmd_lvscan))
+ log_info("Re-scan of RAID device %s failed.", device);
+
+ /* if repair goes OK, report success even if lvscan has failed */
+ if (!dmeventd_lvm2_run_with_lock(state->cmd_lvconvert)) {
+ log_info("Repair of RAID device %s failed.", device);
+ dm_pool_free(state->mem, status);
+ return 0;
}
- if (failure)
- return run_repair(device);
+ } else {
+ state->failed = 0;
+ log_info("%s array, %s, is %s in-sync.",
+ status->raid_type, device,
+ (status->insync_regions == status->total_regions) ? "now" : "not");
}
- p = strstr(resync_ratio, "/");
- if (!p) {
- log_error("Failed to parse resync_ratio for %s: %s.",
- device, resync_ratio);
- return -EINVAL;
- }
- p[0] = '\0';
- log_info("%s array, %s, is %s in-sync.",
- raid_type, device, strcmp(resync_ratio, p+1) ? "not" : "now");
+ dm_pool_free(state->mem, status);
- return 0;
+ return 1;
}
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **user)
{
+ struct dso_state *state = *user;
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
const char *device = dm_task_get_name(dmt);
- dmeventd_lvm2_lock();
-
do {
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, ¶ms);
@@ -147,12 +89,10 @@ void process_event(struct dm_task *dmt,
continue;
}
- if (_process_raid_event(params, device))
+ if (!_process_raid_event(state, params, device))
log_error("Failed to process event for %s.",
device);
} while (next);
-
- dmeventd_lvm2_unlock();
}
int register_device(const char *device,
8 years, 6 months
master - dmeventd: less locking mirror
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=256e432e78b720...
Commit: 256e432e78b720b929a285f5809b1d875b01861a
Parent: 51ff7d5ed8a7afe4e986a08025da9ef294aea479
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 11:35:44 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:02:18 2015 +0200
dmeventd: less locking mirror
Rework mirror plugin to use per-thread mem-pool.
This allows to use locking only for lvm2 library calls.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 33 ++++++---------------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f838b98..30ce2cd 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Use local mem pool and lock only lvm2 execution for mirror dmeventd plugin.
Lock protect only lvm2 execution for snapshot and thin dmeventd plugin.
Use local mempool for raid and mirror plugins.
Reworked thread initialization for dmeventd plugins.
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index e8761d9..62ad331 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -131,47 +131,33 @@ out_parse:
return ME_IGNORE;
}
-static int _remove_failed_devices(const char *device)
+static int _remove_failed_devices(const char *cmd_lvscan, const char *cmd_lvconvert)
{
int r;
-#define CMD_SIZE 256 /* FIXME Use system restriction */
- char cmd_str[CMD_SIZE];
- if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
- "lvscan --cache", device))
- return -1;
-
- r = dmeventd_lvm2_run(cmd_str);
-
- if (!r)
- log_info("Re-scan of mirror device %s failed.", device);
-
- if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
- "lvconvert --config devices{ignore_suspended_devices=1} "
- "--repair --use-policies", device))
- return -ENAMETOOLONG; /* FIXME Replace with generic error return - reason for failure has already got logged */
+ if (!dmeventd_lvm2_run_with_lock(cmd_lvscan))
+ log_info("Re-scan of mirrored device failed.");
/* if repair goes OK, report success even if lvscan has failed */
- r = dmeventd_lvm2_run(cmd_str);
+ r = dmeventd_lvm2_run_with_lock(cmd_lvconvert);
- log_info("Repair of mirrored device %s %s.", device,
+ log_info("Repair of mirrored device %s.",
(r) ? "finished successfully" : "failed");
- return (r) ? 0 : -1;
+ return r;
}
void process_event(struct dm_task *dmt,
enum dm_event_mask event __attribute__((unused)),
void **user)
{
+ struct dso_state *state = *user;
void *next = NULL;
uint64_t start, length;
char *target_type = NULL;
char *params;
const char *device = dm_task_get_name(dmt);
- dmeventd_lvm2_lock();
-
do {
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, ¶ms);
@@ -196,7 +182,8 @@ void process_event(struct dm_task *dmt,
break;
case ME_FAILURE:
log_error("Device failure in %s.", device);
- if (_remove_failed_devices(device))
+ if (!_remove_failed_devices(state->cmd_lvscan,
+ state->cmd_lvconvert))
/* FIXME Why are all the error return codes unused? Get rid of them? */
log_error("Failed to remove faulty devices in %s.",
device);
@@ -213,8 +200,6 @@ void process_event(struct dm_task *dmt,
log_info("Unknown event received.");
}
} while (next);
-
- dmeventd_lvm2_unlock();
}
int register_device(const char *device,
8 years, 6 months
master - dmeventd: less locking for snapshot and thin
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51ff7d5ed8a7af...
Commit: 51ff7d5ed8a7afe4e986a08025da9ef294aea479
Parent: 49e11102c78ddf74bead6020fc51cae0e78e2ad2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 11:35:03 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 16:01:41 2015 +0200
dmeventd: less locking for snapshot and thin
Use lvm lock for lvm library calls.
dm functions in-use are 'thread-safe' since we use
local per-thread mem pool.
---
WHATS_NEW_DM | 1 +
.../dmeventd/plugins/snapshot/dmeventd_snapshot.c | 20 +++++++++-----------
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 7 +------
3 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 902a485..f838b98 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Lock protect only lvm2 execution for snapshot and thin dmeventd plugin.
Use local mempool for raid and mirror plugins.
Reworked thread initialization for dmeventd plugins.
Dmeventd handles snapshot overflow for now equally as invalid.
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index 56fb7c2..aebe5f9 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -80,7 +80,8 @@ static int _run(const char *cmd, ...)
static int _extend(const char *cmd)
{
- return dmeventd_lvm2_run(cmd);
+ log_debug("Extending snapshot via %s.", cmd);
+ return dmeventd_lvm2_run_with_lock(cmd);
}
static void _umount(const char *device, int major, int minor)
@@ -141,22 +142,21 @@ void process_event(struct dm_task *dmt,
if (!state->percent_check)
return;
- dmeventd_lvm2_lock();
-
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
- if (!target_type)
- goto out;
+ if (!target_type || strcmp(target_type, "snapshot")) {
+ log_error("Target %s is not snapshot.", target_type);
+ return;
+ }
if (!dm_get_status_snapshot(state->mem, params, &status))
- goto out;
+ return;
if (status->invalid || status->overflow) {
struct dm_info info;
log_error("Snapshot %s is lost.", device);
if (dm_task_get_info(dmt, &info)) {
- dmeventd_lvm2_unlock();
_umount(device, info.major, info.minor);
- return;
+ goto_out;
} /* else; too bad, but this is best-effort thing... */
}
@@ -190,9 +190,7 @@ void process_event(struct dm_task *dmt,
log_error("Failed to extend snapshot %s.", device);
}
out:
- if (status)
- dm_pool_free(state->mem, status);
- dmeventd_lvm2_unlock();
+ dm_pool_free(state->mem, status);
}
int register_device(const char *device,
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 15af254..4f08d5b 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -143,7 +143,7 @@ static int _extend(struct dso_state *state)
#if THIN_DEBUG
log_info("dmeventd executes: %s.", state->cmd_str);
#endif
- return dmeventd_lvm2_run(state->cmd_str);
+ return dmeventd_lvm2_run_with_lock(state->cmd_str);
}
static int _run(const char *cmd, ...)
@@ -224,8 +224,6 @@ static void _umount(struct dm_task *dmt, const char *device)
if (!dm_task_get_info(dmt, &data.info))
return;
- dmeventd_lvm2_unlock();
-
if (!(data.minors = dm_bitset_create(NULL, MINORS))) {
log_error("Failed to allocate bitset. Not unmounting %s.", device);
goto out;
@@ -244,7 +242,6 @@ static void _umount(struct dm_task *dmt, const char *device)
out:
if (data.minors)
dm_bitset_destroy(data.minors);
- dmeventd_lvm2_lock();
}
void process_event(struct dm_task *dmt,
@@ -265,8 +262,6 @@ void process_event(struct dm_task *dmt,
if (!state->meta_percent_check && !state->data_percent_check)
return;
#endif
- dmeventd_lvm2_lock();
-
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
if (!target_type || (strcmp(target_type, "thin-pool") != 0)) {
8 years, 6 months
master - dmeventd: add local mempool for raid and mirror
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=49e11102c78ddf...
Commit: 49e11102c78ddf74bead6020fc51cae0e78e2ad2
Parent: a11cd2ca2d4edbf16c61f8066b1f745fa2fe7d4b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 13 11:28:57 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Oct 13 15:56:23 2015 +0200
dmeventd: add local mempool for raid and mirror
Using local mempools allows to drop locks when such memory is needed.
---
WHATS_NEW_DM | 1 +
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 35 +++++++++++++++++++--
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 32 +++++++++++++++++--
3 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f041ed1..902a485 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.110 -
======================================
+ Use local mempool for raid and mirror plugins.
Reworked thread initialization for dmeventd plugins.
Dmeventd handles snapshot overflow for now equally as invalid.
Convert dmeventd to use common logging macro system from libdm.
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index d418b08..e8761d9 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -23,6 +23,12 @@
#define ME_INSYNC 1
#define ME_FAILURE 2
+struct dso_state {
+ struct dm_pool *mem;
+ char cmd_lvscan[512];
+ char cmd_lvconvert[512];
+};
+
DM_EVENT_LOG_FN("mirr")
static int _process_status_code(const char status_code, const char *dev_name,
@@ -217,12 +223,33 @@ int register_device(const char *device,
int minor __attribute__((unused)),
void **user)
{
- if (!dmeventd_lvm2_init())
- return 0;
+ struct dso_state *state;
+
+ if (!dmeventd_lvm2_init_with_pool("mirror_state", state))
+ goto_bad;
+
+ if (!dmeventd_lvm2_command(state->mem, state->cmd_lvscan, sizeof(state->cmd_lvscan),
+ "lvscan --cache", device)) {
+ dmeventd_lvm2_exit_with_pool(state);
+ goto_bad;
+ }
+
+ if (!dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert),
+ "lvconvert --config devices{ignore_suspended_devices=1} "
+ "--repair --use-policies", device)) {
+ dmeventd_lvm2_exit_with_pool(state);
+ goto_bad;
+ }
+
+ *user = state;
log_info("Monitoring mirror device %s for events.", device);
return 1;
+bad:
+ log_error("Failed to monitor mirror %s.", device);
+
+ return 0;
}
int unregister_device(const char *device,
@@ -231,9 +258,11 @@ int unregister_device(const char *device,
int minor __attribute__((unused)),
void **user)
{
+ struct dso_state *state = *user;
+
+ dmeventd_lvm2_exit_with_pool(state);
log_info("No longer monitoring mirror device %s for events.",
device);
- dmeventd_lvm2_exit();
return 1;
}
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 6522556..714832b 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -16,6 +16,13 @@
#include "dmeventd_lvm.h"
#include "libdevmapper-event.h"
+struct dso_state {
+ struct dm_pool *mem;
+ char cmd_lvscan[512];
+ char cmd_lvconvert[512];
+ int failed;
+};
+
DM_EVENT_LOG_FN("raid")
/* FIXME Reformat to 80 char lines. */
@@ -154,12 +161,29 @@ int register_device(const char *device,
int minor __attribute__((unused)),
void **user)
{
- if (!dmeventd_lvm2_init())
- return 0;
+ struct dso_state *state;
+
+ if (!dmeventd_lvm2_init_with_pool("raid_state", state))
+ goto_bad;
+
+ if (!dmeventd_lvm2_command(state->mem, state->cmd_lvscan, sizeof(state->cmd_lvscan),
+ "lvscan --cache", device) ||
+ !dmeventd_lvm2_command(state->mem, state->cmd_lvconvert, sizeof(state->cmd_lvconvert),
+ "lvconvert --config devices{ignore_suspended_devices=1} "
+ "--repair --use-policies", device)) {
+ dmeventd_lvm2_exit_with_pool(state);
+ goto_bad;
+ }
+
+ *user = state;
log_info("Monitoring RAID device %s for events.", device);
return 1;
+bad:
+ log_error("Failed to monitor RAID %s.", device);
+
+ return 0;
}
int unregister_device(const char *device,
@@ -168,9 +192,11 @@ int unregister_device(const char *device,
int minor __attribute__((unused)),
void **user)
{
+ struct dso_state *state = *user;
+
+ dmeventd_lvm2_exit_with_pool(state);
log_info("No longer monitoring RAID device %s for events.",
device);
- dmeventd_lvm2_exit();
return 1;
}
8 years, 6 months