#include "lib/rand.h"
#include "memalign.h"
#include "server.h"
+#include "lib/getrusage.h"
+#include "idletime.h"
static pthread_t disk_util_thread;
static struct fio_mutex *disk_thread_mutex;
return 0;
}
+static int fio_file_fsync(struct thread_data *td, struct fio_file *f)
+{
+ int ret;
+
+ if (fio_file_open(f))
+ return fio_io_sync(td, f);
+
+ if (td_io_open_file(td, f))
+ return 1;
+
+ ret = fio_io_sync(td, f);
+ td_io_close_file(td, f);
+ return ret;
+}
+
static inline void __update_tv_cache(struct thread_data *td)
{
fio_gettime(&td->tv_cache, NULL);
i = td->cur_depth;
if (i) {
- ret = io_u_queued_complete(td, i, NULL);
+ ret = io_u_queued_complete(td, i, bytes_done);
if (td->o.fill_device && td->error == ENOSPC)
td->error = 0;
}
td_set_runstate(td, TD_FSYNCING);
for_each_file(td, f, i) {
- if (!fio_file_open(f))
+ if (!fio_file_fsync(td, f))
continue;
- fio_io_sync(td, f);
+
+ log_err("fio: end_fsync failed for file %s\n",
+ f->file_name);
}
}
} else
return 1;
}
- if (ddir_rw_sum(td->io_bytes) < td->o.size)
+ if (ddir_rw_sum(td->io_bytes) < td->o.size) {
+ uint64_t diff;
+
+ /*
+ * If the difference is less than the minimum IO size, we
+ * are done.
+ */
+ diff = td->o.size - ddir_rw_sum(td->io_bytes);
+ if (diff < td->o.rw_min_bs)
+ return 0;
+
return 1;
+ }
return 0;
}
}
fio_gettime(&td->epoch, NULL);
-#ifdef RUSAGE_THREAD
- getrusage(RUSAGE_THREAD, &td->ru_start);
-#else
- getrusage(RUSAGE_SELF, &td->ru_start);
-#endif
+ fio_getrusage(&td->ru_start);
clear_state = 0;
while (keep_running(td)) {
uint64_t verify_bytes;
if (fio_gtod_offload && fio_start_gtod_thread())
return;
+
+ fio_idle_prof_init();
set_sig_handlers();
}
}
+ /* start idle threads before io threads start to run */
+ fio_idle_prof_start();
+
set_genesis_time();
while (todo) {
usleep(10000);
}
+ fio_idle_prof_stop();
+
update_io_ticks();
fio_unpin_memory();
}