[PATCH] Must use ->real_file_size
authorJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 09:58:07 +0000 (10:58 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 20 Dec 2006 09:58:07 +0000 (10:58 +0100)
->file_size is the size of the file from offset, while ->real_file_size
is the total size of the file. So when comparing EOF, we should look
at ->real_file_size against the offset.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
io_u.c

index cc89b7e626903480316052339eed9e7566a594ae..a14cd9503a68dbab9a656b78a3fd92726d46b07c 100644 (file)
@@ -156,7 +156,7 @@ static int file_size(struct thread_data *td, struct fio_file *f)
                        f->file_size = f->real_file_size;
        }
 
                        f->file_size = f->real_file_size;
        }
 
-       f->file_size -= f->file_offset;
+       f->file_size = f->real_file_size - f->file_offset;
        return 0;
 }
 
        return 0;
 }
 
diff --git a/io_u.c b/io_u.c
index 558b0b072cef200dd140020c47008d29a1a01fcc..834e5d214d5da390365858f36d67ed3fd67127a6 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -63,7 +63,7 @@ static int get_next_free_block(struct thread_data *td, struct fio_file *f,
 
        *b = 0;
        i = 0;
 
        *b = 0;
        i = 0;
-       while ((*b) * td->rw_min_bs < f->file_size) {
+       while ((*b) * td->rw_min_bs < f->real_file_size) {
                if (f->file_map[i] != -1UL) {
                        *b += ffz(f->file_map[i]);
                        return 0;
                if (f->file_map[i] != -1UL) {
                        *b += ffz(f->file_map[i]);
                        return 0;
@@ -108,7 +108,7 @@ static int get_next_offset(struct thread_data *td, struct fio_file *f,
                b = f->last_pos / td->min_bs[ddir];
 
        *offset = (b * td->min_bs[ddir]) + f->file_offset;
                b = f->last_pos / td->min_bs[ddir];
 
        *offset = (b * td->min_bs[ddir]) + f->file_offset;
-       if (*offset > f->file_size)
+       if (*offset > f->real_file_size)
                return 1;
 
        return 0;
                return 1;
 
        return 0;
@@ -267,13 +267,13 @@ struct io_u *get_io_u(struct thread_data *td, struct fio_file *f)
                return NULL;
        }
 
                return NULL;
        }
 
-       if (io_u->buflen + io_u->offset > f->file_size) {
+       if (io_u->buflen + io_u->offset > f->real_file_size) {
                if (td->io_ops->flags & FIO_RAWIO) {
                        put_io_u(td, io_u);
                        return NULL;
                }
 
                if (td->io_ops->flags & FIO_RAWIO) {
                        put_io_u(td, io_u);
                        return NULL;
                }
 
-               io_u->buflen = f->file_size - io_u->offset;
+               io_u->buflen = f->real_file_size - io_u->offset;
        }
 
        if (io_u->ddir != DDIR_SYNC) {
        }
 
        if (io_u->ddir != DDIR_SYNC) {