4 * IO engine that uses the Linux SG v3 interface to talk to SCSI devices
14 #include "../optgroup.h"
22 unsigned int writefua;
25 static struct fio_option options[] = {
28 .lname = "sg engine read fua flag support",
30 .off1 = offsetof(struct sg_options, readfua),
31 .help = "Set FUA flag (force unit access) for all Read operations",
33 .category = FIO_OPT_C_ENGINE,
34 .group = FIO_OPT_G_SG,
38 .lname = "sg engine write fua flag support",
40 .off1 = offsetof(struct sg_options, writefua),
41 .help = "Set FUA flag (force unit access) for all Write operations",
43 .category = FIO_OPT_C_ENGINE,
44 .group = FIO_OPT_G_SG,
51 #define MAX_10B_LBA 0xFFFFFFFFULL
52 #define SCSI_TIMEOUT_MS 30000 // 30 second timeout; currently no method to override
53 #define MAX_SB 64 // sense block maximum return size
56 unsigned char cdb[16]; // enhanced from 10 to support 16 byte commands
57 unsigned char sb[MAX_SB]; // add sense block to commands
62 struct sgio_cmd *cmds;
71 static void sgio_hdr_init(struct sgio_data *sd, struct sg_io_hdr *hdr,
72 struct io_u *io_u, int fs)
74 struct sgio_cmd *sc = &sd->cmds[io_u->index];
76 memset(hdr, 0, sizeof(*hdr));
77 memset(sc->cdb, 0, sizeof(sc->cdb));
79 hdr->interface_id = 'S';
81 hdr->cmd_len = sizeof(sc->cdb);
83 hdr->mx_sb_len = sizeof(sc->sb);
84 hdr->pack_id = io_u->index;
88 hdr->dxferp = io_u->xfer_buf;
89 hdr->dxfer_len = io_u->xfer_buflen;
93 static int pollin_events(struct pollfd *pfds, int fds)
97 for (i = 0; i < fds; i++)
98 if (pfds[i].revents & POLLIN)
104 static int sg_fd_read(int fd, void *data, size_t size)
111 ret = read(fd, data, size);
113 if (errno == EAGAIN || errno == EINTR)
133 static int fio_sgio_getevents(struct thread_data *td, unsigned int min,
135 const struct timespec fio_unused *t)
137 struct sgio_data *sd = td->io_ops_data;
138 int left = max, eventNum, ret, r = 0;
139 void *buf = sd->sgbuf;
140 unsigned int i, events;
144 * Fill in the file descriptors
146 for_each_file(td, f, i) {
148 * don't block for min events == 0
151 sd->fd_flags[i] = fio_set_fd_nonblocking(f->fd, "sg");
153 sd->fd_flags[i] = -1;
155 sd->pfds[i].fd = f->fd;
156 sd->pfds[i].events = POLLIN;
162 dprint(FD_IO, "sgio_getevents: sd %p: left=%d\n", sd, left);
168 ret = poll(sd->pfds, td->o.nr_files, -1);
172 td_verror(td, errno, "poll");
177 if (pollin_events(sd->pfds, td->o.nr_files))
187 for_each_file(td, f, i) {
188 for (eventNum = 0; eventNum < left; eventNum++) {
189 ret = sg_fd_read(f->fd, p, sizeof(struct sg_io_hdr));
190 dprint(FD_IO, "sgio_getevents: ret: %d\n", ret);
193 td_verror(td, r, "sg_read");
196 p += sizeof(struct sg_io_hdr);
198 dprint(FD_IO, "sgio_getevents: events: %d\n", events);
202 if (r < 0 && !events)
212 for (i = 0; i < events; i++) {
213 struct sg_io_hdr *hdr = (struct sg_io_hdr *) buf + i;
214 sd->events[i] = hdr->usr_ptr;
216 /* record if an io error occurred, ignore resid */
217 if (hdr->info & SG_INFO_CHECK) {
219 io_u = (struct io_u *)(hdr->usr_ptr);
220 memcpy(&io_u->hdr, hdr, sizeof(struct sg_io_hdr));
221 sd->events[i]->error = EIO;
227 for_each_file(td, f, i) {
228 if (sd->fd_flags[i] == -1)
231 if (fcntl(f->fd, F_SETFL, sd->fd_flags[i]) < 0)
232 log_err("fio: sg failed to restore fcntl flags: %s\n", strerror(errno));
239 static int fio_sgio_ioctl_doio(struct thread_data *td,
240 struct fio_file *f, struct io_u *io_u)
242 struct sgio_data *sd = td->io_ops_data;
243 struct sg_io_hdr *hdr = &io_u->hdr;
246 sd->events[0] = io_u;
248 ret = ioctl(f->fd, SG_IO, hdr);
252 /* record if an io error occurred */
253 if (hdr->info & SG_INFO_CHECK)
256 return FIO_Q_COMPLETED;
259 static int fio_sgio_rw_doio(struct fio_file *f, struct io_u *io_u, int do_sync)
261 struct sg_io_hdr *hdr = &io_u->hdr;
264 ret = write(f->fd, hdr, sizeof(*hdr));
269 ret = read(f->fd, hdr, sizeof(*hdr));
273 /* record if an io error occurred */
274 if (hdr->info & SG_INFO_CHECK)
277 return FIO_Q_COMPLETED;
283 static int fio_sgio_doio(struct thread_data *td, struct io_u *io_u, int do_sync)
285 struct fio_file *f = io_u->file;
288 if (f->filetype == FIO_TYPE_BLOCK) {
289 ret = fio_sgio_ioctl_doio(td, f, io_u);
290 td_verror(td, io_u->error, __func__);
292 ret = fio_sgio_rw_doio(f, io_u, do_sync);
294 td_verror(td, io_u->error, __func__);
300 static int fio_sgio_prep(struct thread_data *td, struct io_u *io_u)
302 struct sg_io_hdr *hdr = &io_u->hdr;
303 struct sg_options *o = td->eo;
304 struct sgio_data *sd = td->io_ops_data;
305 long long nr_blocks, lba;
307 if (io_u->xfer_buflen & (sd->bs - 1)) {
308 log_err("read/write not sector aligned\n");
312 nr_blocks = io_u->xfer_buflen / sd->bs;
313 lba = io_u->offset / sd->bs;
315 if (io_u->ddir == DDIR_READ) {
316 sgio_hdr_init(sd, hdr, io_u, 1);
318 hdr->dxfer_direction = SG_DXFER_FROM_DEV;
319 if (lba < MAX_10B_LBA)
320 hdr->cmdp[0] = 0x28; // read(10)
322 hdr->cmdp[0] = 0x88; // read(16)
325 hdr->cmdp[1] |= 0x08;
327 } else if (io_u->ddir == DDIR_WRITE) {
328 sgio_hdr_init(sd, hdr, io_u, 1);
330 hdr->dxfer_direction = SG_DXFER_TO_DEV;
331 if (lba < MAX_10B_LBA)
332 hdr->cmdp[0] = 0x2a; // write(10)
334 hdr->cmdp[0] = 0x8a; // write(16)
337 hdr->cmdp[1] |= 0x08;
340 sgio_hdr_init(sd, hdr, io_u, 0);
341 hdr->dxfer_direction = SG_DXFER_NONE;
342 if (lba < MAX_10B_LBA)
343 hdr->cmdp[0] = 0x35; // synccache(10)
345 hdr->cmdp[0] = 0x91; // synccache(16)
349 * for synccache, we leave lba and length to 0 to sync all
352 if (hdr->dxfer_direction != SG_DXFER_NONE) {
353 if (lba < MAX_10B_LBA) {
354 hdr->cmdp[2] = (unsigned char) ((lba >> 24) & 0xff);
355 hdr->cmdp[3] = (unsigned char) ((lba >> 16) & 0xff);
356 hdr->cmdp[4] = (unsigned char) ((lba >> 8) & 0xff);
357 hdr->cmdp[5] = (unsigned char) (lba & 0xff);
358 hdr->cmdp[7] = (unsigned char) ((nr_blocks >> 8) & 0xff);
359 hdr->cmdp[8] = (unsigned char) (nr_blocks & 0xff);
361 hdr->cmdp[2] = (unsigned char) ((lba >> 56) & 0xff);
362 hdr->cmdp[3] = (unsigned char) ((lba >> 48) & 0xff);
363 hdr->cmdp[4] = (unsigned char) ((lba >> 40) & 0xff);
364 hdr->cmdp[5] = (unsigned char) ((lba >> 32) & 0xff);
365 hdr->cmdp[6] = (unsigned char) ((lba >> 24) & 0xff);
366 hdr->cmdp[7] = (unsigned char) ((lba >> 16) & 0xff);
367 hdr->cmdp[8] = (unsigned char) ((lba >> 8) & 0xff);
368 hdr->cmdp[9] = (unsigned char) (lba & 0xff);
369 hdr->cmdp[10] = (unsigned char) ((nr_blocks >> 32) & 0xff);
370 hdr->cmdp[11] = (unsigned char) ((nr_blocks >> 16) & 0xff);
371 hdr->cmdp[12] = (unsigned char) ((nr_blocks >> 8) & 0xff);
372 hdr->cmdp[13] = (unsigned char) (nr_blocks & 0xff);
376 hdr->timeout = SCSI_TIMEOUT_MS;
380 static int fio_sgio_queue(struct thread_data *td, struct io_u *io_u)
382 struct sg_io_hdr *hdr = &io_u->hdr;
383 int ret, do_sync = 0;
385 fio_ro_check(td, io_u);
387 if (td->o.sync_io || td->o.odirect || ddir_sync(io_u->ddir))
390 ret = fio_sgio_doio(td, io_u, do_sync);
394 else if (hdr->status) {
395 io_u->resid = hdr->resid;
400 td_verror(td, io_u->error, "xfer");
401 return FIO_Q_COMPLETED;
407 static struct io_u *fio_sgio_event(struct thread_data *td, int event)
409 struct sgio_data *sd = td->io_ops_data;
411 return sd->events[event];
414 static int fio_sgio_read_capacity(struct thread_data *td, unsigned int *bs,
415 unsigned long long *max_lba)
418 * need to do read capacity operation w/o benefit of sd or
419 * io_u structures, which are not initialized until later.
421 struct sg_io_hdr hdr;
422 unsigned char cmd[16];
423 unsigned char sb[64];
424 unsigned char buf[32]; // read capacity return
428 struct fio_file *f = td->files[0];
430 /* open file independent of rest of application */
431 fd = open(f->file_name, O_RDONLY);
435 memset(&hdr, 0, sizeof(hdr));
436 memset(cmd, 0, sizeof(cmd));
437 memset(sb, 0, sizeof(sb));
438 memset(buf, 0, sizeof(buf));
440 /* First let's try a 10 byte read capacity. */
441 hdr.interface_id = 'S';
445 hdr.mx_sb_len = sizeof(sb);
446 hdr.timeout = SCSI_TIMEOUT_MS;
447 hdr.cmdp[0] = 0x25; // Read Capacity(10)
448 hdr.dxfer_direction = SG_DXFER_FROM_DEV;
450 hdr.dxfer_len = sizeof(buf);
452 ret = ioctl(fd, SG_IO, &hdr);
458 *bs = ((unsigned long) buf[4] << 24) | ((unsigned long) buf[5] << 16) |
459 ((unsigned long) buf[6] << 8) | (unsigned long) buf[7];
460 *max_lba = ((unsigned long) buf[0] << 24) | ((unsigned long) buf[1] << 16) |
461 ((unsigned long) buf[2] << 8) | (unsigned long) buf[3];
464 * If max lba masked by MAX_10B_LBA equals MAX_10B_LBA,
465 * then need to retry with 16 byte Read Capacity command.
467 if (*max_lba == MAX_10B_LBA) {
469 hdr.cmdp[0] = 0x9e; // service action
470 hdr.cmdp[1] = 0x10; // Read Capacity(16)
471 hdr.cmdp[10] = (unsigned char) ((sizeof(buf) >> 24) & 0xff);
472 hdr.cmdp[11] = (unsigned char) ((sizeof(buf) >> 16) & 0xff);
473 hdr.cmdp[12] = (unsigned char) ((sizeof(buf) >> 8) & 0xff);
474 hdr.cmdp[13] = (unsigned char) (sizeof(buf) & 0xff);
476 hdr.dxfer_direction = SG_DXFER_FROM_DEV;
478 hdr.dxfer_len = sizeof(buf);
480 ret = ioctl(fd, SG_IO, &hdr);
486 /* record if an io error occurred */
487 if (hdr.info & SG_INFO_CHECK)
488 td_verror(td, EIO, "fio_sgio_read_capacity");
490 *bs = (buf[8] << 24) | (buf[9] << 16) | (buf[10] << 8) | buf[11];
491 *max_lba = ((unsigned long long)buf[0] << 56) |
492 ((unsigned long long)buf[1] << 48) |
493 ((unsigned long long)buf[2] << 40) |
494 ((unsigned long long)buf[3] << 32) |
495 ((unsigned long long)buf[4] << 24) |
496 ((unsigned long long)buf[5] << 16) |
497 ((unsigned long long)buf[6] << 8) |
498 (unsigned long long)buf[7];
505 static void fio_sgio_cleanup(struct thread_data *td)
507 struct sgio_data *sd = td->io_ops_data;
519 static int fio_sgio_init(struct thread_data *td)
521 struct sgio_data *sd;
523 sd = malloc(sizeof(*sd));
524 memset(sd, 0, sizeof(*sd));
525 sd->cmds = malloc(td->o.iodepth * sizeof(struct sgio_cmd));
526 memset(sd->cmds, 0, td->o.iodepth * sizeof(struct sgio_cmd));
527 sd->events = malloc(td->o.iodepth * sizeof(struct io_u *));
528 memset(sd->events, 0, td->o.iodepth * sizeof(struct io_u *));
529 sd->pfds = malloc(sizeof(struct pollfd) * td->o.nr_files);
530 memset(sd->pfds, 0, sizeof(struct pollfd) * td->o.nr_files);
531 sd->fd_flags = malloc(sizeof(int) * td->o.nr_files);
532 memset(sd->fd_flags, 0, sizeof(int) * td->o.nr_files);
533 sd->sgbuf = malloc(sizeof(struct sg_io_hdr) * td->o.iodepth);
534 memset(sd->sgbuf, 0, sizeof(struct sg_io_hdr) * td->o.iodepth);
535 sd->type_checked = 0;
536 td->io_ops_data = sd;
539 * we want to do it, regardless of whether odirect is set or not
541 td->o.override_sync = 1;
545 static int fio_sgio_type_check(struct thread_data *td, struct fio_file *f)
547 struct sgio_data *sd = td->io_ops_data;
549 unsigned long long max_lba = 0;
551 if (f->filetype == FIO_TYPE_BLOCK) {
552 if (ioctl(f->fd, BLKSSZGET, &bs) < 0) {
553 td_verror(td, errno, "ioctl");
556 } else if (f->filetype == FIO_TYPE_CHAR) {
559 if (ioctl(f->fd, SG_GET_VERSION_NUM, &version) < 0) {
560 td_verror(td, errno, "ioctl");
564 ret = fio_sgio_read_capacity(td, &bs, &max_lba);
566 td_verror(td, td->error, "fio_sgio_read_capacity");
567 log_err("ioengine sg unable to read capacity successfully\n");
571 td_verror(td, EINVAL, "wrong file type");
572 log_err("ioengine sg only works on block or character devices\n");
577 // Determine size of commands needed based on max_lba
578 if (max_lba >= MAX_10B_LBA) {
579 dprint(FD_IO, "sgio_type_check: using 16 byte read/write "
580 "commands for lba above 0x%016llx/0x%016llx\n",
581 MAX_10B_LBA, max_lba);
584 if (f->filetype == FIO_TYPE_BLOCK) {
585 td->io_ops->getevents = NULL;
586 td->io_ops->event = NULL;
588 sd->type_checked = 1;
593 static int fio_sgio_open(struct thread_data *td, struct fio_file *f)
595 struct sgio_data *sd = td->io_ops_data;
598 ret = generic_open_file(td, f);
602 if (sd && !sd->type_checked && fio_sgio_type_check(td, f)) {
603 ret = generic_close_file(td, f);
611 * Build an error string with details about the driver, host or scsi
612 * error contained in the sg header Caller will use as necessary.
614 static char *fio_sgio_errdetails(struct io_u *io_u)
616 struct sg_io_hdr *hdr = &io_u->hdr;
617 #define MAXERRDETAIL 1024
618 #define MAXMSGCHUNK 128
619 char *msg, msgchunk[MAXMSGCHUNK];
622 msg = calloc(1, MAXERRDETAIL);
626 * can't seem to find sg_err.h, so I'll just echo the define values
627 * so others can search on internet to find clearer clues of meaning.
629 if (hdr->info & SG_INFO_CHECK) {
630 if (hdr->host_status) {
631 snprintf(msgchunk, MAXMSGCHUNK, "SG Host Status: 0x%02x; ", hdr->host_status);
632 strlcat(msg, msgchunk, MAXERRDETAIL);
633 switch (hdr->host_status) {
635 strlcat(msg, "SG_ERR_DID_NO_CONNECT", MAXERRDETAIL);
638 strlcat(msg, "SG_ERR_DID_BUS_BUSY", MAXERRDETAIL);
641 strlcat(msg, "SG_ERR_DID_TIME_OUT", MAXERRDETAIL);
644 strlcat(msg, "SG_ERR_DID_BAD_TARGET", MAXERRDETAIL);
647 strlcat(msg, "SG_ERR_DID_ABORT", MAXERRDETAIL);
650 strlcat(msg, "SG_ERR_DID_PARITY", MAXERRDETAIL);
653 strlcat(msg, "SG_ERR_DID_ERROR (internal error)", MAXERRDETAIL);
656 strlcat(msg, "SG_ERR_DID_RESET", MAXERRDETAIL);
659 strlcat(msg, "SG_ERR_DID_BAD_INTR (unexpected)", MAXERRDETAIL);
662 strlcat(msg, "SG_ERR_DID_PASSTHROUGH", MAXERRDETAIL);
665 strlcat(msg, "SG_ERR_DID_SOFT_ERROR (driver retry?)", MAXERRDETAIL);
668 strlcat(msg, "SG_ERR_DID_IMM_RETRY", MAXERRDETAIL);
671 strlcat(msg, "SG_ERR_DID_REQUEUE", MAXERRDETAIL);
674 strlcat(msg, "SG_ERR_DID_TRANSPORT_DISRUPTED", MAXERRDETAIL);
677 strlcat(msg, "SG_ERR_DID_TRANSPORT_FAILFAST", MAXERRDETAIL);
680 strlcat(msg, "SG_ERR_DID_TARGET_FAILURE", MAXERRDETAIL);
683 strlcat(msg, "SG_ERR_DID_NEXUS_FAILURE", MAXERRDETAIL);
686 strlcat(msg, "SG_ERR_DID_ALLOC_FAILURE", MAXERRDETAIL);
689 strlcat(msg, "SG_ERR_DID_MEDIUM_ERROR", MAXERRDETAIL);
692 strlcat(msg, "Unknown", MAXERRDETAIL);
695 strlcat(msg, ". ", MAXERRDETAIL);
697 if (hdr->driver_status) {
698 snprintf(msgchunk, MAXMSGCHUNK, "SG Driver Status: 0x%02x; ", hdr->driver_status);
699 strlcat(msg, msgchunk, MAXERRDETAIL);
700 switch (hdr->driver_status & 0x0F) {
702 strlcat(msg, "SG_ERR_DRIVER_BUSY", MAXERRDETAIL);
705 strlcat(msg, "SG_ERR_DRIVER_SOFT", MAXERRDETAIL);
708 strlcat(msg, "SG_ERR_DRIVER_MEDIA", MAXERRDETAIL);
711 strlcat(msg, "SG_ERR_DRIVER_ERROR", MAXERRDETAIL);
714 strlcat(msg, "SG_ERR_DRIVER_INVALID", MAXERRDETAIL);
717 strlcat(msg, "SG_ERR_DRIVER_TIMEOUT", MAXERRDETAIL);
720 strlcat(msg, "SG_ERR_DRIVER_HARD", MAXERRDETAIL);
723 strlcat(msg, "SG_ERR_DRIVER_SENSE", MAXERRDETAIL);
726 strlcat(msg, "Unknown", MAXERRDETAIL);
729 strlcat(msg, "; ", MAXERRDETAIL);
730 switch (hdr->driver_status & 0xF0) {
732 strlcat(msg, "SG_ERR_SUGGEST_RETRY", MAXERRDETAIL);
735 strlcat(msg, "SG_ERR_SUGGEST_ABORT", MAXERRDETAIL);
738 strlcat(msg, "SG_ERR_SUGGEST_REMAP", MAXERRDETAIL);
741 strlcat(msg, "SG_ERR_SUGGEST_DIE", MAXERRDETAIL);
744 strlcat(msg, "SG_ERR_SUGGEST_SENSE", MAXERRDETAIL);
747 strlcat(msg, ". ", MAXERRDETAIL);
750 snprintf(msgchunk, MAXMSGCHUNK, "SG SCSI Status: 0x%02x; ", hdr->status);
751 strlcat(msg, msgchunk, MAXERRDETAIL);
752 // SCSI 3 status codes
753 switch (hdr->status) {
755 strlcat(msg, "CHECK_CONDITION", MAXERRDETAIL);
758 strlcat(msg, "CONDITION_MET", MAXERRDETAIL);
761 strlcat(msg, "BUSY", MAXERRDETAIL);
764 strlcat(msg, "INTERMEDIATE", MAXERRDETAIL);
767 strlcat(msg, "INTERMEDIATE_CONDITION_MET", MAXERRDETAIL);
770 strlcat(msg, "RESERVATION_CONFLICT", MAXERRDETAIL);
773 strlcat(msg, "COMMAND_TERMINATED", MAXERRDETAIL);
776 strlcat(msg, "TASK_SET_FULL", MAXERRDETAIL);
779 strlcat(msg, "ACA_ACTIVE", MAXERRDETAIL);
782 strlcat(msg, "TASK_ABORTED", MAXERRDETAIL);
785 strlcat(msg, "Unknown", MAXERRDETAIL);
788 strlcat(msg, ". ", MAXERRDETAIL);
790 if (hdr->sb_len_wr) {
791 snprintf(msgchunk, MAXMSGCHUNK, "Sense Data (%d bytes):", hdr->sb_len_wr);
792 strlcat(msg, msgchunk, MAXERRDETAIL);
793 for (i = 0; i < hdr->sb_len_wr; i++) {
794 snprintf(msgchunk, MAXMSGCHUNK, " %02x", hdr->sbp[i]);
795 strlcat(msg, msgchunk, MAXERRDETAIL);
797 strlcat(msg, ". ", MAXERRDETAIL);
799 if (hdr->resid != 0) {
800 snprintf(msgchunk, MAXMSGCHUNK, "SG Driver: %d bytes out of %d not transferred. ", hdr->resid, hdr->dxfer_len);
801 strlcat(msg, msgchunk, MAXERRDETAIL);
805 if (!(hdr->info & SG_INFO_CHECK) && !strlen(msg))
806 strncpy(msg, "SG Driver did not report a Host, Driver or Device check",
813 * get max file size from read capacity.
815 static int fio_sgio_get_file_size(struct thread_data *td, struct fio_file *f)
818 * get_file_size is being called even before sgio_init is
819 * called, so none of the sg_io structures are
820 * initialized in the thread_data yet. So we need to do the
821 * ReadCapacity without any of those helpers. One of the effects
822 * is that ReadCapacity may get called 4 times on each open:
823 * readcap(10) followed by readcap(16) if needed - just to get
824 * the file size after the init occurs - it will be called
825 * again when "type_check" is called during structure
826 * initialization I'm not sure how to prevent this little
830 unsigned long long max_lba = 0;
833 if (fio_file_size_known(f))
836 if (f->filetype != FIO_TYPE_BLOCK && f->filetype != FIO_TYPE_CHAR) {
837 td_verror(td, EINVAL, "wrong file type");
838 log_err("ioengine sg only works on block or character devices\n");
842 ret = fio_sgio_read_capacity(td, &bs, &max_lba);
844 td_verror(td, td->error, "fio_sgio_read_capacity");
845 log_err("ioengine sg unable to successfully execute read capacity to get block size and maximum lba\n");
849 f->real_file_size = (max_lba + 1) * bs;
850 fio_file_set_size_known(f);
855 static struct ioengine_ops ioengine = {
857 .version = FIO_IOOPS_VERSION,
858 .init = fio_sgio_init,
859 .prep = fio_sgio_prep,
860 .queue = fio_sgio_queue,
861 .getevents = fio_sgio_getevents,
862 .errdetails = fio_sgio_errdetails,
863 .event = fio_sgio_event,
864 .cleanup = fio_sgio_cleanup,
865 .open_file = fio_sgio_open,
866 .close_file = generic_close_file,
867 .get_file_size = fio_sgio_get_file_size,
868 .flags = FIO_SYNCIO | FIO_RAWIO,
870 .option_struct_size = sizeof(struct sg_options)
873 #else /* FIO_HAVE_SGIO */
876 * When we have a proper configure system in place, we simply wont build
877 * and install this io engine. For now install a crippled version that
878 * just complains and fails to load.
880 static int fio_sgio_init(struct thread_data fio_unused *td)
882 log_err("fio: ioengine sg not available\n");
886 static struct ioengine_ops ioengine = {
888 .version = FIO_IOOPS_VERSION,
889 .init = fio_sgio_init,
894 static void fio_init fio_sgio_register(void)
896 register_ioengine(&ioengine);
899 static void fio_exit fio_sgio_unregister(void)
901 unregister_ioengine(&ioengine);