+
+ fio_ro_check(td, io_u);
+
+ if (ld->queued == td->o.iodepth)
+ return FIO_Q_BUSY;
+
+ /*
+ * fsync is tricky, since it can fail and we need to do it
+ * serialized with other io. the reason is that linux doesn't
+ * support aio fsync yet. So return busy for the case where we
+ * have pending io, to let fio complete those first.
+ */
+ if (ddir_sync(io_u->ddir)) {
+ if (ld->queued)
+ return FIO_Q_BUSY;
+
+ do_io_u_sync(td, io_u);
+ return FIO_Q_COMPLETED;
+ }
+
+ if (io_u->ddir == DDIR_TRIM) {
+ if (ld->queued)
+ return FIO_Q_BUSY;
+
+ do_io_u_trim(td, io_u);
+ return FIO_Q_COMPLETED;
+ }
+
+ ld->iocbs[ld->head] = &io_u->iocb;
+ ld->io_us[ld->head] = io_u;
+ ring_inc(ld, &ld->head, 1);
+ ld->queued++;
+ return FIO_Q_QUEUED;
+}
+
+static void fio_libaio_queued(struct thread_data *td, struct io_u **io_us,
+ unsigned int nr)
+{
+ struct timeval now;
+ unsigned int i;
+
+ if (!fio_fill_issue_time(td))
+ return;
+
+ fio_gettime(&now, NULL);
+
+ for (i = 0; i < nr; i++) {
+ struct io_u *io_u = io_us[i];
+
+ memcpy(&io_u->issue_time, &now, sizeof(now));
+ io_u_queued(td, io_u);
+ }
+}
+
+static int fio_libaio_commit(struct thread_data *td)
+{
+ struct libaio_data *ld = td->io_ops->data;
+ struct iocb **iocbs;
+ struct io_u **io_us;
+ struct timeval tv;
+ int ret, wait_start = 0;
+
+ if (!ld->queued)
+ return 0;