blob: 7f45bd97ea4988ac84ce307d82715dfcf73e4d70 [file] [log] [blame]
Jens Axboea94ea282006-11-24 12:37:34 +01001/*
2 * null engine - doesn't do any transfers. Used to test fio.
3 *
4 */
5#include <stdio.h>
6#include <stdlib.h>
7#include <unistd.h>
8#include <errno.h>
9#include <assert.h>
10
11#include "../fio.h"
12#include "../os.h"
13
Jens Axboe36167d82007-02-18 05:41:31 +010014static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u)
Jens Axboea94ea282006-11-24 12:37:34 +010015{
Jens Axboea94ea282006-11-24 12:37:34 +010016 io_u->resid = 0;
17 io_u->error = 0;
Jens Axboe36167d82007-02-18 05:41:31 +010018 return FIO_Q_COMPLETED;
Jens Axboea94ea282006-11-24 12:37:34 +010019}
20
Jens Axboe2fd233b2007-03-02 08:44:25 +010021static int fio_null_setup(struct thread_data *td)
22{
23 struct fio_file *f;
24 int i;
25
26 if (!td->total_file_size) {
27 log_err("fio: need size= set\n");
28 return 1;
29 }
30
31 td->io_size = td->total_file_size;
32 td->total_io_size = td->io_size;
33
34 for_each_file(td, f, i) {
35 f->fd = dup(STDOUT_FILENO);
36 f->real_file_size = td->total_io_size / td->nr_files;
37 f->file_size = f->real_file_size;
38 }
39
40 td->nr_open_files = td->nr_files;
41 return 0;
42}
43
Jens Axboeb5af8292007-03-08 12:43:13 +010044static int fio_null_open(struct thread_data fio_unused *td,
45 struct fio_file fio_unused *f)
46{
47 return 0;
48}
49
Jens Axboea94ea282006-11-24 12:37:34 +010050static struct ioengine_ops ioengine = {
51 .name = "null",
52 .version = FIO_IOOPS_VERSION,
Jens Axboe2fd233b2007-03-02 08:44:25 +010053 .setup = fio_null_setup,
Jens Axboea94ea282006-11-24 12:37:34 +010054 .queue = fio_null_queue,
Jens Axboeb5af8292007-03-08 12:43:13 +010055 .open_file = fio_null_open,
56 .flags = FIO_SYNCIO | FIO_DISKLESSIO,
Jens Axboea94ea282006-11-24 12:37:34 +010057};
58
59static void fio_init fio_null_register(void)
60{
61 register_ioengine(&ioengine);
62}
63
64static void fio_exit fio_null_unregister(void)
65{
66 unregister_ioengine(&ioengine);
67}