X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=c6d814bf6d8765904f74b9ac01c0dfeaf48cb77a;hp=69bec4bf4bcf83d57d1edf40e63c0a34f912bd02;hb=f686097271b5f9bfcb05f61bce297c29b1e4ece1;hpb=5c8e84cab3bca39de54a69092473f000f8a57f40 diff --git a/io_u.c b/io_u.c index 69bec4bf..c6d814bf 100644 --- a/io_u.c +++ b/io_u.c @@ -62,6 +62,7 @@ static uint64_t last_block(struct thread_data *td, struct fio_file *f, /* * Hmm, should we make sure that ->io_size <= ->real_file_size? + * -> not for now since there is code assuming it could go either. */ max_size = f->io_size; if (max_size > f->real_file_size) @@ -532,6 +533,7 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, unsigned int buflen = 0; unsigned int minbs, maxbs; uint64_t frand_max, r; + bool power_2; assert(ddir_rw(ddir)); @@ -576,9 +578,11 @@ static unsigned int __get_next_buflen(struct thread_data *td, struct io_u *io_u, } } - if (!td->o.bs_unaligned && is_power_of_2(minbs)) + power_2 = is_power_of_2(minbs); + if (!td->o.bs_unaligned && power_2) buflen &= ~(minbs - 1); - + else if (!td->o.bs_unaligned && !power_2) + buflen -= buflen % minbs; } while (!io_u_fits(td, io_u, buflen)); return buflen; @@ -642,7 +646,7 @@ int io_u_quiesce(struct thread_data *td) } while (td->io_u_in_flight) { - int fio_unused ret; + int ret; ret = io_u_queued_complete(td, 1); if (ret > 0) @@ -713,28 +717,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 + * See if it's time to fsync/fdatasync/sync_file_range first, + * and if not then move on to check regular I/Os. */ - 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; - - /* - * see if it's time to sync_file_range - */ - if (td->sync_file_range_nr && - !(td->io_issues[DDIR_WRITE] % td->sync_file_range_nr) && - td->io_issues[DDIR_WRITE] && should_fsync(td)) - return DDIR_SYNC_FILE_RANGE; + if (should_fsync(td)) { + if (td->o.fsync_blocks && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks)) + return DDIR_SYNC; + + if (td->o.fdatasync_blocks && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->o.fdatasync_blocks)) + return DDIR_DATASYNC; + + if (td->sync_file_range_nr && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->sync_file_range_nr)) + return DDIR_SYNC_FILE_RANGE; + } if (td_rw(td)) { /* @@ -1733,6 +1731,9 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, if (td->parent) td = td->parent; + if (!td->o.stats) + return; + if (no_reduce) lusec = utime_since(&io_u->issue_time, &icd->time); @@ -1959,7 +1960,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts) int ret, ddir; struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, }; - dprint(FD_IO, "io_u_queued_completed: min=%d\n", min_evts); + dprint(FD_IO, "io_u_queued_complete: min=%d\n", min_evts); if (!min_evts) tvp = &ts; @@ -1993,7 +1994,7 @@ int io_u_queued_complete(struct thread_data *td, int min_evts) */ void io_u_queued(struct thread_data *td, struct io_u *io_u) { - if (!td->o.disable_slat) { + if (!td->o.disable_slat && ramp_time_over(td) && td->o.stats) { unsigned long slat_time; slat_time = utime_since(&io_u->start_time, &io_u->issue_time);