static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd);
static void handle_ts(struct fio_net_cmd *cmd);
static void handle_gs(struct fio_net_cmd *cmd);
-static void handle_eta(struct fio_client *client, struct fio_net_cmd *cmd);
static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd);
static void handle_text(struct fio_client *client, struct fio_net_cmd *cmd);
.disk_util = handle_du,
.thread_status = handle_ts,
.group_stats = handle_gs,
- .eta = handle_eta,
+ .eta = display_thread_status,
.probe = handle_probe,
};
if (!flist_empty(&client->eta_list)) {
flist_del_init(&client->eta_list);
- fio_client_dec_jobs_eta(client->eta_in_flight, display_thread_status);
+ fio_client_dec_jobs_eta(client->eta_in_flight, client->ops->eta);
}
free(client->hostname);
}
}
-struct fio_client *fio_client_add_explicit(const char *hostname, int type,
+struct fio_client *fio_client_add_explicit(struct client_ops *ops,
+ const char *hostname, int type,
int port)
{
struct fio_client *client;
}
client->fd = -1;
+ client->ops = ops;
__fio_client_add_cmd_option(client, "fio");
return NULL;
}
-int fio_client_add(const char *hostname, void **cookie)
+int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
{
struct fio_client *existing = *cookie;
struct fio_client *client;
return -1;
client->fd = -1;
+ client->ops = ops;
__fio_client_add_cmd_option(client, "fio");
dst->eta_sec = je->eta_sec;
}
-void fio_client_dec_jobs_eta(struct client_eta *eta, void (*fn)(struct jobs_eta *))
+void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
{
if (!--eta->pending) {
- fn(&eta->eta);
+ eta_fn(&eta->eta);
free(eta);
}
}
flist_del_init(&client->eta_list);
fio_client_sum_jobs_eta(&eta->eta, je);
- fio_client_dec_jobs_eta(eta, display_thread_status);
+ fio_client_dec_jobs_eta(eta, client->ops->eta);
}
static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
pdu->log_usec = le64_to_cpu(pdu->log_usec);
}
-int fio_handle_client(struct fio_client *client, struct client_ops *ops)
+int fio_handle_client(struct fio_client *client)
{
+ struct client_ops *ops = client->ops;
struct fio_net_cmd *cmd;
dprint(FD_NET, "client: handle %s\n", client->hostname);
remove_reply_cmd(client, cmd);
convert_jobs_eta(je);
- ops->eta(client, cmd);
+ handle_eta(client, cmd);
free(cmd);
break;
}
return 1;
}
-static void request_client_etas(void)
+static void request_client_etas(struct client_ops *ops)
{
struct fio_client *client;
struct flist_head *entry;
}
while (skipped--)
- fio_client_dec_jobs_eta(eta, display_thread_status);
+ fio_client_dec_jobs_eta(eta, ops->eta);
dprint(FD_NET, "client: requested eta tag %p\n", eta);
}
return flist_empty(&client->cmd_list) && ret;
}
-static int fio_client_timed_out(struct client_ops *ops)
+static int fio_check_clients_timed_out(void)
{
struct fio_client *client;
struct flist_head *entry, *tmp;
if (!client_check_cmd_timeout(client, &tv))
continue;
- if (ops->timed_out)
- ops->timed_out(client);
+ if (client->ops->timed_out)
+ client->ops->timed_out(client);
else
log_err("fio: client %s timed out\n", client->hostname);
flist_for_each_safe(entry, tmp, &client_list) {
client = flist_entry(entry, struct fio_client, list);
- if (!client->sent_job && !ops->stay_connected &&
+ if (!client->sent_job && !client->ops->stay_connected &&
flist_empty(&client->cmd_list)) {
remove_client(client);
continue;
gettimeofday(&tv, NULL);
if (mtime_since(&eta_tv, &tv) >= 900) {
- request_client_etas();
+ request_client_etas(ops);
memcpy(&eta_tv, &tv, sizeof(tv));
- if (fio_client_timed_out(ops))
+ if (fio_check_clients_timed_out())
break;
}
log_err("fio: unknown client fd %d\n", pfds[i].fd);
continue;
}
- if (!fio_handle_client(client, ops)) {
+ if (!fio_handle_client(client)) {
log_info("client: host=%s disconnected\n",
client->hostname);
remove_client(client);
#include "stat.h"
struct fio_net_cmd;
+struct client_ops;
struct fio_client {
struct flist_head list;
uint16_t argc;
char **argv;
+ struct client_ops *ops;
void *client_data;
};
typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
typedef void (*client_thread_status_op)(struct fio_net_cmd *cmd);
typedef void (*client_group_stats_op)(struct fio_net_cmd *cmd);
-typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd);
+typedef void (*client_eta_op)(struct jobs_eta *je);
typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
typedef void (*client_thread_status_display_op)(char *status_message, double perc);
typedef void (*client_quit_op)(struct fio_client *);
unsigned int pending;
};
-extern int fio_handle_client(struct fio_client *, struct client_ops *ops);
-extern void fio_client_dec_jobs_eta(struct client_eta *eta, void (*fn)(struct jobs_eta *));
+extern int fio_handle_client(struct fio_client *);
+extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
enum {
extern int fio_clients_connect(void);
extern int fio_clients_send_ini(const char *);
-extern int fio_handle_clients(struct client_ops *ops);
-extern int fio_client_add(const char *, void **);
-extern struct fio_client *fio_client_add_explicit(const char *, int, int);
+extern int fio_handle_clients(struct client_ops *);
+extern int fio_client_add(struct client_ops *, const char *, void **);
+extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
extern void fio_client_add_cmd_option(void *, const char *);
extern void fio_clients_terminate(void);
gfio_update_thread_status(output, perc);
}
-static void gfio_eta_op(struct fio_client *client, struct fio_net_cmd *cmd)
-{
- struct jobs_eta *je = (struct jobs_eta *) cmd->payload;
- struct client_eta *eta = (struct client_eta *) (uintptr_t) cmd->tag;
-
- client->eta_in_flight = NULL;
- flist_del_init(&client->eta_list);
-
- fio_client_sum_jobs_eta(&eta->eta, je);
- fio_client_dec_jobs_eta(eta, gfio_update_eta);
-}
-
static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
{
struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
.disk_util = gfio_disk_util_op,
.thread_status = gfio_thread_status_op,
.group_stats = gfio_group_stats_op,
- .eta = gfio_eta_op,
+ .eta = gfio_update_eta,
.probe = gfio_probe_op,
.quit = gfio_quit_op,
.add_job = gfio_add_job_op,
ui.job_files[ui.nr_job_files] = strdup(filenames->data);
ui.nr_job_files++;
- ui.client = fio_client_add_explicit(host, type, port);
+ ui.client = fio_client_add_explicit(&gfio_client_ops, host, type, port);
if (!ui.client) {
GError *error;