X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fnet.c;h=d5a5f362bd3b8348deb68b6c24178df99c2c31a8;hb=e078de4a1c4e27f1938db4656e4d7cb6f98a8e1c;hp=d0f4fa0dd25b7c3a4983338301445375e71e5ca4;hpb=26e594a55a54d47ce0a0784c27c6f851c83d101a;p=fio.git diff --git a/engines/net.c b/engines/net.c index d0f4fa0d..d5a5f362 100644 --- a/engines/net.c +++ b/engines/net.c @@ -58,20 +58,27 @@ static int str_hostname_cb(void *data, const char *input); static struct fio_option options[] = { { .name = "hostname", + .lname = "net engine hostname", .type = FIO_OPT_STR_STORE, .cb = str_hostname_cb, .help = "Hostname for net IO engine", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, { .name = "port", + .lname = "net engine port", .type = FIO_OPT_INT, .off1 = offsetof(struct netio_options, port), .minval = 1, .maxval = 65535, .help = "Port to use for TCP or UDP net connections", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, { .name = "protocol", + .lname = "net engine protocol", .alias = "proto", .type = FIO_OPT_STR, .off1 = offsetof(struct netio_options, proto), @@ -91,24 +98,35 @@ static struct fio_option options[] = { .help = "UNIX domain socket", }, }, + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, +#ifdef CONFIG_TCP_NODELAY { .name = "nodelay", .type = FIO_OPT_BOOL, .off1 = offsetof(struct netio_options, nodelay), .help = "Use TCP_NODELAY on TCP connections", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, +#endif { .name = "listen", + .lname = "net engine listen", .type = FIO_OPT_STR_SET, .off1 = offsetof(struct netio_options, listen), .help = "Listen for incoming TCP connections", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, { .name = "pingpong", .type = FIO_OPT_STR_SET, .off1 = offsetof(struct netio_options, pingpong), .help = "Ping-pong IO requests", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, }, { .name = NULL, @@ -456,7 +474,7 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) { struct netio_data *nd = td->io_ops->data; struct netio_options *o = td->eo; - int type, domain, optval; + int type, domain; if (o->proto == FIO_TYPE_TCP) { domain = AF_INET; @@ -479,13 +497,16 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) return 1; } +#ifdef CONFIG_TCP_NODELAY if (o->nodelay && o->proto == FIO_TYPE_TCP) { - optval = 1; + int optval = 1; + if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) { log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno)); return 1; } } +#endif if (o->proto == FIO_TYPE_UDP) return 0; @@ -518,7 +539,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f) struct netio_data *nd = td->io_ops->data; struct netio_options *o = td->eo; socklen_t socklen = sizeof(nd->addr); - int state, optval; + int state; if (o->proto == FIO_TYPE_UDP) { f->fd = nd->listenfd; @@ -539,13 +560,16 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f) goto err; } +#ifdef CONFIG_TCP_NODELAY if (o->nodelay && o->proto == FIO_TYPE_TCP) { - optval = 1; + int optval = 1; + if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) { log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno)); return 1; } } +#endif reset_all_stats(td); td_set_runstate(td, state); @@ -962,7 +986,7 @@ static struct ioengine_ops ioengine_rw = { .options = options, .option_struct_size = sizeof(struct netio_options), .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR | - FIO_PIPEIO, + FIO_PIPEIO | FIO_BIT_BASED, }; static int str_hostname_cb(void *data, const char *input)