mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-20 18:09:23 +03:00
dmeventd: rebase to stable branch
Some minimal set of changes to make vdo plugin compilable in stable branch: Use older headers. Implement simple vdo status parser to only resolve use-percentage.
This commit is contained in:
parent
4ed9b07380
commit
f7645995da
@ -12,10 +12,9 @@
|
|||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib/misc/lib.h"
|
#include "lib.h"
|
||||||
#include "dmeventd_lvm.h"
|
#include "dmeventd_lvm.h"
|
||||||
#include "daemons/dmeventd/libdevmapper-event.h"
|
#include "libdevmapper-event.h"
|
||||||
#include "device_mapper/vdo/target.h"
|
|
||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -46,6 +45,23 @@ struct dso_state {
|
|||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct vdo_status {
|
||||||
|
uint64_t used_blocks;
|
||||||
|
uint64_t total_blocks;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int _vdo_status_parse(const char *params, struct vdo_status *status)
|
||||||
|
{
|
||||||
|
if (sscanf(params, "%*s %*s %*s %*s %*s %" PRIu64 " %" PRIu64,
|
||||||
|
&status->used_blocks,
|
||||||
|
&status->total_blocks) < 2) {
|
||||||
|
log_error("Failed to parse vdo params: %s.", params);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
DM_EVENT_LOG_FN("vdo")
|
DM_EVENT_LOG_FN("vdo")
|
||||||
|
|
||||||
static int _run_command(struct dso_state *state)
|
static int _run_command(struct dso_state *state)
|
||||||
@ -149,7 +165,7 @@ void process_event(struct dm_task *dmt,
|
|||||||
char *params;
|
char *params;
|
||||||
int needs_policy = 0;
|
int needs_policy = 0;
|
||||||
struct dm_task *new_dmt = NULL;
|
struct dm_task *new_dmt = NULL;
|
||||||
struct dm_vdo_status_parse_result vdop = { .status = NULL };
|
struct vdo_status status;
|
||||||
|
|
||||||
#if VDO_DEBUG
|
#if VDO_DEBUG
|
||||||
log_debug("Watch for VDO %s:%.2f%%.", state->name,
|
log_debug("Watch for VDO %s:%.2f%%.", state->name,
|
||||||
@ -195,24 +211,24 @@ void process_event(struct dm_task *dmt,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dm_vdo_status_parse(state->mem, params, &vdop)) {
|
if (!_vdo_status_parse(params, &status)) {
|
||||||
log_error("Failed to parse status.");
|
log_error("Failed to parse status.");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->percent = dm_make_percent(vdop.status->used_blocks,
|
state->percent = dm_make_percent(status.used_blocks,
|
||||||
vdop.status->total_blocks);
|
status.total_blocks);
|
||||||
|
|
||||||
#if VDO_DEBUG
|
#if VDO_DEBUG
|
||||||
log_debug("VDO %s status %.2f%% " FMTu64 "/" FMTu64 ".",
|
log_debug("VDO %s status %.2f%% " FMTu64 "/" FMTu64 ".",
|
||||||
state->name, dm_percent_to_round_float(state->percent, 2),
|
state->name, dm_percent_to_round_float(state->percent, 2),
|
||||||
vdop.status->used_blocks, vdop.status->total_blocks);
|
status.used_blocks, status.total_blocks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* VDO pool size had changed. Clear the threshold. */
|
/* VDO pool size had changed. Clear the threshold. */
|
||||||
if (state->known_data_size != vdop.status->total_blocks) {
|
if (state->known_data_size != status.total_blocks) {
|
||||||
state->percent_check = CHECK_MINIMUM;
|
state->percent_check = CHECK_MINIMUM;
|
||||||
state->known_data_size = vdop.status->total_blocks;
|
state->known_data_size = status.total_blocks;
|
||||||
state->fails = 0;
|
state->fails = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,9 +273,6 @@ void process_event(struct dm_task *dmt,
|
|||||||
if (0 && needs_policy)
|
if (0 && needs_policy)
|
||||||
_use_policy(dmt, state);
|
_use_policy(dmt, state);
|
||||||
out:
|
out:
|
||||||
if (vdop.status)
|
|
||||||
dm_pool_free(state->mem, vdop.status);
|
|
||||||
|
|
||||||
if (new_dmt)
|
if (new_dmt)
|
||||||
dm_task_destroy(new_dmt);
|
dm_task_destroy(new_dmt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user