1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2015-10-13 11:35:03 +02:00
parent 49e11102c7
commit 51ff7d5ed8
3 changed files with 11 additions and 17 deletions

View File

@ -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.

View File

@ -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,

View File

@ -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)) {