+ /*
+ * now file sizes are known, so we can set ->io_size. if size= is
+ * not given, ->io_size is just equal to ->real_file_size. if size
+ * is given, ->io_size is size / nr_files.
+ */
+ extend_size = total_size = 0;
+ need_extend = 0;
+ for_each_file(td, f, i) {
+ f->file_offset = td->o.start_offset;
+
+ if (!td->o.file_size_low) {
+ /*
+ * no file size range given, file size is equal to
+ * total size divided by number of files. if that is
+ * zero, set it to the real file size.
+ */
+ f->io_size = td->o.size / td->o.nr_files;
+ if (!f->io_size) {
+ if (f->file_offset > f->real_file_size)
+ goto err_offset;
+ f->io_size = f->real_file_size - f->file_offset;
+ }
+ } else if (f->real_file_size < td->o.file_size_low ||
+ f->real_file_size > td->o.file_size_high) {
+ if (f->file_offset > td->o.file_size_low)
+ goto err_offset;
+ /*
+ * file size given. if it's fixed, use that. if it's a
+ * range, generate a random size in-between.
+ */
+ if (td->o.file_size_low == td->o.file_size_high)
+ f->io_size = td->o.file_size_low - f->file_offset;
+ else
+ f->io_size = get_rand_file_size(td) - f->file_offset;
+ } else if (f->file_offset > f->real_file_size)
+ goto err_offset;