client/server: send back nr_jobs and error exit code
authorJens Axboe <axboe@kernel.dk>
Sun, 16 Oct 2011 19:34:14 +0000 (21:34 +0200)
committerJens Axboe <axboe@kernel.dk>
Sun, 16 Oct 2011 19:34:14 +0000 (21:34 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
fio.c
fio.h
server.c
server.h

index fb678e177363c7b5a5fb4d1438627dc15653a92e..e6e4291b31d7715ed7f26426f7dee3f834a57fc0 100644 (file)
--- a/client.c
+++ b/client.c
@@ -42,6 +42,8 @@ struct fio_client {
        int skip_newline;
        int is_sock;
        int disk_stats_shown;
        int skip_newline;
        int is_sock;
        int disk_stats_shown;
+       unsigned int jobs;
+       int error;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
 
        struct flist_head eta_list;
        struct client_eta *eta_in_flight;
@@ -770,6 +772,22 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
                client->name = strdup((char *) probe->hostname);
 }
 
                client->name = strdup((char *) probe->hostname);
 }
 
+static void handle_start(struct fio_client *client, struct fio_net_cmd *cmd)
+{
+       struct cmd_start_pdu *pdu = (struct cmd_start_pdu *) cmd->payload;
+
+       client->state = Client_started;
+       client->jobs = le32_to_cpu(pdu->jobs);
+}
+
+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);
+}
+
 static int handle_client(struct fio_client *client)
 {
        struct fio_net_cmd *cmd;
 static int handle_client(struct fio_client *client)
 {
        struct fio_net_cmd *cmd;
@@ -830,11 +848,11 @@ static int handle_client(struct fio_client *client)
                free(cmd);
                break;
        case FIO_NET_CMD_START:
                free(cmd);
                break;
        case FIO_NET_CMD_START:
-               client->state = Client_started;
+               handle_start(client, cmd);
                free(cmd);
                break;
        case FIO_NET_CMD_STOP:
                free(cmd);
                break;
        case FIO_NET_CMD_STOP:
-               client->state = Client_stopped;
+               handle_stop(client, cmd);
                free(cmd);
                break;
        default:
                free(cmd);
                break;
        default:
diff --git a/fio.c b/fio.c
index 856ca753fdd472e7c435c9138422e343ff08edfa..3a537943b8b428da272e3d94bc9d8ccc22ee7c5d 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -55,9 +55,9 @@ unsigned long page_size;
        (char *) (((unsigned long) (buf) + page_mask) & ~page_mask)
 
 int groupid = 0;
        (char *) (((unsigned long) (buf) + page_mask) & ~page_mask)
 
 int groupid = 0;
-int thread_number = 0;
-int nr_process = 0;
-int nr_thread = 0;
+unsigned int thread_number = 0;
+unsigned int nr_process = 0;
+unsigned int nr_thread = 0;
 int shm_id = 0;
 int temp_stall_ts;
 unsigned long done_secs = 0;
 int shm_id = 0;
 int temp_stall_ts;
 unsigned long done_secs = 0;
@@ -1398,10 +1398,12 @@ static int fork_main(int shmid, int offset)
 /*
  * Run over the job map and reap the threads that have exited, if any.
  */
 /*
  * Run over the job map and reap the threads that have exited, if any.
  */
-static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
+static void reap_threads(unsigned int *nr_running, unsigned int *t_rate,
+                        unsigned int *m_rate)
 {
        struct thread_data *td;
 {
        struct thread_data *td;
-       int i, cputhreads, realthreads, pending, status, ret;
+       unsigned int cputhreads, realthreads, pending;
+       int i, status, ret;
 
        /*
         * reap exited threads (TD_EXITED -> TD_REAPED)
 
        /*
         * reap exited threads (TD_EXITED -> TD_REAPED)
@@ -1541,7 +1543,7 @@ static void run_threads(void)
 {
        struct thread_data *td;
        unsigned long spent;
 {
        struct thread_data *td;
        unsigned long spent;
-       int i, todo, nr_running, m_rate, t_rate, nr_started;
+       unsigned int i, todo, nr_running, m_rate, t_rate, nr_started;
 
        if (fio_pin_memory())
                return;
 
        if (fio_pin_memory())
                return;
diff --git a/fio.h b/fio.h
index df0daf64e605734584b7f65cda0512c1531cbcf4..be684ca2544e4c9c5fce8e1655dd2d8a3739535f 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -482,8 +482,8 @@ enum {
 #define __fio_stringify(x)     __fio_stringify_1(x)
 
 extern int exitall_on_terminate;
 #define __fio_stringify(x)     __fio_stringify_1(x)
 
 extern int exitall_on_terminate;
-extern int thread_number;
-extern int nr_process, nr_thread;
+extern unsigned int thread_number;
+extern unsigned int nr_process, nr_thread;
 extern int shm_id;
 extern int groupid;
 extern int terse_output;
 extern int shm_id;
 extern int groupid;
 extern int terse_output;
index 7c4804adc17195675eaad8a101488a9746ab2ecf..4da8bf0040397d5173987b3b993e5a794f1959fc 100644 (file)
--- a/server.c
+++ b/server.c
@@ -332,6 +332,8 @@ static int fio_server_send_quit_cmd(void)
 static int handle_job_cmd(struct fio_net_cmd *cmd)
 {
        char *buf = (char *) cmd->payload;
 static int handle_job_cmd(struct fio_net_cmd *cmd)
 {
        char *buf = (char *) cmd->payload;
+       struct cmd_start_pdu spdu;
+       struct cmd_end_pdu epdu;
        int ret;
 
        if (parse_jobs_ini(buf, 1, 0)) {
        int ret;
 
        if (parse_jobs_ini(buf, 1, 0)) {
@@ -339,9 +341,14 @@ static int handle_job_cmd(struct fio_net_cmd *cmd)
                return -1;
        }
 
                return -1;
        }
 
-       fio_net_send_simple_cmd(server_fd, FIO_NET_CMD_START, 0, NULL);
+       spdu.jobs = cpu_to_le32(thread_number);
+       fio_net_send_cmd(server_fd, FIO_NET_CMD_START, &spdu, sizeof(spdu), 0);
 
        ret = exec_run();
 
        ret = exec_run();
+
+       epdu.error = ret;
+       fio_net_send_cmd(server_fd, FIO_NET_CMD_STOP, &epdu, sizeof(epdu), 0);
+
        fio_server_send_quit_cmd();
        reset_fio_state();
        return ret;
        fio_server_send_quit_cmd();
        reset_fio_state();
        return ret;
index da520e3895a5864f5fe079b9fb13bf676e21e19f..99689d403d9c8c83e103776f01e0f80a5dd822b2 100644 (file)
--- a/server.h
+++ b/server.h
@@ -95,6 +95,14 @@ struct cmd_line_pdu {
        struct cmd_single_line_pdu options[0];
 };
 
        struct cmd_single_line_pdu options[0];
 };
 
+struct cmd_start_pdu {
+       uint32_t jobs;
+};
+
+struct cmd_end_pdu {
+       uint32_t error;
+};
+
 extern int fio_start_server(char *);
 extern int fio_server_text_output(const char *, size_t);
 extern int fio_server_log(const char *format, ...);
 extern int fio_start_server(char *);
 extern int fio_server_text_output(const char *, size_t);
 extern int fio_server_log(const char *format, ...);