From: Jens Axboe Date: Wed, 7 Feb 2007 08:35:29 +0000 (+0100) Subject: [PATCH] Network io engine updates X-Git-Tag: fio-1.12~131 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=7a6499dada619928267d26b4629b0c8623dc423a;hp=e2a26d2c2a75861494f6fc4046a37a71874bd59a [PATCH] Network io engine updates - Use recv/send - Set MSG_MORE on send if we are going to transmit more data - Cleanups Signed-off-by: Jens Axboe --- diff --git a/engines/net.c b/engines/net.c index 43026e5f..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,12 +75,23 @@ 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; - 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->xfer_buf, io_u->xfer_buflen); - else if (io_u->ddir == DDIR_READ) - ret = read(f->fd, io_u->xfer_buf, io_u->xfer_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 != (int) io_u->xfer_buflen) { if (ret > 0) { @@ -111,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; @@ -194,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 */