#include "fio.h"
#include "server.h"
#include "crc/crc16.h"
-#include "ieee754.h"
+#include "lib/ieee754.h"
#include "fio_version.h"
static char *fio_server_arg;
static char *bind_sock;
static struct sockaddr_in saddr_in;
+static int first_cmd_check;
static const char *fio_server_ops[FIO_NET_CMD_NR] = {
"",
"ETA",
"PROBE",
"START",
- "STOP"
+ "STOP",
+ "DISK_UTIL",
+ "RUN",
};
const char *fio_server_op(unsigned int op)
if (first)
memcpy(cmdret, &cmd, sizeof(cmd));
- else
- assert(cmdret->opcode == cmd.opcode);
+ else if (cmdret->opcode != cmd.opcode) {
+ log_err("fio: fragment opcode mismatch (%d != %d)\n",
+ cmdret->opcode, cmd.opcode);
+ ret = 1;
+ break;
+ }
if (!cmd.pdu_len)
break;
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)) {
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;
void fio_server_idle_loop(void)
{
+ if (!first_cmd_check)
+ fio_net_send_simple_cmd(server_fd, FIO_NET_CMD_RUN, 0, NULL);
if (server_fd != -1)
handle_connection(server_fd, 0);
}
fio_net_send_cmd(server_fd, FIO_NET_CMD_GS, &gs, sizeof(gs), 0);
}
+static void convert_agg(struct disk_util_agg *dst, struct disk_util_agg *src)
+{
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ dst->ios[i] = cpu_to_le32(src->ios[i]);
+ dst->merges[i] = cpu_to_le32(src->merges[i]);
+ dst->sectors[i] = cpu_to_le64(src->sectors[i]);
+ dst->ticks[i] = cpu_to_le32(src->ticks[i]);
+ }
+
+ dst->io_ticks = cpu_to_le32(src->io_ticks);
+ dst->time_in_queue = cpu_to_le32(src->time_in_queue);
+ dst->slavecount = cpu_to_le32(src->slavecount);
+ dst->max_util.u.i = __cpu_to_le64(fio_double_to_uint64(src->max_util.u.f));
+}
+
+static void convert_dus(struct disk_util_stat *dst, struct disk_util_stat *src)
+{
+ int i;
+
+ strcpy((char *) dst->name, (char *) src->name);
+
+ for (i = 0; i < 2; i++) {
+ dst->ios[i] = cpu_to_le32(src->ios[i]);
+ dst->merges[i] = cpu_to_le32(src->merges[i]);
+ dst->sectors[i] = cpu_to_le64(src->sectors[i]);
+ dst->ticks[i] = cpu_to_le32(src->ticks[i]);
+ }
+
+ dst->io_ticks = cpu_to_le32(src->io_ticks);
+ dst->time_in_queue = cpu_to_le32(src->time_in_queue);
+ dst->msec = cpu_to_le64(src->msec);
+}
+
+void fio_server_send_du(void)
+{
+ struct disk_util *du;
+ struct flist_head *entry;
+ struct cmd_du_pdu pdu;
+
+ dprint(FD_NET, "server: sending disk_util %d\n", !flist_empty(&disk_list));
+
+ memset(&pdu, 0, sizeof(pdu));
+
+ flist_for_each(entry, &disk_list) {
+ du = flist_entry(entry, struct disk_util, list);
+
+ convert_dus(&pdu.dus, &du->dus);
+ convert_agg(&pdu.agg, &du->agg);
+
+ fio_net_send_cmd(server_fd, FIO_NET_CMD_DU, &pdu, sizeof(pdu), 0);
+ }
+}
+
int fio_server_log(const char *format, ...)
{
char buffer[1024];