add FIO_FILENOHASH ioengine flag
authorJosef Bacik <jbacik@fb.com>
Mon, 9 Oct 2017 20:31:02 +0000 (16:31 -0400)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Oct 2017 20:31:49 +0000 (14:31 -0600)
filecreate doesn't use the file hash table, so don't bother doing shared
memory allocations for the file objects, ye olde malloc will work just
fine.  This way we can create millions of files without jacking up
--alloc-size.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/filecreate.c
filesetup.c
ioengines.h

index 00562c861c2be580083f60032dfc368914c8e6f3..c6b659713c499a53ffb2d4312a99bafa94d1bc19 100644 (file)
@@ -76,7 +76,7 @@ static struct ioengine_ops ioengine = {
        .open_file      = open_file,
        .close_file     = generic_close_file,
        .flags          = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO |
-                               FIO_NOSTATS,
+                               FIO_NOSTATS | FIO_NOFILEHASH,
 };
 
 static void fio_init fio_filecreate_register(void)
index 789f0ed29ea501be4c5e3c3ee895093b305b5787..0631a01f96a635789f925e6f54f7abf9a23ce92f 100644 (file)
@@ -1342,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");
 
@@ -1361,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;
@@ -1481,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;
@@ -1564,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);
 
@@ -1769,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);
 
index e744f3f84d3cd7568a0415ce5cd6c8f8a75f19c5..32b18edadf1f2dbbdcdf2ae66df3ea264a4a16c8 100644 (file)
@@ -60,6 +60,7 @@ enum fio_ioengine_flags {
        FIO_BIT_BASED   = 1 << 10,      /* engine uses a bit base (e.g. uses Kbit as opposed to KB) */
        FIO_FAKEIO      = 1 << 11,      /* engine pretends to do IO */
        FIO_NOSTATS     = 1 << 12,      /* don't do IO stats */
+       FIO_NOFILEHASH  = 1 << 13,      /* doesn't hash the files for lookup later. */
 };
 
 /*