Fio 3.34
[fio.git] / filesetup.c
index 7c32d0af438a304fe3aef5a0fa61a95831e01b81..8e5059412ed5e82c396d0f87a87523a2e61f1c4c 100644 (file)
@@ -737,21 +737,11 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
                        f_out = stderr;
        }
 
-       if (td_trim(td))
-               goto skip_flags;
        if (td->o.odirect)
                flags |= OS_O_DIRECT;
-       if (td->o.oatomic) {
-               if (!FIO_O_ATOMIC) {
-                       td_verror(td, EINVAL, "OS does not support atomic IO");
-                       return 1;
-               }
-               flags |= OS_O_DIRECT | FIO_O_ATOMIC;
-       }
        flags |= td->o.sync_io;
        if (td->o.create_on_open && td->o.allow_create)
                flags |= O_CREAT;
-skip_flags:
        if (f->filetype != FIO_TYPE_FILE)
                flags |= FIO_O_NOATIME;
 
@@ -768,7 +758,7 @@ open_again:
                else
                        from_hash = file_lookup_open(f, flags);
        } else if (td_read(td)) {
-               if (f->filetype == FIO_TYPE_CHAR && !read_only)
+               if (td_ioengine_flagged(td, FIO_RO_NEEDS_RW_OPEN) && !read_only)
                        flags |= O_RDWR;
                else
                        flags |= O_RDONLY;
@@ -1417,6 +1407,12 @@ done:
 
        td_restore_runstate(td, old_state);
 
+       if (td->o.fdp) {
+               err = fdp_init(td);
+               if (err)
+                       goto err_out;
+       }
+
        return 0;
 
 err_offset:
@@ -1454,7 +1450,7 @@ static void __init_rand_distribution(struct thread_data *td, struct fio_file *f)
 
        seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
        if (!td->o.rand_repeatable)
-               seed = td->rand_seeds[4];
+               seed = td->rand_seeds[FIO_RAND_BLOCK_OFF];
 
        if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
                zipf_init(&f->zipf, nranges, td->o.zipf_theta.u.f, td->o.random_center.u.f, seed);
@@ -1594,6 +1590,8 @@ void fio_file_free(struct fio_file *f)
 {
        if (fio_file_axmap(f))
                axmap_free(f->io_axmap);
+       if (f->ruhs_info)
+               sfree(f->ruhs_info);
        if (!fio_file_smalloc(f)) {
                free(f->file_name);
                free(f);
@@ -1627,6 +1625,7 @@ void close_and_free_files(struct thread_data *td)
                }
 
                zbd_close_file(f);
+               fdp_free_ruhs_info(f);
                fio_file_free(f);
        }
 
@@ -2031,11 +2030,12 @@ void dup_files(struct thread_data *td, struct thread_data *org)
        if (!org->files)
                return;
 
-       td->files = malloc(org->files_index * sizeof(f));
+       td->files = calloc(org->files_index, sizeof(f));
 
        if (td->o.file_lock_mode != FILE_LOCK_NONE)
                td->file_locks = malloc(org->files_index);
 
+       assert(org->files_index >= org->o.nr_files);
        for_each_file(org, f, i) {
                struct fio_file *__f;