From 58c55ba02aca24ed30beb343fcb1dc3df4667389 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 9 Mar 2010 12:20:08 +0100 Subject: [PATCH 1/1] Add profile td init/exit with stored data Signed-off-by: Jens Axboe --- fio.h | 1 + init.c | 5 +++++ profile.c | 18 ++++++++++++++++++ profile.h | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/fio.h b/fio.h index 09cd01cd..f00f64a9 100644 --- a/fio.h +++ b/fio.h @@ -432,6 +432,7 @@ struct thread_data { * Can be overloaded by profiles */ struct prof_io_ops prof_io_ops; + void *prof_data; }; /* diff --git a/init.c b/init.c index a79bd1a6..5d185fe7 100644 --- a/init.c +++ b/init.c @@ -178,6 +178,8 @@ static void put_job(struct thread_data *td) { if (td == &def_thread) return; + + profile_td_exit(td); if (td->error) log_info("fio: %s\n", td->verror); @@ -502,6 +504,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) return 0; } + if (profile_td_init(td)) + return 1; + engine = get_engine_name(td->o.ioengine); td->io_ops = load_ioengine(td, engine); if (!td->io_ops) { diff --git a/profile.c b/profile.c index 3ed9127b..855dde3e 100644 --- a/profile.c +++ b/profile.c @@ -96,3 +96,21 @@ void profile_add_hooks(struct thread_data *td) if (ops->io_ops) td->prof_io_ops = *ops->io_ops; } + +int profile_td_init(struct thread_data *td) +{ + struct prof_io_ops *ops = &td->prof_io_ops; + + if (ops->td_init) + return ops->td_init(td); + + return 0; +} + +void profile_td_exit(struct thread_data *td) +{ + struct prof_io_ops *ops = &td->prof_io_ops; + + if (ops->td_exit) + ops->td_exit(td); +} diff --git a/profile.h b/profile.h index a54f0724..673c5c45 100644 --- a/profile.h +++ b/profile.h @@ -7,6 +7,9 @@ * Functions for overriding internal fio io_u functions */ struct prof_io_ops { + int (*td_init)(struct thread_data *); + void (*td_exit)(struct thread_data *); + int (*fill_io_u_off)(struct thread_data *, struct io_u *); int (*fill_io_u_size)(struct thread_data *, struct io_u *); struct fio_file *(*get_next_file)(struct thread_data *); @@ -42,4 +45,7 @@ int load_profile(const char *); struct profile_ops *find_profile(const char *); void profile_add_hooks(struct thread_data *); +int profile_td_init(struct thread_data *); +void profile_td_exit(struct thread_data *); + #endif -- 2.25.1