summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-05-14 16:41:10 +0530
committerAnand Avati <avati@redhat.com>2012-05-18 19:30:14 -0700
commit6629bab3bf3c110ce275ad184b5e358272b7593a (patch)
tree61edb6e2664413f040e3e0de4b2e56bde33c7e52
parentfb5e9b848c2dd358dc23fe56e0e95d3bfd3b9f72 (diff)
Self-heald: Enable configuring of heal poll timeout
Change-Id: I631e5bf4b3615b553b72e7ac7f490714b3b995f9 BUG: 821395 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3329 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c4
-rw-r--r--xlators/cluster/afr/src/afr.c10
-rw-r--r--xlators/cluster/afr/src/afr.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c67
4 files changed, 74 insertions, 8 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index 3a6295749b5..1a749249056 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -19,8 +19,6 @@
#include "protocol-common.h"
#include "event-history.h"
-#define AFR_POLL_TIMEOUT 600
-
typedef enum {
STOP_CRAWL_ON_SINGLE_SUBVOL = 1
} afr_crawl_flags_t;
@@ -602,7 +600,7 @@ afr_poll_self_heal (void *data)
}
if (shd->enabled && (shd->pos[child] == AFR_POS_LOCAL))
_do_self_heal_on_subvol (this, child, INDEX);
- timeout.tv_sec = AFR_POLL_TIMEOUT;
+ timeout.tv_sec = shd->timeout;
timeout.tv_usec = 0;
//notify and previous timer should be synchronized.
LOCK (&priv->lock);
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 3f102f80885..8e94d549737 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -164,6 +164,8 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("quorum-count", priv->quorum_count, options,
uint32, out);
fix_quorum_options(this,priv,qtype);
+ GF_OPTION_RECONF ("heal-timeout", priv->shd.timeout, options,
+ int32, out);
ret = 0;
out:
@@ -402,6 +404,7 @@ init (xlator_t *this)
goto out;
priv->root_inode = inode_ref (this->itable->root);
GF_OPTION_INIT ("node-uuid", priv->shd.node_uuid, str, out);
+ GF_OPTION_INIT ("heal-timeout", priv->shd.timeout, int32, out);
ret = 0;
out:
@@ -596,5 +599,12 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_STR,
.description = "Local glusterd uuid string",
},
+ { .key = {"heal-timeout"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 60,
+ .max = INT_MAX,
+ .default_value = "600",
+ .description = "Poll timeout for checking the need to self-heal"
+ },
{ .key = {NULL} },
};
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 497d82d69ce..f00a8498db4 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -96,6 +96,7 @@ typedef struct afr_self_heald_ {
eh_t *heal_failed;
eh_t *split_brain;
char *node_uuid;
+ int timeout;
} afr_self_heald_t;
typedef struct _afr_private {
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 043f6146b21..1d5241798bd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -125,6 +125,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"cluster.data-self-heal", "cluster/replicate", NULL, NULL, NO_DOC, 0 },
{"cluster.entry-self-heal", "cluster/replicate", NULL, NULL, NO_DOC, 0 },
{"cluster.self-heal-daemon", "cluster/replicate", "!self-heal-daemon" , NULL, NO_DOC, 0 },
+ {"cluster.heal-timeout", "cluster/replicate", "!heal-timeout" , NULL, NO_DOC, 0 },
{"cluster.strict-readdir", "cluster/replicate", NULL, NULL, NO_DOC, 0 },
{"cluster.self-heal-window-size", "cluster/replicate", "data-self-heal-window-size", NULL, DOC, 0},
{"cluster.data-change-log", "cluster/replicate", NULL, NULL, NO_DOC, 0 },
@@ -2535,20 +2536,35 @@ build_client_graph (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
&client_graph_builder);
}
+char *gd_shd_options[] = {
+ "!self-heal-daemon",
+ "!heal-timeout",
+ NULL
+};
+
+char*
+gd_get_matching_option (char **options, char *option)
+{
+ while (*options && strcmp (*options, option))
+ options++;
+ return *options;
+}
+
static int
shd_option_handler (volgen_graph_t *graph, struct volopt_map_entry *vme,
void *param)
{
int ret = 0;
struct volopt_map_entry new_vme = {0};
- int shd = 0;
+ char *shd_option = NULL;
- shd = !strcmp (vme->option, "!self-heal-daemon");
- if ((vme->option[0] == '!') && !shd)
+ if (vme->option[0] != '!')
+ goto out;
+ shd_option = gd_get_matching_option (gd_shd_options, vme->option);
+ if (!shd_option)
goto out;
new_vme = *vme;
- if (shd)
- new_vme.option = "self-heal-daemon";
+ new_vme.option = shd_option + 1;//option with out '!'
ret = no_filter_option_handler (graph, &new_vme, param);
out:
@@ -3415,6 +3431,26 @@ glusterd_delete_volfile (glusterd_volinfo_t *volinfo,
}
int
+validate_shdopts (glusterd_volinfo_t *volinfo,
+ dict_t *val_dict,
+ char **op_errstr)
+{
+ volgen_graph_t graph = {0,};
+ int ret = -1;
+
+ graph.errstr = op_errstr;
+
+ ret = build_shd_graph (&graph, val_dict);
+ if (!ret)
+ ret = graph_reconf_validateopt (&graph.graph, op_errstr);
+
+ volgen_graph_free (&graph);
+
+ gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+int
validate_nfsopts (glusterd_volinfo_t *volinfo,
dict_t *val_dict,
char **op_errstr)
@@ -3618,6 +3654,16 @@ glusterd_validate_globalopts (glusterd_volinfo_t *volinfo,
}
ret = validate_nfsopts (volinfo, val_dict, op_errstr);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs");
+ goto out;
+ }
+
+ ret = validate_shdopts (volinfo, val_dict, op_errstr);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald");
+ goto out;
+ }
out:
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
@@ -3667,6 +3713,17 @@ glusterd_validate_reconfopts (glusterd_volinfo_t *volinfo, dict_t *val_dict,
}
ret = validate_nfsopts (volinfo, val_dict, op_errstr);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Could not Validate nfs");
+ goto out;
+ }
+
+
+ ret = validate_shdopts (volinfo, val_dict, op_errstr);
+ if (ret) {
+ gf_log ("", GF_LOG_DEBUG, "Could not Validate self-heald");
+ goto out;
+ }
out: