- /*
- * we can only have one finished io_u for sync io, since the depth
- * is always 1
- */
- if (list_empty(&td->io_u_busylist))
- return 0;
+ if (!td_random(td)) {
+ if (posix_madvise(f->mmap_ptr, length, POSIX_MADV_SEQUENTIAL) < 0) {
+ td_verror(td, errno, "madvise");
+ goto err;
+ }
+ } else {
+ if (posix_madvise(f->mmap_ptr, length, POSIX_MADV_RANDOM) < 0) {
+ td_verror(td, errno, "madvise");
+ goto err;
+ }
+ }
+
+err:
+ if (td->error && f->mmap_ptr)
+ munmap(f->mmap_ptr, length);
+
+ return td->error;
+}
+
+/*
+ * Just mmap an appropriate portion, we cannot mmap the full extent
+ */
+static int fio_mmapio_prep_limited(struct thread_data *td, struct io_u *io_u)
+{
+ struct fio_file *f = io_u->file;
+
+ if (io_u->buflen > mmap_map_size) {
+ log_err("fio: bs too big for mmap engine\n");
+ return EIO;
+ }