From 3c978125e2bc883a9e69f0bae0122f936f995f17 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 17 Apr 2013 19:27:46 +0200 Subject: [PATCH] Split out td error handling code Signed-off-by: Jens Axboe --- Makefile | 2 +- fio.h | 36 ------------------------------------ td_error.c | 41 +++++++++++++++++++++++++++++++++++++++++ td_error.h | 27 +++++++++++++++++++++++++++ thread_options.h | 19 +------------------ 5 files changed, 70 insertions(+), 55 deletions(-) create mode 100644 td_error.c create mode 100644 td_error.h diff --git a/Makefile b/Makefile index e93bf4d7..c5cef311 100644 --- 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 47e711fd..d5746dd4 100644 --- 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 index 00000000..903f9ea5 --- /dev/null +++ b/td_error.c @@ -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 index 00000000..11339898 --- /dev/null +++ b/td_error.h @@ -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 diff --git a/thread_options.h b/thread_options.h index 60a1b691..f25988ac 100644 --- a/thread_options.h +++ b/thread_options.h @@ -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 { -- 2.25.1