Merge branch 'master' into gfio
[fio.git] / engines / net.c
index b728df1f7385f751d86ed63e526be0c71782745a..566ad2d7482c8f19e3597b9d578882f1ce351feb 100644 (file)
@@ -58,25 +58,31 @@ 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_IO,
        },
        {
                .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_IO,
        },
        {
                .name   = "protocol",
+               .lname  = "net engine protocol",
                .alias  = "proto",
                .type   = FIO_OPT_STR,
                .off1   = offsetof(struct netio_options, proto),
                .help   = "Network protocol to use",
                .def    = "tcp",
+               .category = FIO_OPT_C_IO,
                .posval = {
                          { .ival = "tcp",
                            .oval = FIO_TYPE_TCP,
@@ -92,17 +98,21 @@ static struct fio_option options[] = {
                          },
                },
        },
+#ifdef CONFIG_TCP_NODELAY
        {
                .name   = "nodelay",
                .type   = FIO_OPT_BOOL,
                .off1   = offsetof(struct netio_options, nodelay),
                .help   = "Use TCP_NODELAY on TCP connections",
        },
+#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_IO,
        },
        {
                .name   = "pingpong",
@@ -456,7 +466,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 +489,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;
-               if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(int)) < 0) {
+               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 +531,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 +552,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;
-               if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(int)) < 0) {
+               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);
@@ -767,12 +783,12 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
        }
 
        opt = 1;
-       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(opt)) < 0) {
+       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *) &opt, sizeof(opt)) < 0) {
                td_verror(td, errno, "setsockopt");
                return 1;
        }
 #ifdef SO_REUSEPORT
-       if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) {
+       if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *) &opt, sizeof(opt)) < 0) {
                td_verror(td, errno, "setsockopt");
                return 1;
        }
@@ -962,7 +978,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)