summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
72ddbe7)
Make it more efficient as well, don't pass a lot of potentially
padded space, pass only the exact amount required.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-static int __fio_client_add_cmd_option(struct fio_client *client,
- const char *opt)
+static void __fio_client_add_cmd_option(struct fio_client *client,
+ const char *opt)
- if (client->argc == FIO_NET_CMD_JOBLINE_ARGV) {
- log_err("fio: max cmd line number reached.\n");
- log_err("fio: cmd line <%s> has been ignored.\n", opt);
- return 1;
- }
-
index = client->argc++;
client->argv = realloc(client->argv, sizeof(char *) * client->argc);
client->argv[index] = strdup(opt);
dprint(FD_NET, "client: add cmd %d: %s\n", index, opt);
index = client->argc++;
client->argv = realloc(client->argv, sizeof(char *) * client->argc);
client->argv[index] = strdup(opt);
dprint(FD_NET, "client: add cmd %d: %s\n", index, opt);
-int fio_client_add_cmd_option(void *cookie, const char *opt)
+void fio_client_add_cmd_option(void *cookie, const char *opt)
{
struct fio_client *client = cookie;
if (!client || !opt)
{
struct fio_client *client = cookie;
if (!client || !opt)
- return __fio_client_add_cmd_option(client, opt);
+ __fio_client_add_cmd_option(client, opt);
}
int fio_client_add(const char *hostname, void **cookie)
}
int fio_client_add(const char *hostname, void **cookie)
static int send_client_cmd_line(struct fio_client *client)
{
static int send_client_cmd_line(struct fio_client *client)
{
- struct cmd_line_pdu *pdu;
+ struct cmd_single_line_pdu *cslp;
+ struct cmd_line_pdu *clp;
+ unsigned long offset;
+ void *pdu;
+ size_t mem;
int i, ret;
dprint(FD_NET, "client: send cmdline %d\n", client->argc);
int i, ret;
dprint(FD_NET, "client: send cmdline %d\n", client->argc);
- pdu = malloc(sizeof(*pdu));
- for (i = 0; i < client->argc; i++)
- strcpy((char *) pdu->argv[i], client->argv[i]);
+ /*
+ * Find out how much mem we need
+ */
+ for (i = 0, mem = 0; i < client->argc; i++)
+ mem += strlen(client->argv[i]) + 1;
+
+ /*
+ * We need one cmd_line_pdu, and argc number of cmd_single_line_pdu
+ */
+ mem += sizeof(*clp) + (client->argc * sizeof(*cslp));
+
+ pdu = malloc(mem);
+ clp = pdu;
+ offset = sizeof(*clp);
+
+ for (i = 0; i < client->argc; i++) {
+ uint16_t arg_len = strlen(client->argv[i]) + 1;
+
+ cslp = pdu + offset;
+ strcpy((char *) cslp->text, client->argv[i]);
+ cslp->len = cpu_to_le16(arg_len);
+ offset += sizeof(*cslp) + arg_len;
+ }
- pdu->argc = cpu_to_le16(client->argc);
- ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOBLINE, pdu, sizeof(*pdu));
+ clp->lines = cpu_to_le16(client->argc);
+ ret = fio_net_send_cmd(client->fd, FIO_NET_CMD_JOBLINE, pdu, mem);
-int parse_cmd_client(void *client, char *opt)
+void parse_cmd_client(void *client, char *opt)
- return fio_client_add_cmd_option(client, opt);
+ fio_client_add_cmd_option(client, opt);
}
int parse_cmd_line(int argc, char *argv[])
}
int parse_cmd_line(int argc, char *argv[])
did_arg = 1;
if ((c & FIO_CLIENT_FLAG) || client_flag_set(c)) {
did_arg = 1;
if ((c & FIO_CLIENT_FLAG) || client_flag_set(c)) {
- if (parse_cmd_client(cur_client, argv[optind - 1])) {
- exit_val = 1;
- do_exit++;
- break;
- }
+ parse_cmd_client(cur_client, argv[optind - 1]);
cmd->pdu_len = le32_to_cpu(cmd->pdu_len);
switch (cmd->version) {
cmd->pdu_len = le32_to_cpu(cmd->pdu_len);
switch (cmd->version) {
break;
default:
log_err("fio: bad server cmd version %d\n", cmd->version);
break;
default:
log_err("fio: bad server cmd version %d\n", cmd->version);
static int handle_jobline_cmd(struct fio_net_cmd *cmd)
{
static int handle_jobline_cmd(struct fio_net_cmd *cmd)
{
- struct cmd_line_pdu *pdu = (struct cmd_line_pdu *) cmd->payload;
- char *argv[FIO_NET_CMD_JOBLINE_ARGV];
+ void *pdu = cmd->payload;
+ struct cmd_single_line_pdu *cslp;
+ struct cmd_line_pdu *clp;
+ unsigned long offset;
+ char **argv;
- pdu->argc = le16_to_cpu(pdu->argc);
+ clp = pdu;
+ clp->lines = le16_to_cpu(clp->lines);
+ argv = malloc(clp->lines * sizeof(char *));
+ offset = sizeof(*clp);
- dprint(FD_NET, "server: %d command line args\n", pdu->argc);
+ dprint(FD_NET, "server: %d command line args\n", clp->lines);
- for (i = 0; i < pdu->argc; i++) {
- argv[i] = (char *) pdu->argv[i];
+ for (i = 0; i < clp->lines; i++) {
+ cslp = pdu + offset;
+ argv[i] = (char *) cslp->text;
+
+ offset += sizeof(*cslp) + le16_to_cpu(cslp->len);
dprint(FD_NET, "server: %d: %s\n", i, argv[i]);
}
dprint(FD_NET, "server: %d: %s\n", i, argv[i]);
}
- if (parse_cmd_line(pdu->argc, argv)) {
+ if (parse_cmd_line(clp->lines, argv)) {
fio_server_send_quit_cmd();
fio_server_send_quit_cmd();
fio_net_send_simple_cmd(server_fd, FIO_NET_CMD_START, 0);
ret = exec_run();
fio_net_send_simple_cmd(server_fd, FIO_NET_CMD_START, 0);
ret = exec_run();
- FIO_SERVER_VER = 3,
- FIO_SERVER_VER3 = 3,
FIO_SERVER_MAX_PDU = 1024,
FIO_SERVER_MAX_PDU = 1024,
/* crc does not include the crc fields */
FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
2 * sizeof(uint16_t),
/* crc does not include the crc fields */
FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
2 * sizeof(uint16_t),
-
- FIO_NET_CMD_JOBLINE_ARGV = 128,
+struct cmd_single_line_pdu {
+ uint16_t len;
+ uint8_t text[0];
+};
+
- uint16_t argc;
- uint8_t argv[FIO_NET_CMD_JOBLINE_ARGV][64];
+ uint16_t lines;
+ struct cmd_single_line_pdu options[0];
};
extern int fio_start_server(int);
};
extern int fio_start_server(int);
extern int fio_clients_send_ini(const char *);
extern int fio_handle_clients(void);
extern int fio_client_add(const char *, void **);
extern int fio_clients_send_ini(const char *);
extern int fio_handle_clients(void);
extern int fio_client_add(const char *, void **);
-extern int fio_client_add_cmd_option(void *, const char *);
+extern void fio_client_add_cmd_option(void *, const char *);
extern int fio_recv_data(int sk, void *p, unsigned int len);
extern int fio_send_data(int sk, const void *p, unsigned int len);
extern int fio_recv_data(int sk, void *p, unsigned int len);
extern int fio_send_data(int sk, const void *p, unsigned int len);
{
memset(cmd, 0, sizeof(*cmd));
{
memset(cmd, 0, sizeof(*cmd));
- cmd->version = __cpu_to_le16(FIO_SERVER_VER3);
+ cmd->version = __cpu_to_le16(FIO_SERVER_VER);
cmd->opcode = cpu_to_le16(opcode);
if (pdu) {
cmd->opcode = cpu_to_le16(opcode);
if (pdu) {