X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=filesetup.c;h=70589aa513eaa95d6108664df88d43270d8ba475;hb=f9e256ba1f5f57a61fd6bc9e6ed6cc2f996c0838;hp=d7c83a796f29401752e9c6030988732dd1e1d4ad;hpb=5338f35ddd52203048e2f6262b7254dddc2d8d52;p=fio.git diff --git a/filesetup.c b/filesetup.c index d7c83a79..70589aa5 100644 --- a/filesetup.c +++ b/filesetup.c @@ -303,9 +303,12 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, /* * FIXME: add blockdev flushing too */ - if (f->mmap_ptr) + if (f->mmap_ptr) { ret = madvise(f->mmap_ptr, f->mmap_sz, MADV_DONTNEED); - else if (f->filetype == FIO_TYPE_FILE) { +#ifdef FIO_MADV_FREE + (void) madvise(f->mmap_ptr, f->mmap_sz, FIO_MADV_FREE); +#endif + } else if (f->filetype == FIO_TYPE_FILE) { ret = fadvise(f->fd, off, len, POSIX_FADV_DONTNEED); } else if (f->filetype == FIO_TYPE_BD) { ret = blockdev_invalidate_cache(f->fd); @@ -624,7 +627,8 @@ int setup_files(struct thread_data *td) fio_file_clear_extend(f); if (!td->o.fill_device) { old_len = f->real_file_size; - extend_len = f->io_size + f->file_offset - old_len; + extend_len = f->io_size + f->file_offset - + old_len; } f->real_file_size = (f->io_size + f->file_offset); err = extend_file(td, f); @@ -787,7 +791,7 @@ int add_file(struct thread_data *td, const char *fname) log_err("fio: smalloc OOM\n"); assert(0); } - + f->fd = -1; if (td->files_size <= td->files_index) { @@ -815,7 +819,7 @@ int add_file(struct thread_data *td, const char *fname) log_err("fio: smalloc OOM\n"); assert(0); } - + get_file_type(f); switch (td->o.file_lock_mode) { @@ -1016,14 +1020,14 @@ void dup_files(struct thread_data *td, struct thread_data *org) assert(0); } __f->fd = -1; - + if (f->file_name) { __f->file_name = smalloc_strdup(f->file_name); if (!__f->file_name) { log_err("fio: smalloc OOM\n"); assert(0); } - + __f->filetype = f->filetype; }