From 1e42cc3dc15b40b6f329a8f6fbe8c01af051556a Mon Sep 17 00:00:00 2001 From: Bruce Cran Date: Wed, 1 Feb 2012 21:46:55 +0100 Subject: [PATCH] windowsaio: fix file offset bug I was monitoring file IO while running fio today and noticed that the file offset when using windowsaio was always 0. Because the OVERLAPPED structure contains a union, by initializing Pointer to NULL the code was also overwriting the Offset field. I've attached a patch that fixes it. Signed-off-by: Jens Axboe --- engines/windowsaio.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/engines/windowsaio.c b/engines/windowsaio.c index 78f7382e..e97d176b 100644 --- a/engines/windowsaio.c +++ b/engines/windowsaio.c @@ -223,7 +223,7 @@ static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f) static int fio_windowsaio_close_file(struct thread_data fio_unused *td, struct fio_file *f) { int rc = 0; - + dprint(FD_FILE, "fd close %s\n", f->file_name); if (f->hFile != INVALID_HANDLE_VALUE) { @@ -307,7 +307,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, static int fio_windowsaio_queue(struct thread_data *td, struct io_u *io_u) { - LPOVERLAPPED lpOvl = NULL; + LPOVERLAPPED lpOvl = NULL; struct windowsaio_data *wd; DWORD iobytes; BOOL success; @@ -318,24 +318,23 @@ static int fio_windowsaio_queue(struct thread_data *td, wd = td->io_ops->data; - for (index = 0; index < td->o.iodepth; index++) { - if (wd->ovls[index].io_free) { - wd->ovls[index].io_free = FALSE; - ResetEvent(wd->ovls[index].o.hEvent); - break; - } - } + for (index = 0; index < td->o.iodepth; index++) { + if (wd->ovls[index].io_free) { + wd->ovls[index].io_free = FALSE; + ResetEvent(wd->ovls[index].o.hEvent); + break; + } + } - assert(index < td->o.iodepth); + assert(index < td->o.iodepth); - lpOvl = &wd->ovls[index].o; - wd->ovls[index].io_u = io_u; + lpOvl = &wd->ovls[index].o; + wd->ovls[index].io_u = io_u; lpOvl->Internal = STATUS_PENDING; lpOvl->InternalHigh = 0; lpOvl->Offset = io_u->offset & 0xFFFFFFFF; lpOvl->OffsetHigh = io_u->offset >> 32; - lpOvl->Pointer = NULL; - io_u->engine_data = &wd->ovls[index]; + io_u->engine_data = &wd->ovls[index]; switch (io_u->ddir) { case DDIR_WRITE: -- 2.25.1