static int init_io_u(struct thread_data *td)
{
- unsigned long long buf_size;
struct io_u *io_u;
unsigned int max_bs;
int i, max_units;
max_units = td->o.iodepth;
max_bs = max(td->o.max_bs[DDIR_READ], td->o.max_bs[DDIR_WRITE]);
- buf_size = (unsigned long long) max_bs * (unsigned long long) max_units;
- buf_size += page_mask;
- if (buf_size != (size_t) buf_size) {
- log_err("fio: IO memory too large. Reduce max_bs or iodepth\n");
- return 1;
- }
-
- td->orig_buffer_size = buf_size;
+ td->orig_buffer_size = (unsigned long long) max_bs * (unsigned long long) max_units;
if (td->o.mem_type == MEM_SHMHUGE || td->o.mem_type == MEM_MMAPHUGE)
td->orig_buffer_size = (td->orig_buffer_size + td->o.hugepage_size - 1) & ~(td->o.hugepage_size - 1);
- else if (td->orig_buffer_size & page_mask)
- td->orig_buffer_size = (td->orig_buffer_size + page_mask) & ~page_mask;
+
+ if (td->orig_buffer_size != (size_t) td->orig_buffer_size) {
+ log_err("fio: IO memory too large. Reduce max_bs or iodepth\n");
+ return 1;
+ }
if (allocate_io_mem(td))
return 1;
return 0;
}
+static int keep_running(struct thread_data *td)
+{
+ unsigned long long io_done;
+
+ if (td->o.time_based)
+ return 1;
+ if (td->o.loops) {
+ td->o.loops--;
+ return 1;
+ }
+
+ io_done = td->io_bytes[DDIR_READ] + td->io_bytes[DDIR_WRITE];
+ if (io_done < td->o.size)
+ return 1;
+
+ return 0;
+}
+
static int clear_io_state(struct thread_data *td)
{
struct fio_file *f;
td->last_was_sync = 0;
+ td->nr_done_files = 0;
+
for_each_file(td, f, i)
td_io_close_file(td, f);
ret = 0;
for_each_file(td, f, i) {
+ f->flags &= ~FIO_FILE_DONE;
ret = td_io_open_file(td, f);
if (ret)
break;
if (init_io_u(td))
goto err;
- if (fio_setaffinity(td) == -1) {
+ if (td->o.cpumask_set && fio_setaffinity(td) == -1) {
td_verror(td, errno, "cpu_set_affinity");
goto err;
}
runtime[0] = runtime[1] = 0;
clear_state = 0;
- while (td->o.time_based || td->o.loops--) {
+ while (keep_running(td)) {
fio_gettime(&td->start, NULL);
memcpy(&td->ts.stat_sample_time, &td->start, sizeof(td->start));