Merge branch 'master' of ssh://git.kernel.dk/data/git/fio
[fio.git] / filesetup.c
index a918234fb77f9df22d2e77fb80a40919fdc46df0..7dceddbbf4dc21077d312dace3fa2321ba04f037 100644 (file)
@@ -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) {
@@ -1004,8 +998,10 @@ static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)
 
        if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
                zipf_init(&f->zipf, nranges, td->o.zipf_theta.u.f, seed);
-       else
+       else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
                pareto_init(&f->zipf, nranges, td->o.pareto_h.u.f, seed);
+       else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
+               gauss_init(&f->gauss, nranges, td->o.gauss_dev, seed);
 
        return 1;
 }
@@ -1050,12 +1046,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 +1110,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);
        }
 
@@ -1543,9 +1545,9 @@ void fio_file_reset(struct thread_data *td, struct fio_file *f)
                f->last_start[i] = -1ULL;
        }
 
-       if (f->io_axmap)
+       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]);
 }