Split out td error handling code
authorJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2013 17:27:46 +0000 (19:27 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2013 17:27:46 +0000 (19:27 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Makefile
fio.h
td_error.c [new file with mode: 0644]
td_error.h [new file with mode: 0644]
thread_options.h

index e93bf4d748f0b1d112bcef031bde7ac6af578ee0..c5cef311162e2554bf7b662e245fd32c272b6c1b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
                memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
                cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
                lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
-               lib/hweight.c lib/getrusage.c idletime.c
+               lib/hweight.c lib/getrusage.c idletime.c td_error.c
 
 ifdef CONFIG_64BIT_LLP64
   CFLAGS += -DBITS_PER_LONG=32
diff --git a/fio.h b/fio.h
index 47e711fd4482f3adbf676aaade486e3a7f93a05f..d5746dd4453bb42de63ca581d5969b769d5fbcb4 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -375,42 +375,6 @@ static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u)
 
 #define REAL_MAX_JOBS          2048
 
-static inline enum error_type_bit td_error_type(enum fio_ddir ddir, int err)
-{
-       if (err == EILSEQ)
-               return ERROR_TYPE_VERIFY_BIT;
-       if (ddir == DDIR_READ)
-               return ERROR_TYPE_READ_BIT;
-       return ERROR_TYPE_WRITE_BIT;
-}
-
-static int __NON_FATAL_ERR[] = {EIO, EILSEQ};
-static inline int td_non_fatal_error(struct thread_data *td,
-                                    enum error_type_bit etype, int err)
-{
-       unsigned int i;
-
-       if (!td->o.ignore_error[etype]) {
-               td->o.ignore_error[etype] = __NON_FATAL_ERR;
-               td->o.ignore_error_nr[etype] = sizeof(__NON_FATAL_ERR)
-                       / sizeof(int);
-       }
-
-       if (!(td->o.continue_on_error & (1 << etype)))
-               return 0;
-       for (i = 0; i < td->o.ignore_error_nr[etype]; i++)
-               if (td->o.ignore_error[etype][i] == err)
-                       return 1;
-       return 0;
-}
-
-static inline void update_error_count(struct thread_data *td, int err)
-{
-       td->total_err_count++;
-       if (td->total_err_count == 1)
-               td->first_error = err;
-}
-
 static inline int should_fsync(struct thread_data *td)
 {
        if (td->last_was_sync)
diff --git a/td_error.c b/td_error.c
new file mode 100644 (file)
index 0000000..903f9ea
--- /dev/null
@@ -0,0 +1,41 @@
+#include "fio.h"
+#include "io_ddir.h"
+#include "td_error.h"
+
+static int __NON_FATAL_ERR[] = { EIO, EILSEQ };
+
+enum error_type_bit td_error_type(enum fio_ddir ddir, int err)
+{
+       if (err == EILSEQ)
+               return ERROR_TYPE_VERIFY_BIT;
+       if (ddir == DDIR_READ)
+               return ERROR_TYPE_READ_BIT;
+       return ERROR_TYPE_WRITE_BIT;
+}
+
+int td_non_fatal_error(struct thread_data *td, enum error_type_bit etype,
+                      int err)
+{
+       unsigned int i;
+
+       if (!td->o.ignore_error[etype]) {
+               td->o.ignore_error[etype] = __NON_FATAL_ERR;
+               td->o.ignore_error_nr[etype] = sizeof(__NON_FATAL_ERR)
+                       / sizeof(int);
+       }
+
+       if (!(td->o.continue_on_error & (1 << etype)))
+               return 0;
+       for (i = 0; i < td->o.ignore_error_nr[etype]; i++)
+               if (td->o.ignore_error[etype][i] == err)
+                       return 1;
+
+       return 0;
+}
+
+void update_error_count(struct thread_data *td, int err)
+{
+       td->total_err_count++;
+       if (td->total_err_count == 1)
+               td->first_error = err;
+}
diff --git a/td_error.h b/td_error.h
new file mode 100644 (file)
index 0000000..1133989
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef FIO_TD_ERROR_H
+#define FIO_TD_ERROR_H
+
+/*
+ * What type of errors to continue on when continue_on_error is used
+ */
+enum error_type_bit {
+       ERROR_TYPE_READ_BIT = 0,
+       ERROR_TYPE_WRITE_BIT = 1,
+       ERROR_TYPE_VERIFY_BIT = 2,
+       ERROR_TYPE_CNT = 3,
+};
+
+enum error_type {
+        ERROR_TYPE_NONE = 0,
+        ERROR_TYPE_READ = 1 << ERROR_TYPE_READ_BIT,
+        ERROR_TYPE_WRITE = 1 << ERROR_TYPE_WRITE_BIT,
+        ERROR_TYPE_VERIFY = 1 << ERROR_TYPE_VERIFY_BIT,
+        ERROR_TYPE_ANY = 0xffff,
+};
+
+enum error_type_bit td_error_type(enum fio_ddir ddir, int err);
+int td_non_fatal_error(struct thread_data *td, enum error_type_bit etype,
+                      int err);
+void update_error_count(struct thread_data *td, int err);
+
+#endif
index 60a1b691bd51122429887950085458f6415b3bfc..f25988ac1922a97fa23468678bb742de1fe0dcfa 100644 (file)
@@ -6,6 +6,7 @@
 #include "stat.h"
 #include "gettime.h"
 #include "lib/ieee754.h"
+#include "td_error.h"
 
 /*
  * What type of allocation to use for io buffers
@@ -18,26 +19,8 @@ enum fio_memtype {
        MEM_MMAPHUGE,   /* memory mapped huge file */
 };
 
-/*
- * What type of errors to continue on when continue_on_error is used
- */
-enum error_type_bit {
-       ERROR_TYPE_READ_BIT = 0,
-       ERROR_TYPE_WRITE_BIT = 1,
-       ERROR_TYPE_VERIFY_BIT = 2,
-       ERROR_TYPE_CNT = 3,
-};
-
 #define ERROR_STR_MAX  128
 
-enum error_type {
-        ERROR_TYPE_NONE = 0,
-        ERROR_TYPE_READ = 1 << ERROR_TYPE_READ_BIT,
-        ERROR_TYPE_WRITE = 1 << ERROR_TYPE_WRITE_BIT,
-        ERROR_TYPE_VERIFY = 1 << ERROR_TYPE_VERIFY_BIT,
-        ERROR_TYPE_ANY = 0xffff,
-};
-
 #define BSSPLIT_MAX    64
 
 struct bssplit {