From 3a683040b602e9c981e9fb2beb28dc20d802ef10 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 17 Aug 2016 19:52:29 +0530 Subject: [PATCH 47/86] eventsapi: Bitrot events Following Bitrot Events are added BITROT_ENABLE/BITROT_DISABLE { "nodeid": NODEID, "ts": TIMESTAMP, "event": EVENT_TYPE, "message": { "name": VOLUME_NAME, } } BITROT_SCRUB_THROTTLE/BITROT_SCRUB_FREQ/BITROT_SCRUB { "nodeid": NODEID, "ts": TIMESTAMP, "event": EVENT_TYPE, "message": { "name": VOLUME_NAME, "value": OPTION_VALUE } } EVENT_BITROT_BAD_FILE { "nodeid": NODEID, "ts": TIMESTAMP, "event": EVENT_TYPE, "message": { "gfid": GFID_OF_FILE, "brick": BRICK_ROOT, "path": FILE_PATH_FROM_BRICK_ROOT (if available) } } >Reviewed-on: http://review.gluster.org/15190 >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >Reviewed-by: Atin Mukherjee >CentOS-regression: Gluster Build System >Reviewed-by: Aravinda VK Change-Id: I8c37b0e9db9f4f0f3d05d8f78b5521c7db0e2237 BUG: 1361170 Signed-off-by: Kotresh HR Reviewed-on: https://code.engineering.redhat.com/gerrit/84792 Reviewed-by: Milind Changire Reviewed-by: Aravinda Vishwanathapura Krishna Murthy Reviewed-by: Atin Mukherjee Tested-by: Atin Mukherjee --- cli/src/cli-cmd-volume.c | 64 +++++++++++++++++++++ events/eventskeygen.py | 7 ++ xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 2 + 3 files changed, 73 insertions(+), 0 deletions(-) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 3a7c9ed..0ea461e 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1519,6 +1519,13 @@ cli_cmd_bitrot_cbk (struct cli_state *state, struct cli_cmd_word *word, cli_local_t *local = NULL; rpc_clnt_procedure_t *proc = NULL; int sent = 0; +#if (USE_EVENTS) + int cmd_type = -1; + int ret1 = -1; + int event_type = -1; + char *tmp = NULL; + char *events_str = NULL; +#endif ret = cli_cmd_bitrot_parse (words, wordcount, &options); if (ret < 0) { @@ -1554,6 +1561,63 @@ out: } +#if (USE_EVENTS) + if (ret == 0) { + ret1 = dict_get_int32 (options, "type", &cmd_type); + if (ret1) + cmd_type = -1; + else { + ret1 = dict_get_str (options, "volname", &tmp); + if (ret1) + tmp = ""; + gf_asprintf (&events_str, "name=%s", tmp); + } + + switch (cmd_type) { + case GF_BITROT_OPTION_TYPE_ENABLE: + event_type = EVENT_BITROT_ENABLE; + break; + case GF_BITROT_OPTION_TYPE_DISABLE: + event_type = EVENT_BITROT_DISABLE; + break; + case GF_BITROT_OPTION_TYPE_SCRUB_THROTTLE: + event_type = EVENT_BITROT_SCRUB_THROTTLE; + ret1 = dict_get_str (options, "scrub-throttle-value", + &tmp); + if (ret1) + tmp = ""; + gf_asprintf (&events_str, "%s;value=%s", events_str, + tmp); + break; + case GF_BITROT_OPTION_TYPE_SCRUB_FREQ: + event_type = EVENT_BITROT_SCRUB_FREQ; + ret1 = dict_get_str (options, "scrub-frequency-value", + &tmp); + if (ret1) + tmp = ""; + gf_asprintf (&events_str, "%s;value=%s", events_str, + tmp); + break; + case GF_BITROT_OPTION_TYPE_SCRUB: + event_type = EVENT_BITROT_SCRUB_OPTION; + ret1 = dict_get_str (options, "scrub-value", &tmp); + if (ret1) + tmp = ""; + gf_asprintf (&events_str, "%s;value=%s", events_str, + tmp); + break; + default: + break; + } + + if (event_type > -1) + gf_event (event_type, "%s", events_str); + + if (events_str) + GF_FREE (events_str); + } +#endif + CLI_STACK_DESTROY (frame); return ret; diff --git a/events/eventskeygen.py b/events/eventskeygen.py index 468c795..cac8b7e 100644 --- a/events/eventskeygen.py +++ b/events/eventskeygen.py @@ -39,6 +39,13 @@ keys = ( "EVENT_GEOREP_DELETE", "EVENT_GEOREP_CONFIG_SET", "EVENT_GEOREP_CONFIG_RESET", + + "EVENT_BITROT_ENABLE", + "EVENT_BITROT_DISABLE", + "EVENT_BITROT_SCRUB_THROTTLE", + "EVENT_BITROT_SCRUB_FREQ", + "EVENT_BITROT_SCRUB_OPTION", + "EVENT_BITROT_BAD_FILE", ) LAST_EVENT = "EVENT_LAST" diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c index abf8dcf..265fe60 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -262,6 +262,8 @@ bitd_compare_ckum (xlator_t *this, gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_MARK_CORRUPTED, "Marking" " %s [GFID: %s | Brick: %s] as corrupted..", loc->path, uuid_utoa (linked_inode->gfid), child->brick_path); + gf_event (EVENT_BITROT_BAD_FILE, "gfid=%s;path=%s;brick=%s", + uuid_utoa (linked_inode->gfid), loc->path, child->brick_path); ret = syncop_fsetxattr (child->xl, fd, xattr, 0, NULL, NULL); if (ret) gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_MARK_BAD_FILE, -- 1.7.1