blob: c35ce1e694511b2eb08300e8b3744410d3f7a298 [file] [log] [blame]
Jens Axboe5995a6a2009-06-03 08:53:28 +02001#ifndef FIO_IOLOG_H
2#define FIO_IOLOG_H
3
4/*
5 * Use for maintaining statistics
6 */
7struct io_stat {
8 unsigned long max_val;
9 unsigned long min_val;
10 unsigned long samples;
11
12 double mean;
13 double S;
14};
15
16/*
17 * A single data sample
18 */
19struct io_sample {
20 unsigned long time;
21 unsigned long val;
22 enum fio_ddir ddir;
23 unsigned int bs;
24};
25
26/*
27 * Dynamically growing data sample log
28 */
29struct io_log {
30 unsigned long nr_samples;
31 unsigned long max_samples;
32 struct io_sample *log;
33};
34
Jens Axboe0d29de82010-09-01 13:54:15 +020035enum {
36 IP_F_ONRB = 1,
37 IP_F_ONLIST = 2,
38 IP_F_TRIMMED = 4,
39};
40
Jens Axboe5995a6a2009-06-03 08:53:28 +020041/*
42 * When logging io actions, this matches a single sent io_u
43 */
44struct io_piece {
45 union {
46 struct rb_node rb_node;
47 struct flist_head list;
48 };
Jens Axboe0d29de82010-09-01 13:54:15 +020049 struct flist_head trim_list;
Jens Axboe5995a6a2009-06-03 08:53:28 +020050 union {
51 int fileno;
52 struct fio_file *file;
53 };
54 unsigned long long offset;
55 unsigned long len;
Jens Axboea917a8b2010-09-02 13:23:20 +020056 unsigned int flags;
Jens Axboe5995a6a2009-06-03 08:53:28 +020057 enum fio_ddir ddir;
58 union {
59 unsigned long delay;
60 unsigned int file_action;
61 };
62};
63
64/*
65 * Log exports
66 */
67enum file_log_act {
68 FIO_LOG_ADD_FILE,
69 FIO_LOG_OPEN_FILE,
70 FIO_LOG_CLOSE_FILE,
71 FIO_LOG_UNLINK_FILE,
72};
73
74extern int __must_check read_iolog_get(struct thread_data *, struct io_u *);
75extern void log_io_u(struct thread_data *, struct io_u *);
76extern void log_file(struct thread_data *, struct fio_file *, enum file_log_act);
77extern int __must_check init_iolog(struct thread_data *td);
78extern void log_io_piece(struct thread_data *, struct io_u *);
79extern void queue_io_piece(struct thread_data *, struct io_piece *);
80extern void prune_io_piece_log(struct thread_data *);
81extern void write_iolog_close(struct thread_data *);
82
83/*
84 * Logging
85 */
Jens Axboe02af0982010-06-24 09:59:34 +020086extern void add_lat_sample(struct thread_data *, enum fio_ddir, unsigned long,
87 unsigned int);
Jens Axboe5995a6a2009-06-03 08:53:28 +020088extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long,
89 unsigned int);
90extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long,
91 unsigned int);
92extern void add_bw_sample(struct thread_data *, enum fio_ddir, unsigned int,
93 struct timeval *);
94extern void show_run_stats(void);
95extern void init_disk_util(struct thread_data *);
96extern void update_rusage_stat(struct thread_data *);
97extern void update_io_ticks(void);
98extern void setup_log(struct io_log **);
99extern void finish_log(struct thread_data *, struct io_log *, const char *);
100extern void finish_log_named(struct thread_data *, struct io_log *, const char *, const char *);
101extern void __finish_log(struct io_log *, const char *);
102extern struct io_log *agg_io_log[2];
103extern int write_bw_log;
104extern void add_agg_sample(unsigned long, enum fio_ddir, unsigned int);
105
Jens Axboe0d29de82010-09-01 13:54:15 +0200106static inline void init_ipo(struct io_piece *ipo)
107{
108 memset(ipo, 0, sizeof(*ipo));
109 INIT_FLIST_HEAD(&ipo->trim_list);
110}
111
Jens Axboe5995a6a2009-06-03 08:53:28 +0200112#endif