[PATCH] Make ->buflen == 0 on SYNC io_u's
authorJens Axboe <jens.axboe@oracle.com>
Tue, 24 Oct 2006 17:38:15 +0000 (19:38 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 24 Oct 2006 17:38:15 +0000 (19:38 +0200)
It eases the error handling in the splice and sync io engine.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/fio-engine-splice.c
engines/fio-engine-sync.c
io_u.c

index 3553d646c0a1f15a4a6e1540a214febf328d0abd..192fbd00bffdf14184a249e481dbfc95ab4e7f07 100644 (file)
@@ -129,7 +129,7 @@ static int fio_splice_write(struct thread_data *td, struct io_u *io_u)
 static int fio_spliceio_queue(struct thread_data *td, struct io_u *io_u)
 {
        struct spliceio_data *sd = td->io_ops->data;
-       int ret;
+       unsigned int ret;
 
        if (io_u->ddir == DDIR_READ)
                ret = fio_splice_read(td, io_u);
@@ -138,7 +138,7 @@ static int fio_spliceio_queue(struct thread_data *td, struct io_u *io_u)
        else
                ret = fsync(io_u->file->fd);
 
-       if ((unsigned int) ret != io_u->buflen) {
+       if (ret != io_u->buflen) {
                if (ret > 0) {
                        io_u->resid = io_u->buflen - ret;
                        io_u->error = ENODATA;
index 8bc990d72bcd3de7457169e9b27b1f1389719bd9..43f42ca2ffcace7068656a0ebd4453453af69d7b 100644 (file)
@@ -57,7 +57,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
 {
        struct syncio_data *sd = td->io_ops->data;
        struct fio_file *f = io_u->file;
-       int ret;
+       unsigned int ret;
 
        if (io_u->ddir == DDIR_READ)
                ret = read(f->fd, io_u->buf, io_u->buflen);
@@ -66,7 +66,7 @@ static int fio_syncio_queue(struct thread_data *td, struct io_u *io_u)
        else
                ret = fsync(f->fd);
 
-       if ((unsigned int) ret != io_u->buflen) {
+       if (ret != io_u->buflen) {
                if (ret > 0) {
                        io_u->resid = io_u->buflen - ret;
                        io_u->error = EIO;
diff --git a/io_u.c b/io_u.c
index 738f3e20101eee5e3535f1ff52fd344286c45745..45e8bb81ccc6e4dcfd7bbab57c781824c2d63161 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -229,6 +229,7 @@ struct io_u *__get_io_u(struct thread_data *td)
        if (!queue_full(td)) {
                io_u = list_entry(td->io_u_freelist.next, struct io_u, list);
 
+               io_u->buflen = 0;
                io_u->error = 0;
                io_u->resid = 0;
                list_del(&io_u->list);