From e4ed35c3e9f01b92773c5e34b13e0aa1ef02e53a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 24 Oct 2005 15:46:24 +0200 Subject: [PATCH] [PATCH] fio: collate some common code --- fio.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fio.c b/fio.c index f3d18b1..44d5e57 100644 --- a/fio.c +++ b/fio.c @@ -827,8 +827,6 @@ static void *thread_main(int shm_id, int offset, char *argv[]) td = data + offset * sizeof(struct thread_data); td->pid = getpid(); - td->fd = -1; - if (sched_setaffinity(td->pid, sizeof(td->cpumask), &td->cpumask) == -1) { td->error = errno; goto err; @@ -854,6 +852,13 @@ static void *thread_main(int shm_id, int offset, char *argv[]) if (setup_file(td)) goto err; + if (td->use_aio) + ptr = malloc(td->bs * td->aio_depth + MASK); + else + ptr = malloc(td->bs + MASK); + + td->buf = ALIGN(ptr); + sem_post(&startup_sem); sem_wait(&td->mutex); @@ -864,15 +869,10 @@ static void *thread_main(int shm_id, int offset, char *argv[]) memcpy(&td->stat_sample_time, &td->start, sizeof(td->start)); - if (!td->use_aio) { - ptr = malloc(td->bs + MASK); - td->buf = ALIGN(ptr); + if (!td->use_aio) do_sync_io(td); - } else { - ptr = malloc(td->bs * td->aio_depth + MASK); - td->buf = ALIGN(ptr); + else do_async_io(td); - } td->runtime = mtime_since_now(&td->start); ret = 0; @@ -955,6 +955,7 @@ static struct thread_data *get_new_job(int global) td = &threads[thread_number++]; memset(td, 0, sizeof(*td)); + td->fd = -1; td->thread_number = thread_number; td->ddir = def_thread.ddir; td->bs = def_thread.bs; -- 2.25.1