X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=2e9dac0db6b4aa0adae673a3b21d26173e48da3e;hp=34ab58a11ddc83066d410cc6db71fe7ff8bcff8a;hb=656b1393d43f9f22738404582ea14dec956aea83;hpb=b23b6a2f66637e326c5825bf438059ecc62008d4 diff --git a/io_u.c b/io_u.c index 34ab58a1..2e9dac0d 100644 --- a/io_u.c +++ b/io_u.c @@ -231,11 +231,6 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u) return 0; } -static inline int is_power_of_2(unsigned int val) -{ - return (val != 0 && ((val & (val - 1)) == 0)); -} - static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u) { const int ddir = io_u->ddir; @@ -363,6 +358,22 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td) { enum fio_ddir ddir; + /* + * see if it's time to fsync + */ + if (td->o.fsync_blocks && + !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks) && + td->io_issues[DDIR_WRITE] && should_fsync(td)) + return DDIR_SYNC; + + /* + * see if it's time to fdatasync + */ + if (td->o.fdatasync_blocks && + !(td->io_issues[DDIR_WRITE] % td->o.fdatasync_blocks) && + td->io_issues[DDIR_WRITE] && should_fsync(td)) + return DDIR_DATASYNC; + if (td_rw(td)) { /* * Check if it's time to seed a new data direction. @@ -412,6 +423,12 @@ void put_io_u(struct thread_data *td, struct io_u *io_u) td->cur_depth--; } +void clear_io_u(struct thread_data *td, struct io_u *io_u) +{ + io_u->flags &= ~IO_U_F_FLIGHT; + put_io_u(td, io_u); +} + void requeue_io_u(struct thread_data *td, struct io_u **io_u) { struct io_u *__io_u = *io_u; @@ -419,7 +436,7 @@ void requeue_io_u(struct thread_data *td, struct io_u **io_u) dprint(FD_IO, "requeue %p\n", __io_u); __io_u->flags |= IO_U_F_FREE; - if ((__io_u->flags & IO_U_F_FLIGHT) && (__io_u->ddir != DDIR_SYNC)) + if ((__io_u->flags & IO_U_F_FLIGHT) && !ddir_sync(__io_u->ddir)) td->io_issues[__io_u->ddir]--; __io_u->flags &= ~IO_U_F_FLIGHT; @@ -435,17 +452,13 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) if (td->io_ops->flags & FIO_NOIO) goto out; + io_u->ddir = get_rw_ddir(td); + /* - * see if it's time to sync + * fsync() or fdatasync(), we are done */ - if (td->o.fsync_blocks && - !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks) && - td->io_issues[DDIR_WRITE] && should_fsync(td)) { - io_u->ddir = DDIR_SYNC; + if (ddir_sync(io_u->ddir)) goto out; - } - - io_u->ddir = get_rw_ddir(td); /* * See if it's time to switch to a new zone @@ -872,7 +885,7 @@ struct io_u *get_io_u(struct thread_data *td) f = io_u->file; assert(fio_file_open(f)); - if (io_u->ddir != DDIR_SYNC) { + if (!ddir_sync(io_u->ddir)) { if (!io_u->buflen && !(td->io_ops->flags & FIO_NOIO)) { dprint(FD_IO, "get_io_u: zero buflen on %p\n", io_u); goto err_put; @@ -936,7 +949,7 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, assert(io_u->flags & IO_U_F_FLIGHT); io_u->flags &= ~IO_U_F_FLIGHT; - if (io_u->ddir == DDIR_SYNC) { + if (ddir_sync(io_u->ddir)) { td->last_was_sync = 1; return; } @@ -994,6 +1007,17 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, icd->error = io_u->error; io_u_log_error(td, io_u); } + if (td->o.continue_on_error && icd->error && + td_non_fatal_error(icd->error)) { + /* + * If there is a non_fatal error, then add to the error count + * and clear all the errors. + */ + update_error_count(td, icd->error); + td_clear_error(td); + icd->error = 0; + io_u->error = 0; + } } static void init_icd(struct thread_data *td, struct io_completion_data *icd,