X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=75694bd81825082516d9f1601de08a650ebe9aa1;hp=30af085d0b33e3eb4ee6fd490fee0a01018d368b;hb=56c77c10f79d7be492aa0fb137786978c3596682;hpb=e80d780108fd33350f7c4a3032a8d2d06d7b102f diff --git a/filesetup.c b/filesetup.c index 30af085d..75694bd8 100644 --- a/filesetup.c +++ b/filesetup.c @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include "fio.h" #include "smalloc.h" @@ -15,13 +13,12 @@ #include "os/os.h" #include "hash.h" #include "lib/axmap.h" +#include "rwlock.h" #ifdef CONFIG_LINUX_FALLOCATE #include #endif -static int root_warn; - static FLIST_HEAD(filename_list); /* @@ -490,6 +487,9 @@ 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); } else if (f->filetype == FIO_TYPE_FILE) { dprint(FD_IO, "declare unneeded cache %s: %llu/%llu\n", f->file_name, off, len); @@ -512,19 +512,16 @@ 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; } if (ret < 0) errval = errno; } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE) { dprint(FD_IO, "invalidate not supported %s\n", f->file_name); - ret = 0; } /* @@ -1035,7 +1032,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; @@ -1480,7 +1477,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; @@ -1608,8 +1605,9 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) f->file_name = strdup(file_name); else f->file_name = smalloc_strdup(file_name); - if (!f->file_name) - assert(0); + + /* can't handle smalloc failure from here */ + assert(f->file_name); get_file_type(f); @@ -1620,7 +1618,7 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) f->rwlock = fio_rwlock_init(); break; case FILE_LOCK_EXCLUSIVE: - f->lock = fio_mutex_init(FIO_MUTEX_UNLOCKED); + f->lock = fio_sem_init(FIO_SEM_UNLOCKED); break; default: log_err("fio: unknown lock mode: %d\n", td->o.file_lock_mode); @@ -1705,7 +1703,7 @@ void lock_file(struct thread_data *td, struct fio_file *f, enum fio_ddir ddir) else fio_rwlock_write(f->rwlock); } else if (td->o.file_lock_mode == FILE_LOCK_EXCLUSIVE) - fio_mutex_down(f->lock); + fio_sem_down(f->lock); td->file_locks[f->fileno] = td->o.file_lock_mode; } @@ -1718,7 +1716,7 @@ void unlock_file(struct thread_data *td, struct fio_file *f) if (td->o.file_lock_mode == FILE_LOCK_READWRITE) fio_rwlock_unlock(f->rwlock); else if (td->o.file_lock_mode == FILE_LOCK_EXCLUSIVE) - fio_mutex_up(f->lock); + fio_sem_up(f->lock); td->file_locks[f->fileno] = FILE_LOCK_NONE; } @@ -1814,9 +1812,9 @@ void dup_files(struct thread_data *td, struct thread_data *org) __f->file_name = strdup(f->file_name); else __f->file_name = smalloc_strdup(f->file_name); - if (!__f->file_name) - assert(0); + /* can't handle smalloc failure from here */ + assert(__f->file_name); __f->filetype = f->filetype; }