mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-11 20:58:50 +03:00
thin: dmeventd plugin check number of failures
If plugin's lvm command execution fails too often (>10 times), there is no point to torture system more then necessary, just log and drop monitoring in this case.
This commit is contained in:
parent
b3c81d02c9
commit
099466939e
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.110 -
|
Version 1.02.110 -
|
||||||
======================================
|
======================================
|
||||||
|
Disable thin monitoring plugin when it fails too often (>10 times).
|
||||||
Fix/restore parsing of empty field '-' when processing dmeventd event.
|
Fix/restore parsing of empty field '-' when processing dmeventd event.
|
||||||
Enhance dm_tree_node_size_changed() to recognize size reduction.
|
Enhance dm_tree_node_size_changed() to recognize size reduction.
|
||||||
Support exit on idle for dmenventd (1 hour).
|
Support exit on idle for dmenventd (1 hour).
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
/* TODO - move this mountinfo code into library to be reusable */
|
/* TODO - move this mountinfo code into library to be reusable */
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -36,6 +37,8 @@
|
|||||||
|
|
||||||
#define UMOUNT_COMMAND "/bin/umount"
|
#define UMOUNT_COMMAND "/bin/umount"
|
||||||
|
|
||||||
|
#define MAX_FAILS (10)
|
||||||
|
|
||||||
#define THIN_DEBUG 0
|
#define THIN_DEBUG 0
|
||||||
|
|
||||||
struct dso_state {
|
struct dso_state {
|
||||||
@ -44,6 +47,7 @@ struct dso_state {
|
|||||||
int data_percent_check;
|
int data_percent_check;
|
||||||
uint64_t known_metadata_size;
|
uint64_t known_metadata_size;
|
||||||
uint64_t known_data_size;
|
uint64_t known_data_size;
|
||||||
|
unsigned fails;
|
||||||
char cmd_str[1024];
|
char cmd_str[1024];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -245,7 +249,9 @@ static void _use_policy(struct dm_task *dmt, struct dso_state *state)
|
|||||||
log_error("Failed to extend thin pool %s.",
|
log_error("Failed to extend thin pool %s.",
|
||||||
dm_task_get_name(dmt));
|
dm_task_get_name(dmt));
|
||||||
_umount(dmt);
|
_umount(dmt);
|
||||||
}
|
state->fails++;
|
||||||
|
} else
|
||||||
|
state->fails = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_event(struct dm_task *dmt,
|
void process_event(struct dm_task *dmt,
|
||||||
@ -270,7 +276,7 @@ void process_event(struct dm_task *dmt,
|
|||||||
if (event & DM_EVENT_DEVICE_ERROR) {
|
if (event & DM_EVENT_DEVICE_ERROR) {
|
||||||
/* Error -> no need to check and do instant resize */
|
/* Error -> no need to check and do instant resize */
|
||||||
_use_policy(dmt, state);
|
_use_policy(dmt, state);
|
||||||
return;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms);
|
||||||
@ -338,6 +344,13 @@ void process_event(struct dm_task *dmt,
|
|||||||
out:
|
out:
|
||||||
if (tps)
|
if (tps)
|
||||||
dm_pool_free(state->mem, tps);
|
dm_pool_free(state->mem, tps);
|
||||||
|
|
||||||
|
if (state->fails >= MAX_FAILS) {
|
||||||
|
log_warn("WARNING: Dropping monitoring of %s. "
|
||||||
|
"lvm2 command fails too often (%u times in raw).",
|
||||||
|
device, state->fails);
|
||||||
|
pthread_kill(pthread_self(), SIGALRM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int register_device(const char *device,
|
int register_device(const char *device,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user