For non-file engines, set ->real_file_size if total size is known
authorJens Axboe <jens.axboe@oracle.com>
Wed, 11 Apr 2007 19:20:03 +0000 (21:20 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 11 Apr 2007 19:20:03 +0000 (21:20 +0200)
Fixes a segfault with rand* directions.

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

index cfdf281d1b2ede15ecb7aea920af4eca3bb3b0d1..dd69cedeaff7ee438fb284198dc2b91ad5f2b785 100644 (file)
@@ -18,8 +18,12 @@ static int fio_cpuio_setup(struct thread_data fio_unused *td)
        struct fio_file *f;
        unsigned int i;
 
-       for_each_file(td, f, i)
-               f->real_file_size = -1ULL;
+       for_each_file(td, f, i) {
+               if (td->o.size)
+                       f->real_file_size = td->o.size / td->o.nr_files;
+               else
+                       f->real_file_size = -1ULL;
+       }
 
        return 0;
 }
@@ -47,9 +51,9 @@ static int fio_cpuio_init(struct thread_data *td)
        return 0;
 }
 
-static int fio_cpuio_open(struct thread_data fio_unused *td, struct fio_file *f)
+static int fio_cpuio_open(struct thread_data fio_unused *td,
+                         struct fio_file fio_unused *f)
 {
-       f->fd = 0;
        return 0;
 }
 
index 4de86c12831c758365fc674359da3b445faaedc4..cc707db972178a5cee9c8815d15ce6f97d963f16 100644 (file)
@@ -279,8 +279,12 @@ static int fio_netio_setup(struct thread_data *td)
                nd->listenfd = -1;
                td->io_ops->data = nd;
 
-               for_each_file(td, f, i)
-                       f->real_file_size = -1ULL;
+               for_each_file(td, f, i) {
+                       if (td->o.size)
+                               f->real_file_size = td->o.size / td->o.nr_files;
+                       else
+                               f->real_file_size = -1ULL;
+               }
        }
 
        return 0;
index 70d1fa78f8bed7b9de40e7a0bc6d29d0e3db03c9..318952c2c00d492bed40486c05a12d3300a6a075 100644 (file)
@@ -70,8 +70,12 @@ static int fio_null_setup(struct thread_data *td)
        struct fio_file *f;
        unsigned int i;
 
-       for_each_file(td, f, i)
-               f->real_file_size = -1ULL;
+       for_each_file(td, f, i) {
+               if (td->o.size)
+                       f->real_file_size = td->o.size / td->o.nr_files;
+               else
+                       f->real_file_size = -1ULL;
+       }
 
        return 0;
 }
@@ -79,7 +83,6 @@ static int fio_null_setup(struct thread_data *td)
 static int fio_null_open(struct thread_data fio_unused *td,
                         struct fio_file fio_unused *f)
 {
-       f->fd = 0;
        return 0;
 }