projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
server: rename CMD_RUN to CMD_SERVER_START
[fio.git]
/
client.c
diff --git
a/client.c
b/client.c
index 23c5b6cd2c8fe5d0c85676a4d9f58d592e3979f1..a77dc9350e0d1d57ffcc2c7f065204b3f9b5b254 100644
(file)
--- a/
client.c
+++ b/
client.c
@@
-22,16
+22,18
@@
#include "hash.h"
static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd);
#include "hash.h"
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_ts(struct fio_
client *client, struct fio_
net_cmd *cmd);
+static void handle_gs(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);
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);
+static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd);
struct client_ops fio_client_ops = {
.text_op = handle_text,
.disk_util = handle_du,
.thread_status = handle_ts,
.group_stats = handle_gs,
struct client_ops fio_client_ops = {
.text_op = handle_text,
.disk_util = handle_du,
.thread_status = handle_ts,
.group_stats = handle_gs,
+ .stop = handle_stop,
.eta = display_thread_status,
.probe = handle_probe,
};
.eta = display_thread_status,
.probe = handle_probe,
};
@@
-52,9
+54,10
@@
static FLIST_HEAD(eta_list);
static FLIST_HEAD(arg_list);
static FLIST_HEAD(arg_list);
-static struct thread_stat client_ts;
-static struct group_run_stats client_gs;
-static int sum_stat_clients;
+struct thread_stat client_ts;
+struct group_run_stats client_gs;
+int sum_stat_clients;
+
static int sum_stat_nr;
#define FIO_CLIENT_HASH_BITS 7
static int sum_stat_nr;
#define FIO_CLIENT_HASH_BITS 7
@@
-93,8
+96,10
@@
static struct fio_client *find_client_by_fd(int fd)
flist_for_each(entry, &client_hash[bucket]) {
client = flist_entry(entry, struct fio_client, hash_list);
flist_for_each(entry, &client_hash[bucket]) {
client = flist_entry(entry, struct fio_client, hash_list);
- if (client->fd == fd)
+ if (client->fd == fd) {
+ client->refs++;
return client;
return client;
+ }
}
return NULL;
}
return NULL;
@@
-102,6
+107,11
@@
static struct fio_client *find_client_by_fd(int fd)
static void remove_client(struct fio_client *client)
{
static void remove_client(struct fio_client *client)
{
+ assert(client->refs);
+
+ if (--client->refs)
+ return;
+
dprint(FD_NET, "client: removed <%s>\n", client->hostname);
flist_del(&client->list);
dprint(FD_NET, "client: removed <%s>\n", client->hostname);
flist_del(&client->list);
@@
-123,6
+133,11
@@
static void remove_client(struct fio_client *client)
sum_stat_clients--;
}
sum_stat_clients--;
}
+static void put_client(struct fio_client *client)
+{
+ remove_client(client);
+}
+
static void __fio_client_add_cmd_option(struct fio_client *client,
const char *opt)
{
static void __fio_client_add_cmd_option(struct fio_client *client,
const char *opt)
{
@@
-187,6
+202,7
@@
struct fio_client *fio_client_add_explicit(struct client_ops *ops,
client->fd = -1;
client->ops = ops;
client->fd = -1;
client->ops = ops;
+ client->refs = 1;
__fio_client_add_cmd_option(client, "fio");
__fio_client_add_cmd_option(client, "fio");
@@
-235,6
+251,7
@@
int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
client->fd = -1;
client->ops = ops;
client->fd = -1;
client->ops = ops;
+ client->refs = 1;
__fio_client_add_cmd_option(client, "fio");
__fio_client_add_cmd_option(client, "fio");
@@
-621,7
+638,7
@@
static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src)
dst->groupid = le32_to_cpu(src->groupid);
}
dst->groupid = le32_to_cpu(src->groupid);
}
-static void handle_ts(struct fio_net_cmd *cmd)
+static void handle_ts(struct fio_
client *client, struct fio_
net_cmd *cmd)
{
struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
{
struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
@@
-642,7
+659,7
@@
static void handle_ts(struct fio_net_cmd *cmd)
}
}
}
}
-static void handle_gs(struct fio_net_cmd *cmd)
+static void handle_gs(struct fio_
client *client, struct fio_
net_cmd *cmd)
{
struct group_run_stats *gs = (struct group_run_stats *) cmd->payload;
{
struct group_run_stats *gs = (struct group_run_stats *) cmd->payload;
@@
-730,6
+747,7
@@
static void convert_jobs_eta(struct jobs_eta *je)
je->elapsed_sec = le64_to_cpu(je->elapsed_sec);
je->eta_sec = le64_to_cpu(je->eta_sec);
je->elapsed_sec = le64_to_cpu(je->elapsed_sec);
je->eta_sec = le64_to_cpu(je->eta_sec);
+ je->nr_threads = le32_to_cpu(je->nr_threads);
}
void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
}
void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
@@
-754,6
+772,9
@@
void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
if (je->eta_sec > dst->eta_sec)
dst->eta_sec = je->eta_sec;
if (je->eta_sec > dst->eta_sec)
dst->eta_sec = je->eta_sec;
+
+ dst->nr_threads += je->nr_threads;
+ /* we need to handle je->run_str too ... */
}
void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
}
void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op eta_fn)
@@
-838,15
+859,17
@@
static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd)
static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
{
static void handle_stop(struct fio_client *client, struct fio_net_cmd *cmd)
{
- struct cmd_end_pdu *pdu = (struct cmd_end_pdu *) cmd->payload;
-
- client->state = Client_stopped;
- client->error = le32_to_cpu(pdu->error);
-
if (client->error)
log_info("client <%s>: exited with error %d\n", client->hostname, client->error);
}
if (client->error)
log_info("client <%s>: exited with error %d\n", client->hostname, client->error);
}
+static void convert_stop(struct fio_net_cmd *cmd)
+{
+ struct cmd_end_pdu *pdu = (struct cmd_end_pdu *) cmd->payload;
+
+ pdu->error = le32_to_cpu(pdu->error);
+}
+
static void convert_text(struct fio_net_cmd *cmd)
{
struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmd->payload;
static void convert_text(struct fio_net_cmd *cmd)
{
struct cmd_text_pdu *pdu = (struct cmd_text_pdu *) cmd->payload;
@@
-899,7
+922,7
@@
int fio_handle_client(struct fio_client *client)
convert_ts(&p->ts, &p->ts);
convert_gs(&p->rs, &p->rs);
convert_ts(&p->ts, &p->ts);
convert_gs(&p->rs, &p->rs);
- ops->thread_status(cmd);
+ ops->thread_status(c
lient, c
md);
free(cmd);
break;
}
free(cmd);
break;
}
@@
-908,7
+931,7
@@
int fio_handle_client(struct fio_client *client)
convert_gs(gs, gs);
convert_gs(gs, gs);
- ops->group_stats(cmd);
+ ops->group_stats(c
lient, c
md);
free(cmd);
break;
}
free(cmd);
break;
}
@@
-926,7
+949,7
@@
int fio_handle_client(struct fio_client *client)
ops->probe(client, cmd);
free(cmd);
break;
ops->probe(client, cmd);
free(cmd);
break;
- case FIO_NET_CMD_
RUN
:
+ case FIO_NET_CMD_
SERVER_START
:
client->state = Client_running;
free(cmd);
break;
client->state = Client_running;
free(cmd);
break;
@@
-934,10
+957,16
@@
int fio_handle_client(struct fio_client *client)
handle_start(client, cmd);
free(cmd);
break;
handle_start(client, cmd);
free(cmd);
break;
- case FIO_NET_CMD_STOP:
- handle_stop(client, cmd);
+ case FIO_NET_CMD_STOP: {
+ struct cmd_end_pdu *pdu = (struct cmd_end_pdu *) cmd->payload;
+
+ convert_stop(cmd);
+ client->state = Client_stopped;
+ client->error = pdu->error;
+ ops->stop(client, cmd);
free(cmd);
break;
free(cmd);
break;
+ }
case FIO_NET_CMD_ADD_JOB:
if (ops->add_job)
ops->add_job(client, cmd);
case FIO_NET_CMD_ADD_JOB:
if (ops->add_job)
ops->add_job(client, cmd);
@@
-1116,6
+1145,7
@@
int fio_handle_clients(struct client_ops *ops)
retval = 1;
} else if (client->error)
retval = 1;
retval = 1;
} else if (client->error)
retval = 1;
+ put_client(client);
}
}
}
}