create_on_open=bool Don't pre-setup the files for IO, just create open()
when it's time to do IO to that file.
+pre_read=bool If this is given, files will be pre-read into memory before
+ starting the given IO operation.
+
unlink=bool Unlink the job files when done. Not the default, as repeated
runs of that job would then waste time recreating the file
set again and again.
return 1;
}
+static int pre_read_file(struct thread_data *td, struct fio_file *f)
+{
+ int r;
+ unsigned long long left;
+ unsigned int bs;
+ char *b;
+
+ bs = td->o.max_bs[DDIR_READ];
+ b = malloc(bs);
+ memset(b, 0, bs);
+
+ lseek(f->fd, f->file_offset, SEEK_SET);
+ left = f->io_size;
+
+ while (left && !td->terminate) {
+ if (bs > left)
+ bs = left;
+
+ r = read(f->fd, b, bs);
+
+ if (r == (int) bs) {
+ left -= bs;
+ continue;
+ } else {
+ td_verror(td, EIO, "pre_read");
+ break;
+ }
+ }
+
+ free(b);
+ return 0;
+}
+
static unsigned long long get_rand_file_size(struct thread_data *td)
{
unsigned long long ret, sized;
return 1;
}
+int pre_read_files(struct thread_data *td)
+{
+ struct fio_file *f;
+ unsigned int i;
+
+ dprint(FD_FILE, "pre_read files\n");
+
+ for_each_file(td, f, i) {
+ pre_read_file(td, f);
+ }
+
+ return 1;
+}
+
int init_random_map(struct thread_data *td)
{
unsigned long long blocks, num_maps;
goto err;
}
+ if (td->o.pre_read) {
+ if (pre_read_files(td) < 0)
+ goto err;
+ }
+
fio_gettime(&td->epoch, NULL);
getrusage(RUSAGE_SELF, &td->ts.ru_start);
unsigned int create_fsync;
unsigned int create_on_open;
unsigned int end_fsync;
+ unsigned int pre_read;
unsigned int sync_io;
unsigned int verify;
unsigned int do_verify;
extern int __must_check generic_open_file(struct thread_data *, struct fio_file *);
extern int __must_check generic_close_file(struct thread_data *, struct fio_file *);
extern int __must_check generic_get_file_size(struct thread_data *, struct fio_file *);
+extern int __must_check pre_read_files(struct thread_data *);
extern int add_file(struct thread_data *, const char *);
extern void get_file(struct fio_file *);
extern int __must_check put_file(struct thread_data *, struct fio_file *);
.help = "Create files when they are opened for IO",
.def = "0",
},
+ {
+ .name = "pre_read",
+ .type = FIO_OPT_BOOL,
+ .off1 = td_var_offset(pre_read),
+ .help = "Preread files before starting official testing",
+ .def = "0",
+ },
{
.name = "cpuload",
.type = FIO_OPT_INT,