From: Jens Axboe Date: Wed, 26 Mar 2008 08:23:04 +0000 (+0100) Subject: Merge branch 'master' of ssh://router/data/git/fio X-Git-Tag: fio-1.20-rc4~9^2~4 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=0a308f0fef1ec430ba844111f4dd4a9bcfd7bbfb;hp=6f88bcb0e9a232cf950791edc448edc06bff855f Merge branch 'master' of ssh://router/data/git/fio --- diff --git a/filesetup.c b/filesetup.c index e8472769..bb43ee58 100644 --- a/filesetup.c +++ b/filesetup.c @@ -30,7 +30,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f) * does that for operations involving reads, or for writes * where overwrite is set */ - if (td_read(td) || (td_write(td) && td->o.overwrite)) + if (td_read(td) || (td_write(td) && td->o.overwrite) || + (td_write(td) && td->io_ops->flags & FIO_NOEXTEND)) new_layout = 1; if (td_write(td) && !td->o.overwrite) unlink_file = 1; @@ -94,9 +95,10 @@ static int extend_file(struct thread_data *td, struct fio_file *f) } } - if (td->terminate) + if (td->terminate) { + dprint(FD_FILE, "terminate unlink %s\n", f->file_name); unlink(f->file_name); - else if (td->o.create_fsync) { + } else if (td->o.create_fsync) { if (fsync(f->fd) < 0) { td_verror(td, errno, "fsync"); goto err; @@ -114,6 +116,7 @@ err: return 1; } + dprint(FD_FILE, "layout unlink %s\n", f->file_name); static unsigned long long get_rand_file_size(struct thread_data *td) { unsigned long long ret, size_d; @@ -601,8 +604,10 @@ void close_and_free_files(struct thread_data *td) dprint(FD_FILE, "close files\n"); for_each_file(td, f, i) { - if (td->o.unlink && f->filetype == FIO_TYPE_FILE) + if (td->o.unlink && f->filetype == FIO_TYPE_FILE) { + dprint(FD_FILE, "free unlink %s\n", f->file_name); unlink(f->file_name); + } td_io_close_file(td, f); diff --git a/options.c b/options.c index f05b786b..5626da79 100644 --- a/options.c +++ b/options.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "fio.h" #include "parse.h" @@ -269,6 +270,30 @@ static int str_fst_cb(void *data, const char *str) return 0; } +static int check_dir(struct thread_data *td, char *fname) +{ + char file[PATH_MAX], *dir; + struct stat sb; + + strcpy(file, fname); + dir = dirname(file); + + if (lstat(dir, &sb) < 0) { + int ret = errno; + + log_err("fio: %s is not a directory\n", dir); + td_verror(td, ret, "lstat"); + return 1; + } + + if (!S_ISDIR(sb.st_mode)) { + log_err("fio: %s is not a directory\n", dir); + return 1; + } + + return 0; +} + static int str_filename_cb(void *data, const char *input) { struct thread_data *td = data; @@ -285,6 +310,10 @@ static int str_filename_cb(void *data, const char *input) while ((fname = strsep(&str, ":")) != NULL) { if (!strlen(fname)) break; + if (check_dir(td, fname)) { + free(p); + return 1; + } add_file(td, fname); td->o.nr_files++; } @@ -299,8 +328,10 @@ static int str_directory_cb(void *data, const char fio_unused *str) struct stat sb; if (lstat(td->o.directory, &sb) < 0) { + int ret = errno; + log_err("fio: %s is not a directory\n", td->o.directory); - td_verror(td, errno, "lstat"); + td_verror(td, ret, "lstat"); return 1; } if (!S_ISDIR(sb.st_mode)) {