client/server: send back nr_jobs and error exit code
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/client.c b/client.c
index fb678e1..e6e4291 100644
--- a/client.c
+++ b/client.c
@@ -42,6 +42,8 @@
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 @@
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 @@
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 856ca75..3a53794 100644
--- a/fio.c
+++ b/fio.c
@@ -55,9 +55,9 @@
(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 @@
/*
* 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 @@
{
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 df0daf6..be684ca 100644
--- a/fio.h
+++ b/fio.h
@@ -482,8 +482,8 @@
#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 7c4804a..4da8bf0 100644
--- a/server.c
+++ b/server.c
@@ -332,6 +332,8 @@
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 @@
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 da520e3..99689d4 100644
--- a/server.h
+++ b/server.h
@@ -95,6 +95,14 @@
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, ...);