+static void *submitter_sync_fn(void *data)
+{
+ struct submitter *s = data;
+ int ret;
+
+ submitter_init(s);
+
+ do {
+ uint64_t offset;
+ struct file *f;
+ long r;
+
+ if (s->nr_files == 1) {
+ f = &s->files[0];
+ } else {
+ f = &s->files[s->cur_file];
+ if (f->pending_ios >= file_depth(s)) {
+ s->cur_file++;
+ if (s->cur_file == s->nr_files)
+ s->cur_file = 0;
+ f = &s->files[s->cur_file];
+ }
+ }
+ f->pending_ios++;
+
+ if (random_io) {
+ r = __rand64(&s->rand_state);
+ offset = (r % (f->max_blocks - 1)) * bs;
+ } else {
+ offset = f->cur_off;
+ f->cur_off += bs;
+ if (f->cur_off + bs > f->max_size)
+ f->cur_off = 0;
+ }
+
+#ifdef ARCH_HAVE_CPU_CLOCK
+ if (stats)
+ s->clock_batch[s->clock_index] = get_cpu_clock();
+#endif
+
+ s->inflight++;
+ s->calls++;
+
+ if (polled)
+ ret = preadv2(f->real_fd, &s->iovecs[0], 1, offset, RWF_HIPRI);
+ else
+ ret = preadv2(f->real_fd, &s->iovecs[0], 1, offset, 0);
+
+ if (ret < 0) {
+ perror("preadv2");
+ break;
+ } else if (ret != bs) {
+ break;
+ }
+
+ s->done++;
+ s->inflight--;
+ f->pending_ios--;
+ if (stats)
+ add_stat(s, s->clock_index, 1);
+ } while (!s->finish);
+
+ finish = 1;
+ return NULL;
+}
+