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

dmeventd: add local mempool for raid and mirror

Using local mempools allows to drop locks when such memory is needed.
This commit is contained in:
Zdenek Kabelac 2015-10-13 11:28:57 +02:00
parent a11cd2ca2d
commit 49e11102c7
3 changed files with 62 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.110 - Version 1.02.110 -
====================================== ======================================
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.
Convert dmeventd to use common logging macro system from libdm. Convert dmeventd to use common logging macro system from libdm.

View File

@ -23,6 +23,12 @@
#define ME_INSYNC 1 #define ME_INSYNC 1
#define ME_FAILURE 2 #define ME_FAILURE 2
struct dso_state {
struct dm_pool *mem;
char cmd_lvscan[512];
char cmd_lvconvert[512];
};
DM_EVENT_LOG_FN("mirr") DM_EVENT_LOG_FN("mirr")
static int _process_status_code(const char status_code, const char *dev_name, 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)), int minor __attribute__((unused)),
void **user) void **user)
{ {
if (!dmeventd_lvm2_init()) struct dso_state *state;
return 0;
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); log_info("Monitoring mirror device %s for events.", device);
return 1; return 1;
bad:
log_error("Failed to monitor mirror %s.", device);
return 0;
} }
int unregister_device(const char *device, int unregister_device(const char *device,
@ -231,9 +258,11 @@ int unregister_device(const char *device,
int minor __attribute__((unused)), int minor __attribute__((unused)),
void **user) void **user)
{ {
struct dso_state *state = *user;
dmeventd_lvm2_exit_with_pool(state);
log_info("No longer monitoring mirror device %s for events.", log_info("No longer monitoring mirror device %s for events.",
device); device);
dmeventd_lvm2_exit();
return 1; return 1;
} }

View File

@ -16,6 +16,13 @@
#include "dmeventd_lvm.h" #include "dmeventd_lvm.h"
#include "libdevmapper-event.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") DM_EVENT_LOG_FN("raid")
/* FIXME Reformat to 80 char lines. */ /* FIXME Reformat to 80 char lines. */
@ -154,12 +161,29 @@ int register_device(const char *device,
int minor __attribute__((unused)), int minor __attribute__((unused)),
void **user) void **user)
{ {
if (!dmeventd_lvm2_init()) struct dso_state *state;
return 0;
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); log_info("Monitoring RAID device %s for events.", device);
return 1; return 1;
bad:
log_error("Failed to monitor RAID %s.", device);
return 0;
} }
int unregister_device(const char *device, int unregister_device(const char *device,
@ -168,9 +192,11 @@ int unregister_device(const char *device,
int minor __attribute__((unused)), int minor __attribute__((unused)),
void **user) void **user)
{ {
struct dso_state *state = *user;
dmeventd_lvm2_exit_with_pool(state);
log_info("No longer monitoring RAID device %s for events.", log_info("No longer monitoring RAID device %s for events.",
device); device);
dmeventd_lvm2_exit();
return 1; return 1;
} }