4 * IO engine that doesn't do any IO, just creates files and tracks the latency
5 * of the file creation.
14 enum fio_ddir stat_ddir;
17 static int open_file(struct thread_data *td, struct fio_file *f)
19 struct timespec start;
20 int do_lat = !td->o.disable_lat;
22 dprint(FD_FILE, "fd open %s\n", f->file_name);
24 if (f->filetype != FIO_TYPE_FILE) {
25 log_err("fio: only files are supported fallocate \n");
28 if (!strcmp(f->file_name, "-")) {
29 log_err("fio: can't read/write to stdin/out\n");
34 fio_gettime(&start, NULL);
36 f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
39 char buf[FIO_VERROR_SIZE];
42 snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
43 td_verror(td, e, buf);
48 struct fc_data *data = td->io_ops_data;
51 nsec = ntime_since_now(&start);
52 add_clat_sample(td, data->stat_ddir, nsec, 0, 0, 0);
58 static enum fio_q_status queue_io(struct thread_data *td,
59 struct io_u fio_unused *io_u)
61 return FIO_Q_COMPLETED;
65 * Ensure that we at least have a block size worth of IO to do for each
66 * file. If the job file has td->o.size < nr_files * block_size, then
67 * fio won't do anything.
69 static int get_file_size(struct thread_data *td, struct fio_file *f)
71 f->real_file_size = td_min_bs(td);
75 static int init(struct thread_data *td)
79 data = calloc(1, sizeof(*data));
82 data->stat_ddir = DDIR_READ;
83 else if (td_write(td))
84 data->stat_ddir = DDIR_WRITE;
86 td->io_ops_data = data;
90 static void cleanup(struct thread_data *td)
92 struct fc_data *data = td->io_ops_data;
97 static struct ioengine_ops ioengine = {
99 .version = FIO_IOOPS_VERSION,
103 .get_file_size = get_file_size,
104 .open_file = open_file,
105 .close_file = generic_close_file,
106 .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO |
107 FIO_NOSTATS | FIO_NOFILEHASH,
110 static void fio_init fio_filecreate_register(void)
112 register_ioengine(&ioengine);
115 static void fio_exit fio_filecreate_unregister(void)
117 unregister_ioengine(&ioengine);