X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fnet.c;h=60a68778b18458d9c49a758833911e779f2b7f99;hp=381c731c9bf3892c9261aabcb45bf0d5812f21a2;hb=ad2da605a62faf16887970618b434db19594e17b;hpb=22819ec237297fc39435ed566bee01a4225bfb39 diff --git a/engines/net.c b/engines/net.c index 381c731c..60a68778 100644 --- a/engines/net.c +++ b/engines/net.c @@ -25,7 +25,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u) */ if ((send_to_net(td) && io_u->ddir == DDIR_READ) || (!send_to_net(td) && io_u->ddir == DDIR_WRITE)) { - td_verror(td, EINVAL); + td_verror(td, EINVAL, "bad direction"); return 1; } @@ -38,7 +38,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u) * If offset is different from last end position, it's a seek. * As network io is purely sequential, we don't allow seeks. */ - td_verror(td, EINVAL); + td_verror(td, EINVAL, "cannot seek"); return 1; } @@ -72,7 +72,7 @@ static int fio_netio_queue(struct thread_data *td, struct io_u *io_u) } if (io_u->error) - td_verror(td, io_u->error); + td_verror(td, io_u->error, "xfer"); return FIO_Q_COMPLETED; } @@ -93,7 +93,7 @@ static int fio_netio_setup_connect(struct thread_data *td, const char *host, hent = gethostbyname(host); if (!hent) { - td_verror(td, errno); + td_verror(td, errno, "gethostbyname"); return 1; } @@ -103,12 +103,12 @@ static int fio_netio_setup_connect(struct thread_data *td, const char *host, for_each_file(td, f, i) { f->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (f->fd < 0) { - td_verror(td, errno); + td_verror(td, errno, "socket"); return 1; } if (connect(f->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - td_verror(td, errno); + td_verror(td, errno, "connect"); return 1; } } @@ -142,7 +142,7 @@ static int fio_netio_accept_connections(struct thread_data *td, int fd, if (errno == EINTR) continue; - td_verror(td, errno); + td_verror(td, errno, "poll"); break; } else if (!ret) continue; @@ -159,7 +159,7 @@ static int fio_netio_accept_connections(struct thread_data *td, int fd, f->fd = accept(fd, (struct sockaddr *) addr, &socklen); if (f->fd < 0) { - td_verror(td, errno); + td_verror(td, errno, "accept"); return 1; } accepts++; @@ -177,18 +177,18 @@ static int fio_netio_setup_listen(struct thread_data *td, unsigned short port) fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { - td_verror(td, errno); + td_verror(td, errno, "socket"); return 1; } opt = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { - td_verror(td, errno); + td_verror(td, errno, "setsockopt"); return 1; } #ifdef SO_REUSEPORT if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) < 0) { - td_verror(td, errno); + td_verror(td, errno, "setsockopt"); return 1; } #endif @@ -199,11 +199,11 @@ static int fio_netio_setup_listen(struct thread_data *td, unsigned short port) addr.sin_port = htons(port); if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { - td_verror(td, errno); + td_verror(td, errno, "bind"); return 1; } if (listen(fd, 1) < 0) { - td_verror(td, errno); + td_verror(td, errno, "listen"); return 1; } @@ -223,7 +223,7 @@ static int fio_netio_setup(struct thread_data *td) return 1; } - if (td->iomix) { + if (td_rw(td)) { log_err("fio: network connections must be read OR write\n"); return 1; } @@ -241,7 +241,7 @@ static int fio_netio_setup(struct thread_data *td) strcpy(host, buf); port = atoi(sep); - if (td->ddir == DDIR_READ) { + if (td_read(td)) { send_to_net(td) = 0; ret = fio_netio_setup_listen(td, port); } else {