fio: fix aio trim completion latencies
[fio.git] / client.h
CommitLineData
dd366728
SC
1#ifndef CLIENT_H
2#define CLIENT_H
3
0f92bd20
JA
4#include <sys/un.h>
5#include <netinet/in.h>
6#include <arpa/inet.h>
7
67d2a9b8 8#include "lib/types.h"
3e47bd25
JA
9#include "stat.h"
10
dd366728
SC
11struct fio_net_cmd;
12
b9d2f30a
JA
13enum {
14 Client_created = 0,
15 Client_connected = 1,
16 Client_started = 2,
17 Client_running = 3,
18 Client_stopped = 4,
19 Client_exited = 5,
20};
21
323255cc
JA
22struct client_file {
23 char *file;
bb781643 24 bool remote;
323255cc
JA
25};
26
0f92bd20
JA
27struct fio_client {
28 struct flist_head list;
29 struct flist_head hash_list;
30 struct flist_head arg_list;
31 union {
32 struct sockaddr_in addr;
33 struct sockaddr_in6 addr6;
34 struct sockaddr_un addr_un;
35 };
36 char *hostname;
37 int port;
38 int fd;
5121a9aa 39 unsigned int refs;
47714d68 40 unsigned int last_cmd;
0f92bd20
JA
41
42 char *name;
43
0279b880
JA
44 struct flist_head *opt_lists;
45
0f92bd20
JA
46 int state;
47
67d2a9b8
JA
48 bool skip_newline;
49 bool is_sock;
50 bool disk_stats_shown;
0f92bd20 51 unsigned int jobs;
a89d5319 52 unsigned int nr_stat;
0f92bd20 53 int error;
122c7725 54 int signal;
0f92bd20 55 int ipv6;
67d2a9b8
JA
56 bool sent_job;
57 bool did_stat;
46bcd498 58 uint32_t type;
0f92bd20 59
40c60516
JA
60 uint32_t thread_number;
61 uint32_t groupid;
62
0f92bd20
JA
63 struct flist_head eta_list;
64 struct client_eta *eta_in_flight;
a64c13a4 65 unsigned int eta_timeouts;
0f92bd20
JA
66
67 struct flist_head cmd_list;
68
69 uint16_t argc;
70 char **argv;
3ec62ec4 71
a5276616 72 struct client_ops *ops;
3ec62ec4 73 void *client_data;
14ea90ed 74
323255cc
JA
75 struct client_file *files;
76 unsigned int nr_files;
7c6686fc
JA
77
78 struct buf_output buf;
0f92bd20
JA
79};
80
35c0ba7f 81typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
36ed2f9a 82typedef void (client_op)(struct fio_client *);
35c0ba7f
JA
83typedef void (client_eta_op)(struct jobs_eta *je);
84typedef void (client_timed_out_op)(struct fio_client *);
85typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
3ec62ec4 86
3d2d14bc
SW
87extern struct client_ops fio_client_ops;
88
dd366728 89struct client_ops {
35c0ba7f
JA
90 client_cmd_op *text;
91 client_cmd_op *disk_util;
92 client_cmd_op *thread_status;
93 client_cmd_op *group_stats;
94 client_jobs_eta_op *jobs_eta;
95 client_eta_op *eta;
96 client_cmd_op *probe;
97 client_cmd_op *quit;
98 client_cmd_op *add_job;
40c60516 99 client_cmd_op *update_job;
35c0ba7f 100 client_timed_out_op *timed_out;
36ed2f9a 101 client_op *stop;
35c0ba7f
JA
102 client_cmd_op *start;
103 client_cmd_op *job_start;
0cf3ece0 104 client_timed_out_op *removed;
35c0ba7f 105
6433ee05 106 unsigned int eta_msec;
3ec62ec4 107 int stay_connected;
46bcd498 108 uint32_t client_type;
dd366728
SC
109};
110
3e47bd25 111struct client_eta {
3e47bd25 112 unsigned int pending;
166fb520 113 struct jobs_eta eta;
3e47bd25
JA
114};
115
a5276616 116extern int fio_handle_client(struct fio_client *);
3e47bd25 117extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
3e47bd25 118
3ec62ec4
JA
119enum {
120 Fio_client_ipv4 = 1,
121 Fio_client_ipv6,
122 Fio_client_socket,
123};
124
2f99deb0 125extern int fio_client_connect(struct fio_client *);
3ec62ec4 126extern int fio_clients_connect(void);
b9d2f30a
JA
127extern int fio_start_client(struct fio_client *);
128extern int fio_start_all_clients(void);
3ec62ec4 129extern int fio_clients_send_ini(const char *);
bb781643 130extern int fio_client_send_ini(struct fio_client *, const char *, bool);
a5276616
JA
131extern int fio_handle_clients(struct client_ops *);
132extern int fio_client_add(struct client_ops *, const char *, void **);
133extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
3ec62ec4 134extern void fio_client_add_cmd_option(void *, const char *);
bb781643 135extern int fio_client_add_ini_file(void *, const char *, bool);
0cf3ece0 136extern int fio_client_terminate(struct fio_client *);
343cb4a9
JA
137extern struct fio_client *fio_get_client(struct fio_client *);
138extern void fio_put_client(struct fio_client *);
40c60516
JA
139extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *);
140extern int fio_client_wait_for_reply(struct fio_client *, uint64_t);
ca09be4b 141extern int fio_clients_send_trigger(const char *);
df06f220 142
6433ee05
JA
143#define FIO_CLIENT_DEF_ETA_MSEC 900
144
46bcd498
JA
145enum {
146 FIO_CLIENT_TYPE_CLI = 1,
147 FIO_CLIENT_TYPE_GUI = 2,
148};
149
201ab643
JA
150extern int sum_stat_clients;
151extern struct thread_stat client_ts;
152extern struct group_run_stats client_gs;
153
dd366728
SC
154#endif
155