Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 1 | /* |
| 2 | * scsi generic sg v3 io engine |
| 3 | * |
| 4 | */ |
| 5 | #include <stdio.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <unistd.h> |
| 8 | #include <errno.h> |
| 9 | #include <assert.h> |
| 10 | #include <sys/poll.h> |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 11 | |
| 12 | #include "../fio.h" |
| 13 | #include "../os.h" |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 14 | |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 15 | #ifdef FIO_HAVE_SGIO |
| 16 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 17 | struct sgio_cmd { |
| 18 | unsigned char cdb[10]; |
| 19 | int nr; |
| 20 | }; |
| 21 | |
| 22 | struct sgio_data { |
| 23 | struct sgio_cmd *cmds; |
| 24 | struct io_u **events; |
| 25 | unsigned int bs; |
| 26 | }; |
| 27 | |
| 28 | static void sgio_hdr_init(struct sgio_data *sd, struct sg_io_hdr *hdr, |
| 29 | struct io_u *io_u, int fs) |
| 30 | { |
| 31 | struct sgio_cmd *sc = &sd->cmds[io_u->index]; |
| 32 | |
| 33 | memset(hdr, 0, sizeof(*hdr)); |
| 34 | memset(sc->cdb, 0, sizeof(sc->cdb)); |
| 35 | |
| 36 | hdr->interface_id = 'S'; |
| 37 | hdr->cmdp = sc->cdb; |
| 38 | hdr->cmd_len = sizeof(sc->cdb); |
| 39 | hdr->pack_id = io_u->index; |
| 40 | hdr->usr_ptr = io_u; |
| 41 | |
| 42 | if (fs) { |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 43 | hdr->dxferp = io_u->xfer_buf; |
| 44 | hdr->dxfer_len = io_u->xfer_buflen; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | |
| 48 | static int fio_sgio_ioctl_getevents(struct thread_data *td, int fio_unused min, |
| 49 | int max, struct timespec fio_unused *t) |
| 50 | { |
| 51 | assert(max <= 1); |
| 52 | |
| 53 | /* |
| 54 | * we can only have one finished io_u for sync io, since the depth |
| 55 | * is always 1 |
| 56 | */ |
| 57 | if (list_empty(&td->io_u_busylist)) |
| 58 | return 0; |
| 59 | |
| 60 | return 1; |
| 61 | } |
| 62 | |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 63 | static int pollin_events(struct pollfd *pfds, int fds) |
| 64 | { |
| 65 | int i; |
| 66 | |
| 67 | for (i = 0; i < fds; i++) |
| 68 | if (pfds[i].revents & POLLIN) |
| 69 | return 1; |
| 70 | |
| 71 | return 0; |
| 72 | } |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 73 | |
| 74 | static int fio_sgio_getevents(struct thread_data *td, int min, int max, |
| 75 | struct timespec fio_unused *t) |
| 76 | { |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 77 | /* |
| 78 | * normally hard coding &td->files[0] is a bug that needs to be fixed, |
| 79 | * but it's ok here as all files should point to the same device. |
| 80 | */ |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 81 | struct fio_file *f = &td->files[0]; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 82 | struct sgio_data *sd = td->io_ops->data; |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 83 | int left = max, ret, events, i, r = 0, *fl; |
| 84 | struct pollfd *pfds; |
| 85 | void *buf; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 86 | |
| 87 | /* |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 88 | * Fill in the file descriptors |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 89 | */ |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 90 | pfds = malloc(sizeof(struct pollfd) * td->nr_files); |
| 91 | fl = malloc(sizeof(int) * td->nr_files); |
| 92 | |
| 93 | for_each_file(td, f, i) { |
| 94 | /* |
| 95 | * don't block for min events == 0 |
| 96 | */ |
| 97 | if (!min) { |
| 98 | fl[i] = fcntl(f->fd, F_GETFL); |
| 99 | fcntl(f->fd, F_SETFL, fl[i] | O_NONBLOCK); |
| 100 | } |
| 101 | pfds[i].fd = f->fd; |
| 102 | pfds[i].events = POLLIN; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 103 | } |
| 104 | |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 105 | buf = malloc(max * sizeof(struct sg_io_hdr)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 106 | while (left) { |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 107 | void *p; |
| 108 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 109 | do { |
| 110 | if (!min) |
| 111 | break; |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 112 | |
| 113 | ret = poll(pfds, td->nr_files, -1); |
| 114 | if (ret < 0) { |
| 115 | td_verror(td, errno); |
| 116 | if (!r) |
| 117 | r = -1; |
| 118 | break; |
| 119 | } else if (!ret) |
| 120 | continue; |
| 121 | |
| 122 | if (pollin_events(pfds, td->nr_files)) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 123 | break; |
| 124 | } while (1); |
| 125 | |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 126 | if (r < 0) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 127 | break; |
| 128 | |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 129 | re_read: |
| 130 | p = buf; |
| 131 | events = 0; |
| 132 | for_each_file(td, f, i) { |
| 133 | ret = read(f->fd, p, left * sizeof(struct sg_io_hdr)); |
| 134 | if (ret < 0) { |
| 135 | if (errno == EAGAIN) |
| 136 | continue; |
| 137 | td_verror(td, errno); |
| 138 | r = -1; |
| 139 | break; |
| 140 | } else if (ret) { |
| 141 | p += ret; |
| 142 | events += ret / sizeof(struct sg_io_hdr); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | if (r < 0) |
| 147 | break; |
| 148 | if (!events) { |
| 149 | usleep(1000); |
| 150 | goto re_read; |
| 151 | } |
| 152 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 153 | left -= events; |
| 154 | r += events; |
| 155 | |
| 156 | for (i = 0; i < events; i++) { |
| 157 | struct sg_io_hdr *hdr = (struct sg_io_hdr *) buf + i; |
| 158 | |
| 159 | sd->events[i] = hdr->usr_ptr; |
| 160 | } |
| 161 | } |
| 162 | |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 163 | if (!min) { |
| 164 | for_each_file(td, f, i) |
| 165 | fcntl(f->fd, F_SETFL, fl[i]); |
| 166 | } |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 167 | |
| 168 | free(buf); |
Jens Axboe | adee86c | 2007-02-08 13:04:36 +0100 | [diff] [blame^] | 169 | free(pfds); |
| 170 | free(fl); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 171 | return r; |
| 172 | } |
| 173 | |
Jens Axboe | 7a16dd0 | 2006-10-18 17:21:58 +0200 | [diff] [blame] | 174 | static int fio_sgio_ioctl_doio(struct thread_data *td, |
| 175 | struct fio_file *f, struct io_u *io_u) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 176 | { |
| 177 | struct sgio_data *sd = td->io_ops->data; |
| 178 | struct sg_io_hdr *hdr = &io_u->hdr; |
| 179 | |
| 180 | sd->events[0] = io_u; |
| 181 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 182 | return ioctl(f->fd, SG_IO, hdr); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 183 | } |
| 184 | |
Jens Axboe | 7a16dd0 | 2006-10-18 17:21:58 +0200 | [diff] [blame] | 185 | static int fio_sgio_rw_doio(struct fio_file *f, struct io_u *io_u, int sync) |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 186 | { |
| 187 | struct sg_io_hdr *hdr = &io_u->hdr; |
| 188 | int ret; |
| 189 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 190 | ret = write(f->fd, hdr, sizeof(*hdr)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 191 | if (ret < 0) |
| 192 | return errno; |
| 193 | |
| 194 | if (sync) { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 195 | ret = read(f->fd, hdr, sizeof(*hdr)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 196 | if (ret < 0) |
| 197 | return errno; |
| 198 | } |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int sync) |
| 204 | { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 205 | struct fio_file *f = io_u->file; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 206 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 207 | if (td->filetype == FIO_TYPE_BD) |
| 208 | return fio_sgio_ioctl_doio(td, f, io_u); |
| 209 | |
Jens Axboe | 7a16dd0 | 2006-10-18 17:21:58 +0200 | [diff] [blame] | 210 | return fio_sgio_rw_doio(f, io_u, sync); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 211 | } |
| 212 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 213 | static int fio_sgio_prep(struct thread_data *td, struct io_u *io_u) |
| 214 | { |
| 215 | struct sg_io_hdr *hdr = &io_u->hdr; |
| 216 | struct sgio_data *sd = td->io_ops->data; |
| 217 | int nr_blocks, lba; |
| 218 | |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 219 | if (io_u->xfer_buflen & (sd->bs - 1)) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 220 | log_err("read/write not sector aligned\n"); |
| 221 | return EINVAL; |
| 222 | } |
| 223 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 224 | if (io_u->ddir == DDIR_READ) { |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 225 | sgio_hdr_init(sd, hdr, io_u, 1); |
| 226 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 227 | hdr->dxfer_direction = SG_DXFER_FROM_DEV; |
| 228 | hdr->cmdp[0] = 0x28; |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 229 | } else if (io_u->ddir == DDIR_WRITE) { |
| 230 | sgio_hdr_init(sd, hdr, io_u, 1); |
| 231 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 232 | hdr->dxfer_direction = SG_DXFER_TO_DEV; |
| 233 | hdr->cmdp[0] = 0x2a; |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 234 | } else { |
| 235 | sgio_hdr_init(sd, hdr, io_u, 0); |
| 236 | |
| 237 | hdr->dxfer_direction = SG_DXFER_NONE; |
| 238 | hdr->cmdp[0] = 0x35; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 239 | } |
| 240 | |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 241 | if (hdr->dxfer_direction != SG_DXFER_NONE) { |
Jens Axboe | cec6b55 | 2007-02-06 20:15:38 +0100 | [diff] [blame] | 242 | nr_blocks = io_u->xfer_buflen / sd->bs; |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 243 | lba = io_u->offset / sd->bs; |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 244 | hdr->cmdp[2] = (unsigned char) ((lba >> 24) & 0xff); |
| 245 | hdr->cmdp[3] = (unsigned char) ((lba >> 16) & 0xff); |
| 246 | hdr->cmdp[4] = (unsigned char) ((lba >> 8) & 0xff); |
| 247 | hdr->cmdp[5] = (unsigned char) (lba & 0xff); |
| 248 | hdr->cmdp[7] = (unsigned char) ((nr_blocks >> 8) & 0xff); |
| 249 | hdr->cmdp[8] = (unsigned char) (nr_blocks & 0xff); |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | static int fio_sgio_queue(struct thread_data *td, struct io_u *io_u) |
| 256 | { |
| 257 | struct sg_io_hdr *hdr = &io_u->hdr; |
| 258 | int ret; |
| 259 | |
Jens Axboe | 87dc1ab | 2006-10-24 14:41:26 +0200 | [diff] [blame] | 260 | ret = fio_sgio_doio(td, io_u, io_u->ddir == DDIR_SYNC); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 261 | |
| 262 | if (ret < 0) |
| 263 | io_u->error = errno; |
| 264 | else if (hdr->status) { |
| 265 | io_u->resid = hdr->resid; |
| 266 | io_u->error = EIO; |
| 267 | } |
| 268 | |
| 269 | return io_u->error; |
| 270 | } |
| 271 | |
| 272 | static struct io_u *fio_sgio_event(struct thread_data *td, int event) |
| 273 | { |
| 274 | struct sgio_data *sd = td->io_ops->data; |
| 275 | |
| 276 | return sd->events[event]; |
| 277 | } |
| 278 | |
| 279 | static int fio_sgio_get_bs(struct thread_data *td, unsigned int *bs) |
| 280 | { |
| 281 | struct sgio_data *sd = td->io_ops->data; |
| 282 | struct io_u *io_u; |
| 283 | struct sg_io_hdr *hdr; |
| 284 | unsigned char buf[8]; |
| 285 | int ret; |
| 286 | |
| 287 | io_u = __get_io_u(td); |
| 288 | assert(io_u); |
| 289 | |
| 290 | hdr = &io_u->hdr; |
| 291 | sgio_hdr_init(sd, hdr, io_u, 0); |
| 292 | memset(buf, 0, sizeof(buf)); |
| 293 | |
| 294 | hdr->cmdp[0] = 0x25; |
| 295 | hdr->dxfer_direction = SG_DXFER_FROM_DEV; |
| 296 | hdr->dxferp = buf; |
| 297 | hdr->dxfer_len = sizeof(buf); |
| 298 | |
| 299 | ret = fio_sgio_doio(td, io_u, 1); |
| 300 | if (ret) { |
| 301 | put_io_u(td, io_u); |
| 302 | return ret; |
| 303 | } |
| 304 | |
| 305 | *bs = (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; |
| 306 | put_io_u(td, io_u); |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | static void fio_sgio_cleanup(struct thread_data *td) |
| 311 | { |
| 312 | if (td->io_ops->data) { |
| 313 | free(td->io_ops->data); |
| 314 | td->io_ops->data = NULL; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | static int fio_sgio_init(struct thread_data *td) |
| 319 | { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 320 | struct fio_file *f = &td->files[0]; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 321 | struct sgio_data *sd; |
| 322 | unsigned int bs; |
| 323 | int ret; |
| 324 | |
| 325 | sd = malloc(sizeof(*sd)); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 326 | memset(sd, 0, sizeof(*sd)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 327 | sd->cmds = malloc(td->iodepth * sizeof(struct sgio_cmd)); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 328 | memset(sd->cmds, 0, td->iodepth * sizeof(struct sgio_cmd)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 329 | sd->events = malloc(td->iodepth * sizeof(struct io_u *)); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 330 | memset(sd->events, 0, td->iodepth * sizeof(struct io_u *)); |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 331 | td->io_ops->data = sd; |
| 332 | |
| 333 | if (td->filetype == FIO_TYPE_BD) { |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 334 | if (ioctl(f->fd, BLKSSZGET, &bs) < 0) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 335 | td_verror(td, errno); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 336 | goto err; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 337 | } |
| 338 | } else if (td->filetype == FIO_TYPE_CHAR) { |
| 339 | int version; |
| 340 | |
Jens Axboe | 53cdc68 | 2006-10-18 11:50:58 +0200 | [diff] [blame] | 341 | if (ioctl(f->fd, SG_GET_VERSION_NUM, &version) < 0) { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 342 | td_verror(td, errno); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 343 | goto err; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | ret = fio_sgio_get_bs(td, &bs); |
| 347 | if (ret) |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 348 | goto err; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 349 | } else { |
| 350 | log_err("ioengine sgio only works on block devices\n"); |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 351 | goto err; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | sd->bs = bs; |
| 355 | |
| 356 | if (td->filetype == FIO_TYPE_BD) |
| 357 | td->io_ops->getevents = fio_sgio_ioctl_getevents; |
| 358 | else |
| 359 | td->io_ops->getevents = fio_sgio_getevents; |
| 360 | |
| 361 | /* |
| 362 | * we want to do it, regardless of whether odirect is set or not |
| 363 | */ |
| 364 | td->override_sync = 1; |
| 365 | return 0; |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 366 | err: |
| 367 | free(sd->events); |
| 368 | free(sd->cmds); |
| 369 | free(sd); |
Jens Axboe | e8b8c9f | 2007-02-05 10:47:48 +0100 | [diff] [blame] | 370 | td->io_ops->data = NULL; |
Jens Axboe | cb781c7 | 2006-11-07 14:02:48 +0100 | [diff] [blame] | 371 | return 1; |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 372 | } |
| 373 | |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 374 | static struct ioengine_ops ioengine = { |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 375 | .name = "sg", |
| 376 | .version = FIO_IOOPS_VERSION, |
| 377 | .init = fio_sgio_init, |
| 378 | .prep = fio_sgio_prep, |
| 379 | .queue = fio_sgio_queue, |
| 380 | .getevents = fio_sgio_getevents, |
| 381 | .event = fio_sgio_event, |
| 382 | .cleanup = fio_sgio_cleanup, |
Jens Axboe | b2a1519 | 2006-10-18 14:10:42 +0200 | [diff] [blame] | 383 | .flags = FIO_SYNCIO | FIO_RAWIO, |
Jens Axboe | 2866c82 | 2006-10-09 15:57:48 +0200 | [diff] [blame] | 384 | }; |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 385 | |
| 386 | #else /* FIO_HAVE_SGIO */ |
| 387 | |
| 388 | /* |
| 389 | * When we have a proper configure system in place, we simply wont build |
| 390 | * and install this io engine. For now install a crippled version that |
| 391 | * just complains and fails to load. |
| 392 | */ |
| 393 | static int fio_sgio_init(struct thread_data fio_unused *td) |
| 394 | { |
| 395 | fprintf(stderr, "fio: sgio not available\n"); |
| 396 | return 1; |
| 397 | } |
| 398 | |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 399 | static struct ioengine_ops ioengine = { |
Jens Axboe | 34cfcda | 2006-11-03 14:00:45 +0100 | [diff] [blame] | 400 | .name = "sgio", |
| 401 | .version = FIO_IOOPS_VERSION, |
| 402 | .init = fio_sgio_init, |
| 403 | }; |
| 404 | |
| 405 | #endif |
Jens Axboe | 5f35095 | 2006-11-07 15:20:59 +0100 | [diff] [blame] | 406 | |
| 407 | static void fio_init fio_sgio_register(void) |
| 408 | { |
| 409 | register_ioengine(&ioengine); |
| 410 | } |
| 411 | |
| 412 | static void fio_exit fio_sgio_unregister(void) |
| 413 | { |
| 414 | unregister_ioengine(&ioengine); |
| 415 | } |