Move {is,load}_blktrace() to a new header blktrace.h
authorTomohiro Kusumi <tkusumi@tuxera.com>
Tue, 23 May 2017 18:44:45 +0000 (21:44 +0300)
committerJens Axboe <axboe@fb.com>
Wed, 24 May 2017 02:02:42 +0000 (20:02 -0600)
This commit does exactly the same as what cgroup.h does for cgroup
support.

Since blktrace is Linux specific feature and api compiled only on
Linux and Android, these two could be defined in blktrace.h rather
than in os/os.h which is basically intended to be something generic
whose implementation vary depending on supported platforms.

The reason for adding a new header blktrace.h instead of using
blktrace_api.h is because blktrace_api.h seems to have been added
for blktrace.c to include which gets compiled only on Linux where
blktrace apis are basically guaranteed to exist (unless really old
kernels), whereas these prototypes or inline functions are needed
by all platforms.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
blktrace.c
blktrace.h [new file with mode: 0644]
fio.h
iolog.c
os/os.h

index a3474cb57ee9825077684f3b3f7de96b272a2e4c..65b600f5cfed020c2008e3c77511829fcd4cf02b 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "flist.h"
 #include "fio.h"
+#include "blktrace.h"
 #include "blktrace_api.h"
 #include "oslib/linux-dev-lookup.h"
 
diff --git a/blktrace.h b/blktrace.h
new file mode 100644 (file)
index 0000000..8656a95
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef FIO_BLKTRACE_H
+#define FIO_BLKTRACE_H
+
+#ifdef FIO_HAVE_BLKTRACE
+
+int is_blktrace(const char *, int *);
+int load_blktrace(struct thread_data *, const char *, int);
+
+#else
+
+static inline int is_blktrace(const char *fname, int *need_swap)
+{
+       return 0;
+}
+
+static inline int load_blktrace(struct thread_data *td, const char *fname,
+                               int need_swap)
+{
+       return 1;
+}
+
+#endif
+#endif
diff --git a/fio.h b/fio.h
index ed631bc70ab0c490c98d3e5432b6eebc109139dc..963cf034c260a333f60eca33a365e280c400330f 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -640,14 +640,6 @@ extern void free_threads_shm(void);
  */
 extern void reset_all_stats(struct thread_data *);
 
-/*
- * blktrace support
- */
-#ifdef FIO_HAVE_BLKTRACE
-extern int is_blktrace(const char *, int *);
-extern int load_blktrace(struct thread_data *, const char *, int);
-#endif
-
 extern int io_queue_event(struct thread_data *td, struct io_u *io_u, int *ret,
                   enum fio_ddir ddir, uint64_t *bytes_issued, int from_verify,
                   struct timeval *comp_time);
diff --git a/iolog.c b/iolog.c
index 31d674c24dab7dc607bd7c43b120f524e7ae5ab9..01b82e8dc16b47cab2feef017d7bd60e6b7d49ef 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -19,6 +19,7 @@
 #include "trim.h"
 #include "filelock.h"
 #include "smalloc.h"
+#include "blktrace.h"
 
 static int iolog_flush(struct io_log *log);
 
diff --git a/os/os.h b/os/os.h
index 5e3c813d8fb5b5f726d650c172aedde94f84f21d..c25cc36c4a3bfec2af2017c58df728654bdd7518 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -253,19 +253,6 @@ static inline uint64_t fio_swap64(uint64_t val)
        __cpu_to_le64(val);                     \
 })
 
-#ifndef FIO_HAVE_BLKTRACE
-static inline int is_blktrace(const char *fname, int *need_swap)
-{
-       return 0;
-}
-struct thread_data;
-static inline int load_blktrace(struct thread_data *td, const char *fname,
-                               int need_swap)
-{
-       return 1;
-}
-#endif
-
 #define FIO_DEF_CL_SIZE                128
 
 static inline int os_cache_line_size(void)