[PATCH] Make ->buflen == 0 on SYNC io_u's
It eases the error handling in the splice and sync io engine.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/engines/fio-engine-splice.c b/engines/fio-engine-splice.c
index 3553d64..192fbd0 100644
--- a/engines/fio-engine-splice.c
+++ b/engines/fio-engine-splice.c
@@ -129,7 +129,7 @@
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 @@
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;
diff --git a/engines/fio-engine-sync.c b/engines/fio-engine-sync.c
index 8bc990d..43f42ca 100644
--- a/engines/fio-engine-sync.c
+++ b/engines/fio-engine-sync.c
@@ -57,7 +57,7 @@
{
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 @@
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 738f3e2..45e8bb8 100644
--- a/io_u.c
+++ b/io_u.c
@@ -229,6 +229,7 @@
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);