+ /*
+ * Sort events, oldest issue first, then wait on as many as we
+ * need in order of age. If we have enough events, stop waiting,
+ * and just check if any of the older ones are done.
+ */
+ if (sidx > 1)
+ qsort(rbd->sort_events, sidx, sizeof(struct io_u *), rbd_io_u_cmp);
+
+ for (i = 0; i < sidx; i++) {
+ io_u = rbd->sort_events[i];
+
+ if (fri_check_complete(rbd, io_u, events)) {
+ this_events++;
+ continue;