summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2015-10-13 11:35:03 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2015-10-13 16:01:41 +0200
commit51ff7d5ed8a7afe4e986a08025da9ef294aea479 (patch)
treefac7ab4d64be78a9c55c7a1ca170771b2244c95b
parent49e11102c78ddf74bead6020fc51cae0e78e2ad2 (diff)
downloadlvm2-51ff7d5ed8a7afe4e986a08025da9ef294aea479.tar.gz
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.
-rw-r--r--WHATS_NEW_DM1
-rw-r--r--daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c20
-rw-r--r--daemons/dmeventd/plugins/thin/dmeventd_thin.c7
3 files changed, 11 insertions, 17 deletions
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 902a48514..f838b98b7 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 56fb7c268..aebe5f9d8 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, &params);
- 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 15af254c0..4f08d5b9b 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, &params);
if (!target_type || (strcmp(target_type, "thin-pool") != 0)) {