Fix size setting on raw devices
authorJens Axboe <jens.axboe@oracle.com>
Wed, 28 Mar 2007 07:57:01 +0000 (09:57 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 28 Mar 2007 07:57:01 +0000 (09:57 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c
fio.h

index 40a16638f9ea798a9e4b5c0c97c37ee5e691da15..161f63e7d1a5aee2597e146513396406784fd4c2 100644 (file)
@@ -138,6 +138,9 @@ static int get_file_size(struct thread_data *td, struct fio_file *f)
 {
        int ret = 0;
 
+       if (f->flags & FIO_SIZE_KNOWN)
+               return 0;
+
        if (f->filetype == FIO_TYPE_FILE)
                ret = file_size(td, f);
        else if (f->filetype == FIO_TYPE_BD)
@@ -153,6 +156,7 @@ static int get_file_size(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
+       f->flags |= FIO_SIZE_KNOWN;
        return 0;
 }
 
@@ -280,6 +284,9 @@ static void get_file_sizes(struct thread_data *td)
                        clear_error(td);
                else
                        td->io_ops->close_file(td, f);
+
+               if (f->real_file_size == -1ULL && td->o.size)
+                       f->real_file_size = td->o.size / td->o.nr_files;
        }
 }
 
@@ -321,7 +328,7 @@ int setup_files(struct thread_data *td)
        /*
         * device/file sizes are zero and no size given, punt
         */
-       if (!total_size && !td->o.size) {
+       if ((!total_size || total_size == -1ULL) && !td->o.size) {
                log_err("%s: you need to specify size=\n", td->o.name);
                td_verror(td, EINVAL, "total_file_size");
                return 1;
@@ -386,6 +393,7 @@ int setup_files(struct thread_data *td)
                        if (!(f->flags & FIO_FILE_EXTEND))
                                continue;
 
+                       assert(f->filetype == FIO_TYPE_FILE);
                        f->flags &= ~FIO_FILE_EXTEND;
                        f->real_file_size = f->io_size;
                        err = extend_file(td, f);
diff --git a/fio.h b/fio.h
index 5ca72c59d5c707b80a326df4011b012b31e688be..d8911ef5db8d19ef92804287a3f726cab0f82203 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -241,6 +241,7 @@ enum fio_file_flags {
        FIO_FILE_EXTEND         = 1 << 4,       /* needs extend */
        FIO_FILE_NOSORT         = 1 << 5,       /* don't sort verify blocks */
        FIO_FILE_DONE           = 1 << 6,       /* io completed to this file */
+       FIO_SIZE_KNOWN          = 1 << 7,       /* size has been set */
 };
 
 /*