[PATCH] Note when thread is fsyncing
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index aa5071ca527e7d77817b6ffefb2270171f9254e8..44463350c2acf31dae7d0017d19f7397d4a8148d 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -57,6 +57,7 @@ enum {
        TD_INITIALIZED,
        TD_RUNNING,
        TD_VERIFYING,
+       TD_FSYNCING,
        TD_EXITED,
        TD_REAPED,
 };
@@ -747,6 +748,8 @@ static void do_io(struct thread_data *td)
        struct timeval s, e;
        unsigned long usec;
 
+       td_set_runstate(td, TD_RUNNING);
+
        while (td->this_io_bytes[td->ddir] < td->io_size) {
                struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
                struct timespec *timeout;
@@ -822,8 +825,10 @@ static void do_io(struct thread_data *td)
        if (td->cur_depth)
                cleanup_pending_aio(td);
 
-       if (should_fsync(td) && td->end_fsync)
+       if (should_fsync(td) && td->end_fsync) {
+               td_set_runstate(td, TD_FSYNCING);
                sync_td(td);
+       }
 }
 
 static void cleanup_io(struct thread_data *td)
@@ -933,24 +938,6 @@ static int init_io_u(struct thread_data *td)
        return 0;
 }
 
-static void cleanup_allocs(struct thread_data *td)
-{
-       if (td->directory)
-               free(td->directory);
-       if (td->iolog_file)
-               free(td->iolog_file);
-       if (td->exec_prerun)
-               free(td->exec_prerun);
-       if (td->exec_postrun)
-               free(td->exec_postrun);
-       if (td->ioscheduler)
-               free(td->ioscheduler);
-       if (td->sysfs_root)
-               free(td->sysfs_root);
-       if (td->file_name)
-               free(td->file_name);
-}
-
 static int create_file(struct thread_data *td, unsigned long long size,
                       int extend)
 {
@@ -1191,7 +1178,7 @@ static int setup_file(struct thread_data *td)
        }
 
        if (td->odirect)
-               flags |= O_DIRECT;
+               flags |= OS_O_DIRECT;
 
        if (td_write(td) || td_rw(td)) {
                if (td->filetype == FIO_TYPE_FILE) {
@@ -1406,7 +1393,6 @@ err:
        }
        if (td->mmap)
                munmap(td->mmap, td->file_size);
-       cleanup_allocs(td);
        cleanup_io(td);
        cleanup_io_u(td);
        td_set_runstate(td, TD_EXITED);
@@ -1466,6 +1452,9 @@ static void check_str_update(struct thread_data *td)
                case TD_VERIFYING:
                        c = 'V';
                        break;
+               case TD_FSYNCING:
+                       c = 'F';
+                       break;
                case TD_CREATED:
                        c = 'C';
                        break;
@@ -1568,7 +1557,7 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed)
                        eta_sec = INT_MAX;
        } else {
                /*
-                * thread is already done
+                * thread is already done or waiting for fsync
                 */
                eta_sec = 0;
        }
@@ -1590,7 +1579,8 @@ static void print_thread_status(void)
        for (i = 0; i < thread_number; i++) {
                struct thread_data *td = &threads[i];
 
-               if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING){
+               if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING||
+                   td->runstate == TD_FSYNCING) {
                        nr_running++;
                        t_rate += td->rate;
                        m_rate += td->ratemin;