X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=server.c;h=90c52e01ac231f4972bbd94e91361d3fe61ad132;hb=53b5fa1ea4f821899440637ab632ce0e1687c916;hp=e7846227f2b19bebbb569d40676a9b288c696b2f;hpb=998baa29f571df9d2e4b626bedd317a2fd28c68a;p=fio.git diff --git a/server.c b/server.c index e7846227..90c52e01 100644 --- a/server.c +++ b/server.c @@ -409,8 +409,9 @@ struct fio_net_cmd *fio_net_recv_cmd(int sk, bool wait) if (cmdret->opcode == FIO_NET_CMD_TEXT) { struct cmd_text_pdu *__pdu = (struct cmd_text_pdu *) cmdret->payload; char *buf = (char *) __pdu->buf; + int len = le32_to_cpu(__pdu->buf_len); - buf[__pdu->buf_len] = '\0'; + buf[len] = '\0'; } else if (cmdret->opcode == FIO_NET_CMD_JOB) { struct cmd_job_pdu *__pdu = (struct cmd_job_pdu *) cmdret->payload; char *buf = (char *) __pdu->buf; @@ -950,7 +951,7 @@ static int handle_update_job_cmd(struct fio_net_cmd *cmd) return 0; } - td = &threads[tnumber - 1]; + td = tnumber_to_td(tnumber); convert_thread_options_to_cpu(&td->o, &pdu->top); send_update_job_reply(cmd->tag, 0); return 0; @@ -975,7 +976,7 @@ static int handle_trigger_cmd(struct fio_net_cmd *cmd, struct flist_head *job_li } else fio_net_queue_cmd(FIO_NET_CMD_VTRIGGER, rep, sz, NULL, SK_F_FREE | SK_F_INLINE); - fio_terminate_threads(TERMINATE_ALL); + fio_terminate_threads(TERMINATE_ALL, TERMINATE_ALL); fio_server_check_jobs(job_list); exec_trigger(buf); return 0; @@ -992,7 +993,7 @@ static int handle_command(struct sk_out *sk_out, struct flist_head *job_list, switch (cmd->opcode) { case FIO_NET_CMD_QUIT: - fio_terminate_threads(TERMINATE_ALL); + fio_terminate_threads(TERMINATE_ALL, TERMINATE_ALL); ret = 0; break; case FIO_NET_CMD_EXIT: @@ -1262,7 +1263,7 @@ static int handle_connection(struct sk_out *sk_out) _exit(ret); } -/* get the address on this host bound by the input socket, +/* get the address on this host bound by the input socket, * whether it is ipv6 or ipv4 */ static int get_my_addr_str(int sk) @@ -1463,7 +1464,7 @@ static void convert_gs(struct group_run_stats *dst, struct group_run_stats *src) void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) { struct cmd_ts_pdu p; - int i, j; + int i, j, k; void *ss_buf; uint64_t *ss_iops, *ss_bw; @@ -1490,6 +1491,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) convert_io_stat(&p.ts.bw_stat[i], &ts->bw_stat[i]); convert_io_stat(&p.ts.iops_stat[i], &ts->iops_stat[i]); } + convert_io_stat(&p.ts.sync_stat, &ts->sync_stat); p.ts.usr_time = cpu_to_le64(ts->usr_time); p.ts.sys_time = cpu_to_le64(ts->sys_time); @@ -1498,6 +1500,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.majf = cpu_to_le64(ts->majf); p.ts.clat_percentiles = cpu_to_le32(ts->clat_percentiles); p.ts.lat_percentiles = cpu_to_le32(ts->lat_percentiles); + p.ts.slat_percentiles = cpu_to_le32(ts->slat_percentiles); p.ts.percentile_precision = cpu_to_le64(ts->percentile_precision); for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++) { @@ -1520,12 +1523,18 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) p.ts.io_u_lat_m[i] = cpu_to_le64(ts->io_u_lat_m[i]); - for (i = 0; i < DDIR_RWDIR_CNT; i++) - for (j = 0; j < FIO_IO_U_PLAT_NR; j++) - p.ts.io_u_plat[i][j] = cpu_to_le64(ts->io_u_plat[i][j]); + for (i = 0; i < FIO_LAT_CNT; i++) + for (j = 0; j < DDIR_RWDIR_CNT; j++) + for (k = 0; k < FIO_IO_U_PLAT_NR; k++) + p.ts.io_u_plat[i][j][k] = cpu_to_le64(ts->io_u_plat[i][j][k]); - for (i = 0; i < DDIR_RWDIR_CNT; i++) { + for (j = 0; j < FIO_IO_U_PLAT_NR; j++) + p.ts.io_u_sync_plat[j] = cpu_to_le64(ts->io_u_sync_plat[j]); + + for (i = 0; i < DDIR_RWDIR_SYNC_CNT; i++) p.ts.total_io_u[i] = cpu_to_le64(ts->total_io_u[i]); + + for (i = 0; i < DDIR_RWDIR_CNT; 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]); } @@ -1568,6 +1577,15 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.cachehit = cpu_to_le64(ts->cachehit); p.ts.cachemiss = cpu_to_le64(ts->cachemiss); + for (i = 0; i < DDIR_RWDIR_CNT; i++) { + for (j = 0; j < FIO_IO_U_PLAT_NR; j++) { + p.ts.io_u_plat_high_prio[i][j] = cpu_to_le64(ts->io_u_plat_high_prio[i][j]); + p.ts.io_u_plat_low_prio[i][j] = cpu_to_le64(ts->io_u_plat_low_prio[i][j]); + } + convert_io_stat(&p.ts.clat_high_prio_stat[i], &ts->clat_high_prio_stat[i]); + convert_io_stat(&p.ts.clat_low_prio_stat[i], &ts->clat_low_prio_stat[i]); + } + convert_gs(&p.rs, rs); dprint(FD_NET, "ts->ss_state = %d\n", ts->ss_state); @@ -1892,7 +1910,7 @@ static int fio_append_iolog_gz(struct sk_entry *first, struct io_log *log) break; } flist_add_tail(&entry->list, &first->next); - } while (ret != Z_STREAM_END); + } ret = deflateEnd(&stream); if (ret == Z_OK) @@ -1992,7 +2010,7 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name) s->time = cpu_to_le64(s->time); s->data.val = cpu_to_le64(s->data.val); - s->__ddir = cpu_to_le32(s->__ddir); + s->__ddir = __cpu_to_le32(s->__ddir); s->bs = cpu_to_le64(s->bs); if (log->log_offset) { @@ -2148,7 +2166,8 @@ static int fio_init_server_ip(void) /* * Not fatal if fails, so just ignore it if that happens */ - setsockopt(sk, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)); + if (setsockopt(sk, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt))) { + } #endif if (use_ipv6) { @@ -2438,6 +2457,11 @@ static void set_sig_handlers(void) }; sigaction(SIGINT, &act, NULL); + + /* Windows uses SIGBREAK as a quit signal from other applications */ +#ifdef WIN32 + sigaction(SIGBREAK, &act, NULL); +#endif } void fio_server_destroy_sk_key(void) @@ -2546,6 +2570,7 @@ static int write_pid(pid_t pid, const char *pidfile) */ int fio_start_server(char *pidfile) { + FILE *file; pid_t pid; int ret; @@ -2578,14 +2603,28 @@ int fio_start_server(char *pidfile) setsid(); openlog("fio", LOG_NDELAY|LOG_NOWAIT|LOG_PID, LOG_USER); log_syslog = true; - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); + + file = freopen("/dev/null", "r", stdin); + if (!file) + perror("freopen"); + + file = freopen("/dev/null", "w", stdout); + if (!file) + perror("freopen"); + + file = freopen("/dev/null", "w", stderr); + if (!file) + perror("freopen"); + f_out = NULL; f_err = NULL; ret = fio_server(); + fclose(stdin); + fclose(stdout); + fclose(stderr); + closelog(); unlink(pidfile); free(pidfile);