+ fio_ro_check(td, io_u);
+
+ if (ld->iocbs_nr == (int) 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->iocbs_nr)
+ return FIO_Q_BUSY;
+
+ do_io_u_sync(td, io_u);
+ return FIO_Q_COMPLETED;
+ }
+
+ if (io_u->ddir == DDIR_TRIM) {
+ if (ld->iocbs_nr)
+ return FIO_Q_BUSY;
+
+ do_io_u_trim(td, io_u);
+ return FIO_Q_COMPLETED;
+ }
+
+ ld->iocbs[ld->iocbs_nr] = &io_u->iocb;
+ ld->io_us[ld->iocbs_nr] = io_u;
+ ld->iocbs_nr++;
+ 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;
+ int ret;
+
+ if (!ld->iocbs_nr)
+ return 0;
+
+ io_us = ld->io_us;
+ iocbs = ld->iocbs;