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:
parent
49e11102c7
commit
51ff7d5ed8
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.110 -
|
Version 1.02.110 -
|
||||||
======================================
|
======================================
|
||||||
|
Lock protect only lvm2 execution for snapshot and thin dmeventd plugin.
|
||||||
Use local mempool for raid and mirror plugins.
|
Use local mempool for raid and mirror plugins.
|
||||||
Reworked thread initialization for dmeventd plugins.
|
Reworked thread initialization for dmeventd plugins.
|
||||||
Dmeventd handles snapshot overflow for now equally as invalid.
|
Dmeventd handles snapshot overflow for now equally as invalid.
|
||||||
|
@ -80,7 +80,8 @@ static int _run(const char *cmd, ...)
|
|||||||
|
|
||||||
static int _extend(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)
|
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)
|
if (!state->percent_check)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dmeventd_lvm2_lock();
|
|
||||||
|
|
||||||
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
||||||
if (!target_type)
|
if (!target_type || strcmp(target_type, "snapshot")) {
|
||||||
goto out;
|
log_error("Target %s is not snapshot.", target_type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dm_get_status_snapshot(state->mem, params, &status))
|
if (!dm_get_status_snapshot(state->mem, params, &status))
|
||||||
goto out;
|
return;
|
||||||
|
|
||||||
if (status->invalid || status->overflow) {
|
if (status->invalid || status->overflow) {
|
||||||
struct dm_info info;
|
struct dm_info info;
|
||||||
log_error("Snapshot %s is lost.", device);
|
log_error("Snapshot %s is lost.", device);
|
||||||
if (dm_task_get_info(dmt, &info)) {
|
if (dm_task_get_info(dmt, &info)) {
|
||||||
dmeventd_lvm2_unlock();
|
|
||||||
_umount(device, info.major, info.minor);
|
_umount(device, info.major, info.minor);
|
||||||
return;
|
goto_out;
|
||||||
} /* else; too bad, but this is best-effort thing... */
|
} /* 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);
|
log_error("Failed to extend snapshot %s.", device);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (status)
|
dm_pool_free(state->mem, status);
|
||||||
dm_pool_free(state->mem, status);
|
|
||||||
dmeventd_lvm2_unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int register_device(const char *device,
|
int register_device(const char *device,
|
||||||
|
@ -143,7 +143,7 @@ static int _extend(struct dso_state *state)
|
|||||||
#if THIN_DEBUG
|
#if THIN_DEBUG
|
||||||
log_info("dmeventd executes: %s.", state->cmd_str);
|
log_info("dmeventd executes: %s.", state->cmd_str);
|
||||||
#endif
|
#endif
|
||||||
return dmeventd_lvm2_run(state->cmd_str);
|
return dmeventd_lvm2_run_with_lock(state->cmd_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _run(const char *cmd, ...)
|
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))
|
if (!dm_task_get_info(dmt, &data.info))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dmeventd_lvm2_unlock();
|
|
||||||
|
|
||||||
if (!(data.minors = dm_bitset_create(NULL, MINORS))) {
|
if (!(data.minors = dm_bitset_create(NULL, MINORS))) {
|
||||||
log_error("Failed to allocate bitset. Not unmounting %s.", device);
|
log_error("Failed to allocate bitset. Not unmounting %s.", device);
|
||||||
goto out;
|
goto out;
|
||||||
@ -244,7 +242,6 @@ static void _umount(struct dm_task *dmt, const char *device)
|
|||||||
out:
|
out:
|
||||||
if (data.minors)
|
if (data.minors)
|
||||||
dm_bitset_destroy(data.minors);
|
dm_bitset_destroy(data.minors);
|
||||||
dmeventd_lvm2_lock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_event(struct dm_task *dmt,
|
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)
|
if (!state->meta_percent_check && !state->data_percent_check)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
dmeventd_lvm2_lock();
|
|
||||||
|
|
||||||
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
||||||
|
|
||||||
if (!target_type || (strcmp(target_type, "thin-pool") != 0)) {
|
if (!target_type || (strcmp(target_type, "thin-pool") != 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user