static int create_files(struct thread_data *td)
{
struct fio_file *f;
- int i, err, need_create;
+ int i, err, need_create, can_extend;
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)
+ can_extend = !td->overwrite && !(td->io_ops->flags & FIO_NOEXTEND);
+ if (can_extend)
return 0;
need_create = 0;
{
int ret = 0;
- if (!td->invalidate_cache)
- return 0;
if (td->odirect)
return 0;
if (td_write(td) || td_rw(td)) {
flags |= O_RDWR;
- if (td->filetype == FIO_TYPE_FILE) {
- if (!td->overwrite)
- flags |= O_TRUNC;
-
+ if (td->filetype == FIO_TYPE_FILE)
flags |= O_CREAT;
- }
f->fd = open(f->file_name, flags, 0600);
} else {
if (get_file_size(td, f))
goto err;
- if (file_invalidate_cache(td, f))
+ if (td->invalidate_cache && file_invalidate_cache(td, f))
goto err;
if (!td_random(td)) {
return 1;
}
-int reopen_file(struct thread_data *td, struct fio_file *f)
-{
- f->last_free_lookup = 0;
- f->last_completed_pos = 0;
- f->last_pos = 0;
-
- if (f->file_map)
- memset(f->file_map, 0, f->num_maps * sizeof(long));
-
- return td_io_open_file(td, f);
-}
-
int open_files(struct thread_data *td)
{
struct fio_file *f;
}
td_io_close_file(td, f);
+
+ if (f->file_map)
+ free(f->file_map);
}
td->filename = NULL;