From 68b4db2ac37af3283580b74eef5d405c9370b0c0 Mon Sep 17 00:00:00 2001 From: Zhou Zhengping Date: Fri, 28 Apr 2017 06:12:56 +0800 Subject: 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 Reviewed-on: https://review.gluster.org/17132 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Jeff Darcy --- xlators/debug/error-gen/src/error-gen.c | 16 +++++++++++----- xlators/debug/error-gen/src/error-gen.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'xlators/debug/error-gen') 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; -- cgit