summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhou Zhengping <johnzzpcrystal@gmail.com>2017-04-28 06:12:56 +0800
committerJeff Darcy <jeff@pl.atyp.us>2017-05-08 13:15:12 +0000
commit68b4db2ac37af3283580b74eef5d405c9370b0c0 (patch)
treea8623066d34e99f3b4fae1d8807401454b7cc286
parent5b8e9261f1e8aab1a3475578d56d54037459a5e6 (diff)
debug/error-gen: Don't need to convert error string to int in every fop
Every fop in xlator error-gen will call function error_gen, which will call function conv_error to convert pvt->error_no to int. But actually the function could only be called in init and reconfigure Change-Id: I96c9780574f369fc58eed10fea9d50c4cd7d4e8a BUG: 1446412 Signed-off-by: Zhou Zhengping <johnzzpcrystal@gmail.com> Reviewed-on: https://review.gluster.org/17132 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
-rw-r--r--xlators/debug/error-gen/src/error-gen.c16
-rw-r--r--xlators/debug/error-gen/src/error-gen.h1
2 files changed, 12 insertions, 5 deletions
diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c
index f86a6bb0257..925ab7653ef 100644
--- a/xlators/debug/error-gen/src/error-gen.c
+++ b/xlators/debug/error-gen/src/error-gen.c
@@ -336,7 +336,7 @@ error_gen (xlator_t *this, int op_no)
eg_t *egp = NULL;
int count = 0;
int failure_iter_no = GF_FAILURE_DEFAULT;
- char *error_no = NULL;
+ int error_no_int = 0;
int rand_no = 0;
int ret = 0;
@@ -346,7 +346,7 @@ error_gen (xlator_t *this, int op_no)
{
count = ++egp->op_count;
failure_iter_no = egp->failure_iter_no;
- error_no = egp->error_no;
+ error_no_int = egp->error_no_int;
}
UNLOCK (&egp->lock);
@@ -357,8 +357,8 @@ error_gen (xlator_t *this, int op_no)
}
UNLOCK (&egp->lock);
- if (error_no)
- ret = conv_errno_to_int (&error_no);
+ if (error_no_int)
+ ret = error_no_int;
else {
rand_no = generate_rand_no (op_no);
@@ -1582,6 +1582,9 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("error-no", pvt->error_no, options, str, out);
+ if (pvt->error_no)
+ pvt->error_no_int = conv_errno_to_int (&pvt->error_no);
+
GF_OPTION_RECONF ("failure", failure_percent_int, options, int32,
out);
@@ -1632,6 +1635,9 @@ init (xlator_t *this)
GF_OPTION_INIT ("error-no", pvt->error_no, str, out);
+ if (pvt->error_no)
+ pvt->error_no_int = conv_errno_to_int (&pvt->error_no);
+
GF_OPTION_INIT ("failure", failure_percent_int, int32, out);
GF_OPTION_INIT ("enable", error_enable_fops, str, out);
@@ -1676,7 +1682,7 @@ struct xlator_dumpops dumpops = {
.priv = error_gen_priv_dump,
};
-struct xlator_fops cbks;
+struct xlator_cbks cbks;
struct xlator_fops fops = {
.lookup = error_gen_lookup,
diff --git a/xlators/debug/error-gen/src/error-gen.h b/xlators/debug/error-gen/src/error-gen.h
index 351f5dc99d6..6ef6b232e6a 100644
--- a/xlators/debug/error-gen/src/error-gen.h
+++ b/xlators/debug/error-gen/src/error-gen.h
@@ -31,6 +31,7 @@ typedef struct {
int op_count;
int failure_iter_no;
char *error_no;
+ int error_no_int;
gf_boolean_t random_failure;
gf_lock_t lock;
} eg_t;