ioengine.h revision c592b9fe12d4739d99d5bece517e304804876df6
1df5a7e4c5c64890c2425bb47d665bbce4992b676Dmitry Shmidt#ifndef FIO_IOENGINE_H 2df5a7e4c5c64890c2425bb47d665bbce4992b676Dmitry Shmidt#define FIO_IOENGINE_H 3df5a7e4c5c64890c2425bb47d665bbce4992b676Dmitry Shmidt 4#define FIO_IOOPS_VERSION 10 5 6enum { 7 IO_U_F_FREE = 1 << 0, 8 IO_U_F_FLIGHT = 1 << 1, 9}; 10 11/* 12 * The io unit 13 */ 14struct io_u { 15 union { 16#ifdef FIO_HAVE_LIBAIO 17 struct iocb iocb; 18#endif 19#ifdef FIO_HAVE_POSIXAIO 20 struct aiocb aiocb; 21#endif 22#ifdef FIO_HAVE_SGIO 23 struct sg_io_hdr hdr; 24#endif 25#ifdef FIO_HAVE_GUASI 26 guasi_req_t greq; 27#endif 28#ifdef FIO_HAVE_SOLARISAIO 29 aio_result_t resultp; 30#endif 31 void *mmap_data; 32 }; 33 struct timeval start_time; 34 struct timeval issue_time; 35 36 /* 37 * Allocated/set buffer and length 38 */ 39 void *buf; 40 unsigned long buflen; 41 unsigned long long offset; 42 43 /* 44 * IO engine state, may be different from above when we get 45 * partial transfers / residual data counts 46 */ 47 void *xfer_buf; 48 unsigned long xfer_buflen; 49 50 unsigned int resid; 51 unsigned int error; 52 53 enum fio_ddir ddir; 54 55 /* 56 * io engine private data 57 */ 58 union { 59 unsigned int index; 60 unsigned int seen; 61 void *engine_data; 62 }; 63 64 unsigned int flags; 65 66 struct fio_file *file; 67 68 struct flist_head list; 69 70 /* 71 * Callback for io completion 72 */ 73 int (*end_io)(struct thread_data *, struct io_u *); 74}; 75 76/* 77 * io_ops->queue() return values 78 */ 79enum { 80 FIO_Q_COMPLETED = 0, /* completed sync */ 81 FIO_Q_QUEUED = 1, /* queued, will complete async */ 82 FIO_Q_BUSY = 2, /* no more room, call ->commit() */ 83}; 84 85struct ioengine_ops { 86 struct flist_head list; 87 char name[16]; 88 int version; 89 int flags; 90 int (*setup)(struct thread_data *); 91 int (*init)(struct thread_data *); 92 int (*prep)(struct thread_data *, struct io_u *); 93 int (*queue)(struct thread_data *, struct io_u *); 94 int (*commit)(struct thread_data *); 95 int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *); 96 struct io_u *(*event)(struct thread_data *, int); 97 int (*cancel)(struct thread_data *, struct io_u *); 98 void (*cleanup)(struct thread_data *); 99 int (*open_file)(struct thread_data *, struct fio_file *); 100 int (*close_file)(struct thread_data *, struct fio_file *); 101 int (*get_file_size)(struct thread_data *, struct fio_file *); 102 void *data; 103 void *dlhandle; 104}; 105 106enum fio_ioengine_flags { 107 FIO_SYNCIO = 1 << 0, /* io engine has synchronous ->queue */ 108 FIO_RAWIO = 1 << 1, /* some sort of direct/raw io */ 109 FIO_DISKLESSIO = 1 << 2, /* no disk involved */ 110 FIO_NOEXTEND = 1 << 3, /* engine can't extend file */ 111 FIO_NODISKUTIL = 1 << 4, /* diskutil can't handle filename */ 112 FIO_UNIDIR = 1 << 5, /* engine is uni-directional */ 113 FIO_NOIO = 1 << 6, /* thread does only pseudo IO */ 114 FIO_SIGQUIT = 1 << 7, /* needs SIGQUIT to exit */ 115}; 116 117/* 118 * io engine entry points 119 */ 120extern int __must_check td_io_init(struct thread_data *); 121extern int __must_check td_io_prep(struct thread_data *, struct io_u *); 122extern int __must_check td_io_queue(struct thread_data *, struct io_u *); 123extern int __must_check td_io_sync(struct thread_data *, struct fio_file *); 124extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *); 125extern int __must_check td_io_commit(struct thread_data *); 126extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *); 127extern int td_io_close_file(struct thread_data *, struct fio_file *); 128extern int __must_check td_io_get_file_size(struct thread_data *, struct fio_file *); 129 130extern struct ioengine_ops *load_ioengine(struct thread_data *, const char *); 131extern void register_ioengine(struct ioengine_ops *); 132extern void unregister_ioengine(struct ioengine_ops *); 133extern void close_ioengine(struct thread_data *); 134 135/* 136 * io unit handling 137 */ 138#define queue_full(td) flist_empty(&(td)->io_u_freelist) 139extern struct io_u *__get_io_u(struct thread_data *); 140extern struct io_u *get_io_u(struct thread_data *); 141extern void put_io_u(struct thread_data *, struct io_u *); 142extern void requeue_io_u(struct thread_data *, struct io_u **); 143extern long __must_check io_u_sync_complete(struct thread_data *, struct io_u *); 144extern long __must_check io_u_queued_complete(struct thread_data *, int); 145extern void io_u_queued(struct thread_data *, struct io_u *); 146extern void io_u_log_error(struct thread_data *, struct io_u *); 147extern void io_u_mark_depth(struct thread_data *, unsigned int); 148extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int); 149void io_u_mark_complete(struct thread_data *, unsigned int); 150void io_u_mark_submit(struct thread_data *, unsigned int); 151 152#ifdef FIO_INC_DEBUG 153static inline void dprint_io_u(struct io_u *io_u, const char *p) 154{ 155 struct fio_file *f = io_u->file; 156 157 dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u, 158 (unsigned long long) io_u->offset, 159 io_u->buflen, io_u->ddir); 160 if (fio_debug & (1 << FD_IO)) { 161 if (f) 162 log_info("/%s", f->file_name); 163 164 log_info("\n"); 165 } 166} 167#else 168#define dprint_io_u(io_u, p) 169#endif 170 171#endif 172