server: rename CMD_RUN to CMD_SERVER_START
[fio.git] / client.c
index 7267333d3128017e09d67ef7af8fa23db6a26951..a77dc9350e0d1d57ffcc2c7f065204b3f9b5b254 100644 (file)
--- a/client.c
+++ b/client.c
@@ -26,12 +26,14 @@ 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_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,
+       .stop           = handle_stop,
        .eta            = display_thread_status,
        .probe          = handle_probe,
 };
@@ -745,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->nr_threads          = le32_to_cpu(je->nr_threads);
 }
 
 void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je)
@@ -769,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;
+
+       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)
@@ -853,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)
 {
-       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);
 }
 
+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;
@@ -941,7 +949,7 @@ int fio_handle_client(struct fio_client *client)
                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;
@@ -949,10 +957,16 @@ int fio_handle_client(struct fio_client *client)
                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;
+               }
        case FIO_NET_CMD_ADD_JOB:
                if (ops->add_job)
                        ops->add_job(client, cmd);