X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=filesetup.c;h=0fb5589b7c33ce1aa154c21ecf42cf52a682c4d8;hb=27325ed5a4f770b681c6847352c547d51dbdeb62;hp=cc6d44091736aeba9e6ba1ab5be7a3d56bc29c1b;hpb=42da5c8b2cdd53427145b623293bc5b915fb5f05;p=fio.git diff --git a/filesetup.c b/filesetup.c index cc6d4409..0fb5589b 100644 --- a/filesetup.c +++ b/filesetup.c @@ -400,15 +400,9 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, if (td->io_ops->invalidate) ret = td->io_ops->invalidate(td, f); - else if (f->mmap_ptr) { - ret = posix_madvise(f->mmap_ptr, f->mmap_sz, POSIX_MADV_DONTNEED); -#ifdef FIO_MADV_FREE - if (f->filetype == FIO_TYPE_BD) - (void) posix_madvise(f->mmap_ptr, f->mmap_sz, FIO_MADV_FREE); -#endif - } else if (f->filetype == FIO_TYPE_FILE) { + else if (f->filetype == FIO_TYPE_FILE) ret = posix_fadvise(f->fd, off, len, POSIX_FADV_DONTNEED); - } else if (f->filetype == FIO_TYPE_BD) { + else if (f->filetype == FIO_TYPE_BD) { ret = blockdev_invalidate_cache(f); if (ret < 0 && errno == EACCES && geteuid()) { if (!root_warn) { @@ -1050,12 +1044,16 @@ int init_random_map(struct thread_data *td) seed = td->rand_seeds[FIO_RAND_BLOCK_OFF]; - if (!lfsr_init(&f->lfsr, blocks, seed, 0)) + if (!lfsr_init(&f->lfsr, blocks, seed, 0)) { + fio_file_set_lfsr(f); continue; + } } else if (!td->o.norandommap) { f->io_axmap = axmap_new(blocks); - if (f->io_axmap) + if (f->io_axmap) { + fio_file_set_axmap(f); continue; + } } else if (td->o.norandommap) continue; @@ -1110,8 +1108,10 @@ void close_and_free_files(struct thread_data *td) sfree(f->file_name); f->file_name = NULL; - axmap_free(f->io_axmap); - f->io_axmap = NULL; + if (fio_file_axmap(f)) { + axmap_free(f->io_axmap); + f->io_axmap = NULL; + } sfree(f); } @@ -1536,11 +1536,16 @@ void free_release_files(struct thread_data *td) void fio_file_reset(struct thread_data *td, struct fio_file *f) { - f->last_pos = f->file_offset; - f->last_start = -1ULL; - if (f->io_axmap) + int i; + + for (i = 0; i < DDIR_RWDIR_CNT; i++) { + f->last_pos[i] = f->file_offset; + f->last_start[i] = -1ULL; + } + + if (fio_file_axmap(f)) axmap_reset(f->io_axmap); - if (td->o.random_generator == FIO_RAND_GEN_LFSR) + else if (fio_file_lfsr(f)) lfsr_reset(&f->lfsr, td->rand_seeds[FIO_RAND_BLOCK_OFF]); }