Add profile td init/exit with stored data
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.h b/fio.h
index 09cd01c..f00f64a 100644
--- a/fio.h
+++ b/fio.h
@@ -432,6 +432,7 @@
* Can be overloaded by profiles
*/
struct prof_io_ops prof_io_ops;
+ void *prof_data;
};
/*
diff --git a/init.c b/init.c
index a79bd1a..5d185fe 100644
--- a/init.c
+++ b/init.c
@@ -178,6 +178,8 @@
{
if (td == &def_thread)
return;
+
+ profile_td_exit(td);
if (td->error)
log_info("fio: %s\n", td->verror);
@@ -502,6 +504,9 @@
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 3ed9127..855dde3 100644
--- a/profile.c
+++ b/profile.c
@@ -96,3 +96,21 @@
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 a54f072..673c5c4 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 @@
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