engines/libaio: modify getevents and commit error handling
[fio.git] / engines / libaio.c
index 6f625167e9b7d2f03350a72086fb67db1e421885..6c5d73ed27dd1751ac98c1177fcdbf2bdf2fe487 100644 (file)
@@ -167,6 +167,8 @@ static int fio_libaio_getevents(struct thread_data *td, unsigned int min,
                        events += r;
                else if (r == -EAGAIN)
                        usleep(100);
+               else
+                       break;
        } while (events < min);
 
        return r < 0 ? r : events;
@@ -255,9 +257,11 @@ static int fio_libaio_commit(struct thread_data *td)
                        ld->queued -= ret;
                        ring_inc(ld, &ld->tail, ret);
                        ret = 0;
+                       wait_start = 0;
                } else if (ret == -EINTR || !ret) {
                        if (!ret)
                                io_u_mark_submit(td, ret);
+                       wait_start = 0;
                        continue;
                } else if (ret == -EAGAIN) {
                        /*
@@ -281,6 +285,15 @@ static int fio_libaio_commit(struct thread_data *td)
                        }
                        usleep(1);
                        continue;
+               } else if (ret == -ENOMEM) {
+                       /*
+                        * If we get -ENOMEM, reap events if we can. If
+                        * we cannot, treat it as a fatal event since there's
+                        * nothing we can do about it.
+                        */
+                       if (ld->queued)
+                               ret = 0;
+                       break;
                } else
                        break;
        } while (ld->queued);