The following changes since commit dd8dd3de80910934d8d54325ad52b6d759a71095: Update the Windows installer (2013-02-04 13:50:51 +0100) are available in the git repository at: git://git.kernel.dk/fio.git master Bruce Cran (3): Fix copy/paste error in windowsaio register/unregister function names. windowsaio: fix file header format and improve error reporting. Add --build-32bit-win switch to configure --help output. Huadong Liu (1): Enable forced 32-bit build on Windows Jens Axboe (1): Makefile: fixup init.c dependency Makefile | 4 +- README | 3 ++ configure | 15 ++++++++- engines/windowsaio.c | 77 +++++++++++++++++++++++++++++++------------------- 4 files changed, 66 insertions(+), 33 deletions(-) --- Diff of recent changes: diff --git a/Makefile b/Makefile index a2d671d..d097c05 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ FIO-VERSION-FILE: FORCE override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' -.c.o: FORCE +.c.o: FORCE FIO-VERSION-FILE $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d @mv -f $*.d $*.d.tmp @@ -189,7 +189,7 @@ override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' sed -e 's/^ *//' -e 's/$$/:/' >> $*.d @rm -f $*.d.tmp -init.o: FIO-VERSION-FILE +init.o: FIO-VERSION-FILE init.c $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c t/stest: $(T_SMALLOC_OBJS) diff --git a/README b/README index 4c7b542..4173237 100644 --- a/README +++ b/README @@ -125,6 +125,9 @@ How to compile FIO on 64-bit Windows: 5. Run 'make clean'. 6. Run 'make'. +To build fio on 32-bit Windows, download x86/pthreadGC2.dll instead and do +'./configure --build-32bit-win=yes' before 'make'. + Command line ------------ diff --git a/configure b/configure index 078dab8..258c805 100755 --- a/configure +++ b/configure @@ -133,6 +133,8 @@ for opt do ;; --extra-cflags=*) CFLAGS="$CFLAGS $optarg" ;; + --build-32bit-win=*) build_32bit_win="$optarg" + ;; --help) show_help="yes" ;; @@ -146,6 +148,7 @@ done if test "$show_help" = "yes" ; then echo "--cc= Specify compiler to use" echo "--extra-cflags= Specify extra CFLAGS to pass to compiler" + echo "--build-32bit-win= Specify yes for a 32-bit build on Windows" exit $exit_val fi @@ -183,10 +186,18 @@ SunOS) CYGWIN*) echo "Forcing known good options on Windows" if test -z "$CC" ; then - CC="x86_64-w64-mingw32-gcc" + if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then + CC="i686-w64-mingw32-gcc" + else + CC="x86_64-w64-mingw32-gcc" + fi fi output_sym "CONFIG_LITTLE_ENDIAN" - output_sym "CONFIG_64BIT_LLP64" + if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then + output_sym "CONFIG_32BIT" + else + output_sym "CONFIG_64BIT_LLP64" + fi output_sym "CONFIG_FADVISE" output_sym "CONFIG_SOCKLEN_T" output_sym "CONFIG_POSIX_FALLOCATE" diff --git a/engines/windowsaio.c b/engines/windowsaio.c index 773f027..4a00794 100644 --- a/engines/windowsaio.c +++ b/engines/windowsaio.c @@ -1,6 +1,7 @@ /* - * Native Windows async IO engine - * Copyright (C) 2012 Bruce Cran <bruce@xxxxxxxxxxx> + * windowsaio engine + * + * IO engine using Windows IO Completion Ports. */ #include <stdio.h> @@ -37,13 +38,13 @@ struct thread_ctx { }; static int fio_windowsaio_cancel(struct thread_data *td, - struct io_u *io_u); + struct io_u *io_u); static BOOL timeout_expired(DWORD start_count, DWORD end_count); static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t); + unsigned int max, struct timespec *t); static struct io_u *fio_windowsaio_event(struct thread_data *td, int event); static int fio_windowsaio_queue(struct thread_data *td, - struct io_u *io_u); + struct io_u *io_u); static void fio_windowsaio_cleanup(struct thread_data *td); static DWORD WINAPI IoCompletionRoutine(LPVOID lpParameter); static int fio_windowsaio_init(struct thread_data *td); @@ -132,23 +133,27 @@ static int fio_windowsaio_init(struct thread_data *td) HANDLE hKernel32Dll; int rc = 0; - wd = malloc(sizeof(struct windowsaio_data)); - if (wd != NULL) - ZeroMemory(wd, sizeof(struct windowsaio_data)); - else + wd = calloc(1, sizeof(struct windowsaio_data)); + if (wd == NULL) { + log_err("windowsaio: failed to allocate memory for engine data\n"); rc = 1; + } if (!rc) { wd->aio_events = malloc(td->o.iodepth * sizeof(struct io_u*)); - if (wd->aio_events == NULL) + if (wd->aio_events == NULL) { + log_err("windowsaio: failed to allocate memory for aio events list\n"); rc = 1; + } } if (!rc) { /* Create an auto-reset event */ wd->iocomplete_event = CreateEvent(NULL, FALSE, FALSE, NULL); - if (wd->iocomplete_event == NULL) + if (wd->iocomplete_event == NULL) { + log_err("windowsaio: failed to create io complete event handle\n"); rc = 1; + } } if (rc) { @@ -164,15 +169,16 @@ static int fio_windowsaio_init(struct thread_data *td) wd->pCancelIoEx = (CANCELIOEX)GetProcAddress(hKernel32Dll, "CancelIoEx"); td->io_ops->data = wd; - if (!rc) { struct thread_ctx *ctx; struct windowsaio_data *wd; HANDLE hFile; hFile = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); - if (hFile == INVALID_HANDLE_VALUE) + if (hFile == INVALID_HANDLE_VALUE) { + log_err("windowsaio: failed to create io completion port\n"); rc = 1; + } wd = td->io_ops->data; wd->iothread_running = TRUE; @@ -183,7 +189,7 @@ static int fio_windowsaio_init(struct thread_data *td) if (!rc && ctx == NULL) { - log_err("fio: out of memory in windowsaio\n"); + log_err("windowsaio: failed to allocate memory for thread context structure\n"); CloseHandle(hFile); rc = 1; } @@ -193,6 +199,8 @@ static int fio_windowsaio_init(struct thread_data *td) ctx->iocp = hFile; ctx->wd = wd; wd->iothread = CreateThread(NULL, 0, IoCompletionRoutine, ctx, 0, NULL); + if (wd->iothread == NULL) + log_err("windowsaio: failed to create io completion thread\n"); } if (rc || wd->iothread == NULL) @@ -234,12 +242,12 @@ static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f) dprint(FD_FILE, "fd open %s\n", f->file_name); if (f->filetype == FIO_TYPE_PIPE) { - log_err("fio: windowsaio doesn't support pipes\n"); + log_err("windowsaio: pipes are not supported\n"); return 1; } if (!strcmp(f->file_name, "-")) { - log_err("fio: can't read/write to stdin/out\n"); + log_err("windowsaio: can't read/write to stdin/out\n"); return 1; } @@ -271,8 +279,10 @@ static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f) f->hFile = CreateFile(f->file_name, access, sharemode, NULL, openmode, flags, NULL); - if (f->hFile == INVALID_HANDLE_VALUE) + if (f->hFile == INVALID_HANDLE_VALUE) { + log_err("windowsaio: failed to open file \"%s\"\n", f->file_name); rc = 1; + } /* Only set up the completion port and thread if we're not just * querying the device size */ @@ -281,8 +291,10 @@ static int fio_windowsaio_open_file(struct thread_data *td, struct fio_file *f) wd = td->io_ops->data; - if (CreateIoCompletionPort(f->hFile, wd->iocp, 0, 0) == NULL) + if (CreateIoCompletionPort(f->hFile, wd->iocp, 0, 0) == NULL) { + log_err("windowsaio: failed to create io completion port\n"); rc = 1; + } } return rc; @@ -295,8 +307,10 @@ static int fio_windowsaio_close_file(struct thread_data fio_unused *td, struct f dprint(FD_FILE, "fd close %s\n", f->file_name); if (f->hFile != INVALID_HANDLE_VALUE) { - if (!CloseHandle(f->hFile)) + if (!CloseHandle(f->hFile)) { + log_info("windowsaio: failed to close file handle for \"%s\"\n", f->file_name); rc = 1; + } } f->hFile = INVALID_HANDLE_VALUE; @@ -325,7 +339,7 @@ static struct io_u* fio_windowsaio_event(struct thread_data *td, int event) } static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, - unsigned int max, struct timespec *t) + unsigned int max, struct timespec *t) { struct windowsaio_data *wd = td->io_ops->data; struct flist_head *entry; @@ -362,7 +376,7 @@ static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min, if (dequeued < min) { status = WaitForSingleObject(wd->iocomplete_event, mswait); if (status != WAIT_OBJECT_0 && dequeued >= min) - break; + break; } if (dequeued >= min || (t != NULL && timeout_expired(start_count, end_count))) @@ -398,13 +412,15 @@ static int fio_windowsaio_queue(struct thread_data *td, struct io_u *io_u) case DDIR_DATASYNC: case DDIR_SYNC_FILE_RANGE: success = FlushFileBuffers(io_u->file->hFile); - if (!success) - io_u->error = win_to_posix_error(GetLastError()); + if (!success) { + log_err("windowsaio: failed to flush file buffers\n"); + io_u->error = win_to_posix_error(GetLastError()); + } return FIO_Q_COMPLETED; break; case DDIR_TRIM: - log_err("manual TRIM isn't supported on Windows"); + log_err("windowsaio: manual TRIM isn't supported on Windows\n"); io_u->error = 1; io_u->resid = io_u->xfer_buflen; return FIO_Q_COMPLETED; @@ -463,7 +479,7 @@ static DWORD WINAPI IoCompletionRoutine(LPVOID lpParameter) } static int fio_windowsaio_cancel(struct thread_data *td, - struct io_u *io_u) + struct io_u *io_u) { int rc = 0; @@ -473,8 +489,10 @@ static int fio_windowsaio_cancel(struct thread_data *td, if (wd->pCancelIoEx != NULL) { struct fio_overlapped *ovl = io_u->engine_data; - if (!wd->pCancelIoEx(io_u->file->hFile, &ovl->o)) + if (!wd->pCancelIoEx(io_u->file->hFile, &ovl->o)) { + log_err("windowsaio: failed to cancel io\n"); rc = 1; + } } else rc = 1; @@ -500,7 +518,8 @@ static int fio_windowsaio_io_u_init(struct thread_data *td, struct io_u *io_u) o->io_complete = FALSE; o->io_u = io_u; o->o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - if (!o->o.hEvent) { + if (o->o.hEvent == NULL) { + log_err("windowsaio: failed to create event handle\n"); free(o); return 1; } @@ -525,12 +544,12 @@ static struct ioengine_ops ioengine = { .io_u_free = fio_windowsaio_io_u_free, }; -static void fio_init fio_posixaio_register(void) +static void fio_init fio_windowsaio_register(void) { register_ioengine(&ioengine); } -static void fio_exit fio_posixaio_unregister(void) +static void fio_exit fio_windowsaio_unregister(void) { unregister_ioengine(&ioengine); } -- 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