summaryrefslogtreecommitdiffstats
path: root/xlators/debug
diff options
context:
space:
mode:
authorvinayak hegde <vinayak@gluster.com>2009-10-08 23:35:57 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-08 22:59:48 -0700
commit3949b2828a78e4ecb95edb06f09fb9e7e3e5ce9b (patch)
tree7af7c4cb55c075eed8821214d9e7e8987ce69d16 /xlators/debug
parentd160d55c41913de26a43117b00fcab63746ce96d (diff)
debug/error-gen: Feature enhancement of error-gen translator
In debug/error-gen translator 3-options are provided. failure - specifies the percentage failure in fops. error-no - specifies which error-no to be returned. enable - specifies which are the fops to be enabled for this translator. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 291 (feature enhancement of error-gen translator) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=291
Diffstat (limited to 'xlators/debug')
-rw-r--r--xlators/debug/error-gen/src/Makefile.am2
-rw-r--r--xlators/debug/error-gen/src/error-gen.c1080
-rw-r--r--xlators/debug/error-gen/src/error-gen.h89
3 files changed, 1004 insertions, 167 deletions
diff --git a/xlators/debug/error-gen/src/Makefile.am b/xlators/debug/error-gen/src/Makefile.am
index 1bd7f332ca0..f353b61e69c 100644
--- a/xlators/debug/error-gen/src/Makefile.am
+++ b/xlators/debug/error-gen/src/Makefile.am
@@ -7,6 +7,8 @@ error_gen_la_LDFLAGS = -module -avoidversion
error_gen_la_SOURCES = error-gen.c
error_gen_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+noinst_HEADERS = error-gen.h
+
AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS)\
-I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)
diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c
index 7c544137638..c125a870526 100644
--- a/xlators/debug/error-gen/src/error-gen.c
+++ b/xlators/debug/error-gen/src/error-gen.c
@@ -23,25 +23,367 @@
#endif
#include "xlator.h"
+#include "error-gen.h"
+
+sys_error_t error_no_list[] = {
+ [ERR_LOOKUP] = { .error_no_count = 4,
+ .error_no = {ENOENT,ENOTDIR,
+ ENAMETOOLONG,EAGAIN}},
+ [ERR_STAT] = { .error_no_count = 7,
+ .error_no = {EACCES,EBADF,EFAULT,
+ ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOTDIR}},
+ [ERR_READLINK] = { .error_no_count = 8,
+ .error_no = {EACCES,EFAULT,EINVAL,EIO,
+ ENAMETOOLONG,ENOENT,ENOMEM,
+ ENOTDIR}},
+ [ERR_MKNOD] = { .error_no_count = 11,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ EINVAL,ENAMETOOLONG,
+ ENOENT,ENOMEM,ENOSPC,
+ ENOTDIR,EPERM,EROFS}},
+ [ERR_MKDIR] = { .error_no_count = 10,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOSPC,ENOTDIR,
+ EPERM,EROFS}},
+ [ERR_UNLINK] = { .error_no_count = 10,
+ .error_no = {EACCES,EBUSY,EFAULT,EIO,
+ EISDIR,ENAMETOOLONG,
+ ENOENT,ENOMEM,ENOTDIR,
+ EPERM,EROFS}},
+ [ERR_RMDIR] = { .error_no_count = 8,
+ .error_no = {EACCES,EBUSY,EFAULT,
+ ENOMEM,ENOTDIR,ENOTEMPTY,
+ EPERM,EROFS}},
+ [ERR_SYMLINK] = { .error_no_count = 11,
+ .error_no = {EACCES,EEXIST,EFAULT,EIO,
+ ENAMETOOLONG,ENOENT,ENOMEM,
+ ENOSPC,ENOTDIR,EPERM,
+ EROFS}},
+ [ERR_RENAME] = { .error_no_count = 13,
+ .error_no = {EACCES,EBUSY,EFAULT,
+ EINVAL,EISDIR,EMLINK,
+ ENAMETOOLONG,ENOENT,ENOMEM,
+ ENOSPC,ENOTDIR,EEXIST,
+ EXDEV}},
+ [ERR_LINK] = { .error_no_count = 13,
+ .error_no = {EACCES,EFAULT,EEXIST,EIO,
+ EMLINK,ENAMETOOLONG,
+ ENOENT,ENOMEM,ENOSPC,
+ ENOTDIR,EPERM,EROFS,
+ EXDEV}},
+ [ERR_TRUNCATE] = { .error_no_count = 10,
+ .error_no = {EACCES,EFAULT,EFBIG,
+ EINTR,EINVAL,EIO,EISDIR,
+ ENAMETOOLONG,ENOENT,
+ EISDIR}},
+ [ERR_CREATE] = {.error_no_count = 10,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ EISDIR,EMFILE,ENAMETOOLONG,
+ ENFILE,ENODEV,ENOENT,
+ ENODEV}},
+ [ERR_OPEN] = { .error_no_count = 10,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ EISDIR,EMFILE,
+ ENAMETOOLONG,ENFILE,
+ ENODEV,ENOENT,ENOMEM}},
+ [ERR_READV] = { .error_no_count = 5,
+ .error_no = {EINVAL,EBADF,EFAULT,EISDIR,
+ ENAMETOOLONG}},
+ [ERR_WRITEV] = { .error_no_count = 5,
+ .error_no = {EINVAL,EBADF,EFAULT,EISDIR,
+ ENAMETOOLONG}},
+ [ERR_STATFS] = {.error_no_count = 10,
+ .error_no = {EACCES,EBADF,EFAULT,EINTR,
+ EIO,ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOSYS,ENOTDIR}},
+ [ERR_FLUSH] = { .error_no_count = 5,
+ .error_no = {EACCES,EFAULT,
+ ENAMETOOLONG,ENOSYS,
+ ENOENT}},
+ [ERR_FSYNC] = { .error_no_count = 4,
+ .error_no = {EBADF,EIO,EROFS,EINVAL}},
+ [ERR_SETXATTR] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,EINTR,
+ ENAMETOOLONG}},
+ [ERR_GETXATTR] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,ENAMETOOLONG,
+ EINTR}},
+ [ERR_REMOVEXATTR] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,ENAMETOOLONG,
+ EINTR}},
+ [ERR_OPENDIR] = { .error_no_count = 8,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ EISDIR,EMFILE,
+ ENAMETOOLONG,ENFILE,
+ ENODEV}},
+ [ERR_READDIR] = { .error_no_count = 5,
+ .error_no = {EINVAL,EACCES,EBADF,
+ EMFILE,ENOENT}},
+ [ERR_READDIRP] = { .error_no_count = 5,
+ .error_no = {EINVAL,EACCES,EBADF,
+ EMFILE,ENOENT}},
+ [ERR_GETDENTS] = { .error_no_count = 5,
+ .error_no = {EBADF,EFAULT,EINVAL,
+ ENOENT,ENOTDIR}},
+ [ERR_FSYNCDIR] = { .error_no_count = 4,
+ .error_no = {EBADF,EIO,EROFS,EINVAL}},
+ [ERR_ACCESS] = { .error_no_count = 8,
+ .error_no = {EACCES,ENAMETOOLONG,
+ ENOENT,ENOTDIR,EROFS,
+ EFAULT,EINVAL,EIO}},
+ [ERR_FTRUNCATE] = { .error_no_count = 9,
+ .error_no = {EACCES,EFAULT,EFBIG,
+ EINTR,EINVAL,EIO,EISDIR,
+ ENAMETOOLONG,ENOENT}},
+ [ERR_FSTAT] = { .error_no_count = 7,
+ .error_no = {EACCES,EBADF,EFAULT,
+ ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOTDIR}},
+ [ERR_LK] = { .error_no_count = 4,
+ .error_no = {EACCES,EFAULT,ENOENT,
+ EINTR}},
+ [ERR_SETDENTS] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,EINTR,
+ ENAMETOOLONG}},
+ [ERR_CHECKSUM] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,
+ ENAMETOOLONG,EINTR}},
+ [ERR_XATTROP] = { .error_no_count = 5,
+ .error_no = {EACCES,EFAULT,
+ ENAMETOOLONG,ENOSYS,
+ ENOENT}},
+ [ERR_FXATTROP] = { .error_no_count = 4,
+ .error_no = {EBADF,EIO,EROFS,EINVAL}},
+ [ERR_INODELK] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,EINTR,
+ ENAMETOOLONG}},
+ [ERR_FINODELK] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,EINTR,
+ ENAMETOOLONG}},
+ [ERR_ENTRYLK] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,
+ ENAMETOOLONG,EINTR}},
+ [ERR_FENTRYLK] = { .error_no_count = 10,
+ .error_no = {EACCES,EEXIST,EFAULT,
+ EISDIR,EMFILE,
+ ENAMETOOLONG,ENFILE,
+ ENODEV,ENOENT,ENOMEM}},
+ [ERR_SETATTR] = {.error_no_count = 11,
+ .error_no = {EACCES,EFAULT,EIO,
+ ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOTDIR,EPERM,
+ EROFS,EBADF,EIO}},
+ [ERR_FSETATTR] = { .error_no_count = 11,
+ .error_no = {EACCES,EFAULT,EIO,
+ ENAMETOOLONG,ENOENT,
+ ENOMEM,ENOTDIR,EPERM,
+ EROFS,EBADF,EIO}},
+ [ERR_STATS] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,ENAMETOOLONG,
+ EINTR}},
+ [ERR_GETSPEC] = { .error_no_count = 4,
+ .error_no = {EACCES,EBADF,ENAMETOOLONG,
+ EINTR}}
+};
-typedef struct {
- int op_count;
-} eg_t;
-
-int error_gen (xlator_t *this)
-{
- eg_t *egp = NULL;
- int count = 0;
- egp = this->private;
- count = ++egp->op_count;
- if((count % 10) == 0) {
- count = count / 10;
- if ((count % 2) == 0)
- return ENOTCONN;
- else
- return EIO;
- }
- return 0;
+int
+generate_rand_no (int op_no)
+{
+ int rand_no = 0;
+
+ if (op_no < NO_OF_FOPS)
+ rand_no = rand () % error_no_list[op_no].error_no_count;
+ return rand_no;
+}
+
+int
+conv_errno_to_int (char **error_no)
+{
+ if (!strcmp ((*error_no), "ENOENT"))
+ return ENOENT;
+ else if (!strcmp ((*error_no), "ENOTDIR"))
+ return ENOTDIR;
+ else if (!strcmp ((*error_no), "ENAMETOOLONG"))
+ return ENAMETOOLONG;
+ else if (!strcmp ((*error_no), "EACCES"))
+ return EACCES;
+ else if (!strcmp ((*error_no), "EBADF"))
+ return EBADF;
+ else if (!strcmp ((*error_no), "EFAULT"))
+ return EFAULT;
+ else if (!strcmp ((*error_no), "ENOMEM"))
+ return ENOMEM;
+ else if (!strcmp ((*error_no), "EINVAL"))
+ return EINVAL;
+ else if (!strcmp ((*error_no), "EIO"))
+ return EIO;
+ else if (!strcmp ((*error_no), "EEXIST"))
+ return EEXIST;
+ else if (!strcmp ((*error_no), "ENOSPC"))
+ return ENOSPC;
+ else if (!strcmp ((*error_no), "EPERM"))
+ return EPERM;
+ else if (!strcmp ((*error_no), "EROFS"))
+ return EROFS;
+ else if (!strcmp ((*error_no), "EBUSY"))
+ return EBUSY;
+ else if (!strcmp ((*error_no), "EISDIR"))
+ return EISDIR;
+ else if (!strcmp ((*error_no), "ENOTEMPTY"))
+ return ENOTEMPTY;
+ else if (!strcmp ((*error_no), "EMLINK"))
+ return EMLINK;
+ else if (!strcmp ((*error_no), "ENODEV"))
+ return ENODEV;
+ else if (!strcmp ((*error_no), "EXDEV"))
+ return EXDEV;
+ else if (!strcmp ((*error_no), "EMFILE"))
+ return EMFILE;
+ else if (!strcmp ((*error_no), "ENFILE"))
+ return ENFILE;
+ else if (!strcmp ((*error_no), "ENOSYS"))
+ return ENOSYS;
+ else if (!strcmp ((*error_no), "EINTR"))
+ return EINTR;
+ else if (!strcmp ((*error_no), "EFBIG"))
+ return EFBIG;
+ else
+ return EAGAIN;
+}
+
+int
+get_fop_int (char **op_no_str)
+{
+ if (!strcmp ((*op_no_str), "lookup"))
+ return ERR_LOOKUP;
+ else if (!strcmp ((*op_no_str), "stat"))
+ return ERR_STAT;
+ else if (!strcmp ((*op_no_str), "readlink"))
+ return ERR_READLINK;
+ else if (!strcmp ((*op_no_str), "mknod"))
+ return ERR_MKNOD;
+ else if (!strcmp ((*op_no_str), "mkdir"))
+ return ERR_MKDIR;
+ else if (!strcmp ((*op_no_str), "unlink"))
+ return ERR_UNLINK;
+ else if (!strcmp ((*op_no_str), "rmdir"))
+ return ERR_RMDIR;
+ else if (!strcmp ((*op_no_str), "symlink"))
+ return ERR_SYMLINK;
+ else if (!strcmp ((*op_no_str), "rename"))
+ return ERR_RENAME;
+ else if (!strcmp ((*op_no_str), "link"))
+ return ERR_LINK;
+ else if (!strcmp ((*op_no_str), "truncate"))
+ return ERR_TRUNCATE;
+ else if (!strcmp ((*op_no_str), "create"))
+ return ERR_CREATE;
+ else if (!strcmp ((*op_no_str), "open"))
+ return ERR_OPEN;
+ else if (!strcmp ((*op_no_str), "readv"))
+ return ERR_READV;
+ else if (!strcmp ((*op_no_str), "writev"))
+ return ERR_WRITEV;
+ else if (!strcmp ((*op_no_str), "statfs"))
+ return ERR_STATFS;
+ else if (!strcmp ((*op_no_str), "flush"))
+ return ERR_FLUSH;
+ else if (!strcmp ((*op_no_str), "fsync"))
+ return ERR_FSYNC;
+ else if (!strcmp ((*op_no_str), "setxattr"))
+ return ERR_SETXATTR;
+ else if (!strcmp ((*op_no_str), "getxattr"))
+ return ERR_GETXATTR;
+ else if (!strcmp ((*op_no_str), "removexattr"))
+ return ERR_REMOVEXATTR;
+ else if (!strcmp ((*op_no_str), "opendir"))
+ return ERR_OPENDIR;
+ else if (!strcmp ((*op_no_str), "readdir"))
+ return ERR_READDIR;
+ else if (!strcmp ((*op_no_str), "readdirp"))
+ return ERR_READDIRP;
+ else if (!strcmp ((*op_no_str), "getdents"))
+ return ERR_GETDENTS;
+ else if (!strcmp ((*op_no_str), "fsyncdir"))
+ return ERR_FSYNCDIR;
+ else if (!strcmp ((*op_no_str), "access"))
+ return ERR_ACCESS;
+ else if (!strcmp ((*op_no_str), "ftruncate"))
+ return ERR_FTRUNCATE;
+ else if (!strcmp ((*op_no_str), "fstat"))
+ return ERR_FSTAT;
+ else if (!strcmp ((*op_no_str), "lk"))
+ return ERR_LK;
+ else if (!strcmp ((*op_no_str), "setdents"))
+ return ERR_SETDENTS;
+ else if (!strcmp ((*op_no_str), "checksum"))
+ return ERR_CHECKSUM;
+ else if (!strcmp ((*op_no_str), "xattrop"))
+ return ERR_XATTROP;
+ else if (!strcmp ((*op_no_str), "fxattrop"))
+ return ERR_FXATTROP;
+ else if (!strcmp ((*op_no_str), "inodelk"))
+ return ERR_INODELK;
+ else if (!strcmp ((*op_no_str), "finodelk"))
+ return ERR_FINODELK;
+ else if (!strcmp ((*op_no_str), "etrylk"))
+ return ERR_ENTRYLK;
+ else if (!strcmp ((*op_no_str), "fentrylk"))
+ return ERR_FENTRYLK;
+ else if (!strcmp ((*op_no_str), "setattr"))
+ return ERR_SETATTR;
+ else if (!strcmp ((*op_no_str), "fsetattr"))
+ return ERR_FSETATTR;
+ else if (!strcmp ((*op_no_str), "stats"))
+ return ERR_STATS;
+ else if (!strcmp ((*op_no_str), "getspec"))
+ return ERR_GETSPEC;
+ else
+ return -1;
+}
+
+int
+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 rand_no = 0;
+ int ret = 0;
+
+ egp = this->private;
+
+ LOCK (&egp->lock);
+ {
+ count = ++egp->op_count;
+ failure_iter_no = egp->failure_iter_no;
+ error_no = egp->error_no;
+ }
+ UNLOCK (&egp->lock);
+
+ if((count % failure_iter_no) == 0) {
+ LOCK (&egp->lock);
+ {
+ egp->op_count = 0;
+ }
+ UNLOCK (&egp->lock);
+
+ if (error_no)
+ ret = conv_errno_to_int (&error_no);
+ else {
+
+ rand_no = generate_rand_no (op_no);
+ if (op_no >= NO_OF_FOPS)
+ op_no = 0;
+ if (rand_no >= error_no_list[op_no].error_no_count)
+ rand_no = 0;
+ ret = error_no_list[op_no].error_no[rand_no];
+ }
+ }
+ return ret;
}
static int32_t
@@ -70,8 +412,16 @@ error_gen_lookup (call_frame_t *frame,
loc_t *loc,
dict_t *xattr_req)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_LOOKUP];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_LOOKUP);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL,
@@ -87,7 +437,6 @@ error_gen_lookup (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_forget (xlator_t *this,
inode_t *inode)
@@ -115,8 +464,16 @@ error_gen_stat (call_frame_t *frame,
xlator_t *this,
loc_t *loc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_STAT];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_STAT);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -153,8 +510,16 @@ error_gen_setattr (call_frame_t *frame,
struct stat *stbuf,
int32_t valid)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_SETATTR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_SETATTR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -176,8 +541,16 @@ error_gen_fsetattr (call_frame_t *frame,
struct stat *stbuf,
int32_t valid)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FSETATTR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FSETATTR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -192,7 +565,6 @@ error_gen_fsetattr (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_truncate_cbk (call_frame_t *frame,
void *cookie,
@@ -216,8 +588,16 @@ error_gen_truncate (call_frame_t *frame,
loc_t *loc,
off_t offset)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_TRUNCATE];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_TRUNCATE);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL,
@@ -257,8 +637,16 @@ error_gen_ftruncate (call_frame_t *frame,
fd_t *fd,
off_t offset)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp =NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FTRUNCATE];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FTRUNCATE);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -273,7 +661,6 @@ error_gen_ftruncate (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_access_cbk (call_frame_t *frame,
void *cookie,
@@ -293,8 +680,16 @@ error_gen_access (call_frame_t *frame,
loc_t *loc,
int32_t mask)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_ACCESS];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_ACCESS);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -309,7 +704,6 @@ error_gen_access (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_readlink_cbk (call_frame_t *frame,
void *cookie,
@@ -333,8 +727,16 @@ error_gen_readlink (call_frame_t *frame,
loc_t *loc,
size_t size)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_READLINK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_READLINK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -349,7 +751,6 @@ error_gen_readlink (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_mknod_cbk (call_frame_t *frame,
void *cookie,
@@ -377,8 +778,16 @@ error_gen_mknod (call_frame_t *frame,
mode_t mode,
dev_t rdev)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_MKNOD];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_MKNOD);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -418,8 +827,16 @@ error_gen_mkdir (call_frame_t *frame,
loc_t *loc,
mode_t mode)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_MKDIR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_MKDIR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -451,8 +868,16 @@ error_gen_unlink (call_frame_t *frame,
xlator_t *this,
loc_t *loc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_UNLINK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_UNLINK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -487,8 +912,16 @@ error_gen_rmdir (call_frame_t *frame,
xlator_t *this,
loc_t *loc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_RMDIR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_RMDIR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL,
@@ -503,7 +936,6 @@ error_gen_rmdir (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_symlink_cbk (call_frame_t *frame,
void *cookie,
@@ -526,8 +958,16 @@ error_gen_symlink (call_frame_t *frame,
const char *linkpath,
loc_t *loc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_SYMLINK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_SYMLINK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL,
@@ -542,7 +982,6 @@ error_gen_symlink (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_rename_cbk (call_frame_t *frame,
void *cookie,
@@ -567,8 +1006,16 @@ error_gen_rename (call_frame_t *frame,
loc_t *oldloc,
loc_t *newloc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_RENAME];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_RENAME);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL,
@@ -583,7 +1030,6 @@ error_gen_rename (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_link_cbk (call_frame_t *frame,
void *cookie,
@@ -606,8 +1052,16 @@ error_gen_link (call_frame_t *frame,
loc_t *oldloc,
loc_t *newloc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_LINK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_LINK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL,
@@ -622,7 +1076,6 @@ error_gen_link (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_create_cbk (call_frame_t *frame,
void *cookie,
@@ -647,8 +1100,16 @@ error_gen_create (call_frame_t *frame,
int32_t flags,
mode_t mode, fd_t *fd)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_CREATE];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_CREATE);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL,
@@ -684,8 +1145,16 @@ error_gen_open (call_frame_t *frame,
loc_t *loc,
int32_t flags, fd_t *fd, int32_t wbflags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_OPEN];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_OPEN);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -728,8 +1197,16 @@ error_gen_readv (call_frame_t *frame,
size_t size,
off_t offset)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_READV];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_READV);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, 0, NULL);
@@ -747,7 +1224,6 @@ error_gen_readv (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_writev_cbk (call_frame_t *frame,
void *cookie,
@@ -774,8 +1250,16 @@ error_gen_writev (call_frame_t *frame,
off_t off,
struct iobref *iobref)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_WRITEV];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_WRITEV);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -813,8 +1297,16 @@ error_gen_flush (call_frame_t *frame,
xlator_t *this,
fd_t *fd)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FLUSH];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FLUSH);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -829,7 +1321,6 @@ error_gen_flush (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_fsync_cbk (call_frame_t *frame,
void *cookie,
@@ -851,8 +1342,16 @@ error_gen_fsync (call_frame_t *frame,
fd_t *fd,
int32_t flags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FSYNC];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FSYNC);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -888,8 +1387,16 @@ error_gen_fstat (call_frame_t *frame,
xlator_t *this,
fd_t *fd)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FSTAT];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FSTAT);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -924,8 +1431,16 @@ error_gen_opendir (call_frame_t *frame,
xlator_t *this,
loc_t *loc, fd_t *fd)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_OPENDIR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_OPENDIR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -940,7 +1455,6 @@ error_gen_opendir (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_getdents_cbk (call_frame_t *frame,
void *cookie,
@@ -966,8 +1480,16 @@ error_gen_getdents (call_frame_t *frame,
off_t offset,
int32_t flag)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_GETDENTS];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_GETDENTS);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, 0);
@@ -985,7 +1507,6 @@ error_gen_getdents (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_setdents_cbk (call_frame_t *frame,
void *cookie,
@@ -1007,8 +1528,16 @@ error_gen_setdents (call_frame_t *frame,
dir_entry_t *entries,
int32_t count)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_SETDENTS];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_SETDENTS);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, 0);
@@ -1026,7 +1555,6 @@ error_gen_setdents (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_fsyncdir_cbk (call_frame_t *frame,
void *cookie,
@@ -1046,8 +1574,16 @@ error_gen_fsyncdir (call_frame_t *frame,
fd_t *fd,
int32_t flags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FSYNCDIR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FSYNCDIR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -1063,7 +1599,6 @@ error_gen_fsyncdir (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_statfs_cbk (call_frame_t *frame,
void *cookie,
@@ -1084,8 +1619,16 @@ error_gen_statfs (call_frame_t *frame,
xlator_t *this,
loc_t *loc)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_STATFS];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_STATFS);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1100,7 +1643,6 @@ error_gen_statfs (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_setxattr_cbk (call_frame_t *frame,
void *cookie,
@@ -1121,8 +1663,16 @@ error_gen_setxattr (call_frame_t *frame,
dict_t *dict,
int32_t flags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_SETXATTR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_SETXATTR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -1160,8 +1710,16 @@ error_gen_getxattr (call_frame_t *frame,
loc_t *loc,
const char *name)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_GETXATTR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_GETXATTR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1196,8 +1754,16 @@ error_gen_xattrop (call_frame_t *frame,
gf_xattrop_flags_t flags,
dict_t *dict)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_XATTROP];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_XATTROP);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1226,25 +1792,33 @@ error_gen_fxattrop_cbk (call_frame_t *frame,
int32_t
error_gen_fxattrop (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- gf_xattrop_flags_t flags,
- dict_t *dict)
+ xlator_t *this,
+ fd_t *fd,
+ gf_xattrop_flags_t flags,
+ dict_t *dict)
{
- int op_errno = 0;
- op_errno = error_gen(this);
- if (op_errno) {
- GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
- STACK_UNWIND (frame, -1, op_errno, NULL);
- return 0;
- }
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FXATTROP];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FXATTROP);
+
+ if (op_errno) {
+ GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
+ STACK_UNWIND (frame, -1, op_errno, NULL);
+ return 0;
+ }
- STACK_WIND (frame,
- error_gen_fxattrop_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fxattrop,
- fd, flags, dict);
- return 0;
+ STACK_WIND (frame,
+ error_gen_fxattrop_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fxattrop,
+ fd, flags, dict);
+ return 0;
}
int32_t
@@ -1266,8 +1840,16 @@ error_gen_removexattr (call_frame_t *frame,
loc_t *loc,
const char *name)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_REMOVEXATTR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_REMOVEXATTR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1305,8 +1887,16 @@ error_gen_lk (call_frame_t *frame,
int32_t cmd,
struct flock *lock)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_LK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_LK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1323,7 +1913,6 @@ error_gen_lk (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_inodelk_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno)
@@ -1333,14 +1922,21 @@ error_gen_inodelk_cbk (call_frame_t *frame, void *cookie,
return 0;
}
-
int32_t
error_gen_inodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, int32_t cmd,
+ const char *volume, loc_t *loc, int32_t cmd,
struct flock *lock)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_INODELK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_INODELK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -1355,7 +1951,6 @@ error_gen_inodelk (call_frame_t *frame, xlator_t *this,
return 0;
}
-
int32_t
error_gen_finodelk_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno)
@@ -1365,14 +1960,21 @@ error_gen_finodelk_cbk (call_frame_t *frame, void *cookie,
return 0;
}
-
int32_t
error_gen_finodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, fd_t *fd, int32_t cmd,
+ const char *volume, fd_t *fd, int32_t cmd,
struct flock *lock)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FINODELK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FINODELK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -1387,7 +1989,6 @@ error_gen_finodelk (call_frame_t *frame, xlator_t *this,
return 0;
}
-
int32_t
error_gen_entrylk_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno)
@@ -1402,8 +2003,16 @@ error_gen_entrylk (call_frame_t *frame, xlator_t *this,
const char *volume, loc_t *loc, const char *basename,
entrylk_cmd cmd, entrylk_type type)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_ENTRYLK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_ENTRYLK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -1431,8 +2040,16 @@ error_gen_fentrylk (call_frame_t *frame, xlator_t *this,
const char *volume, fd_t *fd, const char *basename,
entrylk_cmd cmd, entrylk_type type)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_FENTRYLK];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_FENTRYLK);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno);
@@ -1464,14 +2081,21 @@ error_gen_stats_cbk (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_stats (call_frame_t *frame,
xlator_t *this,
int32_t flags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_STATS];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_STATS);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1486,8 +2110,6 @@ error_gen_stats (call_frame_t *frame,
return 0;
}
-
-
int32_t
error_gen_getspec_cbk (call_frame_t *frame,
void *cookie,
@@ -1503,15 +2125,22 @@ error_gen_getspec_cbk (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_getspec (call_frame_t *frame,
xlator_t *this,
const char *key,
int32_t flags)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_GETSPEC];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_GETSPEC);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1526,7 +2155,6 @@ error_gen_getspec (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_checksum_cbk (call_frame_t *frame,
void *cookie,
@@ -1544,15 +2172,22 @@ error_gen_checksum_cbk (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_checksum (call_frame_t *frame,
xlator_t *this,
loc_t *loc,
int32_t flag)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_CHECKSUM];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_CHECKSUM);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -1580,7 +2215,6 @@ error_gen_readdir_cbk (call_frame_t *frame,
return 0;
}
-
int32_t
error_gen_readdir (call_frame_t *frame,
xlator_t *this,
@@ -1588,8 +2222,16 @@ error_gen_readdir (call_frame_t *frame,
size_t size,
off_t off)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_READDIR];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_READDIR);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1617,8 +2259,16 @@ int32_t
error_gen_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t off)
{
- int op_errno = 0;
- op_errno = error_gen(this);
+ int op_errno = 0;
+ eg_t *egp = NULL;
+ int enable = 1;
+
+ egp = this->private;
+ enable = egp->enable[ERR_READDIRP];
+
+ if (enable)
+ op_errno = error_gen (this, ERR_READDIRP);
+
if (op_errno) {
GF_ERROR(this, "unwind(-1, %s)", strerror (op_errno));
STACK_UNWIND (frame, -1, op_errno, NULL);
@@ -1630,7 +2280,6 @@ error_gen_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
return 0;
}
-
int32_t
error_gen_closedir (xlator_t *this,
fd_t *fd)
@@ -1648,31 +2297,113 @@ error_gen_close (xlator_t *this,
int
init (xlator_t *this)
{
- eg_t *pvt = NULL;
-
- if (!this->children || this->children->next) {
- gf_log (this->name, GF_LOG_ERROR,
- "error-gen not configured with one subvolume");
- return -1;
- }
-
- if (!this->parents) {
- gf_log (this->name, GF_LOG_WARNING,
- "dangling volume. check volfile ");
- }
-
- pvt = CALLOC (1, sizeof (eg_t));
- this->private = pvt;
- return 0;
+ eg_t *pvt = NULL;
+ data_t *error_no = NULL;
+ data_t *failure_percent = NULL;
+ data_t *enable = NULL;
+ int32_t ret = 0;
+ char *error_enable_fops = NULL;
+ char *op_no_str = NULL;
+ int op_no = -1;
+ int i = 0;
+ int32_t failure_percent_int = 0;
+
+ if (!this->children || this->children->next) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "error-gen not configured with one subvolume");
+ ret = -1;
+ goto out;
+ }
+
+ if (!this->parents) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "dangling volume. check volfile ");
+ }
+
+ error_no = dict_get (this->options, "error-no");
+ failure_percent = dict_get (this->options, "failure");
+ enable = dict_get (this->options, "enable");
+
+ pvt = CALLOC (1, sizeof (eg_t));
+
+ if (!pvt) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "out of memory.");
+ ret = -1;
+ goto out;
+ }
+
+ LOCK_INIT (&pvt->lock);
+
+ for (i = 0; i < NO_OF_FOPS; i++)
+ pvt->enable[i] = 0;
+ if (!error_no) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Warning error-no not specified.");
+ } else {
+ pvt->error_no = data_to_str (error_no);
+ }
+
+ if (!failure_percent) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "Warning, failure percent not specified.");
+ pvt->failure_iter_no = 100/GF_FAILURE_DEFAULT;
+ } else {
+ failure_percent_int = data_to_int32 (failure_percent);
+ if (failure_percent_int)
+ pvt->failure_iter_no = 100/failure_percent_int;
+ else
+ pvt->failure_iter_no = 100/GF_FAILURE_DEFAULT;
+ }
+
+ if (!enable) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Warning, all fops are enabled.");
+ for (i = 0; i < NO_OF_FOPS; i++)
+ pvt->enable[i] = 1;
+ } else {
+ error_enable_fops = data_to_str (enable);
+ op_no_str = error_enable_fops;
+ while ((*error_enable_fops) != '\0') {
+ error_enable_fops++;
+ if (((*error_enable_fops) == ',') ||
+ ((*error_enable_fops) == '\0')) {
+ if ((*error_enable_fops) != '\0') {
+ (*error_enable_fops) = '\0';
+ error_enable_fops++;
+ }
+ op_no = get_fop_int (&op_no_str);
+ if (op_no == -1) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Wrong option value %s",
+ op_no_str);
+ } else
+ pvt->enable[op_no] = 1;
+ op_no_str = error_enable_fops;
+ }
+ }
+ }
+ this->private = pvt;
+out:
+ return ret;
}
void
fini (xlator_t *this)
{
- gf_log (this->name, GF_LOG_DEBUG, "fini called");
- return;
-}
+ eg_t *pvt = NULL;
+
+ if (!this)
+ return;
+ pvt = this->private;
+ if (pvt) {
+ LOCK_DESTROY (&pvt->lock);
+ FREE (pvt);
+ gf_log (this->name, GF_LOG_DEBUG, "fini called");
+ }
+ return;
+}
struct xlator_fops fops = {
.lookup = error_gen_lookup,
@@ -1727,3 +2458,18 @@ struct xlator_cbks cbks = {
.release = error_gen_close,
.releasedir = error_gen_closedir,
};
+
+struct volume_options options[] = {
+ { .key = {"failure"},
+ .type = GF_OPTION_TYPE_INT },
+ { .key = {"error-no"},
+ .value = {"ENOENT","ENOTDIR","ENAMETOOLONG","EACCES","EBADF",
+ "EFAULT","ENOMEM","EINVAL","EIO","EEXIST","ENOSPC",
+ "EPERM","EROFS","EBUSY","EISDIR","ENOTEMPTY","EMLINK"
+ "ENODEV","EXDEV","EMFILE","ENFILE","ENOSYS","EINTR",
+ "EFBIG","EAGAIN"},
+ .type = GF_OPTION_TYPE_STR },
+ { .key = {"enable"},
+ .type = GF_OPTION_TYPE_STR },
+ { .key = {NULL} }
+};
diff --git a/xlators/debug/error-gen/src/error-gen.h b/xlators/debug/error-gen/src/error-gen.h
new file mode 100644
index 00000000000..7fb5fdfb56c
--- /dev/null
+++ b/xlators/debug/error-gen/src/error-gen.h
@@ -0,0 +1,89 @@
+/*
+ Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _ERROR_GEN_H
+#define _ERROR_GEN_H
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#define GF_FAILURE_DEFAULT 10
+#define NO_OF_FOPS 42
+
+enum {
+ ERR_LOOKUP,
+ ERR_STAT,
+ ERR_READLINK,
+ ERR_MKNOD,
+ ERR_MKDIR,
+ ERR_UNLINK,
+ ERR_RMDIR,
+ ERR_SYMLINK,
+ ERR_RENAME,
+ ERR_LINK,
+ ERR_TRUNCATE,
+ ERR_CREATE,
+ ERR_OPEN,
+ ERR_READV,
+ ERR_WRITEV,
+ ERR_STATFS,
+ ERR_FLUSH,
+ ERR_FSYNC,
+ ERR_SETXATTR,
+ ERR_GETXATTR,
+ ERR_REMOVEXATTR,
+ ERR_OPENDIR,
+ ERR_READDIR,
+ ERR_READDIRP,
+ ERR_GETDENTS,
+ ERR_FSYNCDIR,
+ ERR_ACCESS,
+ ERR_FTRUNCATE,
+ ERR_FSTAT,
+ ERR_LK,
+ ERR_SETDENTS,
+ ERR_CHECKSUM,
+ ERR_XATTROP,
+ ERR_FXATTROP,
+ ERR_INODELK,
+ ERR_FINODELK,
+ ERR_ENTRYLK,
+ ERR_FENTRYLK,
+ ERR_SETATTR,
+ ERR_FSETATTR,
+ ERR_STATS,
+ ERR_GETSPEC
+};
+
+typedef struct {
+ int enable[NO_OF_FOPS];
+ int op_count;
+ int failure_iter_no;
+ char *error_no;
+ gf_lock_t lock;
+} eg_t;
+
+typedef struct {
+ int error_no_count;
+ int error_no[20];
+} sys_error_t;
+
+#endif