From 0b3e4130b576c11156d6327e4cc3c9310a74c143 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Fri, 5 Aug 2016 09:03:22 +0530 Subject: feature/bitrot: Ondemand scrub option for bitrot The bitrot scrubber takes 'hourly/daily/biweekly/monthly' as the values for 'scrub-frequency'. There is no way to schedule the scrubbing when the admin wants it. Ondemand scrubbing brings in the new option 'ondemand' with which the admin can start scrubbing ondemand. It starts the scrubbing immediately. Ondemand scrubbing is successful only if the scrubber is in 'Active (Idle)' (waiting for it's next frequency cycle to start scrubbing). It is not entertained when the scrubber is in 'Paused' or already running. Here is the command line syntax. gluster volume bitrot scrub ondemand Change-Id: I84c28904367eed827a7dae8d6a535c14b28e9f4d BUG: 1366195 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/15111 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Venky Shankar --- glusterfsd/src/glusterfsd-messages.h | 4 +++- glusterfsd/src/glusterfsd-mgmt.c | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd-messages.h b/glusterfsd/src/glusterfsd-messages.h index caa999506e6..e9c28f71263 100644 --- a/glusterfsd/src/glusterfsd-messages.h +++ b/glusterfsd/src/glusterfsd-messages.h @@ -36,7 +36,7 @@ */ #define GLFS_COMP_BASE GLFS_MSGID_COMP_GLUSTERFSD -#define GLFS_NUM_MESSAGES 36 +#define GLFS_NUM_MESSAGES 37 #define GLFS_MSGID_END (GLFS_COMP_BASE + GLFS_NUM_MESSAGES + 1) /* Messaged with message IDs */ #define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages" @@ -108,6 +108,8 @@ " unserialization failed." #define glusterfsd_msg_36 (GLFS_COMP_BASE + 36), "problem in xlator " \ " loading." +#define glusterfsd_msg_37 (GLFS_COMP_BASE + 37), "failed to get dict value" + /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index 51680e68b67..294c6818819 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -669,6 +669,7 @@ glusterfs_handle_bitrot (rpcsvc_request_t *req) char xname[1024] = {0,}; glusterfs_ctx_t *ctx = NULL; glusterfs_graph_t *active = NULL; + char *scrub_opt = NULL; GF_ASSERT (req); this = THIS; @@ -722,8 +723,27 @@ glusterfs_handle_bitrot (rpcsvc_request_t *req) goto out; } - ret = xlator->notify (xlator, GF_EVENT_SCRUB_STATUS, input, - output); + ret = dict_get_str (input, "scrub-value", &scrub_opt); + if (ret) { + snprintf (msg, sizeof (msg), "Failed to get scrub value"); + gf_msg (this->name, GF_LOG_ERROR, 0, glusterfsd_msg_37); + ret = -1; + goto out; + } + + if (!strncmp (scrub_opt, "status", strlen ("status"))) { + ret = xlator->notify (xlator, GF_EVENT_SCRUB_STATUS, input, + output); + } else if (!strncmp (scrub_opt, "ondemand", strlen ("ondemand"))) { + ret = xlator->notify (xlator, GF_EVENT_SCRUB_ONDEMAND, input, + output); + if (ret == -2) { + snprintf (msg, sizeof (msg), "Scrubber is in " + "Pause/Inactive/Running state"); + ret = -1; + goto out; + } + } out: glusterfs_translator_info_response_send (req, ret, msg, output); -- cgit