convert FIO_OS_PATH_SEPARATOR to a character
[fio.git] / filesetup.c
index 5e8ea357deb82a308d1102f888d895171cfc9e3c..a7bbcede08d199cb7660a2771f4b715600ca8af3 100644 (file)
@@ -15,7 +15,6 @@
 #include "os/os.h"
 #include "hash.h"
 #include "lib/axmap.h"
-#include "lib/memalign.h"
 
 #ifdef CONFIG_LINUX_FALLOCATE
 #include <linux/falloc.h>
@@ -110,7 +109,7 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
 {
        int new_layout = 0, unlink_file = 0, flags;
        unsigned long long left;
-       unsigned int bs, alloc_size = 0;
+       unsigned int bs;
        char *b = NULL;
 
        if (read_only) {
@@ -147,8 +146,6 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                flags |= O_CREAT;
        if (new_layout)
                flags |= O_TRUNC;
-       if (td->o.odirect)
-               flags |= OS_O_DIRECT;
 
 #ifdef WIN32
        flags |= _O_BINARY;
@@ -162,14 +159,8 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                if (err == ENOENT && !td->o.allow_create)
                        log_err("fio: file creation disallowed by "
                                        "allow_file_create=0\n");
-               else {
-                       if (err == EINVAL && (flags & OS_O_DIRECT))
-                               log_err("fio: looks like your filesystem "
-                                       "does not support "
-                                       "direct=1/buffered=0\n");
-
+               else
                        td_verror(td, err, "open");
-               }
                return 1;
        }
 
@@ -196,18 +187,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                }
        }
 
-       if (td->o.odirect && !OS_O_DIRECT && fio_set_directio(td, f))
-               goto err;
-
        left = f->real_file_size;
        bs = td->o.max_bs[DDIR_WRITE];
        if (bs > left)
                bs = left;
 
-       alloc_size = bs;
-       b = fio_memalign(page_size, alloc_size);
+       b = malloc(bs);
        if (!b) {
-               td_verror(td, errno, "fio_memalign");
+               td_verror(td, errno, "malloc");
                goto err;
        }
 
@@ -260,14 +247,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                        f->io_size = f->real_file_size;
        }
 
-       fio_memfree(b, alloc_size);
+       free(b);
 done:
        return 0;
 err:
        close(f->fd);
        f->fd = -1;
        if (b)
-               fio_memfree(b, alloc_size);
+               free(b);
        return 1;
 }
 
@@ -1355,6 +1342,7 @@ void close_and_free_files(struct thread_data *td)
 {
        struct fio_file *f;
        unsigned int i;
+       bool use_free = td_ioengine_flagged(td, FIO_NOFILEHASH);
 
        dprint(FD_FILE, "close files\n");
 
@@ -1374,13 +1362,19 @@ void close_and_free_files(struct thread_data *td)
                        td_io_unlink_file(td, f);
                }
 
-               sfree(f->file_name);
+               if (use_free)
+                       free(f->file_name);
+               else
+                       sfree(f->file_name);
                f->file_name = NULL;
                if (fio_file_axmap(f)) {
                        axmap_free(f->io_axmap);
                        f->io_axmap = NULL;
                }
-               sfree(f);
+               if (use_free)
+                       free(f);
+               else
+                       sfree(f);
        }
 
        td->o.filename = NULL;
@@ -1494,7 +1488,10 @@ static struct fio_file *alloc_new_file(struct thread_data *td)
 {
        struct fio_file *f;
 
-       f = smalloc(sizeof(*f));
+       if (td_ioengine_flagged(td, FIO_NOFILEHASH))
+               f = calloc(1, sizeof(*f));
+       else
+               f = smalloc(sizeof(*f));
        if (!f) {
                assert(0);
                return NULL;
@@ -1577,7 +1574,10 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
        if (td->io_ops && td_ioengine_flagged(td, FIO_DISKLESSIO))
                f->real_file_size = -1ULL;
 
-       f->file_name = smalloc_strdup(file_name);
+       if (td_ioengine_flagged(td, FIO_NOFILEHASH))
+               f->file_name = strdup(file_name);
+       else
+               f->file_name = smalloc_strdup(file_name);
        if (!f->file_name)
                assert(0);
 
@@ -1601,7 +1601,8 @@ int add_file(struct thread_data *td, const char *fname, int numjob, int inc)
        if (f->filetype == FIO_TYPE_FILE)
                td->nr_normal_files++;
 
-       set_already_allocated(file_name);
+       if (td->o.numjobs > 1)
+               set_already_allocated(file_name);
 
        if (inc)
                td->o.nr_files++;
@@ -1724,7 +1725,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
                if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
                        continue;
 
-               sprintf(full_path, "%s%s%s", dirname, FIO_OS_PATH_SEPARATOR, dir->d_name);
+               sprintf(full_path, "%s%c%s", dirname, FIO_OS_PATH_SEPARATOR, dir->d_name);
 
                if (lstat(full_path, &sb) == -1) {
                        if (errno != ENOENT) {
@@ -1781,7 +1782,10 @@ void dup_files(struct thread_data *td, struct thread_data *org)
                __f = alloc_new_file(td);
 
                if (f->file_name) {
-                       __f->file_name = smalloc_strdup(f->file_name);
+                       if (td_ioengine_flagged(td, FIO_NOFILEHASH))
+                               __f->file_name = strdup(f->file_name);
+                       else
+                               __f->file_name = smalloc_strdup(f->file_name);
                        if (!__f->file_name)
                                assert(0);
 
@@ -1881,6 +1885,7 @@ int fio_set_directio(struct thread_data *td, struct fio_file *f)
 
        return 0;
 #else
+       log_err("fio: direct IO is not supported on this host operating system\n");
        return -1;
 #endif
 }