diff options
author | Tomohiro Kusumi <tkusumi@tuxera.com> | 2017-03-07 22:13:07 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-03-10 14:43:37 -0700 |
commit | 710bf9c592b849935e1bcc56ffc805fa1d5f9365 (patch) | |
tree | 2108c7790857f45f5663612a9f7a08b2cb043ba1 /file.h | |
parent | bf651609cda6c8968edb49d80efe7ee007983f61 (diff) | |
download | fio-710bf9c592b849935e1bcc56ffc805fa1d5f9365.tar.gz fio-710bf9c592b849935e1bcc56ffc805fa1d5f9365.tar.bz2 |
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 <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'file.h')
-rw-r--r-- | file.h | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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) \ |