X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=server.c;h=33c512c78f96a5d19cd0f110b6d418d581ad1357;hp=077dce5c349f67efec5c76a6371e89e2a2a4724f;hb=91c0e7c5de1b4413c5fab8f5746272d1aee10f78;hpb=9bdb9265ed6cfd95fc217a9030b188a5a345cc89 diff --git a/server.c b/server.c index 077dce5c..33c512c7 100644 --- a/server.c +++ b/server.c @@ -69,6 +69,8 @@ static const char *fio_server_ops[FIO_NET_CMD_NR] = { "ADD_JOB", "CMD_RUN", "CMD_IOLOG", + "CMD_UPDATE_JOB", + "CMD_LOAD_FILE", }; const char *fio_server_op(unsigned int op) @@ -550,11 +552,34 @@ static void fio_server_check_conns(struct flist_head *conn_list) fio_server_check_fork_items(conn_list); } +static int handle_load_file_cmd(struct fio_net_cmd *cmd) +{ + struct cmd_load_file_pdu *pdu = (struct cmd_load_file_pdu *) cmd->payload; + void *file_name = pdu->file; + struct cmd_start_pdu spdu; + + dprint(FD_NET, "server: loading local file %s\n", (char *) file_name); + + pdu->name_len = le16_to_cpu(pdu->name_len); + pdu->client_type = le16_to_cpu(pdu->client_type); + + if (parse_jobs_ini(file_name, 0, 0, pdu->client_type)) { + fio_net_send_quit(server_fd); + return -1; + } + + spdu.jobs = cpu_to_le32(thread_number); + spdu.stat_outputs = cpu_to_le32(stat_number); + fio_net_send_cmd(server_fd, FIO_NET_CMD_START, &spdu, sizeof(spdu), NULL, NULL); + return 0; +} + static int handle_run_cmd(struct flist_head *job_list, struct fio_net_cmd *cmd) { pid_t pid; int ret; + fio_time_init(); set_genesis_time(); pid = fork(); @@ -665,21 +690,13 @@ static int handle_probe_cmd(struct fio_net_cmd *cmd) static int handle_send_eta_cmd(struct fio_net_cmd *cmd) { struct jobs_eta *je; - size_t size; uint64_t tag = cmd->tag; + size_t size; int i; - if (!thread_number) - return 0; - - size = sizeof(*je) + thread_number * sizeof(char) + 1; - je = malloc(size); - memset(je, 0, size); - - if (!calc_thread_status(je, 1)) { - free(je); + je = get_jobs_eta(1, &size); + if (!je) return 0; - } dprint(FD_NET, "server sending status\n"); @@ -754,6 +771,9 @@ static int handle_command(struct flist_head *job_list, struct fio_net_cmd *cmd) case FIO_NET_CMD_EXIT: exit_backend = 1; return -1; + case FIO_NET_CMD_LOAD_FILE: + ret = handle_load_file_cmd(cmd); + break; case FIO_NET_CMD_JOB: ret = handle_job_cmd(cmd); break; @@ -1046,6 +1066,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) for (i = 0; i < DDIR_RWDIR_CNT; i++) { p.ts.total_io_u[i] = cpu_to_le64(ts->total_io_u[i]); p.ts.short_io_u[i] = cpu_to_le64(ts->short_io_u[i]); + p.ts.drop_io_u[i] = cpu_to_le64(ts->drop_io_u[i]); } p.ts.total_submit = cpu_to_le64(ts->total_submit); @@ -1184,7 +1205,7 @@ static int fio_send_iolog_gz(struct cmd_iolog_pdu *pdu, struct io_log *log) } stream.next_in = (void *) log->log; - stream.avail_in = log->nr_samples * sizeof(struct io_sample); + stream.avail_in = log->nr_samples * log_entry_sz(log); do { unsigned int this_len, flags = 0; @@ -1221,8 +1242,8 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name) struct cmd_iolog_pdu pdu; int i, ret = 0; + pdu.nr_samples = cpu_to_le64(log->nr_samples); pdu.thread_number = cpu_to_le32(td->thread_number); - pdu.nr_samples = __cpu_to_le32(log->nr_samples); pdu.log_type = cpu_to_le32(log->log_type); pdu.compressed = cpu_to_le32(use_zlib); @@ -1230,12 +1251,18 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name) pdu.name[FIO_NET_NAME_MAX - 1] = '\0'; for (i = 0; i < log->nr_samples; i++) { - struct io_sample *s = &log->log[i]; + struct io_sample *s = get_sample(log, i); - s->time = cpu_to_le64(s->time); - s->val = cpu_to_le64(s->val); - s->ddir = cpu_to_le32(s->ddir); - s->bs = cpu_to_le32(s->bs); + s->time = cpu_to_le64(s->time); + s->val = cpu_to_le64(s->val); + s->__ddir = cpu_to_le32(s->__ddir); + s->bs = cpu_to_le32(s->bs); + + if (log->log_offset) { + struct io_sample_offset *so = (void *) s; + + so->offset = cpu_to_le64(so->offset); + } } /* @@ -1253,7 +1280,7 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name) return fio_send_iolog_gz(&pdu, log); return fio_send_cmd_ext_pdu(server_fd, FIO_NET_CMD_IOLOG, log->log, - log->nr_samples * sizeof(struct io_sample), 0, 0); + log->nr_samples * log_entry_sz(log), 0, 0); } void fio_server_send_add_job(struct thread_data *td) @@ -1710,7 +1737,7 @@ int fio_start_server(char *pidfile) int ret = write_pid(pid, pidfile); free(pidfile); - exit(ret); + _exit(ret); } setsid();