4 * IO engine that doesn't do any IO, just stat files and tracks the latency
10 #include <sys/types.h>
16 enum fio_ddir stat_ddir;
19 static int stat_file(struct thread_data *td, struct fio_file *f)
21 struct timespec start;
22 int do_lat = !td->o.disable_lat;
26 dprint(FD_FILE, "fd stat %s\n", f->file_name);
28 if (f->filetype != FIO_TYPE_FILE) {
29 log_err("fio: only files are supported\n");
32 if (!strcmp(f->file_name, "-")) {
33 log_err("fio: can't read/write to stdin/out\n");
38 fio_gettime(&start, NULL);
40 ret = stat(f->file_name, &statbuf);
43 char buf[FIO_VERROR_SIZE];
46 snprintf(buf, sizeof(buf), "stat(%s)", f->file_name);
47 td_verror(td, e, buf);
52 struct fc_data *data = td->io_ops_data;
55 nsec = ntime_since_now(&start);
56 add_clat_sample(td, data->stat_ddir, nsec, 0, 0);
62 static enum fio_q_status queue_io(struct thread_data *td, struct io_u fio_unused *io_u)
64 return FIO_Q_COMPLETED;
67 static int init(struct thread_data *td)
71 data = calloc(1, sizeof(*data));
74 data->stat_ddir = DDIR_READ;
75 else if (td_write(td))
76 data->stat_ddir = DDIR_WRITE;
78 td->io_ops_data = data;
82 static void cleanup(struct thread_data *td)
84 struct fc_data *data = td->io_ops_data;
89 static int stat_invalidate(struct thread_data *td, struct fio_file *f)
91 /* do nothing because file not opened */
95 static struct ioengine_ops ioengine = {
97 .version = FIO_IOOPS_VERSION,
101 .invalidate = stat_invalidate,
102 .get_file_size = generic_get_file_size,
103 .open_file = stat_file,
104 .flags = FIO_SYNCIO | FIO_FAKEIO |
105 FIO_NOSTATS | FIO_NOFILEHASH,
108 static void fio_init fio_filestat_register(void)
110 register_ioengine(&ioengine);
113 static void fio_exit fio_filestat_unregister(void)
115 unregister_ioengine(&ioengine);