Fix problem with io_u being beyond EOF
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 136dc04e7e22d881e1e07f32265ceebc9fbe4122..8acc0c3941783aa0ffb858d255c9b15d2d8cba8f 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -190,6 +190,9 @@ static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
                        buflen = (buflen + td->o.min_bs[ddir] - 1) & ~(td->o.min_bs[ddir] - 1);
        }
 
+       if (io_u->offset + buflen > io_u->file->real_file_size)
+               buflen = td->o.min_bs[ddir];
+
        return buflen;
 }
 
@@ -341,6 +344,9 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
        if (!io_u->buflen)
                return 1;
 
+       if (io_u->offset + io_u->buflen > io_u->file->real_file_size)
+               return 1;
+
        /*
         * mark entry before potentially trimming io_u
         */