diff options
Diffstat (limited to 'xlators/debug/error-gen/src/error-gen.c')
| -rw-r--r-- | xlators/debug/error-gen/src/error-gen.c | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index c6595b4c0e4..d45655ef4c3 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -7,10 +7,10 @@ later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ -#include "xlator.h" +#include <glusterfs/xlator.h> #include "error-gen.h" -#include "statedump.h" -#include "defaults.h" +#include <glusterfs/statedump.h> +#include <glusterfs/defaults.h> /* * The user can specify an error probability as a float percentage, but we @@ -31,9 +31,9 @@ sys_error_t error_no_list[] = { [GF_FOP_LOOKUP] = {.error_no_count = 4, .error_no = {ENOENT, ENOTDIR, ENAMETOOLONG, EAGAIN}}, - [GF_FOP_STAT] = {.error_no_count = 7, - .error_no = {EACCES, EBADF, EFAULT, ENAMETOOLONG, ENOENT, - ENOMEM, ENOTDIR}}, + [GF_FOP_STAT] = {.error_no_count = 6, + .error_no = {EACCES, EFAULT, ENAMETOOLONG, ENOENT, ENOMEM, + ENOTDIR}}, [GF_FOP_READLINK] = {.error_no_count = 8, .error_no = {EACCES, EFAULT, EINVAL, EIO, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR}}, @@ -79,21 +79,20 @@ sys_error_t error_no_list[] = { [GF_FOP_WRITE] = {.error_no_count = 7, .error_no = {EINVAL, EBADF, EFAULT, EISDIR, ENAMETOOLONG, ENOSPC, GF_ERROR_SHORT_WRITE}}, - [GF_FOP_STATFS] = {.error_no_count = 10, - .error_no = {EACCES, EBADF, EFAULT, EINTR, EIO, - ENAMETOOLONG, ENOENT, ENOMEM, ENOSYS, - ENOTDIR}}, + [GF_FOP_STATFS] = {.error_no_count = 9, + .error_no = {EACCES, EFAULT, EINTR, EIO, ENAMETOOLONG, + ENOENT, ENOMEM, ENOSYS, ENOTDIR}}, [GF_FOP_FLUSH] = {.error_no_count = 5, .error_no = {EACCES, EFAULT, ENAMETOOLONG, ENOSYS, ENOENT}}, [GF_FOP_FSYNC] = {.error_no_count = 4, .error_no = {EBADF, EIO, EROFS, EINVAL}}, - [GF_FOP_SETXATTR] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, EINTR, ENAMETOOLONG}}, - [GF_FOP_GETXATTR] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, ENAMETOOLONG, EINTR}}, - [GF_FOP_REMOVEXATTR] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, ENAMETOOLONG, EINTR}}, + [GF_FOP_SETXATTR] = {.error_no_count = 3, + .error_no = {EACCES, EINTR, ENAMETOOLONG}}, + [GF_FOP_GETXATTR] = {.error_no_count = 3, + .error_no = {EACCES, ENAMETOOLONG, EINTR}}, + [GF_FOP_REMOVEXATTR] = {.error_no_count = 3, + .error_no = {EACCES, ENAMETOOLONG, EINTR}}, [GF_FOP_FSETXATTR] = {.error_no_count = 4, .error_no = {EACCES, EBADF, EINTR, ENAMETOOLONG}}, [GF_FOP_FGETXATTR] = {.error_no_count = 4, @@ -125,26 +124,25 @@ sys_error_t error_no_list[] = { ENOENT}}, [GF_FOP_FXATTROP] = {.error_no_count = 4, .error_no = {EBADF, EIO, EROFS, EINVAL}}, - [GF_FOP_INODELK] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, EINTR, ENAMETOOLONG}}, + [GF_FOP_INODELK] = {.error_no_count = 3, + .error_no = {EACCES, EINTR, ENAMETOOLONG}}, [GF_FOP_FINODELK] = {.error_no_count = 4, .error_no = {EACCES, EBADF, EINTR, ENAMETOOLONG}}, - [GF_FOP_ENTRYLK] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, ENAMETOOLONG, EINTR}}, + [GF_FOP_ENTRYLK] = {.error_no_count = 3, + .error_no = {EACCES, ENAMETOOLONG, EINTR}}, [GF_FOP_FENTRYLK] = {.error_no_count = 10, .error_no = {EACCES, EEXIST, EFAULT, EISDIR, EMFILE, ENAMETOOLONG, ENFILE, ENODEV, ENOENT, ENOMEM}}, - [GF_FOP_SETATTR] = {.error_no_count = 11, + [GF_FOP_SETATTR] = {.error_no_count = 10, .error_no = {EACCES, EFAULT, EIO, ENAMETOOLONG, ENOENT, - ENOMEM, ENOTDIR, EPERM, EROFS, EBADF, - EIO}}, + ENOMEM, ENOTDIR, EPERM, EROFS, EIO}}, [GF_FOP_FSETATTR] = {.error_no_count = 11, .error_no = {EACCES, EFAULT, EIO, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EPERM, EROFS, EBADF, EIO}}, - [GF_FOP_GETSPEC] = {.error_no_count = 4, - .error_no = {EACCES, EBADF, ENAMETOOLONG, EINTR}}}; + [GF_FOP_GETSPEC] = {.error_no_count = 3, + .error_no = {EACCES, ENAMETOOLONG, EINTR}}}; int generate_rand_no(int op_no) @@ -761,6 +759,7 @@ error_gen_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, */ shortvec = iov_dup(vector, 1); shortvec->iov_len /= 2; + count = 1; goto wind; } else if (op_errno) { GF_ERROR(this, "unwind(-1, %s)", strerror(op_errno)); @@ -1396,7 +1395,7 @@ error_gen_priv_dump(xlator_t *this) gf_proc_dump_write("op_count", "%d", conf->op_count); gf_proc_dump_write("failure_iter_no", "%d", conf->failure_iter_no); - gf_proc_dump_write("error_no", "%s", conf->error_no); + gf_proc_dump_write("error_no", "%d", conf->error_no_int); gf_proc_dump_write("random_failure", "%d", conf->random_failure); UNLOCK(&conf->lock); @@ -1430,6 +1429,7 @@ reconfigure(xlator_t *this, dict_t *options) eg_t *pvt = NULL; int32_t ret = 0; char *error_enable_fops = NULL; + char *error_no = NULL; double failure_percent_dbl = 0.0; if (!this || !this->private) @@ -1439,10 +1439,10 @@ reconfigure(xlator_t *this, dict_t *options) ret = -1; - GF_OPTION_RECONF("error-no", pvt->error_no, options, str, out); + GF_OPTION_RECONF("error-no", error_no, options, str, out); - if (pvt->error_no) - pvt->error_no_int = conv_errno_to_int(&pvt->error_no); + if (error_no) + pvt->error_no_int = conv_errno_to_int(&error_no); GF_OPTION_RECONF("failure", failure_percent_dbl, options, percent, out); @@ -1466,6 +1466,7 @@ init(xlator_t *this) eg_t *pvt = NULL; int32_t ret = 0; char *error_enable_fops = NULL; + char *error_no = NULL; double failure_percent_dbl = 0.0; if (!this->children || this->children->next) { @@ -1490,10 +1491,10 @@ init(xlator_t *this) ret = -1; - GF_OPTION_INIT("error-no", pvt->error_no, str, out); + GF_OPTION_INIT("error-no", error_no, str, out); - if (pvt->error_no) - pvt->error_no_int = conv_errno_to_int(&pvt->error_no); + if (error_no) + pvt->error_no_int = conv_errno_to_int(&error_no); GF_OPTION_INIT("failure", failure_percent_dbl, percent, out); @@ -1506,8 +1507,8 @@ init(xlator_t *this) this->private = pvt; - /* Give some seed value here */ - srand(time(NULL)); + /* Give some seed value here. */ + srand(gf_time()); ret = 0; out: @@ -1644,4 +1645,19 @@ struct volume_options options[] = { .flags = OPT_FLAG_SETTABLE, }, - {.key = {NULL}}}; + {.key = {NULL}}, +}; + +xlator_api_t xlator_api = { + .init = init, + .fini = fini, + .reconfigure = reconfigure, + .mem_acct_init = mem_acct_init, + .op_version = {1}, + .dumpops = &dumpops, + .fops = &fops, + .cbks = &cbks, + .options = options, + .identifier = "error-gen", + .category = GF_TECH_PREVIEW, +}; |
