Merge branch 'master' of ssh://brick.kernel.dk/data/git/fio
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index e205b3aa52ac9f9a693fd249c52de1b84f45afb8..2beda816bb43d3102c675c848d67794b6f0876ca 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -45,6 +45,7 @@
 #include "cgroup.h"
 #include "profile.h"
 #include "lib/rand.h"
+#include "memalign.h"
 
 unsigned long page_mask;
 unsigned long page_size;
@@ -101,7 +102,7 @@ static void terminate_threads(int group_id)
                        /*
                         * if the thread is running, just let it exit
                         */
-                       if (td->runstate < TD_RUNNING)
+                       if (td->runstate < TD_RAMP)
                                kill(td->pid, SIGTERM);
                        else {
                                struct ioengine_ops *ops = td->io_ops;
@@ -113,18 +114,12 @@ static void terminate_threads(int group_id)
        }
 }
 
-/*
- * Happens on thread runs with ctrl-c, ignore our own SIGQUIT
- */
-static void sig_quit(int sig)
-{
-}
-
 static void sig_int(int sig)
 {
        if (threads) {
                log_info("\nfio: terminating on signal %d\n", sig);
                fflush(stdout);
+               exit_value = 128;
                terminate_threads(TERMINATE_ALL);
        }
 }
@@ -176,7 +171,7 @@ static void set_sig_handlers(void)
        sigaction(SIGINT, &act, NULL);
 
        memset(&act, 0, sizeof(act));
-       act.sa_handler = sig_quit;
+       act.sa_handler = sig_int;
        act.sa_flags = SA_RESTART;
        sigaction(SIGTERM, &act, NULL);
 }
@@ -185,7 +180,7 @@ static void set_sig_handlers(void)
  * Check if we are above the minimum rate given.
  */
 static int __check_min_rate(struct thread_data *td, struct timeval *now,
-                           enum td_ddir ddir)
+                           enum fio_ddir ddir)
 {
        unsigned long long bytes = 0;
        unsigned long iops = 0;
@@ -765,8 +760,11 @@ sync_done:
                struct fio_file *f;
 
                i = td->cur_depth;
-               if (i)
+               if (i) {
                        ret = io_u_queued_complete(td, i, NULL);
+                       if (td->o.fill_device && td->error == ENOSPC)
+                               td->error = 0;
+               }
 
                if (should_fsync(td) && td->o.end_fsync) {
                        td_set_runstate(td, TD_FSYNCING);
@@ -796,7 +794,7 @@ static void cleanup_io_u(struct thread_data *td)
                io_u = flist_entry(entry, struct io_u, list);
 
                flist_del(&io_u->list);
-               free(io_u);
+               fio_memfree(io_u, sizeof(*io_u));
        }
 
        free_io_mem(td);
@@ -843,8 +841,9 @@ static int init_io_u(struct thread_data *td)
                if (td->terminate)
                        return 1;
 
-               if (posix_memalign(&ptr, cl_align, sizeof(*io_u))) {
-                       log_err("fio: posix_memalign=%s\n", strerror(errno));
+               ptr = fio_memalign(cl_align, sizeof(*io_u));
+               if (!ptr) {
+                       log_err("fio: unable to allocate aligned memory\n");
                        break;
                }
 
@@ -1516,7 +1515,7 @@ static void run_threads(void)
        set_genesis_time();
 
        while (todo) {
-               struct thread_data *map[MAX_JOBS];
+               struct thread_data *map[REAL_MAX_JOBS];
                struct timeval this_start;
                int this_jobs = 0, left;