Add a 'continue_on_error' option to fio

Add option to make fio continue on non-fatal errors.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.h b/fio.h
index 21d49a6..477b19a 100644
--- a/fio.h
+++ b/fio.h
@@ -111,6 +111,13 @@
 	unsigned long long io_bytes[2];
 	unsigned long runtime[2];
 	unsigned long total_run_time;
+
+	/*
+	 * IO Error related stats
+	 */
+	unsigned continue_on_error;
+	unsigned long total_err_count;
+	int first_error;
 };
 
 struct bssplit {
@@ -241,6 +248,11 @@
 	 */
 	unsigned int cpuload;
 	unsigned int cpucycle;
+
+	/*
+	 * I/O Error handling
+	 */
+	unsigned int continue_on_error;
 };
 
 #define FIO_VERROR_SIZE	128
@@ -369,6 +381,12 @@
 	 * For generating file sizes
 	 */
 	os_random_state_t file_size_state;
+
+	/*
+	 * Error counts
+	 */
+	unsigned int total_err_count;
+	int first_error;
 };
 
 /*
@@ -386,10 +404,13 @@
 			break;						\
 		int e = (err);						\
 		(td)->error = e;					\
-		snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg));	\
+		if (!(td)->first_error)					\
+			snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, func=%s, error=%s", __FILE__, __LINE__, (func), (msg));		\
 	} while (0)
 
 
+#define td_clear_error(td)		\
+	(td)->error = 0;
 #define td_verror(td, err, func)	\
 	__td_verror((td), (err), strerror((err)), (func))
 #define td_vmsg(td, err, msg, func)	\
@@ -425,6 +446,15 @@
 
 #define MAX_JOBS	(1024)
 
+#define td_non_fatal_error(e)	((e) == -EIO || (e) == EILSEQ)
+
+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)