Define SIGUSR1 to inform fio to dump run stats while continuing to run
[fio.git] / backend.c
index 7343286d53219b0c8d4e8a44ec586f1cd66ac6b8..f4bc553b0a5ee9dab880685f1844221975d4c64f 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -87,6 +87,11 @@ static void sig_int(int sig)
        }
 }
 
+static void sig_show_status(int sig)
+{
+       show_running_run_stats();
+}
+
 static void set_sig_handlers(void)
 {
        struct sigaction act;
@@ -101,6 +106,11 @@ static void set_sig_handlers(void)
        act.sa_flags = SA_RESTART;
        sigaction(SIGTERM, &act, NULL);
 
+       memset(&act, 0, sizeof(act));
+       act.sa_handler = sig_show_status;
+       act.sa_flags = SA_RESTART;
+       sigaction(SIGUSR1, &act, NULL);
+
        if (is_backend) {
                memset(&act, 0, sizeof(act));
                act.sa_handler = sig_int;
@@ -494,7 +504,10 @@ sync_done:
                if (full || !td->o.iodepth_batch_complete) {
                        min_events = min(td->o.iodepth_batch_complete,
                                         td->cur_depth);
-                       if (full && !min_events && td->o.iodepth_batch_complete != 0)
+                       /*
+                        * if the queue is full, we MUST reap at least 1 event
+                        */
+                       if (full && !min_events)
                                min_events = 1;
 
                        do {
@@ -555,7 +568,8 @@ static void do_io(struct thread_data *td)
                td_set_runstate(td, TD_RUNNING);
 
        while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
-               (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) {
+               (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) ||
+               td->o.time_based) {
                struct timeval comp_time;
                unsigned long bytes_done[2] = { 0, 0 };
                int min_evts = 0;
@@ -676,7 +690,10 @@ sync_done:
                if (full || !td->o.iodepth_batch_complete) {
                        min_evts = min(td->o.iodepth_batch_complete,
                                        td->cur_depth);
-                       if (full && !min_evts && td->o.iodepth_batch_complete != 0)
+                       /*
+                        * if the queue is full, we MUST reap at least 1 event
+                        */
+                       if (full && !min_evts)
                                min_evts = 1;
 
                        if (__should_check_rate(td, 0) ||
@@ -1287,6 +1304,7 @@ static void reap_threads(unsigned int *nr_running, unsigned int *t_rate,
                        if (errno == ECHILD) {
                                log_err("fio: pid=%d disappeared %d\n",
                                                (int) td->pid, td->runstate);
+                               td->sig = ECHILD;
                                td_set_runstate(td, TD_REAPED);
                                goto reaped;
                        }
@@ -1298,6 +1316,7 @@ static void reap_threads(unsigned int *nr_running, unsigned int *t_rate,
                                if (sig != SIGTERM)
                                        log_err("fio: pid=%d, got signal=%d\n",
                                                        (int) td->pid, sig);
+                               td->sig = sig;
                                td_set_runstate(td, TD_REAPED);
                                goto reaped;
                        }
@@ -1654,6 +1673,7 @@ int fio_backend(void)
        for_each_td(td, i)
                fio_options_free(td);
 
+       free_disk_util();
        cgroup_kill(cgroup_list);
        sfree(cgroup_list);
        sfree(cgroup_mnt);