Fix wrong accouning of zone bytes

Ryan Thomas <Ryan.Thomas@nuance.com> writes:

**********

With the following job description

[global]
bs=1k
direct=1
rw=read
ioengine=libaio
iodepth=2
zonesize=1k
zoneskip=1023k
write_bw_log

[/dev/cciss/c0d1]
write_iolog=foo2

The idea here is that I wanted to line up my zones to start at 1M
boundaries across the disk by writing 1k and skipping the next 1023k.
In practice I don't get the alignment because of an extra initial I/O.
I get an iolog that looks like

fio version 2 iolog
/dev/cciss/c0d1 add
/dev/cciss/c0d1 open
/dev/cciss/c0d1 read 0 1024
/dev/cciss/c0d1 read 1024 1024
/dev/cciss/c0d1 read 1049600 1024
/dev/cciss/c0d1 read 2098176 1024

There's a read that I don't expect in that log, namely the read starting
at byte 1024.  Because that read is there, the disk zones get offset by
one block.  I expected output like

fio version 2 iolog
/dev/cciss/c0d1 add
/dev/cciss/c0d1 open
/dev/cciss/c0d1 read 0 1024
/dev/cciss/c0d1 read 1048576 1024
/dev/cciss/c0d1 read 2097152 1024
/dev/cciss/c0d1 read 3145728 1024

***********

The problem is due to the fact that fio account zone_bytes when the IO
completes, which is clearly not correct for io depth > 1. So move the
accounting to when we fill the io_u instead.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/io_u.c b/io_u.c
index 7890a87..8201ccd 100644
--- a/io_u.c
+++ b/io_u.c
@@ -375,6 +375,7 @@
 	 * If using a write iolog, store this entry.
 	 */
 out:
+	td->zone_bytes += io_u->buflen;
 	log_io_u(td, io_u);
 	return 0;
 }
@@ -765,7 +766,6 @@
 
 		td->io_blocks[idx]++;
 		td->io_bytes[idx] += bytes;
-		td->zone_bytes += bytes;
 		td->this_io_bytes[idx] += bytes;
 
 		io_u->file->last_completed_pos = io_u->endpos;