X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=server.c;h=e7846227f2b19bebbb569d40676a9b288c696b2f;hp=d3f69774165f8add2cab5d998989e31866ff173c;hb=36833fb04b5f9a734e96a571dfb52fc54b5b95e7;hpb=87c6f22bf24da4679849ccf778451b8432c2b368 diff --git a/server.c b/server.c index d3f69774..e7846227 100644 --- a/server.c +++ b/server.c @@ -28,7 +28,7 @@ int fio_net_port = FIO_NET_PORT; -int exit_backend = 0; +bool exit_backend = false; enum { SK_F_FREE = 1, @@ -296,6 +296,8 @@ static int verify_convert_cmd(struct fio_net_cmd *cmd) if (crc != cmd->cmd_crc16) { log_err("fio: server bad crc on command (got %x, wanted %x)\n", cmd->cmd_crc16, crc); + fprintf(f_err, "fio: server bad crc on command (got %x, wanted %x)\n", + cmd->cmd_crc16, crc); return 1; } @@ -310,6 +312,8 @@ static int verify_convert_cmd(struct fio_net_cmd *cmd) break; default: log_err("fio: bad server cmd version %d\n", cmd->version); + fprintf(f_err, "fio: client/server version mismatch (%d != %d)\n", + cmd->version, FIO_SERVER_VER); return 1; } @@ -861,7 +865,8 @@ static int handle_probe_cmd(struct fio_net_cmd *cmd) strcpy(me, (char *) pdu->server); gethostname((char *) probe.hostname, sizeof(probe.hostname)); - strncpy((char *) probe.fio_version, fio_version_string, sizeof(probe.fio_version) - 1); + snprintf((char *) probe.fio_version, sizeof(probe.fio_version), "%s", + fio_version_string); /* * If the client supports compression and we do too, then enable it @@ -991,7 +996,7 @@ static int handle_command(struct sk_out *sk_out, struct flist_head *job_list, ret = 0; break; case FIO_NET_CMD_EXIT: - exit_backend = 1; + exit_backend = true; return -1; case FIO_NET_CMD_LOAD_FILE: ret = handle_load_file_cmd(cmd); @@ -1199,7 +1204,6 @@ static int handle_connection(struct sk_out *sk_out) .events = POLLIN, }; - ret = 0; do { int timeout = 1000; @@ -1467,9 +1471,10 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) memset(&p, 0, sizeof(p)); - strncpy(p.ts.name, ts->name, FIO_JOBNAME_SIZE - 1); - strncpy(p.ts.verror, ts->verror, FIO_VERROR_SIZE - 1); - strncpy(p.ts.description, ts->description, FIO_JOBDESC_SIZE - 1); + snprintf(p.ts.name, sizeof(p.ts.name), "%s", ts->name); + snprintf(p.ts.verror, sizeof(p.ts.verror), "%s", ts->verror); + snprintf(p.ts.description, sizeof(p.ts.description), "%s", + ts->description); p.ts.error = cpu_to_le32(ts->error); p.ts.thread_number = cpu_to_le32(ts->thread_number); @@ -1527,6 +1532,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.total_submit = cpu_to_le64(ts->total_submit); p.ts.total_complete = cpu_to_le64(ts->total_complete); + p.ts.nr_zone_resets = cpu_to_le64(ts->nr_zone_resets); for (i = 0; i < DDIR_RWDIR_CNT; i++) { p.ts.io_bytes[i] = cpu_to_le64(ts->io_bytes[i]); @@ -1559,6 +1565,9 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.ss_deviation.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_deviation.u.f)); p.ts.ss_criterion.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_criterion.u.f)); + p.ts.cachehit = cpu_to_le64(ts->cachehit); + p.ts.cachemiss = cpu_to_le64(ts->cachemiss); + convert_gs(&p.rs, rs); dprint(FD_NET, "ts->ss_state = %d\n", ts->ss_state); @@ -1595,7 +1604,7 @@ void fio_server_send_gs(struct group_run_stats *rs) } void fio_server_send_job_options(struct flist_head *opt_list, - unsigned int groupid) + unsigned int gid) { struct cmd_job_option pdu; struct flist_head *entry; @@ -1610,12 +1619,12 @@ void fio_server_send_job_options(struct flist_head *opt_list, p = flist_entry(entry, struct print_option, list); memset(&pdu, 0, sizeof(pdu)); - if (groupid == -1U) { + if (gid == -1U) { pdu.global = __cpu_to_le16(1); pdu.groupid = 0; } else { pdu.global = 0; - pdu.groupid = cpu_to_le32(groupid); + pdu.groupid = cpu_to_le32(gid); } len = strlen(p->name); if (len >= sizeof(pdu.name)) { @@ -1656,8 +1665,7 @@ static void convert_dus(struct disk_util_stat *dst, struct disk_util_stat *src) { int i; - dst->name[FIO_DU_NAME_SZ - 1] = '\0'; - strncpy((char *) dst->name, (char *) src->name, FIO_DU_NAME_SZ - 1); + snprintf((char *) dst->name, sizeof(dst->name), "%s", src->name); for (i = 0; i < 2; i++) { dst->s.ios[i] = cpu_to_le64(src->s.ios[i]); @@ -1967,8 +1975,7 @@ int fio_send_iolog(struct thread_data *td, struct io_log *log, const char *name) else pdu.compressed = 0; - strncpy((char *) pdu.name, name, FIO_NET_NAME_MAX); - pdu.name[FIO_NET_NAME_MAX - 1] = '\0'; + snprintf((char *) pdu.name, sizeof(pdu.name), "%s", name); /* * We can't do this for a pre-compressed log, but for that case, @@ -1986,7 +1993,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->bs = cpu_to_le32(s->bs); + s->bs = cpu_to_le64(s->bs); if (log->log_offset) { struct io_sample_offset *so = (void *) s; @@ -2145,14 +2152,14 @@ static int fio_init_server_ip(void) #endif if (use_ipv6) { - const void *src = &saddr_in6.sin6_addr; + void *src = &saddr_in6.sin6_addr; addr = (struct sockaddr *) &saddr_in6; socklen = sizeof(saddr_in6); saddr_in6.sin6_family = AF_INET6; str = inet_ntop(AF_INET6, src, buf, sizeof(buf)); } else { - const void *src = &saddr_in.sin_addr; + void *src = &saddr_in.sin_addr; addr = (struct sockaddr *) &saddr_in; socklen = sizeof(saddr_in); @@ -2185,9 +2192,8 @@ static int fio_init_server_sock(void) mode = umask(000); - memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, bind_sock, sizeof(addr.sun_path) - 1); + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", bind_sock); len = sizeof(addr.sun_family) + strlen(bind_sock) + 1; @@ -2220,7 +2226,7 @@ static int fio_init_server_connection(void) if (!bind_sock) { char *p, port[16]; - const void *src; + void *src; int af; if (use_ipv6) { @@ -2237,9 +2243,9 @@ static int fio_init_server_connection(void) if (p) strcat(p, port); else - strncpy(bind_str, port, sizeof(bind_str) - 1); + snprintf(bind_str, sizeof(bind_str), "%s", port); } else - strncpy(bind_str, bind_sock, sizeof(bind_str) - 1); + snprintf(bind_str, sizeof(bind_str), "%s", bind_sock); log_info("fio: server listening on %s\n", bind_str); @@ -2489,7 +2495,7 @@ void fio_server_got_signal(int signal) sk_out->sk = -1; else { log_info("\nfio: terminating on signal %d\n", signal); - exit_backend = 1; + exit_backend = true; } } @@ -2571,7 +2577,7 @@ int fio_start_server(char *pidfile) setsid(); openlog("fio", LOG_NDELAY|LOG_NOWAIT|LOG_PID, LOG_USER); - log_syslog = 1; + log_syslog = true; close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO);