libaio: retry on -EINTR
[fio.git] / engines / libaio.c
index ca7bfdef58a35a58d29de89a33d7176eef3e4cf7..d11a262e62cbaf8b0c30bf47e52b9dfaa584ae86 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 if (r != -EINTR)
+                       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,9 +285,18 @@ 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->head != ld->tail);
+       } while (ld->queued);
 
        return ret;
 }