Split off diskutil include
authorJens Axboe <jens.axboe@oracle.com>
Wed, 3 Jun 2009 07:25:57 +0000 (09:25 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 3 Jun 2009 07:25:57 +0000 (09:25 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diskutil.c
diskutil.h [new file with mode: 0644]
fio.c
fio.h
ioengines.c
stat.c

index 3cbd6fc3b04e1d2f7dba60375dcf1c5d65683583..cb15882ffe7b696cb505122d41e44aad14ac0d9b 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "fio.h"
 #include "smalloc.h"
+#include "diskutil.h"
 
 static int last_majdev, last_mindev;
 static struct disk_util *last_du;
diff --git a/diskutil.h b/diskutil.h
new file mode 100644 (file)
index 0000000..35fd0a5
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef FIO_DISKUTIL_H
+#define FIO_DISKUTIL_H
+
+/*
+ * Disk utils as read in /sys/block/<dev>/stat
+ */
+struct disk_util_stat {
+       unsigned ios[2];
+       unsigned merges[2];
+       unsigned long long sectors[2];
+       unsigned ticks[2];
+       unsigned io_ticks;
+       unsigned time_in_queue;
+};
+
+/*
+ * Per-device disk util management
+ */
+struct disk_util {
+       struct flist_head list;
+       /* If this disk is a slave, hook it into the master's
+        * list using this head.
+        */
+       struct flist_head slavelist;
+
+       char *name;
+       char *sysfs_root;
+       char path[256];
+       int major, minor;
+
+       struct disk_util_stat dus;
+       struct disk_util_stat last_dus;
+
+       /* For software raids, this entry maintains pointers to the
+        * entries for the slave devices. The disk_util entries for
+        * the slaves devices should primarily be maintained through
+        * the disk_list list, i.e. for memory allocation and
+        * de-allocation, etc. Whereas this list should be used only
+        * for aggregating a software RAID's disk util figures.
+        */
+       struct flist_head slaves;
+
+       unsigned long msec;
+       struct timeval time;
+
+       struct fio_mutex *lock;
+       unsigned long users;
+};
+
+static inline void disk_util_inc(struct disk_util *du)
+{
+       if (du) {
+               fio_mutex_down(du->lock);
+               du->users++;
+               fio_mutex_up(du->lock);
+       }
+}
+
+static inline void disk_util_dec(struct disk_util *du)
+{
+       if (du) {
+               fio_mutex_down(du->lock);
+               du->users--;
+               fio_mutex_up(du->lock);
+       }
+}
+
+#define DISK_UTIL_MSEC (250)
+
+/*
+ * disk util stuff
+ */
+#ifdef FIO_HAVE_DISK_UTIL
+extern void show_disk_util(void);
+extern void init_disk_util(struct thread_data *);
+extern void update_io_ticks(void);
+#else
+#define show_disk_util()
+#define init_disk_util(td)
+#define update_io_ticks()
+#endif
+
+#endif
diff --git a/fio.c b/fio.c
index 8c1502ec80319775240d3300b2b565eba718a562..bdf9fd188dde338bcffe13a4eb43df938993fbf6 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -38,6 +38,7 @@
 #include "hash.h"
 #include "smalloc.h"
 #include "verify.h"
+#include "diskutil.h"
 
 unsigned long page_mask;
 unsigned long page_size;
diff --git a/fio.h b/fio.h
index 2c45b98cbe1e1c1d0e47a3482fae1801038827d0..9222c051651408bfcdb811883884afced52dc49a 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -445,72 +445,6 @@ static inline int should_fsync(struct thread_data *td)
        return 0;
 }
 
-/*
- * Disk utils as read in /sys/block/<dev>/stat
- */
-struct disk_util_stat {
-       unsigned ios[2];
-       unsigned merges[2];
-       unsigned long long sectors[2];
-       unsigned ticks[2];
-       unsigned io_ticks;
-       unsigned time_in_queue;
-};
-
-/*
- * Per-device disk util management
- */
-struct disk_util {
-       struct flist_head list;
-       /* If this disk is a slave, hook it into the master's
-        * list using this head.
-        */
-       struct flist_head slavelist;
-
-       char *name;
-       char *sysfs_root;
-       char path[256];
-       int major, minor;
-
-       struct disk_util_stat dus;
-       struct disk_util_stat last_dus;
-
-       /* For software raids, this entry maintains pointers to the
-        * entries for the slave devices. The disk_util entries for
-        * the slaves devices should primarily be maintained through
-        * the disk_list list, i.e. for memory allocation and
-        * de-allocation, etc. Whereas this list should be used only
-        * for aggregating a software RAID's disk util figures.
-        */
-       struct flist_head slaves;
-
-       unsigned long msec;
-       struct timeval time;
-
-       struct fio_mutex *lock;
-       unsigned long users;
-};
-
-static inline void disk_util_inc(struct disk_util *du)
-{
-       if (du) {
-               fio_mutex_down(du->lock);
-               du->users++;
-               fio_mutex_up(du->lock);
-       }
-}
-
-static inline void disk_util_dec(struct disk_util *du)
-{
-       if (du) {
-               fio_mutex_down(du->lock);
-               du->users--;
-               fio_mutex_up(du->lock);
-       }
-}
-
-#define DISK_UTIL_MSEC (250)
-
 /*
  * Time functions
  */
@@ -552,19 +486,6 @@ extern void td_fill_rand_seeds(struct thread_data *);
 extern void print_thread_status(void);
 extern void print_status_init(int);
 
-/*
- * disk util stuff
- */
-#ifdef FIO_HAVE_DISK_UTIL
-extern void show_disk_util(void);
-extern void init_disk_util(struct thread_data *);
-extern void update_io_ticks(void);
-#else
-#define show_disk_util()
-#define init_disk_util(td)
-#define update_io_ticks()
-#endif
-
 /*
  * Thread life cycle. Once a thread has a runstate beyond TD_INITIALIZED, it
  * will never back again. It may cycle between running/verififying/fsyncing.
index 7840d2a86abb1447a3b5daeb7135ff225b275593..51cf1ba40e13cd67549d552c1a879461cb383a83 100644 (file)
@@ -17,6 +17,7 @@
 #include <assert.h>
 
 #include "fio.h"
+#include "diskutil.h"
 
 static FLIST_HEAD(engine_list);
 
diff --git a/stat.c b/stat.c
index a42ed98843bbf6b4d892d0fc6bd1b1af9f2c2e6c..44edd1e97b35fca609b7969c2e8340842d49f927 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -8,6 +8,7 @@
 #include <math.h>
 
 #include "fio.h"
+#include "diskutil.h"
 
 /*
  * Cheesy number->string conversion, complete with carry rounding error.