From: Jens Axboe Date: Sun, 16 Oct 2011 19:34:14 +0000 (+0200) Subject: client/server: send back nr_jobs and error exit code X-Git-Tag: fio-1.99.8~3 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=11e950bd785d9f03b7d35a8ee4b4704256217504 client/server: send back nr_jobs and error exit code Signed-off-by: Jens Axboe --- diff --git a/client.c b/client.c index fb678e17..e6e4291b 100644 --- a/client.c +++ b/client.c @@ -42,6 +42,8 @@ struct fio_client { 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; @@ -770,6 +772,22 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd) 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; @@ -830,11 +848,11 @@ static int handle_client(struct fio_client *client) free(cmd); break; case FIO_NET_CMD_START: - client->state = Client_started; + handle_start(client, cmd); free(cmd); break; case FIO_NET_CMD_STOP: - client->state = Client_stopped; + handle_stop(client, cmd); free(cmd); break; default: diff --git a/fio.c b/fio.c index 856ca753..3a537943 100644 --- 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; -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; @@ -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. */ -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; - int i, cputhreads, realthreads, pending, status, ret; + unsigned int cputhreads, realthreads, pending; + int i, status, ret; /* * reap exited threads (TD_EXITED -> TD_REAPED) @@ -1541,7 +1543,7 @@ static void run_threads(void) { 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; diff --git a/fio.h b/fio.h index df0daf64..be684ca2 100644 --- a/fio.h +++ b/fio.h @@ -482,8 +482,8 @@ enum { #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; diff --git a/server.c b/server.c index 7c4804ad..4da8bf00 100644 --- 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; + struct cmd_start_pdu spdu; + struct cmd_end_pdu epdu; 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; } - 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(); + + 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; diff --git a/server.h b/server.h index da520e38..99689d40 100644 --- a/server.h +++ b/server.h @@ -95,6 +95,14 @@ struct cmd_line_pdu { 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, ...);