t/nvmept_trim: increase transfer size for some tests
[fio.git] / filesetup.c
index 144a0572410398b3c5fad3dfe4fa8b33c3dfd424..cb42a852c8cf3728571e54f55103e17d802ef4c4 100644 (file)
@@ -143,7 +143,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
        if (unlink_file || new_layout) {
                int ret;
 
-               dprint(FD_FILE, "layout %d unlink %d %s\n", new_layout, unlink_file, f->file_name);
+               dprint(FD_FILE, "layout unlink %s\n", f->file_name);
 
                ret = td_io_unlink_file(td, f);
                if (ret != 0 && ret != ENOENT) {
@@ -198,9 +198,6 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                }
        }
 
-
-       dprint(FD_FILE, "fill file %s, size %llu\n", f->file_name, (unsigned long long) f->real_file_size);
-
        left = f->real_file_size;
        bs = td->o.max_bs[DDIR_WRITE];
        if (bs > left)
@@ -306,13 +303,12 @@ static bool pre_read_file(struct thread_data *td, struct fio_file *f)
        if (bs > left)
                bs = left;
 
-       b = malloc(bs);
+       b = calloc(1, bs);
        if (!b) {
                td_verror(td, errno, "malloc");
                ret = false;
                goto error;
        }
-       memset(b, 0, bs);
 
        if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
                td_verror(td, errno, "lseek");
@@ -740,21 +736,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;
 
@@ -763,6 +749,11 @@ open_again:
                if (!read_only)
                        flags |= O_RDWR;
 
+               if (td->o.verify_only) {
+                       flags &= ~O_RDWR;
+                       flags |= O_RDONLY;
+               }
+
                if (f->filetype == FIO_TYPE_FILE && td->o.allow_create)
                        flags |= O_CREAT;
 
@@ -771,7 +762,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;
@@ -1081,45 +1072,6 @@ static bool create_work_dirs(struct thread_data *td, const char *fname)
        return true;
 }
 
-int setup_shared_file(struct thread_data *td)
-{
-       struct fio_file *f;
-       uint64_t file_size;
-       int err = 0;
-
-       if (td->o.nr_files > 1) {
-               log_err("fio: shared file setup called for multiple files\n");
-               return -1;
-       }
-
-       get_file_sizes(td);
-
-       f = td->files[0];
-
-       if (f == NULL) {
-               log_err("fio: NULL shared file\n");
-               return -1;
-       }
-
-       file_size = thread_number * td->o.size;
-       dprint(FD_FILE, "shared setup %s real_file_size=%llu, desired=%llu\n", 
-                       f->file_name, (unsigned long long)f->real_file_size, (unsigned long long)file_size);
-
-       if (f->real_file_size < file_size) {
-               dprint(FD_FILE, "fio: extending shared file\n");
-               f->real_file_size = file_size;
-               err = extend_file(td, f);
-               if (!err) {
-                       err = __file_invalidate_cache(td, f, 0, f->real_file_size);
-               }
-               get_file_sizes(td);
-               dprint(FD_FILE, "shared setup new real_file_size=%llu\n", 
-                               (unsigned long long)f->real_file_size);
-       }
-
-       return err;
-}
-
 /*
  * Open the files and setup files sizes, creating files if necessary.
  */
@@ -1134,7 +1086,7 @@ int setup_files(struct thread_data *td)
        const unsigned long long bs = td_min_bs(td);
        uint64_t fs = 0;
 
-       dprint(FD_FILE, "setup files (thread_number=%d, subjob_number=%d)\n", td->thread_number, td->subjob_number);
+       dprint(FD_FILE, "setup files\n");
 
        old_state = td_bump_runstate(td, TD_SETTING_UP);
 
@@ -1459,6 +1411,12 @@ done:
 
        td_restore_runstate(td, old_state);
 
+       if (td->o.dp_type != FIO_DP_NONE) {
+               err = dp_init(td);
+               if (err)
+                       goto err_out;
+       }
+
        return 0;
 
 err_offset:
@@ -1494,9 +1452,8 @@ static void __init_rand_distribution(struct thread_data *td, struct fio_file *f)
 
        nranges = (fsize + range_size - 1ULL) / range_size;
 
-       seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
-       if (!td->o.rand_repeatable)
-               seed = td->rand_seeds[FIO_RAND_BLOCK_OFF];
+       seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number *
+               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);
@@ -1636,6 +1593,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);
@@ -1669,6 +1628,7 @@ void close_and_free_files(struct thread_data *td)
                }
 
                zbd_close_file(f);
+               fdp_free_ruhs_info(f);
                fio_file_free(f);
        }