engines/filecreate: set FIO_NOSTATS flag
[fio.git] / engines / filecreate.c
CommitLineData
1216cc5a
JB
1/*
2 * filecreate engine
3 *
4 * IO engine that doesn't do any IO, just creates files and tracks the latency
5 * of the file creation.
6 */
7#include <stdio.h>
8#include <unistd.h>
9#include <fcntl.h>
10#include <errno.h>
11
12#include "../fio.h"
13#include "../filehash.h"
14
15static int open_file(struct thread_data *td, struct fio_file *f)
16{
17 struct timespec start, end;
1216cc5a
JB
18 int do_lat = !td->o.disable_lat;
19
20 dprint(FD_FILE, "fd open %s\n", f->file_name);
21
22 if (f->filetype != FIO_TYPE_FILE) {
23 log_err("fio: only files are supported fallocate \n");
24 return 1;
25 }
26 if (!strcmp(f->file_name, "-")) {
27 log_err("fio: can't read/write to stdin/out\n");
28 return 1;
29 }
30
1216cc5a
JB
31 if (do_lat)
32 fio_gettime(&start, NULL);
1216cc5a 33
52582166 34 f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
1216cc5a
JB
35
36 if (f->fd == -1) {
37 char buf[FIO_VERROR_SIZE];
38 int e = errno;
39
40 snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
41 td_verror(td, e, buf);
52582166 42 return 1;
1216cc5a
JB
43 }
44
52582166
JA
45 if (do_lat) {
46 unsigned long long nsec;
1216cc5a 47
52582166
JA
48 fio_gettime(&end, NULL);
49 nsec = ntime_since(&start, &end);
50 add_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
1216cc5a
JB
51 }
52
53 return 0;
54}
55
56static int queue_io(struct thread_data *td, struct io_u fio_unused *io_u)
57{
58 return FIO_Q_COMPLETED;
59}
60
edc5fa12
JA
61/*
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.
65 */
66static int get_file_size(struct thread_data *td, struct fio_file *f)
67{
68 f->real_file_size = td_min_bs(td);
69 return 0;
70}
71
1216cc5a
JB
72static struct ioengine_ops ioengine = {
73 .name = "filecreate",
74 .version = FIO_IOOPS_VERSION,
1216cc5a 75 .queue = queue_io,
edc5fa12
JA
76 .get_file_size = get_file_size,
77 .open_file = open_file,
1216cc5a 78 .close_file = generic_close_file,
132b1ee4
JA
79 .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO |
80 FIO_NOSTATS,
1216cc5a
JB
81};
82
83static void fio_init fio_filecreate_register(void)
84{
85 register_ioengine(&ioengine);
86}
87
88static void fio_exit fio_filecreate_unregister(void)
89{
90 unregister_ioengine(&ioengine);
91}