Handle short read at the end of file
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index 2f0d74012a93a04f0ef464020bebe3f2e913b859..ef63ce6e4e47b384da36024e50a2c2504aa16b79 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -452,8 +452,14 @@ static void do_io(struct thread_data *td)
 
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
 
                                io_u->xfer_buflen = io_u->resid;
                                io_u->xfer_buf += bytes;
+                               io_u->offset += bytes;
+
+                               if (io_u->offset == io_u->file->real_file_size)
+                                       goto sync_done;
+
                                requeue_io_u(td, &io_u);
                        } else {
                                requeue_io_u(td, &io_u);
                        } else {
+sync_done:
                                fio_gettime(&comp_time, NULL);
                                bytes_done = io_u_sync_complete(td, io_u);
                                if (bytes_done < 0)
                                fio_gettime(&comp_time, NULL);
                                bytes_done = io_u_sync_complete(td, io_u);
                                if (bytes_done < 0)