time: add ntime_since_now()
[fio.git] / engines / filecreate.c
index e078f067fb51e572c80406d0ad2b70f4ac0ad23a..d753df24c94f830b6ef581a754677a8c0212b1ff 100644 (file)
@@ -14,8 +14,7 @@
 
 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 +28,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,18 +39,14 @@ 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) {
+               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_lat_sample(td, DDIR_WRITE, nsec, 0, 0);
        }
 
        return 0;
@@ -87,7 +75,8 @@ static struct ioengine_ops ioengine = {
        .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,
 };
 
 static void fio_init fio_filecreate_register(void)