io_u->end_io = verify_io_u;
ddir = io_u->ddir;
+ if (!td->o.disable_slat)
+ fio_gettime(&io_u->start_time, NULL);
ret = td_io_queue(td, io_u);
switch (ret) {
if (!td->o.number_ios)
return 0;
- number_ios = ddir_rw_sum(td->this_io_blocks);
+ number_ios = ddir_rw_sum(td->io_blocks);
number_ios += td->io_u_queued + td->io_u_in_flight;
- return number_ios >= td->o.number_ios;
+ return number_ios >= (td->o.number_ios * td->loops);
}
-static int io_bytes_exceeded(struct thread_data *td)
+static int io_issue_bytes_exceeded(struct thread_data *td)
+{
+ unsigned long long bytes, limit;
+
+ if (td_rw(td))
+ bytes = td->io_issue_bytes[DDIR_READ] + td->io_issue_bytes[DDIR_WRITE];
+ else if (td_write(td))
+ bytes = td->io_issue_bytes[DDIR_WRITE];
+ else if (td_read(td))
+ bytes = td->io_issue_bytes[DDIR_READ];
+ else
+ bytes = td->io_issue_bytes[DDIR_TRIM];
+
+ if (td->o.io_limit)
+ limit = td->o.io_limit;
+ else
+ limit = td->o.size;
+
+ limit *= td->loops;
+ return bytes >= limit || exceeds_number_ios(td);
+}
+
+static int io_complete_bytes_exceeded(struct thread_data *td)
{
unsigned long long bytes, limit;
else
limit = td->o.size;
+ limit *= td->loops;
return bytes >= limit || exceeds_number_ios(td);
}
lat_target_init(td);
+ total_bytes = td->o.size;
+ /*
+ * Allow random overwrite workloads to write up to io_limit
+ * before starting verification phase as 'size' doesn't apply.
+ */
+ if (td_write(td) && td_random(td) && td->o.norandommap)
+ total_bytes = max(total_bytes, (uint64_t) td->o.io_limit);
/*
* If verify_backlog is enabled, we'll run the verify in this
* handler as well. For that case, we may need up to twice the
* amount of bytes.
*/
- total_bytes = td->o.size;
if (td->o.verify != VERIFY_NONE &&
(td_write(td) && td->o.verify_backlog))
total_bytes += td->o.size;
+ /* In trimwrite mode, each byte is trimmed and then written, so
+ * allow total_bytes to be twice as big */
+ if (td_trimwrite(td))
+ total_bytes += td->total_io_size;
+
while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
- (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) ||
+ (!flist_empty(&td->trim_list)) || !io_issue_bytes_exceeded(td) ||
td->o.time_based) {
struct timeval comp_time;
struct io_u *io_u;
td_set_runstate(td, TD_RUNNING);
while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
- (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) {
+ (!flist_empty(&td->trim_list)) || !io_complete_bytes_exceeded(td)) {
struct io_u *io_u;
int ret;
clear_state = 1;
+ /*
+ * Make sure we've successfully updated the rusage stats
+ * before waiting on the stat mutex. Otherwise we could have
+ * the stat thread holding stat mutex and waiting for
+ * the rusage_sem, which would never get upped because
+ * this thread is waiting for the stat mutex.
+ */
+ check_update_rusage(td);
+
fio_mutex_down(stat_mutex);
if (td_read(td) && td->io_bytes[DDIR_READ]) {
elapsed = mtime_since_now(&td->start);
do_verify(td, verify_bytes);
+ /*
+ * See comment further up for why this is done here.
+ */
+ check_update_rusage(td);
+
fio_mutex_down(stat_mutex);
td->ts.runtime[DDIR_READ] += mtime_since_now(&td->start);
fio_gettime(&td->start, NULL);
gettimeofday(&tv, NULL);
ts.tv_sec = tv.tv_sec + sec;
ts.tv_nsec = (tv.tv_usec * 1000) + nsec;
- if (ts.tv_nsec > 1000000000ULL) {
+
+ if (ts.tv_nsec >= 1000000000ULL) {
ts.tv_nsec -= 1000000000ULL;
ts.tv_sec++;
}