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;
18 int do_lat = !td->o.disable_lat;
20 dprint(FD_FILE, "fd open %s\n", f->file_name);
22 if (f->filetype != FIO_TYPE_FILE) {
23 log_err("fio: only files are supported fallocate \n");
26 if (!strcmp(f->file_name, "-")) {
27 log_err("fio: can't read/write to stdin/out\n");
32 fio_gettime(&start, NULL);
34 f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
37 char buf[FIO_VERROR_SIZE];
40 snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
41 td_verror(td, e, buf);
46 unsigned long long nsec;
48 fio_gettime(&end, NULL);
49 nsec = ntime_since(&start, &end);
50 add_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
56 static int queue_io(struct thread_data *td, struct io_u fio_unused *io_u)
58 return FIO_Q_COMPLETED;
62 * Ensure that we at least have a block size worth of IO to do for each
63 * file. If the job file has td->o.size < nr_files * block_size, then
64 * fio won't do anything.
66 static int get_file_size(struct thread_data *td, struct fio_file *f)
68 f->real_file_size = td_min_bs(td);
72 static struct ioengine_ops ioengine = {
74 .version = FIO_IOOPS_VERSION,
76 .get_file_size = get_file_size,
77 .open_file = open_file,
78 .close_file = generic_close_file,
79 .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO |
83 static void fio_init fio_filecreate_register(void)
85 register_ioengine(&ioengine);
88 static void fio_exit fio_filecreate_unregister(void)
90 unregister_ioengine(&ioengine);