[PATCH] Make the libaio fsync fallback really work
authorJens Axboe <jens.axboe@oracle.com>
Sat, 10 Feb 2007 13:49:02 +0000 (14:49 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Sat, 10 Feb 2007 13:49:02 +0000 (14:49 +0100)
This time it's tested :-)

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/libaio.c

index acc125f48e46df799c7d7fdcf0c42daea9694145..47c1d4b8d8603571779b59be064173327ae24c0c 100644 (file)
@@ -88,7 +88,7 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
        do {
                ret = io_submit(ld->aio_ctx, 1, &iocb);
                if (ret == 1)
-                       return 0;
+                       break;
                else if (ret == -EAGAIN || !ret)
                        usleep(100);
                else if (ret == -EINTR)
@@ -101,8 +101,12 @@ static int fio_libaio_queue(struct thread_data *td, struct io_u *io_u)
                         * with libaio (still), we don't have pending
                         * requests to flush first.
                         */
-                       ret = fsync(io_u->file->fd);
-                       ld->sync_io_u = io_u;
+                       if (fsync(io_u->file->fd) < 0)
+                               ret = errno;
+                       else {
+                               ret = 1;
+                               ld->sync_io_u = io_u;
+                       }
                        break;
                } else
                        break;