Fix wrong accouning of zone bytes
authorJens Axboe <jens.axboe@oracle.com>
Thu, 31 Jan 2008 12:25:42 +0000 (13:25 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 31 Jan 2008 12:25:42 +0000 (13:25 +0100)
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>
io_u.c

diff --git a/io_u.c b/io_u.c
index 7890a87099c26f7d5802f9a0479e8ddc6d768bad..8201ccde751147c85c4b7605b7ef811fae0d6b49 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -375,6 +375,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u)
         * 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 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
 
                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;