Blame SOURCES/lvm2-2_02_181-dmeventd-rebase-to-stable-branch.patch

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