From db1cd90b90d4d5c49db90d5afeb79ea3a3b034d1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 26 Apr 2007 13:47:07 +0200 Subject: [PATCH] Allow termination during io_u building If we are setting up gigabytes of io buffers, it can take many seconds for that operation to complete. If the user wishes to abort, fio wont honor that request. Fix that. Signed-off-by: Jens Axboe --- fio.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/fio.c b/fio.c index d8c14333..75b448d5 100644 --- a/fio.c +++ b/fio.c @@ -645,6 +645,8 @@ static int init_io_u(struct thread_data *td) p = ALIGN(td->orig_buffer); for (i = 0; i < max_units; i++) { + if (td->terminate) + return 1; io_u = malloc(sizeof(*io_u)); memset(io_u, 0, sizeof(*io_u)); INIT_LIST_HEAD(&io_u->list); @@ -770,41 +772,41 @@ static void *thread_main(void *data) INIT_LIST_HEAD(&td->io_hist_list); td->io_hist_tree = RB_ROOT; + td_set_runstate(td, TD_INITIALIZED); + fio_sem_up(startup_sem); + fio_sem_down(td->mutex); + + /* + * the ->mutex semaphore is now no longer used, close it to avoid + * eating a file descriptor + */ + fio_sem_remove(td->mutex); + if (init_io_u(td)) - goto err_sem; + goto err; if (fio_setaffinity(td) == -1) { td_verror(td, errno, "cpu_set_affinity"); - goto err_sem; + goto err; } if (init_iolog(td)) - goto err_sem; + goto err; if (td->ioprio) { if (ioprio_set(IOPRIO_WHO_PROCESS, 0, td->ioprio) == -1) { td_verror(td, errno, "ioprio_set"); - goto err_sem; + goto err; } } if (nice(td->o.nice) == -1) { td_verror(td, errno, "nice"); - goto err_sem; + goto err; } if (td->o.ioscheduler && switch_ioscheduler(td)) - goto err_sem; - - td_set_runstate(td, TD_INITIALIZED); - fio_sem_up(startup_sem); - fio_sem_down(td->mutex); - - /* - * the ->mutex semaphore is now no longer used, close it to avoid - * eating a file descriptor - */ - fio_sem_remove(td->mutex); + goto err; if (!td->o.create_serialize && setup_files(td)) goto err; @@ -913,9 +915,6 @@ err: options_mem_free(td); td_set_runstate(td, TD_EXITED); return (void *) (unsigned long) td->error; -err_sem: - fio_sem_up(startup_sem); - goto err; } /* -- 2.25.1