X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=filesetup.c;h=8e5059412ed5e82c396d0f87a87523a2e61f1c4c;hb=HEAD;hp=661d4c2fa083e2c4b948b628a344c6f294b28ebe;hpb=d16e84e256ffdcd3143c9439cf1e408d8db61c1a;p=fio.git diff --git a/filesetup.c b/filesetup.c index 661d4c2f..cb42a852 100644 --- a/filesetup.c +++ b/filesetup.c @@ -226,11 +226,16 @@ static int extend_file(struct thread_data *td, struct fio_file *f) if (r < 0) { int __e = errno; - if (__e == ENOSPC) { + if (__e == ENOSPC || __e == EDQUOT) { + const char *__e_name; if (td->o.fill_device) break; - log_info("fio: ENOSPC on laying out " - "file, stopping\n"); + if (__e == ENOSPC) + __e_name = "ENOSPC"; + else + __e_name = "EDQUOT"; + log_info("fio: %s on laying out " + "file, stopping\n", __e_name); } td_verror(td, errno, "write"); } else @@ -298,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"); @@ -732,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; @@ -755,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; @@ -763,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; @@ -1019,7 +1018,6 @@ int longest_existing_path(char *path) { while (!done) { buf_pos = strrchr(buf, FIO_OS_PATH_SEPARATOR); if (!buf_pos) { - done = true; offset = 0; break; } @@ -1115,6 +1113,13 @@ int setup_files(struct thread_data *td) if (err) goto err_out; + if (td->o.zone_mode == ZONE_MODE_ZBD) { + err = zbd_init_files(td); + if (err) + goto err_out; + } + zbd_recalc_options_with_zone_granularity(td); + if (o->read_iolog_file) goto done; @@ -1395,16 +1400,23 @@ int setup_files(struct thread_data *td) } done: + if (td->o.zone_mode == ZONE_MODE_ZBD) { + err = zbd_setup_files(td); + if (err) + goto err_out; + } + if (o->create_only) td->done = 1; td_restore_runstate(td, old_state); - if (td->o.zone_mode == ZONE_MODE_ZBD) { - err = zbd_setup_files(td); + if (td->o.dp_type != FIO_DP_NONE) { + err = dp_init(td); if (err) goto err_out; } + return 0; err_offset: @@ -1440,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[4]; + 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); @@ -1474,7 +1485,7 @@ static bool init_rand_distribution(struct thread_data *td) /* * Check if the number of blocks exceeds the randomness capability of - * the selected generator. Tausworthe is 32-bit, the others are fullly + * the selected generator. Tausworthe is 32-bit, the others are fully * 64-bit capable. */ static int check_rand_gen_limits(struct thread_data *td, struct fio_file *f, @@ -1582,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); @@ -1615,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); } @@ -2019,11 +2033,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;