Add profile td init/exit with stored data
authorJens Axboe <jens.axboe@oracle.com>
Tue, 9 Mar 2010 11:20:08 +0000 (12:20 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 9 Mar 2010 11:20:08 +0000 (12:20 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.h
init.c
profile.c
profile.h

diff --git a/fio.h b/fio.h
index 09cd01cdcf6a17fccc627ec1261eb048e5c6ab68..f00f64a9dc4297217e870eae87b27b5980151719 100644 (file)
--- 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 a79bd1a666a0ed6d2bc5562089c578abaec5f2d6..5d185fe7e7dbbe90d82462d76072063d33205f17 100644 (file)
--- 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) {
index 3ed9127b9007e6a5978ef8008e90b62bd2bac59c..855dde3e6d1efb2c316d28265be80754d604283b 100644 (file)
--- 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);
+}
index a54f072455928713f9b6149ca13b461ae028be67..673c5c457096fec566d08e720fa81788075dbb43 100644 (file)
--- 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