1 #ifndef FIO_IOENGINE_H 2 #define FIO_IOENGINE_H 3 4 #include "compiler/compiler.h" 5 #include "os/os.h" 6 #include "file.h" 7 #include "io_u.h" 8 9 #define FIO_IOOPS_VERSION 23 10 11 /* 12 * io_ops->queue() return values 13 */ 14 enum { 15 FIO_Q_COMPLETED = 0, /* completed sync */ 16 FIO_Q_QUEUED = 1, /* queued, will complete async */ 17 FIO_Q_BUSY = 2, /* no more room, call ->commit() */ 18 }; 19 20 struct ioengine_ops { 21 struct flist_head list; 22 const char *name; 23 int version; 24 int flags; 25 int (*setup)(struct thread_data *); 26 int (*init)(struct thread_data *); 27 int (*prep)(struct thread_data *, struct io_u *); 28 int (*queue)(struct thread_data *, struct io_u *); 29 int (*commit)(struct thread_data *); 30 int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *); 31 struct io_u *(*event)(struct thread_data *, int); 32 char *(*errdetails)(struct io_u *); 33 int (*cancel)(struct thread_data *, struct io_u *); 34 void (*cleanup)(struct thread_data *); 35 int (*open_file)(struct thread_data *, struct fio_file *); 36 int (*close_file)(struct thread_data *, struct fio_file *); 37 int (*invalidate)(struct thread_data *, struct fio_file *); 38 int (*unlink_file)(struct thread_data *, struct fio_file *); 39 int (*get_file_size)(struct thread_data *, struct fio_file *); 40 void (*terminate)(struct thread_data *); 41 int (*iomem_alloc)(struct thread_data *, size_t); 42 void (*iomem_free)(struct thread_data *); 43 int (*io_u_init)(struct thread_data *, struct io_u *); 44 void (*io_u_free)(struct thread_data *, struct io_u *); 45 int option_struct_size; 46 struct fio_option *options; 47 }; 48 49 enum fio_ioengine_flags { 50 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */ 51 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */ 52 FIO_DISKLESSIO = 1 << 2, /* no disk involved */ 53 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */ 54 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ 55 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */ 56 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */ 57 FIO_PIPEIO = 1 << 7, /* input/output no seekable */ 58 FIO_BARRIER = 1 << 8, /* engine supports barriers */ 59 FIO_MEMALIGN = 1 << 9, /* engine wants aligned memory */ 60 FIO_BIT_BASED = 1 << 10, /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */ 61 FIO_FAKEIO = 1 << 11, /* engine pretends to do IO */ 62 }; 63 64 /* 65 * External engine defined symbol to fill in the engine ops structure 66 */ 67 typedef void (*get_ioengine_t)(struct ioengine_ops **); 68 69 /* 70 * io engine entry points 71 */ 72 extern int __must_check td_io_init(struct thread_data *); 73 extern int __must_check td_io_prep(struct thread_data *, struct io_u *); 74 extern int __must_check td_io_queue(struct thread_data *, struct io_u *); 75 extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *); 76 extern int __must_check td_io_commit(struct thread_data *); 77 extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); 78 extern int td_io_close_file(struct thread_data *, struct fio_file *); 79 extern int td_io_unlink_file(struct thread_data *, struct fio_file *); 80 extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *); 81 82 extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *); 83 extern void register_ioengine(struct ioengine_ops *); 84 extern void unregister_ioengine(struct ioengine_ops *); 85 extern void free_ioengine(struct thread_data *); 86 extern void close_ioengine(struct thread_data *); 87 88 extern int fio_show_ioengine_help(const char *engine); 89 90 #endif 91