X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=engines%2Fnet.c;h=222624d946d091e017274ea8f2b3d854b3527fa6;hp=b1a4cdc21e4092d39b907526a25078cb184de4e1;hb=7a6499dada619928267d26b4629b0c8623dc423a;hpb=2fc2698113c087352c1851bf5ebfcad6adb53932 diff --git a/engines/net.c b/engines/net.c index b1a4cdc2..222624d9 100644 --- a/engines/net.c +++ b/engines/net.c @@ -48,18 +48,16 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u) struct net_data *nd = td->io_ops->data; struct fio_file *f = io_u->file; - if (nd->send_to_net) { - if (io_u->ddir == DDIR_READ) { - td_verror(td, EINVAL); - return 1; - } - } else { - if (io_u->ddir == DDIR_WRITE) { - td_verror(td, EINVAL); - return 1; - } + /* + * Make sure we don't see spurious reads to a receiver, and vice versa + */ + if ((nd->send_to_net && io_u->ddir == DDIR_READ) || + (!nd->send_to_net && io_u->ddir == DDIR_WRITE)) { + printf("boo!\n"); + td_verror(td, EINVAL); + return 1; } - + if (io_u->ddir == DDIR_SYNC) return 0; if (io_u->offset == f->last_completed_pos) @@ -77,17 +75,29 @@ static int fio_netio_queue(struct thread_data *td, struct io_u *io_u) { struct net_data *nd = td->io_ops->data; struct fio_file *f = io_u->file; - unsigned int ret = 0; + int ret; + + if (io_u->ddir == DDIR_WRITE) { + int flags = 0; + + /* + * if we are going to write more, set MSG_MORE + */ + if (td->this_io_bytes[DDIR_WRITE] + io_u->xfer_buflen < + td->io_size) + flags = MSG_MORE; - if (io_u->ddir == DDIR_WRITE) - ret = write(f->fd, io_u->buf, io_u->buflen); - else if (io_u->ddir == DDIR_READ) - ret = read(f->fd, io_u->buf, io_u->buflen); + ret = send(f->fd, io_u->xfer_buf, io_u->xfer_buflen, flags); + } else if (io_u->ddir == DDIR_READ) + ret = recv(f->fd, io_u->xfer_buf, io_u->xfer_buflen, MSG_WAITALL); + else + ret = 0; /* must be a SYNC */ - if (ret != io_u->buflen) { + if (ret != (int) io_u->xfer_buflen) { if (ret > 0) { - io_u->resid = io_u->buflen - ret; - io_u->error = EIO; + io_u->resid = io_u->xfer_buflen - ret; + io_u->error = 0; + return ret; } else io_u->error = errno; } @@ -110,8 +120,9 @@ static int fio_netio_setup_connect(struct thread_data *td, const char *host, addr.sin_port = htons(port); if (inet_aton(host, &addr.sin_addr) != 1) { - struct hostent *hent = gethostbyname(host); + struct hostent *hent; + hent = gethostbyname(host); if (!hent) { td_vmsg(td, errno, "gethostbyname"); return 1; @@ -193,6 +204,11 @@ static int fio_netio_setup(struct thread_data *td) char *sep; int ret, i; + if (!td->total_file_size) { + log_err("fio: need size= set\n"); + return 1; + } + /* * work around for late init call */