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;
72 static struct ioengine_ops ioengine = {
74 .version = FIO_IOOPS_VERSION,
75 .open_file = open_file,
77 .close_file = generic_close_file,
78 .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO,
81 static void fio_init fio_filecreate_register(void)
83 register_ioengine(&ioengine);
86 static void fio_exit fio_filecreate_unregister(void)
88 unregister_ioengine(&ioengine);