X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=filesetup.c;h=bf56112b72b9784cf32583ebc0dbba72324b9f86;hp=fa09219f62a2e2b93f0e001b2e7254da72e04e99;hb=f3e1eb23a6c900921caa58c6cad66d3b60b0b6d7;hpb=c3afb7639f41e58e44481151e3aa4caa6be789f6 diff --git a/filesetup.c b/filesetup.c index fa09219f..bf56112b 100644 --- a/filesetup.c +++ b/filesetup.c @@ -38,7 +38,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f) int r, new_layout = 0, unlink_file = 0, flags; unsigned long long left; unsigned int bs; - char *b; + char *b = NULL; if (read_only) { log_err("fio: refusing extend of file due to read-only\n"); @@ -189,6 +189,8 @@ done: err: close(f->fd); f->fd = -1; + if (b) + free(b); return 1; } @@ -395,9 +397,6 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off, len); - /* - * FIXME: add blockdev flushing too - */ if (f->mmap_ptr) { ret = posix_madvise(f->mmap_ptr, f->mmap_sz, POSIX_MADV_DONTNEED); #ifdef FIO_MADV_FREE @@ -419,15 +418,18 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f, } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE) ret = 0; - if (ret < 0) { - td_verror(td, errno, "invalidate_cache"); - return 1; - } else if (ret > 0) { - td_verror(td, ret, "invalidate_cache"); - return 1; + /* + * Cache flushing isn't a fatal condition, and we know it will + * happen on some platforms where we don't have the proper + * function to flush eg block device caches. So just warn and + * continue on our way. + */ + if (ret) { + log_info("fio: cache invalidation of %s failed: %s\n", f->file_name, strerror(errno)); + ret = 0; } - return ret; + return 0; } @@ -806,7 +808,7 @@ int setup_files(struct thread_data *td) * Calculate per-file size and potential extra size for the * first files, if needed. */ - if (!o->file_size_low) { + if (!o->file_size_low && o->nr_files) { uint64_t all_fs; fs = o->size / o->nr_files; @@ -1279,13 +1281,6 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc) set_already_allocated(file_name); - /* - * For adding files after the fact - if openfiles= isn't - * given as an option, ensure we allow at least one file open - */ - if (!td->o.open_files) - td->o.open_files = 1; - if (inc) td->o.nr_files++; @@ -1409,7 +1404,8 @@ 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"); - return 1; + ret = 1; + break; } }