X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=1a187ff2648d35c933740852751cd147c2ec0a36;hp=1c36ff8fdecd66ec63fc35ea74ac9c1bf5e4fcb3;hb=e0b3258bde6f39ab3a9d178b56526b65e0e32a8d;hpb=0a93fb3e08bf8957b782b80b4d5487852f0c81ce diff --git a/filesetup.c b/filesetup.c index 1c36ff8f..1a187ff2 100644 --- a/filesetup.c +++ b/filesetup.c @@ -20,8 +20,6 @@ #include #endif -static int root_warn; - static FLIST_HEAD(filename_list); /* @@ -59,8 +57,6 @@ static int native_fallocate(struct thread_data *td, struct fio_file *f) static void fallocate_file(struct thread_data *td, struct fio_file *f) { - int r; - if (td->o.fill_device) return; @@ -71,7 +67,9 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) case FIO_FALLOCATE_NONE: break; #ifdef CONFIG_POSIX_FALLOCATE - case FIO_FALLOCATE_POSIX: + case FIO_FALLOCATE_POSIX: { + int r; + dprint(FD_FILE, "posix_fallocate file %s size %llu\n", f->file_name, (unsigned long long) f->real_file_size); @@ -80,9 +78,12 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) if (r > 0) log_err("fio: posix_fallocate fails: %s\n", strerror(r)); break; + } #endif /* CONFIG_POSIX_FALLOCATE */ #ifdef CONFIG_LINUX_FALLOCATE - case FIO_FALLOCATE_KEEP_SIZE: + case FIO_FALLOCATE_KEEP_SIZE: { + int r; + dprint(FD_FILE, "fallocate(FALLOC_FL_KEEP_SIZE) " "file %s size %llu\n", f->file_name, (unsigned long long) f->real_file_size); @@ -92,6 +93,7 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) td_verror(td, errno, "fallocate"); break; + } #endif /* CONFIG_LINUX_FALLOCATE */ default: log_err("fio: unknown fallocate mode: %d\n", td->o.fallocate_mode); @@ -431,8 +433,12 @@ static int get_file_size(struct thread_data *td, struct fio_file *f) ret = bdev_size(td, f); else if (f->filetype == FIO_TYPE_CHAR) ret = char_size(td, f); - else - f->real_file_size = -1ULL; + else { + f->real_file_size = -1; + log_info("%s: failed to get file size of %s\n", td->o.name, + f->file_name); + return 1; /* avoid offset extends end error message */ + } /* * Leave ->real_file_size with 0 since it could be expectation @@ -441,23 +447,11 @@ static int get_file_size(struct thread_data *td, struct fio_file *f) if (ret) return ret; - /* - * If ->real_file_size is -1, a conditional for the message - * "offset extends end" is always true, but it makes no sense, - * so just return the same value here. - */ - if (f->real_file_size == -1ULL) { - log_info("%s: failed to get file size of %s\n", td->o.name, - f->file_name); - return 1; - } - - if (td->o.start_offset && f->file_offset == 0) - dprint(FD_FILE, "offset of file %s not initialized yet\n", - f->file_name); /* * ->file_offset normally hasn't been initialized yet, so this - * is basically always false. + * is basically always false unless ->real_file_size is -1, but + * if ->real_file_size is -1 this message doesn't make sense. + * As a result, this message is basically useless. */ if (f->file_offset > f->real_file_size) { log_err("%s: offset extends end (%llu > %llu)\n", td->o.name, @@ -494,6 +488,10 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, ret = td->io_ops->invalidate(td, f); if (ret < 0) errval = -ret; + } else if (td_ioengine_flagged(td, FIO_DISKLESSIO)) { + dprint(FD_IO, "invalidate not supported by ioengine %s\n", + td->io_ops->name); + ret = 0; } else if (f->filetype == FIO_TYPE_FILE) { dprint(FD_IO, "declare unneeded cache %s: %llu/%llu\n", f->file_name, off, len); @@ -516,10 +514,9 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, ret = blockdev_invalidate_cache(f); } if (ret < 0 && errno == EACCES && geteuid()) { - if (!root_warn) { + if (!fio_did_warn(FIO_WARN_ROOT_FLUSH)) { log_err("fio: only root may flush block " "devices. Cache flush bypassed!\n"); - root_warn = 1; } ret = 0; } @@ -1039,7 +1036,7 @@ int setup_files(struct thread_data *td) if (f->io_size == -1ULL) total_size = -1ULL; else { - if (o->size_percent) { + if (o->size_percent && o->size_percent != 100) { uint64_t file_size; file_size = f->io_size + f->file_offset; @@ -1484,7 +1481,7 @@ static struct fio_file *alloc_new_file(struct thread_data *td) if (td_ioengine_flagged(td, FIO_NOFILEHASH)) f = calloc(1, sizeof(*f)); else - f = smalloc(sizeof(*f)); + f = scalloc(1, sizeof(*f)); if (!f) { assert(0); return NULL; @@ -1632,8 +1629,6 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) } td->files_index++; - if (f->filetype == FIO_TYPE_FILE) - td->nr_normal_files++; if (td->o.numjobs > 1) set_already_allocated(file_name); @@ -1737,10 +1732,10 @@ void unlock_file_all(struct thread_data *td, struct fio_file *f) unlock_file(td, f); } -static int recurse_dir(struct thread_data *td, const char *dirname) +static bool recurse_dir(struct thread_data *td, const char *dirname) { struct dirent *dir; - int ret = 0; + bool ret = false; DIR *D; D = opendir(dirname); @@ -1749,7 +1744,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname) snprintf(buf, FIO_VERROR_SIZE, "opendir(%s)", dirname); td_verror(td, errno, buf); - return 1; + return true; } while ((dir = readdir(D)) != NULL) { @@ -1764,7 +1759,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname) if (lstat(full_path, &sb) == -1) { if (errno != ENOENT) { td_verror(td, errno, "stat"); - ret = 1; + ret = true; break; } } @@ -1859,7 +1854,6 @@ void free_release_files(struct thread_data *td) td->o.nr_files = 0; td->o.open_files = 0; td->files_index = 0; - td->nr_normal_files = 0; } void fio_file_reset(struct thread_data *td, struct fio_file *f)