|
|
5e29a5 |
daemons/dmeventd/plugins/vdo/dmeventd_vdo.c | 39 +++++++++++++++++++----------
|
|
|
5e29a5 |
1 file changed, 26 insertions(+), 13 deletions(-)
|
|
|
5e29a5 |
|
|
|
5e29a5 |
diff --git a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
|
|
|
5e29a5 |
index d77ca79..389632c 100644
|
|
|
5e29a5 |
--- a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
|
|
|
5e29a5 |
+++ b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
|
|
|
5e29a5 |
@@ -12,10 +12,9 @@
|
|
|
5e29a5 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
5e29a5 |
*/
|
|
|
5e29a5 |
|
|
|
5e29a5 |
-#include "lib/misc/lib.h"
|
|
|
5e29a5 |
+#include "lib.h"
|
|
|
5e29a5 |
#include "dmeventd_lvm.h"
|
|
|
5e29a5 |
-#include "daemons/dmeventd/libdevmapper-event.h"
|
|
|
5e29a5 |
-#include "device_mapper/vdo/target.h"
|
|
|
5e29a5 |
+#include "libdevmapper-event.h"
|
|
|
5e29a5 |
|
|
|
5e29a5 |
#include <sys/wait.h>
|
|
|
5e29a5 |
#include <stdarg.h>
|
|
|
5e29a5 |
@@ -46,6 +45,23 @@ struct dso_state {
|
|
|
5e29a5 |
const char *name;
|
|
|
5e29a5 |
};
|
|
|
5e29a5 |
|
|
|
5e29a5 |
+struct vdo_status {
|
|
|
5e29a5 |
+ uint64_t used_blocks;
|
|
|
5e29a5 |
+ uint64_t total_blocks;
|
|
|
5e29a5 |
+};
|
|
|
5e29a5 |
+
|
|
|
5e29a5 |
+static int _vdo_status_parse(const char *params, struct vdo_status *status)
|
|
|
5e29a5 |
+{
|
|
|
5e29a5 |
+ if (sscanf(params, "%*s %*s %*s %*s %*s %" PRIu64 " %" PRIu64,
|
|
|
5e29a5 |
+ &status->used_blocks,
|
|
|
5e29a5 |
+ &status->total_blocks) < 2) {
|
|
|
5e29a5 |
+ log_error("Failed to parse vdo params: %s.", params);
|
|
|
5e29a5 |
+ return 0;
|
|
|
5e29a5 |
+ }
|
|
|
5e29a5 |
+
|
|
|
5e29a5 |
+ return 1;
|
|
|
5e29a5 |
+}
|
|
|
5e29a5 |
+
|
|
|
5e29a5 |
DM_EVENT_LOG_FN("vdo")
|
|
|
5e29a5 |
|
|
|
5e29a5 |
static int _run_command(struct dso_state *state)
|
|
|
5e29a5 |
@@ -149,7 +165,7 @@ void process_event(struct dm_task *dmt,
|
|
|
5e29a5 |
char *params;
|
|
|
5e29a5 |
int needs_policy = 0;
|
|
|
5e29a5 |
struct dm_task *new_dmt = NULL;
|
|
|
5e29a5 |
- struct dm_vdo_status_parse_result vdop = { .status = NULL };
|
|
|
5e29a5 |
+ struct vdo_status status;
|
|
|
5e29a5 |
|
|
|
5e29a5 |
#if VDO_DEBUG
|
|
|
5e29a5 |
log_debug("Watch for VDO %s:%.2f%%.", state->name,
|
|
|
5e29a5 |
@@ -195,24 +211,24 @@ void process_event(struct dm_task *dmt,
|
|
|
5e29a5 |
goto out;
|
|
|
5e29a5 |
}
|
|
|
5e29a5 |
|
|
|
5e29a5 |
- if (!dm_vdo_status_parse(state->mem, params, &vdop)) {
|
|
|
5e29a5 |
+ if (!_vdo_status_parse(params, &status)) {
|
|
|
5e29a5 |
log_error("Failed to parse status.");
|
|
|
5e29a5 |
goto out;
|
|
|
5e29a5 |
}
|
|
|
5e29a5 |
|
|
|
5e29a5 |
- state->percent = dm_make_percent(vdop.status->used_blocks,
|
|
|
5e29a5 |
- vdop.status->total_blocks);
|
|
|
5e29a5 |
+ state->percent = dm_make_percent(status.used_blocks,
|
|
|
5e29a5 |
+ status.total_blocks);
|
|
|
5e29a5 |
|
|
|
5e29a5 |
#if VDO_DEBUG
|
|
|
5e29a5 |
log_debug("VDO %s status %.2f%% " FMTu64 "/" FMTu64 ".",
|
|
|
5e29a5 |
state->name, dm_percent_to_round_float(state->percent, 2),
|
|
|
5e29a5 |
- vdop.status->used_blocks, vdop.status->total_blocks);
|
|
|
5e29a5 |
+ status.used_blocks, status.total_blocks);
|
|
|
5e29a5 |
#endif
|
|
|
5e29a5 |
|
|
|
5e29a5 |
/* VDO pool size had changed. Clear the threshold. */
|
|
|
5e29a5 |
- if (state->known_data_size != vdop.status->total_blocks) {
|
|
|
5e29a5 |
+ if (state->known_data_size != status.total_blocks) {
|
|
|
5e29a5 |
state->percent_check = CHECK_MINIMUM;
|
|
|
5e29a5 |
- state->known_data_size = vdop.status->total_blocks;
|
|
|
5e29a5 |
+ state->known_data_size = status.total_blocks;
|
|
|
5e29a5 |
state->fails = 0;
|
|
|
5e29a5 |
}
|
|
|
5e29a5 |
|
|
|
5e29a5 |
@@ -257,9 +273,6 @@ void process_event(struct dm_task *dmt,
|
|
|
5e29a5 |
if (0 && needs_policy)
|
|
|
5e29a5 |
_use_policy(dmt, state);
|
|
|
5e29a5 |
out:
|
|
|
5e29a5 |
- if (vdop.status)
|
|
|
5e29a5 |
- dm_pool_free(state->mem, vdop.status);
|
|
|
5e29a5 |
-
|
|
|
5e29a5 |
if (new_dmt)
|
|
|
5e29a5 |
dm_task_destroy(new_dmt);
|
|
|
5e29a5 |
}
|