path: root/file.h
diff options
authorTomohiro Kusumi <>2017-03-07 22:13:07 +0200
committerJens Axboe <>2017-03-10 14:43:37 -0700
commit710bf9c592b849935e1bcc56ffc805fa1d5f9365 (patch)
tree2108c7790857f45f5663612a9f7a08b2cb043ba1 /file.h
parentbf651609cda6c8968edb49d80efe7ee007983f61 (diff)
Use union for per file engine private data storage
fio_file::engine_data has been used by i/o engines to either keep the offset or point to engine specific private data with casts. This commit changes it to a union consists of void* and uint64_t so get/set of offset/pointer can be done without casts (which is a common technique used even within this same struct). This may break external engines on compile time, but fio generally doesn't care about breakage on external engines (no guarantees on api/abi compatibility) anyway. Also confirmed this compiles with pmemblk enabled. Signed-off-by: Tomohiro Kusumi <> Signed-off-by: Jens Axboe <>
Diffstat (limited to 'file.h')
1 files changed, 7 insertions, 5 deletions
diff --git a/file.h b/file.h
index c403b176..9801bb58 100644
--- a/file.h
+++ b/file.h
@@ -113,9 +113,12 @@ struct fio_file {
unsigned int last_write_idx;
- * For use by the io engine
+ * For use by the io engine for offset or private data storage
- uint64_t engine_data;
+ union {
+ uint64_t engine_pos;
+ void *engine_data;
+ };
* if io is protected by a semaphore, this is set
@@ -147,9 +150,8 @@ struct fio_file {
struct disk_util *du;
-#define FILE_ENG_DATA(f) ((void *) (uintptr_t) (f)->engine_data)
-#define FILE_SET_ENG_DATA(f, data) \
- ((f)->engine_data = (uintptr_t) (data))
+#define FILE_ENG_DATA(f) ((f)->engine_data)
+#define FILE_SET_ENG_DATA(f, data) ((f)->engine_data = (data))
#define FILE_FLAG_FNS(name) \
static inline void fio_file_set_##name(struct fio_file *f) \