The following changes since commit 0329ecda39a8ed42e173d25e16d39c968568d783: Merge branch 'master' of ssh://brick.kernel.dk/data/git/fio (2012-01-31 14:07:04 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Bruce Cran (1): windowsaio: fix file offset bug Jens Axboe (4): Grow file num_maps to unsigned long Fix bad types for mac blockdev_size() Keep reducing jobs on ENOMEM for shmget() windowsaio: style fixes engines/windowsaio.c | 60 ++++++++++++++++++++++++------------------------- file.h | 6 ++-- init.c | 2 +- os/os-mac.h | 14 +++++++---- 4 files changed, 42 insertions(+), 40 deletions(-) --- Diff of recent changes: diff --git a/engines/windowsaio.c b/engines/windowsaio.c index 78f7382..45d23d2 100644 --- a/engines/windowsaio.c +++ b/engines/windowsaio.c @@ -18,7 +18,7 @@ struct fio_overlapped { OVERLAPPED o; struct io_u *io_u; BOOL io_complete; - BOOL io_free; + BOOL io_free; }; struct windowsaio_data { @@ -127,15 +127,14 @@ static void fio_windowsaio_cleanup(struct thread_data *td) wd = td->io_ops->data; if (wd != NULL) { - wd->iothread_running = FALSE; - WaitForSingleObject(wd->iothread, INFINITE); + wd->iothread_running = FALSE; + WaitForSingleObject(wd->iothread, INFINITE); CloseHandle(wd->iothread); CloseHandle(wd->iocomplete_event); - for (i = 0; i < td->o.iodepth; i++) { + for (i = 0; i < td->o.iodepth; i++) CloseHandle(wd->ovls[i].o.hEvent); - } free(wd->aio_events); free(wd->ovls); @@ -196,13 +195,13 @@ static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f) /* Only set up the competion port and thread if we're not just * querying the device size */ - if (!rc && td->io_ops->data != NULL) { + if (!rc && td->io_ops->data != NULL) { struct thread_ctx *ctx; - struct windowsaio_data *wd; - hFile = CreateIoCompletionPort(f->hFile, NULL, 0, 0); + struct windowsaio_data *wd; - wd = td->io_ops->data; + hFile = CreateIoCompletionPort(f->hFile, NULL, 0, 0); + wd = td->io_ops->data; wd->iothread_running = TRUE; if (!rc) { @@ -223,7 +222,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) { @@ -281,7 +280,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, fov = (struct fio_overlapped*)io_u->engine_data; if (fov->io_complete) { - fov->io_complete = FALSE; + fov->io_complete = FALSE; fov->io_free = TRUE; wd->aio_events[dequeued] = io_u; dequeued++; @@ -291,7 +290,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, break; } - if (dequeued < min) { + if (dequeued < min) { status = WaitForSingleObject(wd->iocomplete_event, mswait); if (status != WAIT_OBJECT_0 && dequeued > 0) break; @@ -304,10 +303,9 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, return dequeued; } -static int fio_windowsaio_queue(struct thread_data *td, - struct io_u *io_u) +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,27 +316,26 @@ 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: + case DDIR_WRITE: success = WriteFile(io_u->file->hFile, io_u->xfer_buf, io_u->xfer_buflen, &iobytes, lpOvl); break; case DDIR_READ: @@ -363,9 +360,9 @@ static int fio_windowsaio_queue(struct thread_data *td, assert(0); } - if (success || GetLastError() == ERROR_IO_PENDING) { + if (success || GetLastError() == ERROR_IO_PENDING) rc = FIO_Q_QUEUED; - } else { + else { io_u->error = GetLastError(); io_u->resid = io_u->xfer_buflen; } @@ -402,7 +399,7 @@ static DWORD WINAPI IoCompletionRoutine(LPVOID lpParameter) io_u->error = ovl->Internal; } - fov->io_complete = TRUE; + fov->io_complete = TRUE; SetEvent(wd->iocomplete_event); } while (ctx->wd->iothread_running); @@ -421,6 +418,7 @@ static int fio_windowsaio_cancel(struct thread_data *td, /* If we're running on Vista or newer, we can cancel individual IO requests */ if (wd->pCancelIoEx != NULL) { struct fio_overlapped *ovl = io_u->engine_data; + if (!wd->pCancelIoEx(io_u->file->hFile, &ovl->o)) rc = 1; } else diff --git a/file.h b/file.h index b3ff051..67ef24f 100644 --- a/file.h +++ b/file.h @@ -107,9 +107,9 @@ struct fio_file { * block map for random io */ unsigned long *file_map; - unsigned int num_maps; - unsigned int last_free_lookup; - unsigned int failed_rands; + unsigned long num_maps; + unsigned long last_free_lookup; + unsigned failed_rands; int references; enum fio_file_flags flags; diff --git a/init.c b/init.c index 4a3716b..8dc5784 100644 --- a/init.c +++ b/init.c @@ -255,7 +255,7 @@ static int setup_thread_area(void) shm_id = shmget(0, size, IPC_CREAT | 0600); if (shm_id != -1) break; - if (errno != EINVAL) { + if (errno != EINVAL && errno != ENOMEM) { perror("shmget"); break; } diff --git a/os/os-mac.h b/os/os-mac.h index 80c49f4..9f19b8a 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -143,13 +143,17 @@ static inline int fio_set_odirect(int fd) static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) { - uint64_t temp = 1; - if (ioctl(f->fd, DKIOCGETBLOCKCOUNT, bytes) == -1) + uint32_t block_size; + uint64_t block_count; + + if (ioctl(f->fd, DKIOCGETBLOCKCOUNT, &block_count) == -1) return errno; - if (ioctl(f->fd, DKIOCGETBLOCKSIZE, &temp) == -1) + if (ioctl(f->fd, DKIOCGETBLOCKSIZE, &block_size) == -1) return errno; - (*bytes) *= temp; - return 0; + + *bytes = block_size; + *bytes *= block_count; + return 0; } static inline int chardev_size(struct fio_file *f, unsigned long long *bytes) -- To unsubscribe from this list: send the line "unsubscribe fio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html