- for_each_file(td, f, i)
- f->file_size = td->total_file_size / td->nr_files;
-
- /*
- * unless specifically asked for overwrite, let normal io extend it
- */
- if (!td->overwrite)
- return 0;
-
- need_create = 0;
- if (td->filetype == FIO_TYPE_FILE) {
- for_each_file(td, f, i) {
- int file_there = !file_ok(td, f);
-
- if (file_there && td->ddir == DDIR_WRITE &&
- !td->overwrite) {
- unlink(f->file_name);
- file_there = 0;
- }
-
- need_create += !file_there;
- }
- }
-
- if (!need_create)
- return 0;
-
- if (!td->total_file_size) {
- log_err("Need size for create\n");
- td_verror(td, EINVAL);
- return 1;
- }
-
- temp_stall_ts = 1;
- fprintf(f_out, "%s: Laying out IO file(s) (%u x %LuMiB == %LuMiB)\n",
- td->name, td->nr_uniq_files,
- (td->total_file_size >> 20) / td->nr_uniq_files,
- td->total_file_size >> 20);
-
- err = 0;
- for_each_file(td, f, i) {
- /*
- * Only unlink files that we created.
- */
- f->unlink = 0;
- if (file_ok(td, f)) {
- f->unlink = td->unlink;
- err = create_file(td, f);
- if (err)
- break;
- }
- }
-
- temp_stall_ts = 0;
- return err;
+ r = os_random_long(&td->file_size_state);
+ ret = td->o.file_size_low + (unsigned long long) ((double) (td->o.file_size_high - td->o.file_size_low) * (r / (RAND_MAX + 1.0)));
+ ret -= (ret % td->o.rw_min_bs);
+ return ret;