[PATCH] Juggle some includes, add cscope make target
[fio.git] / fio-io.c
index f3606e176ee9eadaf80671d73aeb0e8f56e419e1..7b1c1bd3a3360e9feadd4def4eb8c90bd83111aa 100644 (file)
--- a/fio-io.c
+++ b/fio-io.c
@@ -760,7 +760,7 @@ struct spliceio_data {
 
 static struct io_u *fio_spliceio_event(struct thread_data *td, int event)
 {
 
 static struct io_u *fio_spliceio_event(struct thread_data *td, int event)
 {
-       struct syncio_data *sd = td->io_data;
+       struct spliceio_data *sd = td->io_data;
 
        assert(event == 0);
 
 
        assert(event == 0);
 
@@ -776,16 +776,25 @@ static int fio_splice_read(struct thread_data *td, struct io_u *io_u)
 {
        struct spliceio_data *sd = td->io_data;
        int ret, ret2, buflen;
 {
        struct spliceio_data *sd = td->io_data;
        int ret, ret2, buflen;
+       off_t offset;
        void *p;
 
        void *p;
 
+       offset = io_u->offset;
        buflen = io_u->buflen;
        p = io_u->buf;
        buflen = io_u->buflen;
        p = io_u->buf;
-       do {
-               off_t off = io_u->offset;
+       while (buflen) {
+               int this_len = buflen;
+
+               if (this_len > SPLICE_DEF_SIZE)
+                       this_len = SPLICE_DEF_SIZE;
+
+               ret = splice(td->fd, &offset, sd->pipe[1], NULL, this_len, SPLICE_F_MORE);
+               if (ret < 0) {
+                       if (errno == ENODATA || errno == EAGAIN)
+                               continue;
 
 
-               ret = splice(td->fd, &off, sd->pipe[1], NULL, buflen, 0);
-               if (ret < 0)
                        return errno;
                        return errno;
+               }
 
                buflen -= ret;
 
 
                buflen -= ret;
 
@@ -797,7 +806,7 @@ static int fio_splice_read(struct thread_data *td, struct io_u *io_u)
                        ret -= ret2;
                        p += ret2;
                }
                        ret -= ret2;
                        p += ret2;
                }
-       } while (buflen);
+       }
 
        return io_u->buflen;
 }
 
        return io_u->buflen;
 }
@@ -816,6 +825,7 @@ static int fio_splice_write(struct thread_data *td, struct io_u *io_u)
                }
        };
        struct pollfd pfd = { .fd = sd->pipe[1], .events = POLLOUT, };
                }
        };
        struct pollfd pfd = { .fd = sd->pipe[1], .events = POLLOUT, };
+       off_t off = io_u->offset;
        int ret, ret2;
 
        while (iov[0].iov_len) {
        int ret, ret2;
 
        while (iov[0].iov_len) {
@@ -830,8 +840,6 @@ static int fio_splice_write(struct thread_data *td, struct io_u *io_u)
                iov[0].iov_base += ret;
 
                while (ret) {
                iov[0].iov_base += ret;
 
                while (ret) {
-                       off_t off = io_u->offset;
-
                        ret2 = splice(sd->pipe[0], NULL, td->fd, &off, ret, 0);
                        if (ret2 < 0)
                                return errno;
                        ret2 = splice(sd->pipe[0], NULL, td->fd, &off, ret, 0);
                        if (ret2 < 0)
                                return errno;