summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-09-17 05:56:32 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-22 06:13:34 -0700
commit35f96c039e8961e48af46af43b6ecf7a335feb15 (patch)
treed73021e62255efd6d7d8f83820c472467409fda4 /xlators/cluster/afr/src
parentd2b7e65ec0c35c4ee16f28f449553d90fb88fa6a (diff)
cluster/afr: Add new option "data-self-heal-algorithm"
option: data-self-heal-algorithm type: string default: "full" This option allows the user to specify the algorithm to be used for data self-heal. Currently supported values are "full" and "diff". Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.c1
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-algorithm.h2
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c20
-rw-r--r--xlators/cluster/afr/src/afr.c12
-rw-r--r--xlators/cluster/afr/src/afr.h4
5 files changed, 36 insertions, 3 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.c b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
index f2d80c3e9..f6efcfa66 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.c
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.c
@@ -582,4 +582,5 @@ afr_sh_algo_diff (call_frame_t *frame, xlator_t *this)
struct afr_sh_algorithm afr_self_heal_algorithms[] = {
{.name = "full", .fn = afr_sh_algo_full},
{.name = "diff", .fn = afr_sh_algo_diff},
+ {0, 0},
};
diff --git a/xlators/cluster/afr/src/afr-self-heal-algorithm.h b/xlators/cluster/afr/src/afr-self-heal-algorithm.h
index 8998ce888..b5dba06ee 100644
--- a/xlators/cluster/afr/src/afr-self-heal-algorithm.h
+++ b/xlators/cluster/afr/src/afr-self-heal-algorithm.h
@@ -29,7 +29,7 @@ struct afr_sh_algorithm {
afr_sh_algo_fn fn;
};
-struct afr_sh_algorithm afr_self_heal_algorithms[2];
+struct afr_sh_algorithm afr_self_heal_algorithms[3];
typedef struct {
uint8_t *checksum; /* array of MD5 checksums for each child
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 4ed6071ab..576a15e06 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -476,7 +476,25 @@ afr_sh_data_trim_sinks (call_frame_t *frame, xlator_t *this)
struct afr_sh_algorithm *
afr_sh_data_pick_algo (call_frame_t *frame, xlator_t *this)
{
- return &afr_self_heal_algorithms[1]; /* full */
+ afr_private_t *priv = NULL;
+ int i = 0;
+
+ priv = this->private;
+
+ while (afr_self_heal_algorithms[i].name) {
+ if (!strcmp (priv->data_self_heal_algorithm,
+ afr_self_heal_algorithms[i].name)) {
+ goto out;
+ }
+
+ i++;
+ }
+
+ /* No match found, so fall back on "full" */
+
+ i = 0;
+out:
+ return &afr_self_heal_algorithms[i];
}
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index 6b7b007ae..5c2320715 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -2341,6 +2341,7 @@ init (xlator_t *this)
char * read_subvol = NULL;
char * fav_child = NULL;
char * self_heal = NULL;
+ char * algo = NULL;
char * change_log = NULL;
int32_t lock_server_count = 1;
@@ -2389,6 +2390,14 @@ init (xlator_t *this)
}
}
+ priv->data_self_heal_algorithm = "full";
+
+ dict_ret = dict_get_str (this->options, "data-self-heal-algorithm",
+ &algo);
+ if (dict_ret == 0) {
+ priv->data_self_heal_algorithm = strdup (algo);
+ }
+
dict_ret = dict_get_str (this->options, "metadata-self-heal",
&self_heal);
if (dict_ret == 0) {
@@ -2662,6 +2671,9 @@ struct volume_options options[] = {
{ .key = {"data-self-heal"},
.type = GF_OPTION_TYPE_BOOL
},
+ { .key = {"data-self-heal-algorithm"},
+ .type = GF_OPTION_TYPE_STR
+ },
{ .key = {"metadata-self-heal"},
.type = GF_OPTION_TYPE_BOOL
},
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index a7f980475..d80243313 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -45,7 +45,9 @@ typedef struct _afr_private {
char **pending_key;
- gf_boolean_t data_self_heal; /* on/off */
+ gf_boolean_t data_self_heal; /* on/off */
+ char * data_self_heal_algorithm; /* name of algorithm */
+
gf_boolean_t metadata_self_heal; /* on/off */
gf_boolean_t entry_self_heal; /* on/off */