glusterfs: update for new API
[fio.git] / engines / filecreate.c
index 284aaf398328177d11bcf9fd549090aa42e7d5c1..39a2950293f70b8e74e57624dfea5e1fb050d3c6 100644 (file)
@@ -5,17 +5,18 @@
  * of the file creation.
  */
 #include <stdio.h>
-#include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
 
 #include "../fio.h"
-#include "../filehash.h"
+
+struct fc_data {
+       enum fio_ddir stat_ddir;
+};
 
 static int open_file(struct thread_data *td, struct fio_file *f)
 {
-       struct timespec start, end;
-       int from_hash = 0;
+       struct timespec start;
        int do_lat = !td->o.disable_lat;
 
        dprint(FD_FILE, "fd open %s\n", f->file_name);
@@ -29,17 +30,10 @@ static int open_file(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
-open_again:
        if (do_lat)
                fio_gettime(&start, NULL);
-       from_hash = file_lookup_open(f, O_CREAT|O_RDWR);
-       if (do_lat) {
-               unsigned long long nsec;
 
-               fio_gettime(&end, NULL);
-               nsec = ntime_since(&start, &end);
-               add_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
-       }
+       f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
 
        if (f->fd == -1) {
                char buf[FIO_VERROR_SIZE];
@@ -47,35 +41,70 @@ open_again:
 
                snprintf(buf, sizeof(buf), "open(%s)", f->file_name);
                td_verror(td, e, buf);
+               return 1;
        }
 
-       if (!from_hash && f->fd != -1) {
-               if (add_file_hash(f)) {
-                       int fio_unused ret;
+       if (do_lat) {
+               struct fc_data *data = td->io_ops_data;
+               uint64_t nsec;
 
-                       /*
-                        * OK to ignore, we haven't done anything with it
-                        */
-                       ret = generic_close_file(td, f);
-                       goto open_again;
-               }
+               nsec = ntime_since_now(&start);
+               add_clat_sample(td, data->stat_ddir, nsec, 0, 0);
        }
 
        return 0;
 }
 
-static int queue_io(struct thread_data *td, struct io_u fio_unused *io_u)
+static enum fio_q_status queue_io(struct thread_data *td,
+                                 struct io_u fio_unused *io_u)
 {
        return FIO_Q_COMPLETED;
 }
 
+/*
+ * Ensure that we at least have a block size worth of IO to do for each
+ * file. If the job file has td->o.size < nr_files * block_size, then
+ * fio won't do anything.
+ */
+static int get_file_size(struct thread_data *td, struct fio_file *f)
+{
+       f->real_file_size = td_min_bs(td);
+       return 0;
+}
+
+static int init(struct thread_data *td)
+{
+       struct fc_data *data;
+
+       data = calloc(1, sizeof(*data));
+
+       if (td_read(td))
+               data->stat_ddir = DDIR_READ;
+       else if (td_write(td))
+               data->stat_ddir = DDIR_WRITE;
+
+       td->io_ops_data = data;
+       return 0;
+}
+
+static void cleanup(struct thread_data *td)
+{
+       struct fc_data *data = td->io_ops_data;
+
+       free(data);
+}
+
 static struct ioengine_ops ioengine = {
        .name           = "filecreate",
        .version        = FIO_IOOPS_VERSION,
-       .open_file      = open_file,
+       .init           = init,
+       .cleanup        = cleanup,
        .queue          = queue_io,
+       .get_file_size  = get_file_size,
+       .open_file      = open_file,
        .close_file     = generic_close_file,
-       .flags          = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO,
+       .flags          = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO |
+                               FIO_NOSTATS | FIO_NOFILEHASH,
 };
 
 static void fio_init fio_filecreate_register(void)