4 * IO engine that doesn't do any IO, just creates files and tracks the latency
5 * of the file creation.
13 #include "../filehash.h"
15 static int open_file(struct thread_data *td, struct fio_file *f)
17 struct timespec start, end;
19 int do_lat = !td->o.disable_lat;
21 dprint(FD_FILE, "fd open %s\n", f->file_name);
23 if (f->filetype != FIO_TYPE_FILE) {
24 log_err("fio: only files are supported fallocate \n");
27 if (!strcmp(f->file_name, "-")) {
28 log_err("fio: can't read/write to stdin/out\n");
34 fio_gettime(&start, NULL);
35 from_hash = file_lookup_open(f, O_CREAT|O_RDWR);
37 unsigned long long nsec;
39 fio_gettime(&end, NULL);
40 nsec = ntime_since(&start, &end);
41 add_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
45 char buf[FIO_VERROR_SIZE];
48 snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
49 td_verror(td, e, buf);
52 if (!from_hash && f->fd != -1) {
53 if (add_file_hash(f)) {
57 * OK to ignore, we haven't done anything with it
59 ret = generic_close_file(td, f);
67 static int queue_io(struct thread_data *td, struct io_u fio_unused *io_u)
69 return FIO_Q_COMPLETED;
73 * Ensure that we at least have a block size worth of IO to do for each
74 * file. If the job file has td->o.size < nr_files * block_size, then
75 * fio won't do anything.
77 static int get_file_size(struct thread_data *td, struct fio_file *f)
79 f->real_file_size = td_min_bs(td);
83 static struct ioengine_ops ioengine = {
85 .version = FIO_IOOPS_VERSION,
87 .get_file_size = get_file_size,
88 .open_file = open_file,
89 .close_file = generic_close_file,
90 .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO,
93 static void fio_init fio_filecreate_register(void)
95 register_ioengine(&ioengine);
98 static void fio_exit fio_filecreate_unregister(void)
100 unregister_ioengine(&ioengine);