[PATCH] Support residual io counts from io engines

We need this for requeuing support, the network engine makes this
pretty apparent (it's not unusual to see short tranfers there).

Basically we add an xfer_buf and xfer_buflen member to the io_u,
and these are the fields that the io engine MUST use. That allows
fio to increment and reset these appropriately, and simply requeue
the io_u for service of the next part of it.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.c b/fio.c
index bce13a7..127314e 100644
--- a/fio.c
+++ b/fio.c
@@ -406,11 +406,22 @@
 
 		memcpy(&s, &io_u->start_time, sizeof(s));
 
+requeue:
 		ret = td_io_queue(td, io_u);
 		if (ret) {
-			td_verror(td, io_u->error);
-			put_io_u(td, io_u);
-			break;
+			if (ret > 0 && (io_u->xfer_buflen != io_u->resid) &&
+			    io_u->resid) {
+				/*
+				 * short read/write. requeue.
+				 */
+				io_u->xfer_buflen = io_u->resid;
+				io_u->xfer_buf += ret;
+				goto requeue;
+			} else {
+				td_verror(td, io_u->error);
+				put_io_u(td, io_u);
+				break;
+			}
 		}
 
 		add_slat_sample(td, io_u->ddir, mtime_since(&io_u->start_time, &io_u->issue_time));