X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=4e828542e97535b6606d966cd9c08711f88f4639;hp=478bda8cb0331017b55574d8df67c09cd1151bed;hb=29df29eaf88958c8741103d2056a4773d4959d9d;hpb=38f30c81d8d194da047950cbbda3896bd35cd98c diff --git a/filesetup.c b/filesetup.c index 478bda8c..4e828542 100644 --- a/filesetup.c +++ b/filesetup.c @@ -15,7 +15,7 @@ #include "hash.h" #include "lib/axmap.h" -#ifdef FIO_HAVE_LINUX_FALLOCATE +#ifdef CONFIG_LINUX_FALLOCATE #include #endif @@ -72,7 +72,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f) return 1; } -#ifdef FIO_HAVE_FALLOCATE +#ifdef CONFIG_POSIX_FALLOCATE if (!td->o.fill_device) { switch (td->o.fallocate_mode) { case FIO_FALLOCATE_NONE: @@ -87,7 +87,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f) strerror(r)); } break; -#ifdef FIO_HAVE_LINUX_FALLOCATE +#ifdef CONFIG_LINUX_FALLOCATE case FIO_FALLOCATE_KEEP_SIZE: dprint(FD_FILE, "fallocate(FALLOC_FL_KEEP_SIZE) " @@ -96,18 +96,18 @@ static int extend_file(struct thread_data *td, struct fio_file *f) r = fallocate(f->fd, FALLOC_FL_KEEP_SIZE, 0, f->real_file_size); - if (r != 0) { + if (r != 0) td_verror(td, errno, "fallocate"); - } + break; -#endif /* FIO_HAVE_LINUX_FALLOCATE */ +#endif /* CONFIG_LINUX_FALLOCATE */ default: log_err("fio: unknown fallocate mode: %d\n", td->o.fallocate_mode); assert(0); } } -#endif /* FIO_HAVE_FALLOCATE */ +#endif /* CONFIG_POSIX_FALLOCATE */ if (!new_layout) goto done; @@ -563,7 +563,7 @@ open_again: if (__e == EMFILE && file_close_shadow_fds(td)) goto open_again; - snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name); + snprintf(buf, sizeof(buf), "open(%s)", f->file_name); if (__e == EINVAL && (flags & OS_O_DIRECT)) { log_err("fio: looks like your file system does not " \ @@ -919,9 +919,9 @@ static int __init_rand_distribution(struct thread_data *td, struct fio_file *f) seed = td->rand_seeds[4]; if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) - zipf_init(&f->zipf, nranges, td->o.zipf_theta, seed); + zipf_init(&f->zipf, nranges, td->o.zipf_theta.u.f, seed); else - pareto_init(&f->zipf, nranges, td->o.pareto_h, seed); + pareto_init(&f->zipf, nranges, td->o.pareto_h.u.f, seed); return 1; } @@ -958,8 +958,8 @@ int init_random_map(struct thread_data *td) for_each_file(td, f, i) { uint64_t file_size = min(f->real_file_size, f->io_size); - blocks = (file_size + td->o.rw_min_bs - 1) / - (unsigned long long) td->o.rw_min_bs; + blocks = file_size / (unsigned long long) td->o.rw_min_bs; + if (td->o.random_generator == FIO_RAND_GEN_LFSR) { unsigned long seed; @@ -1073,7 +1073,7 @@ int add_file(struct thread_data *td, const char *fname) f->fd = -1; f->shadow_fd = -1; - fio_file_reset(f); + fio_file_reset(td, f); if (td->files_size <= td->files_index) { unsigned int new_size = td->o.nr_files + 1; @@ -1250,7 +1250,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname) if (!D) { char buf[FIO_VERROR_SIZE]; - snprintf(buf, FIO_VERROR_SIZE - 1, "opendir(%s)", dirname); + snprintf(buf, FIO_VERROR_SIZE, "opendir(%s)", dirname); td_verror(td, errno, buf); return 1; } @@ -1319,7 +1319,7 @@ void dup_files(struct thread_data *td, struct thread_data *org) assert(0); } __f->fd = -1; - fio_file_reset(__f); + fio_file_reset(td, __f); if (f->file_name) { __f->file_name = smalloc_strdup(f->file_name); @@ -1359,3 +1359,13 @@ void free_release_files(struct thread_data *td) td->files_index = 0; td->nr_normal_files = 0; } + +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) + axmap_reset(f->io_axmap); + if (td->o.random_generator == FIO_RAND_GEN_LFSR) + lfsr_reset(&f->lfsr, td->rand_seeds[FIO_RAND_BLOCK_OFF]); +}