X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=48b034a6b4f83d4913e94a19a72611e8d1755e80;hp=f4004588fcd4f9ac803322528d8a5f5876027510;hb=cf3d609747c3e070001173b17ea95e9d6f46b15c;hpb=b5af82930ccfd7dda6a1b11794efb452eb76d8dc diff --git a/filesetup.c b/filesetup.c index f4004588..48b034a6 100644 --- a/filesetup.c +++ b/filesetup.c @@ -98,7 +98,7 @@ err: 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; @@ -106,7 +106,8 @@ static int create_files(struct thread_data *td) /* * 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; @@ -225,9 +226,7 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f) { int ret = 0; - if (!td->invalidate_cache) - return 0; - if (!td->odirect) + if (td->odirect) return 0; /* @@ -268,12 +267,8 @@ int generic_open_file(struct thread_data *td, struct fio_file *f) 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 { @@ -297,7 +292,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f) 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)) { @@ -318,19 +313,6 @@ err: 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)); - - printf("setting up %s again\n", f->file_name); - return td_io_open_file(td, f); -} - int open_files(struct thread_data *td) { struct fio_file *f; @@ -380,6 +362,8 @@ int setup_files(struct thread_data *td) for_each_file(td, f, i) td->total_file_size += f->file_size; + td->total_file_size = (td->total_file_size * td->nr_files) / td->open_files; + td->io_size = td->total_file_size; if (td->io_size == 0) { log_err("%s: no io blocks\n", td->name); @@ -412,6 +396,9 @@ void close_files(struct thread_data *td) } td_io_close_file(td, f); + + if (f->file_map) + free(f->file_map); } td->filename = NULL;