Remove a reference check
[fio.git] / diskutil.h
1 #ifndef FIO_DISKUTIL_H
2 #define FIO_DISKUTIL_H
3
4 /*
5  * Disk utils as read in /sys/block/<dev>/stat
6  */
7 struct disk_util_stat {
8         unsigned ios[2];
9         unsigned merges[2];
10         unsigned long long sectors[2];
11         unsigned ticks[2];
12         unsigned io_ticks;
13         unsigned time_in_queue;
14 };
15
16 /*
17  * Per-device disk util management
18  */
19 struct disk_util {
20         struct flist_head list;
21         /* If this disk is a slave, hook it into the master's
22          * list using this head.
23          */
24         struct flist_head slavelist;
25
26         char *name;
27         char *sysfs_root;
28         char path[256];
29         int major, minor;
30
31         struct disk_util_stat dus;
32         struct disk_util_stat last_dus;
33
34         /* For software raids, this entry maintains pointers to the
35          * entries for the slave devices. The disk_util entries for
36          * the slaves devices should primarily be maintained through
37          * the disk_list list, i.e. for memory allocation and
38          * de-allocation, etc. Whereas this list should be used only
39          * for aggregating a software RAID's disk util figures.
40          */
41         struct flist_head slaves;
42
43         unsigned long msec;
44         struct timeval time;
45
46         struct fio_mutex *lock;
47         unsigned long users;
48 };
49
50 static inline void disk_util_inc(struct disk_util *du)
51 {
52         if (du) {
53                 fio_mutex_down(du->lock);
54                 du->users++;
55                 fio_mutex_up(du->lock);
56         }
57 }
58
59 static inline void disk_util_dec(struct disk_util *du)
60 {
61         if (du) {
62                 fio_mutex_down(du->lock);
63                 du->users--;
64                 fio_mutex_up(du->lock);
65         }
66 }
67
68 #define DISK_UTIL_MSEC  (250)
69
70 /*
71  * disk util stuff
72  */
73 #ifdef FIO_HAVE_DISK_UTIL
74 extern void show_disk_util(void);
75 extern void init_disk_util(struct thread_data *);
76 extern void update_io_ticks(void);
77 #else
78 #define show_disk_util()
79 #define init_disk_util(td)
80 #define update_io_ticks()
81 #endif
82
83 #endif