+static void fio_syslet_complete_atom(struct thread_data *td,
+ struct syslet_uatom *atom)
+{
+ struct syslet_data *sd = td->io_ops->data;
+ struct syslet_uatom *last;
+ struct io_u *io_u;
+
+ /*
+ * complete from the beginning of the sequence up to (and
+ * including) this atom
+ */
+ last = atom;
+ io_u = atom->private;
+ atom = io_u->req.head;
+
+ /*
+ * now complete in right order
+ */
+ do {
+ long ret;
+
+ io_u = atom->private;
+ ret = *atom->ret_ptr;
+ if (ret > 0)
+ io_u->resid = io_u->xfer_buflen - ret;
+ else if (ret < 0)
+ io_u->error = ret;
+
+ assert(sd->nr_events < td->iodepth);
+ sd->events[sd->nr_events++] = io_u;
+
+ if (atom == last)
+ break;
+
+ atom = atom->next;
+ } while (1);
+
+ assert(!last->next);
+}
+