summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-12-05 10:40:37 -0700
committerJens Axboe <axboe@kernel.dk>2019-12-05 10:40:37 -0700
commit274b48535e3ad2e46b8ceaed3ebea9efb3be85fe (patch)
tree88abd01ab2de0f6f37c42743c8e0579d7fd0e482
parentbef74db41fb5a1607fd55cb86544165fc08acac1 (diff)
downloadfio-274b48535e3ad2e46b8ceaed3ebea9efb3be85fe.tar.gz
fio-274b48535e3ad2e46b8ceaed3ebea9efb3be85fe.tar.bz2
Revert "filesetup: don't call create_work_dirs() for ioengine with FIO_DISKLESSIO"issue-870
This reverts commit 95af8dd57a7a9a564f99492bb1e04bb6d13b95b1.
-rw-r--r--filesetup.c85
1 files changed, 41 insertions, 44 deletions
diff --git a/filesetup.c b/filesetup.c
index 7fe2ebd4..f83150be 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -913,42 +913,6 @@ uint64_t get_start_offset(struct thread_data *td, struct fio_file *f)
return offset;
}
-static bool create_work_dirs(struct thread_data *td, const char *fname)
-{
- char path[PATH_MAX];
- char *start, *end;
-
- if (td->o.directory) {
- snprintf(path, PATH_MAX, "%s%c%s", td->o.directory,
- FIO_OS_PATH_SEPARATOR, fname);
- start = strstr(path, fname);
- } else {
- snprintf(path, PATH_MAX, "%s", fname);
- start = path;
- }
-
- end = start;
- while ((end = strchr(end, FIO_OS_PATH_SEPARATOR)) != NULL) {
- if (end == start)
- break;
- *end = '\0';
- errno = 0;
-#ifdef CONFIG_HAVE_MKDIR_TWO
- if (mkdir(path, 0600) && errno != EEXIST) {
-#else
- if (mkdir(path) && errno != EEXIST) {
-#endif
- log_err("fio: failed to create dir (%s): %d\n",
- start, errno);
- return false;
- }
- *end = FIO_OS_PATH_SEPARATOR;
- end++;
- }
- td->flags |= TD_F_DIRS_CREATED;
- return true;
-}
-
/*
* Open the files and setup files sizes, creating files if necessary.
*/
@@ -967,14 +931,6 @@ int setup_files(struct thread_data *td)
old_state = td_bump_runstate(td, TD_SETTING_UP);
- for_each_file(td, f, i) {
- if (!td_ioengine_flagged(td, FIO_DISKLESSIO) &&
- strchr(f->file_name, FIO_OS_PATH_SEPARATOR) &&
- !(td->flags & TD_F_DIRS_CREATED) &&
- !create_work_dirs(td, f->file_name))
- goto err_out;
- }
-
/*
* Find out physical size of files or devices for this thread,
* before we determine I/O size and range of our targets.
@@ -1592,6 +1548,42 @@ bool exists_and_not_regfile(const char *filename)
return true;
}
+static bool create_work_dirs(struct thread_data *td, const char *fname)
+{
+ char path[PATH_MAX];
+ char *start, *end;
+
+ if (td->o.directory) {
+ snprintf(path, PATH_MAX, "%s%c%s", td->o.directory,
+ FIO_OS_PATH_SEPARATOR, fname);
+ start = strstr(path, fname);
+ } else {
+ snprintf(path, PATH_MAX, "%s", fname);
+ start = path;
+ }
+
+ end = start;
+ while ((end = strchr(end, FIO_OS_PATH_SEPARATOR)) != NULL) {
+ if (end == start)
+ break;
+ *end = '\0';
+ errno = 0;
+#ifdef CONFIG_HAVE_MKDIR_TWO
+ if (mkdir(path, 0600) && errno != EEXIST) {
+#else
+ if (mkdir(path) && errno != EEXIST) {
+#endif
+ log_err("fio: failed to create dir (%s): %d\n",
+ start, errno);
+ return false;
+ }
+ *end = FIO_OS_PATH_SEPARATOR;
+ end++;
+ }
+ td->flags |= TD_F_DIRS_CREATED;
+ return true;
+}
+
int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
{
int cur_files = td->files_index;
@@ -1607,6 +1599,11 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
sprintf(file_name + len, "%s", fname);
+ if (strchr(fname, FIO_OS_PATH_SEPARATOR) &&
+ !(td->flags & TD_F_DIRS_CREATED) &&
+ !create_work_dirs(td, fname))
+ return 1;
+
/* clean cloned siblings using existing files */
if (numjob && is_already_allocated(file_name) &&
!exists_and_not_regfile(fname))