summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-12-02 15:35:09 +0530
committerAmar Tumballi <amarts@redhat.com>2018-12-17 17:19:00 +0000
commitc228f0c2d94c028619088c07b66f88488f7c3335 (patch)
treec312f100b984ae36ec2d4e865194743a47f44769 /xlators/cluster/afr
parentbdcb2d8497d77ff28cb031ae3992eb7ea0c90486 (diff)
Don't depend on string options to be valid always
updates bz#1650403 Change-Id: Ib5a11e691599ce4bd93c1ed5aca6060592893961 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r--xlators/cluster/afr/src/afr-common.c22
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c7
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c13
-rw-r--r--xlators/cluster/afr/src/afr.c43
-rw-r--r--xlators/cluster/afr/src/afr.h12
5 files changed, 56 insertions, 41 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 5656cec..4074081 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -1156,18 +1156,12 @@ ret:
}
gf_boolean_t
-afr_selfheal_enabled(xlator_t *this)
+afr_selfheal_enabled(const xlator_t *this)
{
- afr_private_t *priv = NULL;
- gf_boolean_t data = _gf_false;
- int ret = 0;
-
- priv = this->private;
-
- ret = gf_string2boolean(priv->data_self_heal, &data);
- GF_ASSERT(!ret);
+ const afr_private_t *priv = this->private;
- return data || priv->metadata_self_heal || priv->entry_self_heal;
+ return priv->data_self_heal || priv->metadata_self_heal ||
+ priv->entry_self_heal;
}
int
@@ -4876,7 +4870,7 @@ afr_priv_dump(xlator_t *this)
sprintf(key, "child_latency[%d]", i);
gf_proc_dump_write(key, "%" PRId64, priv->child_latency[i]);
}
- gf_proc_dump_write("data_self_heal", "%s", priv->data_self_heal);
+ gf_proc_dump_write("data_self_heal", "%d", priv->data_self_heal);
gf_proc_dump_write("metadata_self_heal", "%d", priv->metadata_self_heal);
gf_proc_dump_write("entry_self_heal", "%d", priv->entry_self_heal);
gf_proc_dump_write("read_child", "%d", priv->read_child);
@@ -6020,8 +6014,10 @@ afr_selfheal_locked_entry_inspect(call_frame_t *frame, xlator_t *this,
gf_boolean_t granular_locks = _gf_false;
priv = this->private;
- if (strcmp("granular", priv->locking_scheme) == 0)
- granular_locks = _gf_true;
+ granular_locks = priv->granular_locks; /*Assign to local variable so that
+ reconfigure doesn't change this
+ value between locking and unlocking
+ below*/
locked_on = alloca0(priv->child_count);
data_lock = alloca0(priv->child_count);
sources = alloca0(priv->child_count);
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index c137bf8..071ed1c 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -2469,14 +2469,9 @@ afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid)
gf_boolean_t metadata_selfheal = _gf_false;
gf_boolean_t entry_selfheal = _gf_false;
afr_private_t *priv = NULL;
- gf_boolean_t dataheal_enabled = _gf_false;
priv = this->private;
- ret = gf_string2boolean(priv->data_self_heal, &dataheal_enabled);
- if (ret)
- goto out;
-
ret = afr_selfheal_unlocked_inspect(frame, this, gfid, &inode,
&data_selfheal, &metadata_selfheal,
&entry_selfheal);
@@ -2496,7 +2491,7 @@ afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid)
}
}
- if (data_selfheal && dataheal_enabled)
+ if (data_selfheal && priv->data_self_heal)
data_ret = afr_selfheal_data(frame, this, fd);
if (metadata_selfheal && priv->metadata_self_heal)
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 1dd18b3..6dd38ef 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -15,11 +15,6 @@
#include "afr-messages.h"
#include <glusterfs/events.h>
-enum {
- AFR_SELFHEAL_DATA_FULL = 0,
- AFR_SELFHEAL_DATA_DIFF,
-};
-
#define HAS_HOLES(i) ((i->ia_blocks * 512) < (i->ia_size))
static int
__checksum_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
@@ -301,7 +296,7 @@ afr_data_self_heal_type_get(afr_private_t *priv, unsigned char *healed_sinks,
int type = AFR_SELFHEAL_DATA_FULL;
int i = 0;
- if (priv->data_self_heal_algorithm == NULL) {
+ if (priv->data_self_heal_algorithm == AFR_SELFHEAL_DATA_DYNAMIC) {
type = AFR_SELFHEAL_DATA_FULL;
for (i = 0; i < priv->child_count; i++) {
if (!healed_sinks[i] && i != source)
@@ -311,10 +306,8 @@ afr_data_self_heal_type_get(afr_private_t *priv, unsigned char *healed_sinks,
break;
}
}
- } else if (strcmp(priv->data_self_heal_algorithm, "full") == 0) {
- type = AFR_SELFHEAL_DATA_FULL;
- } else if (strcmp(priv->data_self_heal_algorithm, "diff") == 0) {
- type = AFR_SELFHEAL_DATA_DIFF;
+ } else {
+ type = priv->data_self_heal_algorithm;
}
return type;
}
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index c13ac87..78eff15 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -120,6 +120,21 @@ afr_set_favorite_child_policy(afr_private_t *priv, char *policy)
return 0;
}
+
+static void
+set_data_self_heal_algorithm(afr_private_t *priv, char *algo)
+{
+ if (!algo) {
+ priv->data_self_heal_algorithm = AFR_SELFHEAL_DATA_DYNAMIC;
+ } else if (strcmp(algo, "full") == 0) {
+ priv->data_self_heal_algorithm = AFR_SELFHEAL_DATA_FULL;
+ } else if (strcmp(algo, "diff") == 0) {
+ priv->data_self_heal_algorithm = AFR_SELFHEAL_DATA_DIFF;
+ } else {
+ priv->data_self_heal_algorithm = AFR_SELFHEAL_DATA_DYNAMIC;
+ }
+}
+
int
reconfigure(xlator_t *this, dict_t *options)
{
@@ -130,13 +145,14 @@ reconfigure(xlator_t *this, dict_t *options)
int index = -1;
char *qtype = NULL;
char *fav_child_policy = NULL;
+ char *data_self_heal = NULL;
+ char *data_self_heal_algorithm = NULL;
+ char *locking_scheme = NULL;
gf_boolean_t consistent_io = _gf_false;
gf_boolean_t choose_local_old = _gf_false;
priv = this->private;
- GF_OPTION_RECONF("afr-dirty-xattr", priv->afr_dirty, options, str, out);
-
GF_OPTION_RECONF("metadata-splitbrain-forced-heal",
priv->metadata_splitbrain_forced_heal, options, bool, out);
@@ -149,7 +165,8 @@ reconfigure(xlator_t *this, dict_t *options)
GF_OPTION_RECONF("metadata-self-heal", priv->metadata_self_heal, options,
bool, out);
- GF_OPTION_RECONF("data-self-heal", priv->data_self_heal, options, str, out);
+ GF_OPTION_RECONF("data-self-heal", data_self_heal, options, str, out);
+ gf_string2boolean(data_self_heal, &priv->data_self_heal);
GF_OPTION_RECONF("entry-self-heal", priv->entry_self_heal, options, bool,
out);
@@ -157,8 +174,9 @@ reconfigure(xlator_t *this, dict_t *options)
GF_OPTION_RECONF("data-self-heal-window-size",
priv->data_self_heal_window_size, options, uint32, out);
- GF_OPTION_RECONF("data-self-heal-algorithm", priv->data_self_heal_algorithm,
+ GF_OPTION_RECONF("data-self-heal-algorithm", data_self_heal_algorithm,
options, str, out);
+ set_data_self_heal_algorithm(priv, data_self_heal_algorithm);
GF_OPTION_RECONF("halo-enabled", priv->halo_enabled, options, bool, out);
@@ -214,7 +232,8 @@ reconfigure(xlator_t *this, dict_t *options)
}
GF_OPTION_RECONF("pre-op-compat", priv->pre_op_compat, options, bool, out);
- GF_OPTION_RECONF("locking-scheme", priv->locking_scheme, options, str, out);
+ GF_OPTION_RECONF("locking-scheme", locking_scheme, options, str, out);
+ priv->granular_locks = (strcmp(locking_scheme, "granular") == 0);
GF_OPTION_RECONF("full-lock", priv->full_lock, options, bool, out);
GF_OPTION_RECONF("granular-entry-heal", priv->esh_granular, options, bool,
out);
@@ -366,6 +385,9 @@ init(xlator_t *this)
char *qtype = NULL;
char *fav_child_policy = NULL;
char *thin_arbiter = NULL;
+ char *data_self_heal = NULL;
+ char *locking_scheme = NULL;
+ char *data_self_heal_algorithm = NULL;
if (!this->children) {
gf_msg(this->name, GF_LOG_ERROR, 0, AFR_MSG_CHILD_MISCONFIGURED,
@@ -448,10 +470,12 @@ init(xlator_t *this)
GF_OPTION_INIT("heal-wait-queue-length", priv->heal_wait_qlen, uint32, out);
- GF_OPTION_INIT("data-self-heal", priv->data_self_heal, str, out);
+ GF_OPTION_INIT("data-self-heal", data_self_heal, str, out);
+ gf_string2boolean(data_self_heal, &priv->data_self_heal);
- GF_OPTION_INIT("data-self-heal-algorithm", priv->data_self_heal_algorithm,
- str, out);
+ GF_OPTION_INIT("data-self-heal-algorithm", data_self_heal_algorithm, str,
+ out);
+ set_data_self_heal_algorithm(priv, data_self_heal_algorithm);
GF_OPTION_INIT("data-self-heal-window-size",
priv->data_self_heal_window_size, uint32, out);
@@ -479,7 +503,8 @@ init(xlator_t *this)
out);
GF_OPTION_INIT("pre-op-compat", priv->pre_op_compat, bool, out);
- GF_OPTION_INIT("locking-scheme", priv->locking_scheme, str, out);
+ GF_OPTION_INIT("locking-scheme", locking_scheme, str, out);
+ priv->granular_locks = (strcmp(locking_scheme, "granular") == 0);
GF_OPTION_INIT("full-lock", priv->full_lock, bool, out);
GF_OPTION_INIT("granular-entry-heal", priv->esh_granular, bool, out);
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 1a54d5d..489fdc7 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -105,6 +105,12 @@ typedef enum {
} afr_favorite_child_policy;
typedef enum {
+ AFR_SELFHEAL_DATA_FULL = 0,
+ AFR_SELFHEAL_DATA_DIFF,
+ AFR_SELFHEAL_DATA_DYNAMIC,
+} afr_data_self_heal_type_t;
+
+typedef enum {
AFR_CHILD_UNKNOWN = -1,
AFR_CHILD_ZERO,
AFR_CHILD_ONE,
@@ -155,8 +161,7 @@ typedef struct _afr_private {
char **pending_key;
- char *data_self_heal; /* on/off/open */
- char *data_self_heal_algorithm; /* name of algorithm */
+ afr_data_self_heal_type_t data_self_heal_algorithm;
unsigned int data_self_heal_window_size; /* max number of pipelined
read/writes */
@@ -230,10 +235,11 @@ typedef struct _afr_private {
/* pump dependencies */
void *pump_private;
gf_boolean_t use_afr_in_pump;
- char *locking_scheme;
+ gf_boolean_t granular_locks;
gf_boolean_t full_lock;
gf_boolean_t esh_granular;
gf_boolean_t consistent_io;
+ gf_boolean_t data_self_heal; /* on/off */
} afr_private_t;
typedef enum {