X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=fd55cc4b2bc4c98723194a3a655d420f82bb6c79;hp=4bfa470d0e285539e7de0d441c4d63aedd0eeb9c;hb=4db205dc7c0195cacc949cfbc461350ca6ec74b0;hpb=a2879fea33ee8c701da766e2def867f7fb2d052e diff --git a/filesetup.c b/filesetup.c index 4bfa470d..fd55cc4b 100644 --- a/filesetup.c +++ b/filesetup.c @@ -50,10 +50,11 @@ static int extend_file(struct thread_data *td, struct fio_file *f) * does that for operations involving reads, or for writes * where overwrite is set */ - if (td_read(td) || (td_write(td) && td->o.overwrite) || + if (td_read(td) || + (td_write(td) && td->o.overwrite && !td->o.file_append) || (td_write(td) && td->io_ops->flags & FIO_NOEXTEND)) new_layout = 1; - if (td_write(td) && !td->o.overwrite) + if (td_write(td) && !td->o.overwrite && !td->o.file_append) unlink_file = 1; if (unlink_file || new_layout) { @@ -722,8 +723,13 @@ static unsigned long long get_fs_free_counts(struct thread_data *td) return ret; } -uint64_t get_start_offset(struct thread_data *td) +uint64_t get_start_offset(struct thread_data *td, struct fio_file *f) { + struct thread_options *o = &td->o; + + if (o->file_append && f->filetype == FIO_TYPE_FILE) + return f->real_file_size; + return td->o.start_offset + (td->thread_number - 1) * td->o.offset_increment; } @@ -810,7 +816,7 @@ int setup_files(struct thread_data *td) extend_size = total_size = 0; need_extend = 0; for_each_file(td, f, i) { - f->file_offset = get_start_offset(td); + f->file_offset = get_start_offset(td, f); if (!o->file_size_low) { /* @@ -1052,16 +1058,16 @@ void close_and_free_files(struct thread_data *td) dprint(FD_FILE, "close files\n"); for_each_file(td, f, i) { - if (td->o.unlink && f->filetype == FIO_TYPE_FILE) { - dprint(FD_FILE, "free unlink %s\n", f->file_name); - unlink(f->file_name); - } - if (fio_file_open(f)) td_io_close_file(td, f); remove_file_hash(f); + if (td->o.unlink && f->filetype == FIO_TYPE_FILE) { + dprint(FD_FILE, "free unlink %s\n", f->file_name); + unlink(f->file_name); + } + sfree(f->file_name); f->file_name = NULL; axmap_free(f->io_axmap); @@ -1103,7 +1109,8 @@ static void get_file_type(struct fio_file *f) } } -static void set_already_allocated(const char *fname) { +static void set_already_allocated(const char *fname) +{ struct file_name *fn; fn = malloc(sizeof(struct file_name)); @@ -1129,7 +1136,8 @@ static int is_already_allocated(const char *fname) return 0; } -static void free_already_allocated() { +static void free_already_allocated(void) +{ struct flist_head *entry, *tmp; struct file_name *fn; @@ -1413,6 +1421,7 @@ void dup_files(struct thread_data *td, struct thread_data *org) assert(0); } __f->fd = -1; + __f->shadow_fd = -1; fio_file_reset(td, __f); if (f->file_name) { @@ -1482,6 +1491,7 @@ int fio_files_done(struct thread_data *td) } /* free memory used in initialization phase only */ -void filesetup_mem_free() { +void filesetup_mem_free(void) +{ free_already_allocated(); }