X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=738f3e20101eee5e3535f1ff52fd344286c45745;hp=962c17a9e8ddeb7c0ffa70926aa30142b417e947;hb=87dc1ab1b4df7b977f60e3d43533a896e2ee665b;hpb=dfd7bc2c24d3a4281982eaf4f83aa1aeb09424de diff --git a/io_u.c b/io_u.c index 962c17a9..738f3e20 100644 --- a/io_u.c +++ b/io_u.c @@ -189,6 +189,16 @@ static int fill_io_u(struct thread_data *td, struct fio_file *f, if (td->read_iolog) return read_iolog_get(td, io_u); + /* + * see if it's time to sync + */ + if (td->fsync_blocks && !(td->io_blocks[DDIR_WRITE] % td->fsync_blocks) + && should_fsync(td)) { + io_u->ddir = DDIR_SYNC; + io_u->file = f; + return 0; + } + /* * No log, let the seq/rand engine retrieve the next position. */ @@ -260,18 +270,20 @@ struct io_u *get_io_u(struct thread_data *td, struct fio_file *f) io_u->buflen = f->file_size - io_u->offset; } - if (!io_u->buflen) { - put_io_u(td, io_u); - return NULL; - } + if (io_u->ddir != DDIR_SYNC) { + if (!io_u->buflen) { + put_io_u(td, io_u); + return NULL; + } - if (!td->read_iolog && !td->sequential) - mark_random_map(td, f, io_u); + if (!td->read_iolog && !td->sequential) + mark_random_map(td, f, io_u); - f->last_pos += io_u->buflen; + f->last_pos += io_u->buflen; - if (td->verify != VERIFY_NONE) - populate_verify_io_u(td, io_u); + if (td->verify != VERIFY_NONE) + populate_verify_io_u(td, io_u); + } if (td_io_prep(td, io_u)) { put_io_u(td, io_u); @@ -288,6 +300,13 @@ void io_completed(struct thread_data *td, struct io_u *io_u, struct timeval e; unsigned long msec; + if (io_u->ddir == DDIR_SYNC) { + td->last_was_sync = 1; + return; + } + + td->last_was_sync = 0; + gettimeofday(&e, NULL); if (!io_u->error) {