| 1 | /* |
| 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 | |
| 14 | static int fio_null_queue(struct thread_data fio_unused *td, struct io_u *io_u) |
| 15 | { |
| 16 | io_u->resid = 0; |
| 17 | io_u->error = 0; |
| 18 | return FIO_Q_COMPLETED; |
| 19 | } |
| 20 | |
| 21 | static 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->real_file_size = td->total_io_size / td->nr_files; |
| 36 | f->file_size = f->real_file_size; |
| 37 | } |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static int fio_null_open(struct thread_data fio_unused *td, |
| 43 | struct fio_file fio_unused *f) |
| 44 | { |
| 45 | f->fd = 0; |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static struct ioengine_ops ioengine = { |
| 50 | .name = "null", |
| 51 | .version = FIO_IOOPS_VERSION, |
| 52 | .setup = fio_null_setup, |
| 53 | .queue = fio_null_queue, |
| 54 | .open_file = fio_null_open, |
| 55 | .flags = FIO_SYNCIO | FIO_DISKLESSIO, |
| 56 | }; |
| 57 | |
| 58 | static void fio_init fio_null_register(void) |
| 59 | { |
| 60 | register_ioengine(&ioengine); |
| 61 | } |
| 62 | |
| 63 | static void fio_exit fio_null_unregister(void) |
| 64 | { |
| 65 | unregister_ioengine(&ioengine); |
| 66 | } |