Merge branch 'epoch-time-hist-logs' of https://github.com/parallel-fs-utils/fio
authorJens Axboe <axboe@kernel.dk>
Wed, 19 Sep 2018 15:42:47 +0000 (09:42 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 19 Sep 2018 15:42:47 +0000 (09:42 -0600)
* 'epoch-time-hist-logs' of https://github.com/parallel-fs-utils/fio:
  raise exception if test start time can't be estimated
  handle log_unix_epoch=1

38 files changed:
FIO-VERSION-GEN
Makefile
backend.c
client.c
client.h
configure
engines/fusion-aw.c [deleted file]
examples/fio-rand-RW.fio [new file with mode: 0644]
examples/fio-rand-RW.job [deleted file]
examples/fio-rand-read.fio [new file with mode: 0644]
examples/fio-rand-read.job [deleted file]
examples/fio-rand-write.fio [new file with mode: 0644]
examples/fio-rand-write.job [deleted file]
examples/fio-seq-RW.fio [new file with mode: 0644]
examples/fio-seq-RW.job [deleted file]
examples/fio-seq-read.fio [new file with mode: 0644]
examples/fio-seq-read.job [deleted file]
examples/fio-seq-write.fio [new file with mode: 0644]
examples/fio-seq-write.job [deleted file]
examples/fusion-aw-sync.fio [deleted file]
filesetup.c
init.c
iolog.c
lib/axmap.c
lib/axmap.h
lib/lfsr.c
lib/num2str.c
lib/zipf.c
lib/zipf.h
options.c
os/windows/examples.wxs
os/windows/posix.c
rate-submit.c
stat.c
t/axmap.c
t/jobs/t0010-b7aae4ba.fio [new file with mode: 0644]
tools/hist/fio-histo-log-pctiles.py
zbd.c

index f0315948bf9476277650f78a22011b08cc33bef7..f1d25d0b76057317b89d4f1760bfb836bda39e1a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=FIO-VERSION-FILE
-DEF_VER=fio-3.9
+DEF_VER=fio-3.10
 
 LF='
 '
index 7e87b2fd6c1eca0cdfce8881e631b753e492787f..4721b789be273ec70fdbc50f567c2bab771cddf0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -86,9 +86,6 @@ endif
 ifdef CONFIG_GUASI
   SOURCE += engines/guasi.c
 endif
-ifdef CONFIG_FUSION_AW
-  SOURCE += engines/fusion-aw.c
-endif
 ifdef CONFIG_SOLARISAIO
   SOURCE += engines/solarisaio.c
 endif
@@ -201,7 +198,7 @@ endif
 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
   SOURCE += os/windows/posix.c
   LIBS  += -lpthread -lpsapi -lws2_32
-  CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
+  CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
 endif
 
 OBJS := $(SOURCE:.c=.o)
index 8fec1ce3141f4f5b3f910784c75f5f6a200c88d9..bb8bd13bd11f973e616fd3897483e27ec833cbc5 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -2213,18 +2213,22 @@ static void run_threads(struct sk_out *sk_out)
        }
 
        if (output_format & FIO_OUTPUT_NORMAL) {
-               log_info("Starting ");
+               struct buf_output out;
+
+               buf_output_init(&out);
+               __log_buf(&out, "Starting ");
                if (nr_thread)
-                       log_info("%d thread%s", nr_thread,
+                       __log_buf(&out, "%d thread%s", nr_thread,
                                                nr_thread > 1 ? "s" : "");
                if (nr_process) {
                        if (nr_thread)
-                               log_info(" and ");
-                       log_info("%d process%s", nr_process,
+                               __log_buf(&out, " and ");
+                       __log_buf(&out, "%d process%s", nr_process,
                                                nr_process > 1 ? "es" : "");
                }
-               log_info("\n");
-               log_info_flush();
+               __log_buf(&out, "\n");
+               log_info_buf(out.buf, out.buflen);
+               buf_output_free(&out);
        }
 
        todo = thread_number;
index 31c7c6495790e91018cface694803ff9bfcefa1e..3248906756db77d9586fb2a71513943c9e57b0b6 100644 (file)
--- a/client.c
+++ b/client.c
@@ -198,14 +198,23 @@ static void fio_client_json_init(void)
 
 static void fio_client_json_fini(void)
 {
-       if (!(output_format & FIO_OUTPUT_JSON))
+       struct buf_output out;
+
+       if (!root)
                return;
 
-       log_info("\n");
-       json_print_object(root, NULL);
-       log_info("\n");
+       buf_output_init(&out);
+
+       __log_buf(&out, "\n");
+       json_print_object(root, &out);
+       __log_buf(&out, "\n");
+       log_info_buf(out.buf, out.buflen);
+
+       buf_output_free(&out);
+
        json_free_object(root);
        root = NULL;
+       job_opt_object = NULL;
        clients_array = NULL;
        du_array = NULL;
 }
@@ -233,6 +242,9 @@ void fio_put_client(struct fio_client *client)
        if (--client->refs)
                return;
 
+       log_info_buf(client->buf.buf, client->buf.buflen);
+       buf_output_free(&client->buf);
+
        free(client->hostname);
        if (client->argv)
                free(client->argv);
@@ -351,9 +363,7 @@ void fio_client_add_cmd_option(void *cookie, const char *opt)
        }
 }
 
-struct fio_client *fio_client_add_explicit(struct client_ops *ops,
-                                          const char *hostname, int type,
-                                          int port)
+static struct fio_client *get_new_client(void)
 {
        struct fio_client *client;
 
@@ -366,6 +376,19 @@ struct fio_client *fio_client_add_explicit(struct client_ops *ops,
        INIT_FLIST_HEAD(&client->eta_list);
        INIT_FLIST_HEAD(&client->cmd_list);
 
+       buf_output_init(&client->buf);
+
+       return client;
+}
+
+struct fio_client *fio_client_add_explicit(struct client_ops *ops,
+                                          const char *hostname, int type,
+                                          int port)
+{
+       struct fio_client *client;
+
+       client = get_new_client();
+
        client->hostname = strdup(hostname);
 
        if (type == Fio_client_socket)
@@ -441,14 +464,7 @@ int fio_client_add(struct client_ops *ops, const char *hostname, void **cookie)
                }
        }
 
-       client = malloc(sizeof(*client));
-       memset(client, 0, sizeof(*client));
-
-       INIT_FLIST_HEAD(&client->list);
-       INIT_FLIST_HEAD(&client->hash_list);
-       INIT_FLIST_HEAD(&client->arg_list);
-       INIT_FLIST_HEAD(&client->eta_list);
-       INIT_FLIST_HEAD(&client->cmd_list);
+       client = get_new_client();
 
        if (fio_server_parse_string(hostname, &client->hostname,
                                        &client->is_sock, &client->port,
@@ -1059,13 +1075,10 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd)
        struct flist_head *opt_list = NULL;
        struct json_object *tsobj;
 
-       if (output_format & FIO_OUTPUT_TERSE)
-               return;
-
        if (client->opt_lists && p->ts.thread_number <= client->jobs)
                opt_list = &client->opt_lists[p->ts.thread_number - 1];
 
-       tsobj = show_thread_status(&p->ts, &p->rs, opt_list, NULL);
+       tsobj = show_thread_status(&p->ts, &p->rs, opt_list, &client->buf);
        client->did_stat = true;
        if (tsobj) {
                json_object_add_client_info(tsobj, client);
@@ -1086,7 +1099,7 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd)
 
        if (++sum_stat_nr == sum_stat_clients) {
                strcpy(client_ts.name, "All clients");
-               tsobj = show_thread_status(&client_ts, &client_gs, NULL, NULL);
+               tsobj = show_thread_status(&client_ts, &client_gs, NULL, &client->buf);
                if (tsobj) {
                        json_object_add_client_info(tsobj, client);
                        json_array_add_value_object(clients_array, tsobj);
@@ -1098,11 +1111,8 @@ static void handle_gs(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct group_run_stats *gs = (struct group_run_stats *) cmd->payload;
 
-       if (output_format & FIO_OUTPUT_TERSE)
-               return;
-
        if (output_format & FIO_OUTPUT_NORMAL)
-               show_group_stats(gs, NULL);
+               show_group_stats(gs, &client->buf);
 }
 
 static void handle_job_opt(struct fio_client *client, struct fio_net_cmd *cmd)
@@ -1144,13 +1154,17 @@ static void handle_text(struct fio_client *client, struct fio_net_cmd *cmd)
        const char *buf = (const char *) pdu->buf;
        const char *name;
        int fio_unused ret;
+       struct buf_output out;
+
+       buf_output_init(&out);
 
        name = client->name ? client->name : client->hostname;
 
        if (!client->skip_newline && !(output_format & FIO_OUTPUT_TERSE))
-               fprintf(f_out, "<%s> ", name);
-       ret = fwrite(buf, pdu->buf_len, 1, f_out);
-       fflush(f_out);
+               __log_buf(&out, "<%s> ", name);
+       __log_buf(&out, "%s", buf);
+       log_info_buf(out.buf, out.buflen);
+       buf_output_free(&out);
        client->skip_newline = strchr(buf, '\n') == NULL;
 }
 
@@ -1191,23 +1205,21 @@ static void handle_du(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_du_pdu *du = (struct cmd_du_pdu *) cmd->payload;
 
-       if (output_format & FIO_OUTPUT_TERSE)
-               return;
-
-       if (!client->disk_stats_shown) {
+       if (!client->disk_stats_shown)
                client->disk_stats_shown = true;
-               if (!(output_format & FIO_OUTPUT_JSON))
-                       log_info("\nDisk stats (read/write):\n");
-       }
 
        if (output_format & FIO_OUTPUT_JSON) {
                struct json_object *duobj;
+
                json_array_add_disk_util(&du->dus, &du->agg, du_array);
                duobj = json_array_last_value_object(du_array);
                json_object_add_client_info(duobj, client);
+       } else if (output_format & FIO_OUTPUT_TERSE)
+               print_disk_util(&du->dus, &du->agg, 1, &client->buf);
+       else if (output_format & FIO_OUTPUT_NORMAL) {
+               __log_buf(&client->buf, "\nDisk stats (read/write):\n");
+               print_disk_util(&du->dus, &du->agg, 0, &client->buf);
        }
-       if (output_format & FIO_OUTPUT_NORMAL)
-               print_disk_util(&du->dus, &du->agg, 0, NULL);
 }
 
 static void convert_jobs_eta(struct jobs_eta *je)
@@ -1465,9 +1477,6 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
        const char *os, *arch;
        char bit[16];
 
-       if (output_format & FIO_OUTPUT_TERSE)
-               return;
-
        os = fio_get_os_string(probe->os);
        if (!os)
                os = "unknown";
@@ -1479,10 +1488,11 @@ static void handle_probe(struct fio_client *client, struct fio_net_cmd *cmd)
        sprintf(bit, "%d-bit", probe->bpp * 8);
        probe->flags = le64_to_cpu(probe->flags);
 
-       if (!(output_format & FIO_OUTPUT_JSON))
+       if (output_format & FIO_OUTPUT_NORMAL) {
                log_info("hostname=%s, be=%u, %s, os=%s, arch=%s, fio=%s, flags=%lx\n",
                        probe->hostname, probe->bigendian, bit, os, arch,
                        probe->fio_version, (unsigned long) probe->flags);
+       }
 
        if (!client->name)
                client->name = strdup((char *) probe->hostname);
index a597449dcbb218cff12dc36da09001e9bd5bc084..8033325ed0a94371643cb5ebf8c1f69b029e8889 100644 (file)
--- a/client.h
+++ b/client.h
@@ -74,6 +74,8 @@ struct fio_client {
 
        struct client_file *files;
        unsigned int nr_files;
+
+       struct buf_output buf;
 };
 
 typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
index 5e11195d60b66cb003d7e5eeff6d7a0ed7355299..5490e26ea70f2db55f86c2e49ec2f9f362568767 100755 (executable)
--- a/configure
+++ b/configure
@@ -361,6 +361,7 @@ CYGWIN*)
   output_sym "CONFIG_WINDOWSAIO"
   # We now take the regular configuration path without having exit 0 here.
   # Flags below are still necessary mostly for MinGW.
+  build_static="yes"
   socklen_t="yes"
   rusage_thread="yes"
   fdatasync="yes"
@@ -1148,28 +1149,6 @@ if compile_prog "" "" "guasi"; then
 fi
 print_config "GUASI" "$guasi"
 
-##########################################
-# fusion-aw probe
-if test "$fusion_aw" != "yes" ; then
-  fusion_aw="no"
-fi
-cat > $TMPC << EOF
-#include <nvm/nvm_primitives.h>
-int main(int argc, char **argv)
-{
-  nvm_version_t ver_info;
-  nvm_handle_t handle;
-
-  handle = nvm_get_handle(0, &ver_info);
-  return nvm_atomic_write(handle, 0, 0, 0);
-}
-EOF
-if compile_prog "" "-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread" "fusion-aw"; then
-  LIBS="-L/usr/lib/fio -L/usr/lib/nvm -lnvm-primitives -ldl -lpthread $LIBS"
-  fusion_aw="yes"
-fi
-print_config "Fusion-io atomic engine" "$fusion_aw"
-
 ##########################################
 # libnuma probe
 if test "$libnuma" != "yes" ; then
@@ -2405,9 +2384,6 @@ fi
 if test "$guasi" = "yes" ; then
   output_sym "CONFIG_GUASI"
 fi
-if test "$fusion_aw" = "yes" ; then
-  output_sym "CONFIG_FUSION_AW"
-fi
 if test "$libnuma_v2" = "yes" ; then
   output_sym "CONFIG_LIBNUMA"
 fi
diff --git a/engines/fusion-aw.c b/engines/fusion-aw.c
deleted file mode 100644 (file)
index eb5fdf5..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Custom fio(1) engine that submits synchronous atomic writes to file.
- *
- * Copyright (C) 2013 Fusion-io, Inc.
- * Author: Santhosh Kumar Koundinya (skoundinya@fusionio.com).
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; under version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version
- * 2 for more details.
- *
- * You should have received a copy of the GNU General Public License Version 2
- * along with this program; if not see <http://www.gnu.org/licenses/>
- */
-
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "../fio.h"
-
-#include <nvm/nvm_primitives.h>
-
-#define NUM_ATOMIC_CAPABILITIES (5)
-
-struct fas_data {
-       nvm_handle_t nvm_handle;
-       size_t xfer_buf_align;
-       size_t xfer_buflen_align;
-       size_t xfer_buflen_max;
-       size_t sector_size;
-};
-
-static enum fio_q_status queue(struct thread_data *td, struct io_u *io_u)
-{
-       struct fas_data *d = FILE_ENG_DATA(io_u->file);
-       int rc;
-
-       if (io_u->ddir != DDIR_WRITE) {
-               td_vmsg(td, EINVAL, "only writes supported", "io_u->ddir");
-               rc = -EINVAL;
-               goto out;
-       }
-
-       if ((size_t) io_u->xfer_buf % d->xfer_buf_align) {
-               td_vmsg(td, EINVAL, "unaligned data buffer", "io_u->xfer_buf");
-               rc = -EINVAL;
-               goto out;
-       }
-
-       if (io_u->xfer_buflen % d->xfer_buflen_align) {
-               td_vmsg(td, EINVAL, "unaligned data size", "io_u->xfer_buflen");
-               rc = -EINVAL;
-               goto out;
-       }
-
-       if (io_u->xfer_buflen > d->xfer_buflen_max) {
-               td_vmsg(td, EINVAL, "data too big", "io_u->xfer_buflen");
-               rc = -EINVAL;
-               goto out;
-       }
-
-       rc = nvm_atomic_write(d->nvm_handle, (uint64_t) io_u->xfer_buf,
-               io_u->xfer_buflen, io_u->offset / d->sector_size);
-       if (rc == -1) {
-               td_verror(td, errno, "nvm_atomic_write");
-               rc = -errno;
-               goto out;
-       }
-       rc = FIO_Q_COMPLETED;
-out:
-       if (rc < 0)
-               io_u->error = -rc;
-
-       return rc;
-}
-
-static int open_file(struct thread_data *td, struct fio_file *f)
-{
-       int rc;
-       int fio_unused close_file_rc;
-       struct fas_data *d;
-       nvm_version_t nvm_version;
-       nvm_capability_t nvm_capability[NUM_ATOMIC_CAPABILITIES];
-
-
-       d = malloc(sizeof(*d));
-       if (!d) {
-               td_verror(td, ENOMEM, "malloc");
-               rc = ENOMEM;
-               goto error;
-       }
-       d->nvm_handle = -1;
-       FILE_SET_ENG_DATA(f, d);
-
-       rc = generic_open_file(td, f);
-
-       if (rc)
-               goto free_engine_data;
-
-       /* Set the version of the library as seen when engine is compiled */
-       nvm_version.major = NVM_PRIMITIVES_API_MAJOR;
-       nvm_version.minor = NVM_PRIMITIVES_API_MINOR;
-       nvm_version.micro = NVM_PRIMITIVES_API_MICRO;
-
-       d->nvm_handle = nvm_get_handle(f->fd, &nvm_version);
-       if (d->nvm_handle == -1) {
-               td_vmsg(td, errno, "nvm_get_handle failed", "nvm_get_handle");
-               rc = errno;
-               goto close_file;
-       }
-
-       nvm_capability[0].cap_id = NVM_CAP_ATOMIC_WRITE_START_ALIGN_ID;
-       nvm_capability[1].cap_id = NVM_CAP_ATOMIC_WRITE_MULTIPLICITY_ID;
-       nvm_capability[2].cap_id = NVM_CAP_ATOMIC_WRITE_MAX_VECTOR_SIZE_ID;
-       nvm_capability[3].cap_id = NVM_CAP_SECTOR_SIZE_ID;
-       nvm_capability[4].cap_id = NVM_CAP_ATOMIC_MAX_IOV_ID;
-       rc = nvm_get_capabilities(d->nvm_handle, nvm_capability,
-                                  NUM_ATOMIC_CAPABILITIES, false);
-       if (rc == -1) {
-               td_vmsg(td, errno, "error in getting atomic write capabilities", "nvm_get_capabilities");
-               rc = errno;
-               goto close_file;
-       } else if (rc < NUM_ATOMIC_CAPABILITIES) {
-               td_vmsg(td, EINVAL, "couldn't get all the atomic write capabilities" , "nvm_get_capabilities");
-               rc = ECANCELED;
-               goto close_file;
-       }
-       /* Reset rc to 0 because we got all capabilities we needed */
-       rc = 0;
-       d->xfer_buf_align = nvm_capability[0].cap_value;
-       d->xfer_buflen_align = nvm_capability[1].cap_value;
-       d->xfer_buflen_max = d->xfer_buflen_align * nvm_capability[2].cap_value * nvm_capability[4].cap_value;
-       d->sector_size = nvm_capability[3].cap_value;
-
-out:
-       return rc;
-close_file:
-       close_file_rc = generic_close_file(td, f);
-free_engine_data:
-       free(d);
-error:
-       f->fd = -1;
-       FILE_SET_ENG_DATA(f, NULL);
-       goto out;
-}
-
-static int close_file(struct thread_data *td, struct fio_file *f)
-{
-       struct fas_data *d = FILE_ENG_DATA(f);
-
-       if (d) {
-               if (d->nvm_handle != -1)
-                       nvm_release_handle(d->nvm_handle);
-               free(d);
-               FILE_SET_ENG_DATA(f, NULL);
-       }
-
-       return generic_close_file(td, f);
-}
-
-static struct ioengine_ops ioengine = {
-       .name = "fusion-aw-sync",
-       .version = FIO_IOOPS_VERSION,
-       .queue = queue,
-       .open_file = open_file,
-       .close_file = close_file,
-       .get_file_size = generic_get_file_size,
-       .flags = FIO_SYNCIO | FIO_RAWIO | FIO_MEMALIGN
-};
-
-static void fio_init fio_fusion_aw_init(void)
-{
-       register_ioengine(&ioengine);
-}
-
-static void fio_exit fio_fusion_aw_exit(void)
-{
-       unregister_ioengine(&ioengine);
-}
diff --git a/examples/fio-rand-RW.fio b/examples/fio-rand-RW.fio
new file mode 100644 (file)
index 0000000..0df0bc1
--- /dev/null
@@ -0,0 +1,18 @@
+; fio-rand-RW.job for fiotest
+
+[global]
+name=fio-rand-RW
+filename=fio-rand-RW
+rw=randrw
+rwmixread=60
+rwmixwrite=40
+bs=4K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-rand-RW.job b/examples/fio-rand-RW.job
deleted file mode 100644 (file)
index 0df0bc1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-; fio-rand-RW.job for fiotest
-
-[global]
-name=fio-rand-RW
-filename=fio-rand-RW
-rw=randrw
-rwmixread=60
-rwmixwrite=40
-bs=4K
-direct=0
-numjobs=4
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fio-rand-read.fio b/examples/fio-rand-read.fio
new file mode 100644 (file)
index 0000000..bc15466
--- /dev/null
@@ -0,0 +1,16 @@
+; fio-rand-read.job for fiotest
+
+[global]
+name=fio-rand-read
+filename=fio-rand-read
+rw=randread
+bs=4K
+direct=0
+numjobs=1
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-rand-read.job b/examples/fio-rand-read.job
deleted file mode 100644 (file)
index bc15466..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-; fio-rand-read.job for fiotest
-
-[global]
-name=fio-rand-read
-filename=fio-rand-read
-rw=randread
-bs=4K
-direct=0
-numjobs=1
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fio-rand-write.fio b/examples/fio-rand-write.fio
new file mode 100644 (file)
index 0000000..bd1b73a
--- /dev/null
@@ -0,0 +1,16 @@
+; fio-rand-write.job for fiotest
+
+[global]
+name=fio-rand-write
+filename=fio-rand-write
+rw=randwrite
+bs=4K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-rand-write.job b/examples/fio-rand-write.job
deleted file mode 100644 (file)
index bd1b73a..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-; fio-rand-write.job for fiotest
-
-[global]
-name=fio-rand-write
-filename=fio-rand-write
-rw=randwrite
-bs=4K
-direct=0
-numjobs=4
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fio-seq-RW.fio b/examples/fio-seq-RW.fio
new file mode 100644 (file)
index 0000000..8f7090f
--- /dev/null
@@ -0,0 +1,18 @@
+; fio-seq-RW.job for fiotest
+
+[global]
+name=fio-seq-RW
+filename=fio-seq-RW
+rw=rw
+rwmixread=60
+rwmixwrite=40
+bs=256K
+direct=0
+numjobs=4
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-seq-RW.job b/examples/fio-seq-RW.job
deleted file mode 100644 (file)
index 8f7090f..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-; fio-seq-RW.job for fiotest
-
-[global]
-name=fio-seq-RW
-filename=fio-seq-RW
-rw=rw
-rwmixread=60
-rwmixwrite=40
-bs=256K
-direct=0
-numjobs=4
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fio-seq-read.fio b/examples/fio-seq-read.fio
new file mode 100644 (file)
index 0000000..28de93c
--- /dev/null
@@ -0,0 +1,14 @@
+[global]
+name=fio-seq-reads
+filename=fio-seq-reads
+rw=read
+bs=256K
+direct=1
+numjobs=1
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-seq-read.job b/examples/fio-seq-read.job
deleted file mode 100644 (file)
index 28de93c..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[global]
-name=fio-seq-reads
-filename=fio-seq-reads
-rw=read
-bs=256K
-direct=1
-numjobs=1
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fio-seq-write.fio b/examples/fio-seq-write.fio
new file mode 100644 (file)
index 0000000..b291a15
--- /dev/null
@@ -0,0 +1,16 @@
+; fio-seq-write.job for fiotest
+
+[global]
+name=fio-seq-write
+filename=fio-seq-write
+rw=write
+bs=256K
+direct=0
+numjobs=1
+time_based=1
+runtime=900
+
+[file1]
+size=10G
+ioengine=libaio
+iodepth=16
diff --git a/examples/fio-seq-write.job b/examples/fio-seq-write.job
deleted file mode 100644 (file)
index b291a15..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-; fio-seq-write.job for fiotest
-
-[global]
-name=fio-seq-write
-filename=fio-seq-write
-rw=write
-bs=256K
-direct=0
-numjobs=1
-time_based=1
-runtime=900
-
-[file1]
-size=10G
-ioengine=libaio
-iodepth=16
diff --git a/examples/fusion-aw-sync.fio b/examples/fusion-aw-sync.fio
deleted file mode 100644 (file)
index f2ca313..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# Example Job File that randomly writes 8k worth of data atomically for
-# 60 seconds.
-[rw_aw_file_sync]
-rw=randwrite
-ioengine=fusion-aw-sync
-blocksize=8k
-blockalign=8k
-
-# if file system supports atomic write
-filename=/mnt/fs/file
-# or test on a direct block device instead
-#filename=/dev/fioa
-randrepeat=1
-fallocate=none
-direct=1
-invalidate=0
-runtime=60
-time_based
index 580403dbc232aa8676d2a3933c3eac4a5f7e31a5..c0fa3cdae882b0a738dce77c07a585616c31e937 100644 (file)
@@ -331,7 +331,7 @@ unsigned long long get_rand_file_size(struct thread_data *td)
 {
        unsigned long long ret, sized;
        uint64_t frand_max;
-       unsigned long r;
+       uint64_t r;
 
        frand_max = rand_max(&td->file_size_state);
        r = __rand(&td->file_size_state);
@@ -1192,13 +1192,13 @@ bool pre_read_files(struct thread_data *td)
 static void __init_rand_distribution(struct thread_data *td, struct fio_file *f)
 {
        unsigned int range_size, seed;
-       unsigned long nranges;
+       uint64_t nranges;
        uint64_t fsize;
 
        range_size = min(td->o.min_bs[DDIR_READ], td->o.min_bs[DDIR_WRITE]);
        fsize = min(f->real_file_size, f->io_size);
 
-       nranges = (fsize + range_size - 1) / range_size;
+       nranges = (fsize + range_size - 1ULL) / range_size;
 
        seed = jhash(f->file_name, strlen(f->file_name), 0) * td->thread_number;
        if (!td->o.rand_repeatable)
diff --git a/init.c b/init.c
index 09f58a3538d4c4b28974bfc64b384ab111420e19..c235b05e192584073f0792253a733fd16b59aabb 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1681,6 +1681,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                                char *c1, *c2, *c3, *c4;
                                char *c5 = NULL, *c6 = NULL;
                                int i2p = is_power_of_2(o->kb_base);
+                               struct buf_output out;
 
                                c1 = num2str(o->min_bs[DDIR_READ], o->sig_figs, 1, i2p, N2S_BYTE);
                                c2 = num2str(o->max_bs[DDIR_READ], o->sig_figs, 1, i2p, N2S_BYTE);
@@ -1692,19 +1693,22 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                                        c6 = num2str(o->max_bs[DDIR_TRIM], o->sig_figs, 1, i2p, N2S_BYTE);
                                }
 
-                               log_info("%s: (g=%d): rw=%s, ", td->o.name,
+                               buf_output_init(&out);
+                               __log_buf(&out, "%s: (g=%d): rw=%s, ", td->o.name,
                                                        td->groupid,
                                                        ddir_str(o->td_ddir));
 
                                if (o->bs_is_seq_rand)
-                                       log_info("bs=(R) %s-%s, (W) %s-%s, bs_is_seq_rand, ",
+                                       __log_buf(&out, "bs=(R) %s-%s, (W) %s-%s, bs_is_seq_rand, ",
                                                        c1, c2, c3, c4);
                                else
-                                       log_info("bs=(R) %s-%s, (W) %s-%s, (T) %s-%s, ",
+                                       __log_buf(&out, "bs=(R) %s-%s, (W) %s-%s, (T) %s-%s, ",
                                                        c1, c2, c3, c4, c5, c6);
 
-                               log_info("ioengine=%s, iodepth=%u\n",
+                               __log_buf(&out, "ioengine=%s, iodepth=%u\n",
                                                td->io_ops->name, o->iodepth);
+                               log_info_buf(out.buf, out.buflen);
+                               buf_output_free(&out);
 
                                free(c1);
                                free(c2);
diff --git a/iolog.c b/iolog.c
index f3eedb56252c9b177c2f75d2d50e9a99a2b59696..26c3458638adf94f41d407c5444187e64f299647 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -580,7 +580,10 @@ static int open_socket(const char *path)
        if (fd < 0)
                return fd;
        addr.sun_family = AF_UNIX;
-       strncpy(addr.sun_path, path, sizeof(addr.sun_path));
+       if (snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path) >=
+           sizeof(addr.sun_path))
+               log_err("%s: path name %s is too long for a Unix socket\n",
+                       __func__, path);
        if (connect(fd, (const struct sockaddr *)&addr, strlen(path) + sizeof(addr.sun_family)) == 0)
                return fd;
        else
index 03e712f53be7a7623f90b12a3eecf57d73fc6f62..27301bd8465848d3cf8af57fb4c28b1078084742 100644 (file)
@@ -110,7 +110,7 @@ void axmap_free(struct axmap *axmap)
 }
 
 /* Allocate memory for a set that can store the numbers 0 .. @nr_bits - 1. */
-struct axmap *axmap_new(unsigned long nr_bits)
+struct axmap *axmap_new(uint64_t nr_bits)
 {
        struct axmap *axmap;
        unsigned int i, levels;
@@ -135,13 +135,14 @@ struct axmap *axmap_new(unsigned long nr_bits)
        for (i = 0; i < axmap->nr_levels; i++) {
                struct axmap_level *al = &axmap->levels[i];
 
+               nr_bits = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;
+
                al->level = i;
-               al->map_size = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;
+               al->map_size = nr_bits;
                al->map = malloc(al->map_size * sizeof(unsigned long));
                if (!al->map)
                        goto free_levels;
 
-               nr_bits = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;
        }
 
        axmap_reset(axmap);
@@ -164,7 +165,7 @@ free_axmap:
  * returns true.
  */
 static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr,
-                         bool (*func)(struct axmap_level *, unsigned long, unsigned int,
+                         bool (*func)(struct axmap_level *, uint64_t, unsigned int,
                          void *), void *data)
 {
        struct axmap_level *al;
@@ -193,12 +194,12 @@ static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr,
  * returns true.
  */
 static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
-       bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *))
+       bool (*func)(struct axmap_level *, uint64_t, unsigned int, void *))
 {
        int i;
 
        for (i = axmap->nr_levels - 1; i >= 0; i--) {
-               unsigned long index = bit_nr >> (UNIT_SHIFT * i);
+               uint64_t index = bit_nr >> (UNIT_SHIFT * i);
                unsigned long offset = index >> UNIT_SHIFT;
                unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
 
@@ -219,7 +220,7 @@ struct axmap_set_data {
  * the boundary of the element at offset @offset. Return the number of bits
  * that have been set in @__data->set_bits if @al->level == 0.
  */
-static bool axmap_set_fn(struct axmap_level *al, unsigned long offset,
+static bool axmap_set_fn(struct axmap_level *al, uint64_t offset,
                         unsigned int bit, void *__data)
 {
        struct axmap_set_data *data = __data;
@@ -321,10 +322,10 @@ unsigned int axmap_set_nr(struct axmap *axmap, uint64_t bit_nr,
        return set_bits;
 }
 
-static bool axmap_isset_fn(struct axmap_level *al, unsigned long offset,
+static bool axmap_isset_fn(struct axmap_level *al, uint64_t offset,
                           unsigned int bit, void *unused)
 {
-       return (al->map[offset] & (1UL << bit)) != 0;
+       return (al->map[offset] & (1ULL << bit)) != 0;
 }
 
 bool axmap_isset(struct axmap *axmap, uint64_t bit_nr)
index 55349d8731f2e4edfcc01f7aad025e309782acf6..aa5976898c114fb8870865db753200a6140cc978 100644 (file)
@@ -5,7 +5,7 @@
 #include "types.h"
 
 struct axmap;
-struct axmap *axmap_new(unsigned long nr_bits);
+struct axmap *axmap_new(uint64_t nr_bits);
 void axmap_free(struct axmap *bm);
 
 void axmap_set(struct axmap *axmap, uint64_t bit_nr);
index a4f1fb13b64f7b1087970bba0e9c58afafd002db..49e34a8cfa9e3227d75342438fefbaae8804ae85 100644 (file)
@@ -78,7 +78,7 @@ static uint8_t lfsr_taps[64][FIO_MAX_TAPS] =
 
 #define __LFSR_NEXT(__fl, __v)                                         \
        __v = ((__v >> 1) | __fl->cached_bit) ^                 \
-                       (((__v & 1UL) - 1UL) & __fl->xormask);
+                       (((__v & 1ULL) - 1ULL) & __fl->xormask);
 
 static inline void __lfsr_next(struct fio_lfsr *fl, unsigned int spin)
 {
@@ -146,7 +146,7 @@ static uint64_t lfsr_create_xormask(uint8_t *taps)
        uint64_t xormask = 0;
 
        for(i = 0; i < FIO_MAX_TAPS && taps[i] != 0; i++)
-               xormask |= 1UL << (taps[i] - 1);
+               xormask |= 1ULL << (taps[i] - 1);
 
        return xormask;
 }
@@ -161,7 +161,7 @@ static uint8_t *find_lfsr(uint64_t size)
         * take that into account.
         */
        for (i = 3; i < 64; i++)
-               if ((1UL << i) > size)
+               if ((1ULL << i) > size)
                        return lfsr_taps[i];
 
        return NULL;
@@ -241,7 +241,7 @@ int lfsr_init(struct fio_lfsr *fl, uint64_t nums, unsigned long seed,
 
        fl->max_val = nums - 1;
        fl->xormask = lfsr_create_xormask(taps);
-       fl->cached_bit = 1UL << (taps[0] - 1);
+       fl->cached_bit = 1ULL << (taps[0] - 1);
 
        if (prepare_spin(fl, spin))
                return 1;
index 40fb3aec923d3ce6199b64d0cf4c791c92e2151a..1abe22f33794c0ccf6b724e74aef7a1f62271166 100644 (file)
@@ -30,7 +30,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units)
                [N2S_BYTEPERSEC]= "B/s",
                [N2S_BITPERSEC] = "bit/s"
        };
-       const unsigned int thousand[] = { 1000, 1024 };
+       const unsigned int thousand = pow2 ? 1024 : 1000;
        unsigned int modulo;
        int post_index, carry = 0;
        char tmp[32], fmt[32];
@@ -49,7 +49,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units)
                unitprefix = sistr;
 
        for (post_index = 0; base > 1; post_index++)
-               base /= thousand[!!pow2];
+               base /= thousand;
 
        switch (units) {
        case N2S_NONE:
@@ -72,14 +72,14 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units)
         * Divide by K/Ki until string length of num <= maxlen.
         */
        modulo = -1U;
-       while (post_index < sizeof(sistr)) {
+       while (post_index < ARRAY_SIZE(sistr)) {
                sprintf(tmp, "%llu", (unsigned long long) num);
                if (strlen(tmp) <= maxlen)
                        break;
 
-               modulo = num % thousand[!!pow2];
-               num /= thousand[!!pow2];
-               carry = modulo >= thousand[!!pow2] / 2;
+               modulo = num % thousand;
+               num /= thousand;
+               carry = modulo >= thousand / 2;
                post_index++;
        }
 
@@ -110,9 +110,9 @@ done:
         * Fill in everything and return the result.
         */
        assert(maxlen - strlen(tmp) - 1 > 0);
-       assert(modulo < thousand[!!pow2]);
+       assert(modulo < thousand);
        sprintf(fmt, "%%.%df", (int)(maxlen - strlen(tmp) - 1));
-       sprintf(tmp, fmt, (double)modulo / (double)thousand[!!pow2]);
+       sprintf(tmp, fmt, (double)modulo / (double)thousand);
 
        sprintf(buf, "%llu.%s%s%s", (unsigned long long) num, &tmp[2],
                        unitprefix[post_index], unitstr[units]);
index 1ff8568094dcecc34ad8350b9f364051de756dd5..321a4fb9645e8995e1145758ec75530aeea75a16 100644 (file)
@@ -8,7 +8,7 @@
 
 static void zipf_update(struct zipf_state *zs)
 {
-       unsigned long to_gen;
+       uint64_t to_gen;
        unsigned int i;
 
        /*
@@ -22,7 +22,7 @@ static void zipf_update(struct zipf_state *zs)
                zs->zetan += pow(1.0 / (double) (i + 1), zs->theta);
 }
 
-static void shared_rand_init(struct zipf_state *zs, unsigned long nranges,
+static void shared_rand_init(struct zipf_state *zs, uint64_t nranges,
                             unsigned int seed)
 {
        memset(zs, 0, sizeof(*zs));
@@ -32,7 +32,7 @@ static void shared_rand_init(struct zipf_state *zs, unsigned long nranges,
        zs->rand_off = __rand(&zs->rand);
 }
 
-void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
+void zipf_init(struct zipf_state *zs, uint64_t nranges, double theta,
               unsigned int seed)
 {
        shared_rand_init(zs, nranges, seed);
@@ -43,7 +43,7 @@ void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta,
        zipf_update(zs);
 }
 
-unsigned long long zipf_next(struct zipf_state *zs)
+uint64_t zipf_next(struct zipf_state *zs)
 {
        double alpha, eta, rand_uni, rand_z;
        unsigned long long n = zs->nranges;
@@ -70,14 +70,14 @@ unsigned long long zipf_next(struct zipf_state *zs)
        return (val + zs->rand_off) % zs->nranges;
 }
 
-void pareto_init(struct zipf_state *zs, unsigned long nranges, double h,
+void pareto_init(struct zipf_state *zs, uint64_t nranges, double h,
                 unsigned int seed)
 {
        shared_rand_init(zs, nranges, seed);
        zs->pareto_pow = log(h) / log(1.0 - h);
 }
 
-unsigned long long pareto_next(struct zipf_state *zs)
+uint64_t pareto_next(struct zipf_state *zs)
 {
        double rand = (double) __rand(&zs->rand) / (double) FRAND32_MAX;
        unsigned long long n;
index a4aa163c80bc1dde7ad46e2f8ae85f32935d3456..16b65f57f146f0247581f52f2aee8fcf455b1694 100644 (file)
@@ -16,11 +16,11 @@ struct zipf_state {
        bool disable_hash;
 };
 
-void zipf_init(struct zipf_state *zs, unsigned long nranges, double theta, unsigned int seed);
-unsigned long long zipf_next(struct zipf_state *zs);
+void zipf_init(struct zipf_state *zs, uint64_t nranges, double theta, unsigned int seed);
+uint64_t zipf_next(struct zipf_state *zs);
 
-void pareto_init(struct zipf_state *zs, unsigned long nranges, double h, unsigned int seed);
-unsigned long long pareto_next(struct zipf_state *zs);
+void pareto_init(struct zipf_state *zs, uint64_t nranges, double h, unsigned int seed);
+uint64_t pareto_next(struct zipf_state *zs);
 void zipf_disable_hash(struct zipf_state *zs);
 
 #endif
index 534233bdbc297251d040f605a84b37d21d1b51be..6bd745553644283681c095853bca80483671c975 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1828,11 +1828,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
                            .help = "RDMA IO engine",
                          },
 #endif
-#ifdef CONFIG_FUSION_AW
-                         { .ival = "fusion-aw-sync",
-                           .help = "Fusion-io atomic write engine",
-                         },
-#endif
 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
                          { .ival = "e4defrag",
                            .help = "ext4 defrag engine",
index e8580d91c6db9203b7576f5f953e20a8368b8458..9308ba8be829c62b88cb06470a068cc2aef3f7dc 100755 (executable)
                   <File Source="..\..\examples\filecreate-ioengine.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-rand-read.job" />
+                  <File Source="..\..\examples\fio-rand-read.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-rand-RW.job" />
+                  <File Source="..\..\examples\fio-rand-RW.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-rand-write.job" />
+                  <File Source="..\..\examples\fio-rand-write.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-seq-read.job" />
+                  <File Source="..\..\examples\fio-seq-read.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-seq-RW.job" />
+                  <File Source="..\..\examples\fio-seq-RW.fio" />
                 </Component>
                 <Component>
-                  <File Source="..\..\examples\fio-seq-write.job" />
+                  <File Source="..\..\examples\fio-seq-write.fio" />
                 </Component>
                 <Component>
                   <File Source="..\..\examples\fixed-rate-submission.fio" />
@@ -74,9 +74,6 @@
                 <Component>
                   <File Source="..\..\examples\ftruncate.fio" />
                 </Component>
-                <Component>
-                  <File Source="..\..\examples\fusion-aw-sync.fio" />
-                </Component>
                 <Component>
                   <File Source="..\..\examples\gfapi.fio" />
                 </Component>
             <ComponentRef Id="enospc_pressure.fio" />
             <ComponentRef Id="falloc.fio" />
             <ComponentRef Id="filecreate_ioengine.fio"/>
-            <ComponentRef Id="fio_rand_read.job"/>
-            <ComponentRef Id="fio_rand_RW.job"/>
-            <ComponentRef Id="fio_rand_write.job"/>
-            <ComponentRef Id="fio_seq_read.job"/>
-            <ComponentRef Id="fio_seq_RW.job"/>
-            <ComponentRef Id="fio_seq_write.job"/>
+            <ComponentRef Id="fio_rand_read.fio"/>
+            <ComponentRef Id="fio_rand_RW.fio"/>
+            <ComponentRef Id="fio_rand_write.fio"/>
+            <ComponentRef Id="fio_seq_read.fio"/>
+            <ComponentRef Id="fio_seq_RW.fio"/>
+            <ComponentRef Id="fio_seq_write.fio"/>
             <ComponentRef Id="fixed_rate_submission.fio" />
             <ComponentRef Id="flow.fio" />
             <ComponentRef Id="fsx.fio" />
             <ComponentRef Id="ftruncate.fio"/>
-            <ComponentRef Id="fusion_aw_sync.fio" />
             <ComponentRef Id="gfapi.fio" />
             <ComponentRef Id="gpudirect_rdmaio_client.fio"/>
             <ComponentRef Id="gpudirect_rdmaio_server.fio"/>
index d33250de0f85ab9f0c1ccb6b0df36feb1c805b17..fd1d5582f1b33c73b84c21f4fffec4c8aafd79b9 100644 (file)
@@ -29,87 +29,151 @@ extern unsigned long mtime_since_now(struct timespec *);
 extern void fio_gettime(struct timespec *, void *);
 
 /* These aren't defined in the MinGW headers */
-HRESULT WINAPI StringCchCopyA(
-  char *pszDest,
-  size_t cchDest,
-  const char *pszSrc);
-
-HRESULT WINAPI StringCchPrintfA(
-  char *pszDest,
-  size_t cchDest,
-  const char *pszFormat,
-  ...);
+HRESULT WINAPI StringCchCopyA(char *pszDest, size_t cchDest, const char *pszSrc);
+HRESULT WINAPI StringCchPrintfA(char *pszDest, size_t cchDest, const char *pszFormat, ...);
 
 int win_to_posix_error(DWORD winerr)
 {
-       switch (winerr)
-       {
-       case ERROR_FILE_NOT_FOUND:              return ENOENT;
-       case ERROR_PATH_NOT_FOUND:              return ENOENT;
-       case ERROR_ACCESS_DENIED:               return EACCES;
-       case ERROR_INVALID_HANDLE:              return EBADF;
-       case ERROR_NOT_ENOUGH_MEMORY:   return ENOMEM;
-       case ERROR_INVALID_DATA:                return EINVAL;
-       case ERROR_OUTOFMEMORY:                 return ENOMEM;
-       case ERROR_INVALID_DRIVE:               return ENODEV;
-       case ERROR_NOT_SAME_DEVICE:             return EXDEV;
-       case ERROR_WRITE_PROTECT:               return EROFS;
-       case ERROR_BAD_UNIT:                    return ENODEV;
-       case ERROR_SHARING_VIOLATION:   return EACCES;
-       case ERROR_LOCK_VIOLATION:              return EACCES;
-       case ERROR_SHARING_BUFFER_EXCEEDED:     return ENOLCK;
-       case ERROR_HANDLE_DISK_FULL:    return ENOSPC;
-       case ERROR_NOT_SUPPORTED:               return ENOSYS;
-       case ERROR_FILE_EXISTS:                 return EEXIST;
-       case ERROR_CANNOT_MAKE:                 return EPERM;
-       case ERROR_INVALID_PARAMETER:   return EINVAL;
-       case ERROR_NO_PROC_SLOTS:               return EAGAIN;
-       case ERROR_BROKEN_PIPE:                 return EPIPE;
-       case ERROR_OPEN_FAILED:                 return EIO;
-       case ERROR_NO_MORE_SEARCH_HANDLES:      return ENFILE;
-       case ERROR_CALL_NOT_IMPLEMENTED:        return ENOSYS;
-       case ERROR_INVALID_NAME:                return ENOENT;
-       case ERROR_WAIT_NO_CHILDREN:    return ECHILD;
-       case ERROR_CHILD_NOT_COMPLETE:  return EBUSY;
-       case ERROR_DIR_NOT_EMPTY:               return ENOTEMPTY;
-       case ERROR_SIGNAL_REFUSED:              return EIO;
-       case ERROR_BAD_PATHNAME:                return ENOENT;
-       case ERROR_SIGNAL_PENDING:              return EBUSY;
-       case ERROR_MAX_THRDS_REACHED:   return EAGAIN;
-       case ERROR_BUSY:                                return EBUSY;
-       case ERROR_ALREADY_EXISTS:              return EEXIST;
-       case ERROR_NO_SIGNAL_SENT:              return EIO;
-       case ERROR_FILENAME_EXCED_RANGE:        return EINVAL;
-       case ERROR_META_EXPANSION_TOO_LONG:     return EINVAL;
-       case ERROR_INVALID_SIGNAL_NUMBER:       return EINVAL;
-       case ERROR_THREAD_1_INACTIVE:   return EINVAL;
-       case ERROR_BAD_PIPE:                    return EINVAL;
-       case ERROR_PIPE_BUSY:                   return EBUSY;
-       case ERROR_NO_DATA:                             return EPIPE;
-       case ERROR_MORE_DATA:                   return EAGAIN;
-       case ERROR_DIRECTORY:                   return ENOTDIR;
-       case ERROR_PIPE_CONNECTED:              return EBUSY;
-       case ERROR_NO_TOKEN:                    return EINVAL;
-       case ERROR_PROCESS_ABORTED:             return EFAULT;
-       case ERROR_BAD_DEVICE:                  return ENODEV;
-       case ERROR_BAD_USERNAME:                return EINVAL;
-       case ERROR_OPEN_FILES:                  return EAGAIN;
-       case ERROR_ACTIVE_CONNECTIONS:  return EAGAIN;
-       case ERROR_DEVICE_IN_USE:               return EAGAIN;
-       case ERROR_INVALID_AT_INTERRUPT_TIME:   return EINTR;
-       case ERROR_IO_DEVICE:                   return EIO;
-       case ERROR_NOT_OWNER:                   return EPERM;
-       case ERROR_END_OF_MEDIA:                return ENOSPC;
-       case ERROR_EOM_OVERFLOW:                return ENOSPC;
-       case ERROR_BEGINNING_OF_MEDIA:  return ESPIPE;
-       case ERROR_SETMARK_DETECTED:    return ESPIPE;
-       case ERROR_NO_DATA_DETECTED:    return ENOSPC;
-       case ERROR_POSSIBLE_DEADLOCK:   return EDEADLOCK;
-       case ERROR_CRC:                                 return EIO;
-       case ERROR_NEGATIVE_SEEK:               return EINVAL;
-       case ERROR_DISK_FULL:                   return ENOSPC;
-       case ERROR_NOACCESS:                    return EFAULT;
-       case ERROR_FILE_INVALID:                return ENXIO;
+       switch (winerr) {
+       case ERROR_SUCCESS:
+               return 0;
+       case ERROR_FILE_NOT_FOUND:
+               return ENOENT;
+       case ERROR_PATH_NOT_FOUND:
+               return ENOENT;
+       case ERROR_ACCESS_DENIED:
+               return EACCES;
+       case ERROR_INVALID_HANDLE:
+               return EBADF;
+       case ERROR_NOT_ENOUGH_MEMORY:
+               return ENOMEM;
+       case ERROR_INVALID_DATA:
+               return EINVAL;
+       case ERROR_OUTOFMEMORY:
+               return ENOMEM;
+       case ERROR_INVALID_DRIVE:
+               return ENODEV;
+       case ERROR_NOT_SAME_DEVICE:
+               return EXDEV;
+       case ERROR_WRITE_PROTECT:
+               return EROFS;
+       case ERROR_BAD_UNIT:
+               return ENODEV;
+       case ERROR_NOT_READY:
+               return EAGAIN;
+       case ERROR_SHARING_VIOLATION:
+               return EACCES;
+       case ERROR_LOCK_VIOLATION:
+               return EACCES;
+       case ERROR_SHARING_BUFFER_EXCEEDED:
+               return ENOLCK;
+       case ERROR_HANDLE_DISK_FULL:
+               return ENOSPC;
+       case ERROR_NOT_SUPPORTED:
+               return ENOSYS;
+       case ERROR_FILE_EXISTS:
+               return EEXIST;
+       case ERROR_CANNOT_MAKE:
+               return EPERM;
+       case ERROR_INVALID_PARAMETER:
+               return EINVAL;
+       case ERROR_NO_PROC_SLOTS:
+               return EAGAIN;
+       case ERROR_BROKEN_PIPE:
+               return EPIPE;
+       case ERROR_OPEN_FAILED:
+               return EIO;
+       case ERROR_NO_MORE_SEARCH_HANDLES:
+               return ENFILE;
+       case ERROR_CALL_NOT_IMPLEMENTED:
+               return ENOSYS;
+       case ERROR_INVALID_NAME:
+               return ENOENT;
+       case ERROR_WAIT_NO_CHILDREN:
+               return ECHILD;
+       case ERROR_CHILD_NOT_COMPLETE:
+               return EBUSY;
+       case ERROR_DIR_NOT_EMPTY:
+               return ENOTEMPTY;
+       case ERROR_SIGNAL_REFUSED:
+               return EIO;
+       case ERROR_BAD_PATHNAME:
+               return ENOENT;
+       case ERROR_SIGNAL_PENDING:
+               return EBUSY;
+       case ERROR_MAX_THRDS_REACHED:
+               return EAGAIN;
+       case ERROR_BUSY:
+               return EBUSY;
+       case ERROR_ALREADY_EXISTS:
+               return EEXIST;
+       case ERROR_NO_SIGNAL_SENT:
+               return EIO;
+       case ERROR_FILENAME_EXCED_RANGE:
+               return EINVAL;
+       case ERROR_META_EXPANSION_TOO_LONG:
+               return EINVAL;
+       case ERROR_INVALID_SIGNAL_NUMBER:
+               return EINVAL;
+       case ERROR_THREAD_1_INACTIVE:
+               return EINVAL;
+       case ERROR_BAD_PIPE:
+               return EINVAL;
+       case ERROR_PIPE_BUSY:
+               return EBUSY;
+       case ERROR_NO_DATA:
+               return EPIPE;
+       case ERROR_MORE_DATA:
+               return EAGAIN;
+       case ERROR_DIRECTORY:
+               return ENOTDIR;
+       case ERROR_PIPE_CONNECTED:
+               return EBUSY;
+       case ERROR_NO_TOKEN:
+               return EINVAL;
+       case ERROR_PROCESS_ABORTED:
+               return EFAULT;
+       case ERROR_BAD_DEVICE:
+               return ENODEV;
+       case ERROR_BAD_USERNAME:
+               return EINVAL;
+       case ERROR_OPEN_FILES:
+               return EAGAIN;
+       case ERROR_ACTIVE_CONNECTIONS:
+               return EAGAIN;
+       case ERROR_DEVICE_IN_USE:
+               return EBUSY;
+       case ERROR_INVALID_AT_INTERRUPT_TIME:
+               return EINTR;
+       case ERROR_IO_DEVICE:
+               return EIO;
+       case ERROR_NOT_OWNER:
+               return EPERM;
+       case ERROR_END_OF_MEDIA:
+               return ENOSPC;
+       case ERROR_EOM_OVERFLOW:
+               return ENOSPC;
+       case ERROR_BEGINNING_OF_MEDIA:
+               return ESPIPE;
+       case ERROR_SETMARK_DETECTED:
+               return ESPIPE;
+       case ERROR_NO_DATA_DETECTED:
+               return ENOSPC;
+       case ERROR_POSSIBLE_DEADLOCK:
+               return EDEADLOCK;
+       case ERROR_CRC:
+               return EIO;
+       case ERROR_NEGATIVE_SEEK:
+               return EINVAL;
+       case ERROR_DISK_FULL:
+               return ENOSPC;
+       case ERROR_NOACCESS:
+               return EFAULT;
+       case ERROR_FILE_INVALID:
+               return ENXIO;
+       default:
+               log_err("fio: windows error %d not handled\n", winerr);
+               return EIO;
        }
 
        return winerr;
@@ -138,8 +202,7 @@ int GetNumLogicalProcessors(void)
                }
        }
 
-       for (i = 0; i < len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); i++)
-       {
+       for (i = 0; i < len / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); i++) {
                if (processor_info[i].Relationship == RelationProcessorCore)
                        num_processors += hweight64(processor_info[i].ProcessorMask);
        }
@@ -155,8 +218,7 @@ long sysconf(int name)
        SYSTEM_INFO sysInfo;
        MEMORYSTATUSEX status;
 
-       switch (name)
-       {
+       switch (name) {
        case _SC_NPROCESSORS_ONLN:
                val = GetNumLogicalProcessors();
                if (val == -1)
@@ -226,29 +288,36 @@ char *dlerror(void)
 /* Copied from http://blogs.msdn.com/b/joshpoley/archive/2007/12/19/date-time-formats-and-conversions.aspx */
 void Time_tToSystemTime(time_t dosTime, SYSTEMTIME *systemTime)
 {
-    FILETIME utcFT;
-    LONGLONG jan1970;
+       FILETIME utcFT;
+       LONGLONG jan1970;
        SYSTEMTIME tempSystemTime;
 
-    jan1970 = Int32x32To64(dosTime, 10000000) + 116444736000000000;
-    utcFT.dwLowDateTime = (DWORD)jan1970;
-    utcFT.dwHighDateTime = jan1970 >> 32;
+       jan1970 = Int32x32To64(dosTime, 10000000) + 116444736000000000;
+       utcFT.dwLowDateTime = (DWORD)jan1970;
+       utcFT.dwHighDateTime = jan1970 >> 32;
 
-    FileTimeToSystemTime((FILETIME*)&utcFT, &tempSystemTime);
+       FileTimeToSystemTime((FILETIME*)&utcFT, &tempSystemTime);
        SystemTimeToTzSpecificLocalTime(NULL, &tempSystemTime, systemTime);
 }
 
-charctime_r(const time_t *t, char *buf)
+char *ctime_r(const time_t *t, char *buf)
 {
-    SYSTEMTIME systime;
-    const char * const dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-    const char * const monthOfYear[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-
-    Time_tToSystemTime(*t, &systime);
-    /* We don't know how long `buf` is, but assume it's rounded up from the minimum of 25 to 32 */
-    StringCchPrintfA(buf, 31, "%s %s %d %02d:%02d:%02d %04d\n", dayOfWeek[systime.wDayOfWeek % 7], monthOfYear[(systime.wMonth - 1) % 12],
-                                                                                systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wYear);
-    return buf;
+       SYSTEMTIME systime;
+       const char * const dayOfWeek[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+       const char * const monthOfYear[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+       Time_tToSystemTime(*t, &systime);
+
+       /*
+        * We don't know how long `buf` is, but assume it's rounded up from
+        * the minimum of 25 to 32
+        */
+       StringCchPrintfA(buf, 31, "%s %s %d %02d:%02d:%02d %04d\n",
+                               dayOfWeek[systime.wDayOfWeek % 7],
+                               monthOfYear[(systime.wMonth - 1) % 12],
+                               systime.wDay, systime.wHour, systime.wMinute,
+                               systime.wSecond, systime.wYear);
+       return buf;
 }
 
 int gettimeofday(struct timeval *restrict tp, void *restrict tzp)
@@ -275,8 +344,7 @@ int gettimeofday(struct timeval *restrict tp, void *restrict tzp)
        return 0;
 }
 
-int sigaction(int sig, const struct sigaction *act,
-               struct sigaction *oact)
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
 {
        int rc = 0;
        void (*prev_handler)(int);
@@ -291,13 +359,12 @@ int sigaction(int sig, const struct sigaction *act,
        return rc;
 }
 
-int lstat(const char * path, struct stat * buf)
+int lstat(const char *path, struct stat *buf)
 {
        return stat(path, buf);
 }
 
-void *mmap(void *addr, size_t len, int prot, int flags,
-               int fildes, off_t off)
+void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
 {
        DWORD vaProt = 0;
        DWORD mapAccess = 0;
@@ -323,25 +390,20 @@ void *mmap(void *addr, size_t len, int prot, int flags,
        lenhigh = len >> 16;
        /* If the low DWORD is zero and the high DWORD is non-zero, `CreateFileMapping`
           will return ERROR_INVALID_PARAMETER. To avoid this, set both to zero. */
-       if (lenlow == 0) {
+       if (lenlow == 0)
                lenhigh = 0;
-       }
 
-       if (flags & MAP_ANON || flags & MAP_ANONYMOUS)
-       {
+       if (flags & MAP_ANON || flags & MAP_ANONYMOUS) {
                allocAddr = VirtualAlloc(addr, len, MEM_COMMIT, vaProt);
                if (allocAddr == NULL)
                        errno = win_to_posix_error(GetLastError());
-       }
-       else
-       {
-               hMap = CreateFileMapping((HANDLE)_get_osfhandle(fildes), NULL, vaProt, lenhigh, lenlow, NULL);
+       } else {
+               hMap = CreateFileMapping((HANDLE)_get_osfhandle(fildes), NULL,
+                                               vaProt, lenhigh, lenlow, NULL);
 
                if (hMap != NULL)
-               {
-                       allocAddr = MapViewOfFile(hMap, mapAccess, off >> 16, off & 0xFFFF, len);
-               }
-
+                       allocAddr = MapViewOfFile(hMap, mapAccess, off >> 16,
+                                                       off & 0xFFFF, len);
                if (hMap == NULL || allocAddr == NULL)
                        errno = win_to_posix_error(GetLastError());
 
@@ -360,9 +422,7 @@ int munmap(void *addr, size_t len)
        success = UnmapViewOfFile(addr);
 
        if (!success)
-       {
                success = VirtualFree(addr, 0, MEM_RELEASE);
-       }
 
        return !success;
 }
@@ -390,8 +450,12 @@ static HANDLE log_file = INVALID_HANDLE_VALUE;
 
 void openlog(const char *ident, int logopt, int facility)
 {
-       if (log_file == INVALID_HANDLE_VALUE)
-               log_file = CreateFileA("syslog.txt", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
+       if (log_file != INVALID_HANDLE_VALUE)
+               return;
+
+       log_file = CreateFileA("syslog.txt", GENERIC_WRITE,
+                               FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+                               OPEN_ALWAYS, 0, NULL);
 }
 
 void closelog(void)
@@ -408,7 +472,9 @@ void syslog(int priority, const char *message, ... /* argument */)
        DWORD bytes_written;
 
        if (log_file == INVALID_HANDLE_VALUE) {
-               log_file = CreateFileA("syslog.txt", GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
+               log_file = CreateFileA("syslog.txt", GENERIC_WRITE,
+                                       FILE_SHARE_READ | FILE_SHARE_WRITE,
+                                       NULL, OPEN_ALWAYS, 0, NULL);
        }
 
        if (log_file == INVALID_HANDLE_VALUE) {
@@ -483,8 +549,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
 {
        int rc = 0;
 
-       if (clock_id == CLOCK_MONOTONIC)
-       {
+       if (clock_id == CLOCK_MONOTONIC) {
                static LARGE_INTEGER freq = {{0,0}};
                LARGE_INTEGER counts;
                uint64_t t;
@@ -503,9 +568,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
                 * and then divide by the frequency. */
                t *= 1000000000;
                tp->tv_nsec = t / freq.QuadPart;
-       }
-       else if (clock_id == CLOCK_REALTIME)
-       {
+       } else if (clock_id == CLOCK_REALTIME) {
                /* clock_gettime(CLOCK_REALTIME,...) is just an alias for gettimeofday with a
                 * higher-precision field. */
                struct timeval tv;
@@ -552,6 +615,7 @@ int mlock(const void * addr, size_t len)
 int munlock(const void * addr, size_t len)
 {
        BOOL success = VirtualUnlock((LPVOID)addr, len);
+
        if (!success) {
                errno = win_to_posix_error(GetLastError());
                return -1;
@@ -611,22 +675,26 @@ int shmget(key_t key, size_t size, int shmflg)
        int mapid = -1;
        uint32_t size_low = size & 0xFFFFFFFF;
        uint32_t size_high = ((uint64_t)size) >> 32;
-       HANDLE hMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, (PAGE_EXECUTE_READWRITE | SEC_RESERVE), size_high, size_low, NULL);
+       HANDLE hMapping;
+
+       hMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
+                                       PAGE_EXECUTE_READWRITE | SEC_RESERVE,
+                                       size_high, size_low, NULL);
        if (hMapping != NULL) {
                fileMappings[nFileMappings] = hMapping;
                mapid = nFileMappings;
                nFileMappings++;
-       } else {
+       } else
                errno = ENOSYS;
-       }
 
        return mapid;
 }
 
 void *shmat(int shmid, const void *shmaddr, int shmflg)
 {
-       voidmapAddr;
+       void *mapAddr;
        MEMORY_BASIC_INFORMATION memInfo;
+
        mapAddr = MapViewOfFile(fileMappings[shmid], FILE_MAP_ALL_ACCESS, 0, 0, 0);
        if (mapAddr == NULL) {
                errno = win_to_posix_error(GetLastError());
@@ -662,9 +730,9 @@ int shmctl(int shmid, int cmd, struct shmid_ds *buf)
        if (cmd == IPC_RMID) {
                fileMappings[shmid] = INVALID_HANDLE_VALUE;
                return 0;
-       } else {
-               log_err("%s is not implemented\n", __func__);
        }
+
+       log_err("%s is not implemented\n", __func__);
        errno = ENOSYS;
        return -1;
 }
@@ -753,6 +821,7 @@ ssize_t pwrite(int fildes, const void *buf, size_t nbyte,
 {
        int64_t pos = _telli64(fildes);
        ssize_t len = _write(fildes, buf, nbyte);
+
        _lseeki64(fildes, pos, SEEK_SET);
        return len;
 }
@@ -761,6 +830,7 @@ ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset)
 {
        int64_t pos = _telli64(fildes);
        ssize_t len = read(fildes, buf, nbyte);
+
        _lseeki64(fildes, pos, SEEK_SET);
        return len;
 }
@@ -776,11 +846,12 @@ ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
 {
        int i;
        DWORD bytes_written = 0;
-       for (i = 0; i < iovcnt; i++)
-       {
-               int len = send((SOCKET)fildes, iov[i].iov_base, iov[i].iov_len, 0);
-               if (len == SOCKET_ERROR)
-               {
+
+       for (i = 0; i < iovcnt; i++) {
+               int len;
+
+               len = send((SOCKET)fildes, iov[i].iov_base, iov[i].iov_len, 0);
+               if (len == SOCKET_ERROR) {
                        DWORD err = GetLastError();
                        errno = win_to_posix_error(err);
                        bytes_written = -1;
@@ -792,8 +863,7 @@ ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
        return bytes_written;
 }
 
-long long strtoll(const char *restrict str, char **restrict endptr,
-               int base)
+long long strtoll(const char *restrict str, char **restrict endptr, int base)
 {
        return _strtoi64(str, endptr, base);
 }
@@ -816,8 +886,7 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
        FD_ZERO(&writefds);
        FD_ZERO(&exceptfds);
 
-       for (i = 0; i < nfds; i++)
-       {
+       for (i = 0; i < nfds; i++) {
                if (fds[i].fd < 0) {
                        fds[i].revents = 0;
                        continue;
@@ -834,11 +903,9 @@ int poll(struct pollfd fds[], nfds_t nfds, int timeout)
        rc = select(nfds, &readfds, &writefds, &exceptfds, to);
 
        if (rc != SOCKET_ERROR) {
-               for (i = 0; i < nfds; i++)
-               {
-                       if (fds[i].fd < 0) {
+               for (i = 0; i < nfds; i++) {
+                       if (fds[i].fd < 0)
                                continue;
-                       }
 
                        if ((fds[i].events & POLLIN) && FD_ISSET(fds[i].fd, &readfds))
                                fds[i].revents |= POLLIN;
@@ -884,9 +951,11 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
 DIR *opendir(const char *dirname)
 {
        struct dirent_ctx *dc = NULL;
+       HANDLE file;
 
        /* See if we can open it. If not, we'll return an error here */
-       HANDLE file = CreateFileA(dirname, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+       file = CreateFileA(dirname, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+                               OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
        if (file != INVALID_HANDLE_VALUE) {
                CloseHandle(file);
                dc = (struct dirent_ctx*)malloc(sizeof(struct dirent_ctx));
@@ -929,6 +998,7 @@ struct dirent *readdir(DIR *dirp)
 
        if (dirp->find_handle == INVALID_HANDLE_VALUE) {
                char search_pattern[MAX_PATH];
+
                StringCchPrintfA(search_pattern, MAX_PATH-1, "%s\\*", dirp->dirname);
                dirp->find_handle = FindFirstFileA(search_pattern, &find_data);
                if (dirp->find_handle == INVALID_HANDLE_VALUE)
@@ -960,8 +1030,8 @@ in_addr_t inet_network(const char *cp)
 }
 
 #ifdef CONFIG_WINDOWS_XP
-const char* inet_ntop(int af, const void *restrict src,
-               char *restrict dst, socklen_t size)
+const char *inet_ntop(int af, const void *restrict src, char *restrict dst,
+                     socklen_t size)
 {
        INT status = SOCKET_ERROR;
        WSADATA wsd;
@@ -977,6 +1047,7 @@ const char* inet_ntop(int af, const void *restrict src,
        if (af == AF_INET) {
                struct sockaddr_in si;
                DWORD len = size;
+
                memset(&si, 0, sizeof(si));
                si.sin_family = af;
                memcpy(&si.sin_addr, src, sizeof(si.sin_addr));
@@ -984,6 +1055,7 @@ const char* inet_ntop(int af, const void *restrict src,
        } else if (af == AF_INET6) {
                struct sockaddr_in6 si6;
                DWORD len = size;
+
                memset(&si6, 0, sizeof(si6));
                si6.sin6_family = af;
                memcpy(&si6.sin6_addr, src, sizeof(si6.sin6_addr));
@@ -1016,6 +1088,7 @@ int inet_pton(int af, const char *restrict src, void *restrict dst)
        if (af == AF_INET) {
                struct sockaddr_in si;
                INT len = sizeof(si);
+
                memset(&si, 0, sizeof(si));
                si.sin_family = af;
                status = WSAStringToAddressA((char*)src, af, NULL, (struct sockaddr*)&si, &len);
@@ -1024,6 +1097,7 @@ int inet_pton(int af, const char *restrict src, void *restrict dst)
        } else if (af == AF_INET6) {
                struct sockaddr_in6 si6;
                INT len = sizeof(si6);
+
                memset(&si6, 0, sizeof(si6));
                si6.sin6_family = af;
                status = WSAStringToAddressA((char*)src, af, NULL, (struct sockaddr*)&si6, &len);
index 5c77a4e8ecb83089ad2fb6a0322aafcbcab2bc4c..2f02fe2ba8365dea762051e555b1f28651ee45e3 100644 (file)
@@ -126,7 +126,7 @@ static int io_workqueue_init_worker_fn(struct submit_worker *sw)
        clear_io_state(td, 1);
 
        td_set_runstate(td, TD_RUNNING);
-       td->flags |= TD_F_CHILD;
+       td->flags |= TD_F_CHILD | TD_F_NEED_LOCK;
        td->parent = parent;
        return 0;
 
diff --git a/stat.c b/stat.c
index 1a9c553b12b744d72a1f25c28f6b7f1f53accfa0..5fca99845ff88d10b9c4b96d1b76b37672170349 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1928,8 +1928,6 @@ void __show_run_stats(void)
                if (is_backend) {
                        fio_server_send_job_options(opt_lists[i], i);
                        fio_server_send_ts(ts, rs);
-                       if (output_format & FIO_OUTPUT_TERSE)
-                               show_thread_status_terse(ts, rs, &output[__FIO_OUTPUT_TERSE]);
                } else {
                        if (output_format & FIO_OUTPUT_TERSE)
                                show_thread_status_terse(ts, rs, &output[__FIO_OUTPUT_TERSE]);
index a2e6fd6210636fbe1509764999e70963fb805094..9d6bdee5e8b7f7c18e3388caae096fe879bf1bb3 100644 (file)
--- a/t/axmap.c
+++ b/t/axmap.c
@@ -5,7 +5,7 @@
 #include "../lib/lfsr.h"
 #include "../lib/axmap.h"
 
-static int test_regular(size_t size, int seed)
+static int test_regular(uint64_t size, int seed)
 {
        struct fio_lfsr lfsr;
        struct axmap *map;
@@ -61,11 +61,11 @@ static int check_next_free(struct axmap *map, uint64_t start, uint64_t expected)
        return 0;
 }
 
-static int test_next_free(size_t size, int seed)
+static int test_next_free(uint64_t size, int seed)
 {
        struct fio_lfsr lfsr;
        struct axmap *map;
-       size_t osize;
+       uint64_t osize;
        uint64_t ff, lastfree;
        int err, i;
 
@@ -196,7 +196,7 @@ static int test_next_free(size_t size, int seed)
        return 0;
 }
 
-static int test_multi(size_t size, unsigned int bit_off)
+static int test_multi(uint64_t size, unsigned int bit_off)
 {
        unsigned int map_size = size;
        struct axmap *map;
@@ -395,7 +395,7 @@ static int test_overlap(void)
 
 int main(int argc, char *argv[])
 {
-       size_t size = (1UL << 23) - 200;
+       uint64_t size = (1ULL << 23) - 200;
        int seed = 1;
 
        if (argc > 1) {
diff --git a/t/jobs/t0010-b7aae4ba.fio b/t/jobs/t0010-b7aae4ba.fio
new file mode 100644 (file)
index 0000000..0223770
--- /dev/null
@@ -0,0 +1,8 @@
+# Expected result: fio runs and completes the job
+# Buggy result: fio segfaults
+#
+[test]
+ioengine=null
+size=10g
+io_submit_mode=offload
+iodepth=16
index 81f6de6e1a1e20842d4c83fc87594f9fe0911a6c..7f08f6e32d15cb64946ec53bf42db816ad741669 100755 (executable)
 import sys, os, math, copy, time
 from copy import deepcopy
 import argparse
-import unittest2
+
+unittest2_imported = True
+try:
+    import unittest2
+except ImportError:
+    unittest2_imported = False
 
 msec_per_sec = 1000
 nsec_per_usec = 1000
@@ -66,6 +71,8 @@ def parse_hist_file(logfn, buckets_per_interval, log_hist_msec):
     with open(logfn, 'r') as f:
         records = [ l.strip() for l in f.readlines() ]
     intervals = []
+    last_time_ms = -1
+    last_direction = -1
     for k, r in enumerate(records):
         if r == '':
             continue
@@ -104,6 +111,15 @@ def parse_hist_file(logfn, buckets_per_interval, log_hist_msec):
         if len(buckets) != buckets_per_interval:
             raise FioHistoLogExc('%d buckets per interval but %d expected in %s' % 
                     (len(buckets), buckets_per_interval, exception_suffix(k+1, logfn)))
+
+        # hack to filter out records with the same timestamp
+        # we should not have to do this if fio logs histogram records correctly
+
+        if time_ms == last_time_ms and direction == last_direction:
+            continue
+        last_time_ms = time_ms
+        last_direction = direction
+
         intervals.append((time_ms, direction, bsz, buckets))
     if len(intervals) == 0:
         raise FioHistoLogExc('no records in %s' % logfn)
@@ -460,14 +476,14 @@ def compute_percentiles_from_logs():
 #end of MAIN PROGRAM
 
 
-
 ##### below are unit tests ##############
 
-import tempfile, shutil
-from os.path import join
-should_not_get_here = False
+if unittest2_imported:
+  import tempfile, shutil
+  from os.path import join
+  should_not_get_here = False
 
-class Test(unittest2.TestCase):
+  class Test(unittest2.TestCase):
     tempdir = None
 
     # a little less typing please
@@ -732,7 +748,10 @@ class Test(unittest2.TestCase):
 
 if __name__ == '__main__':
     if os.getenv('UNITTEST'):
-        sys.exit(unittest2.main())
+        if unittest2_imported:
+            sys.exit(unittest2.main())
+        else:
+            raise Exception('you must install unittest2 module to run unit test')
     else:
         compute_percentiles_from_logs()
 
diff --git a/zbd.c b/zbd.c
index 0f3636a525d835a1514de71a9f652729105cfaff..9c3092ab2424dae64c6f19646ff8ae85cbda9515 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -128,9 +128,9 @@ static bool zbd_verify_sizes(void)
                                                 f->file_name);
                                        return false;
                                }
-                               log_info("%s: rounded up offset from %lu to %lu\n",
-                                        f->file_name, f->file_offset,
-                                        new_offset);
+                               log_info("%s: rounded up offset from %llu to %llu\n",
+                                        f->file_name, (unsigned long long) f->file_offset,
+                                        (unsigned long long) new_offset);
                                f->io_size -= (new_offset - f->file_offset);
                                f->file_offset = new_offset;
                        }
@@ -143,9 +143,9 @@ static bool zbd_verify_sizes(void)
                                                 f->file_name);
                                        return false;
                                }
-                               log_info("%s: rounded down io_size from %lu to %lu\n",
-                                        f->file_name, f->io_size,
-                                        new_end - f->file_offset);
+                               log_info("%s: rounded down io_size from %llu to %llu\n",
+                                        f->file_name, (unsigned long long) f->io_size,
+                                        (unsigned long long) new_end - f->file_offset);
                                f->io_size = new_end - f->file_offset;
                        }
                }
@@ -357,14 +357,15 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
        if (td->o.zone_size == 0) {
                td->o.zone_size = zone_size;
        } else if (td->o.zone_size != zone_size) {
-               log_info("fio: %s job parameter zonesize %lld does not match disk zone size %ld.\n",
-                        f->file_name, td->o.zone_size, zone_size);
+               log_info("fio: %s job parameter zonesize %llu does not match disk zone size %llu.\n",
+                        f->file_name, (unsigned long long) td->o.zone_size,
+                       (unsigned long long) zone_size);
                ret = -EINVAL;
                goto close;
        }
 
-       dprint(FD_ZBD, "Device %s has %d zones of size %lu KB\n", f->file_name,
-              nr_zones, zone_size / 1024);
+       dprint(FD_ZBD, "Device %s has %d zones of size %llu KB\n", f->file_name,
+              nr_zones, (unsigned long long) zone_size / 1024);
 
        zbd_info = scalloc(1, sizeof(*zbd_info) +
                           (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
@@ -407,8 +408,8 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
                        break;
                ret = read_zone_info(fd, start_sector, buf, bufsz);
                if (ret < 0) {
-                       log_info("fio: BLKREPORTZONE(%lu) failed for %s (%d).\n",
-                                start_sector, f->file_name, -ret);
+                       log_info("fio: BLKREPORTZONE(%llu) failed for %s (%d).\n",
+                                (unsigned long long) start_sector, f->file_name, -ret);
                        goto close;
                }
        }
@@ -602,6 +603,12 @@ static int zbd_reset_range(struct thread_data *td, const struct fio_file *f,
        return ret;
 }
 
+static unsigned int zbd_zone_nr(struct zoned_block_device_info *zbd_info,
+                               struct fio_zone_info *zone)
+{
+       return (uintptr_t) zone - (uintptr_t) zbd_info->zone_info;
+}
+
 /**
  * zbd_reset_zone - reset the write pointer of a single zone
  * @td: FIO thread data.
@@ -615,8 +622,8 @@ static int zbd_reset_zone(struct thread_data *td, const struct fio_file *f,
 {
        int ret;
 
-       dprint(FD_ZBD, "%s: resetting wp of zone %lu.\n", f->file_name,
-              z - f->zbd_info->zone_info);
+       dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
+               zbd_zone_nr(f->zbd_info, z));
        ret = zbd_reset_range(td, f, z->start, (z+1)->start - z->start);
        return ret;
 }
@@ -639,8 +646,8 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
        bool reset_wp;
        int res = 0;
 
-       dprint(FD_ZBD, "%s: examining zones %lu .. %lu\n", f->file_name,
-              zb - f->zbd_info->zone_info, ze - f->zbd_info->zone_info);
+       dprint(FD_ZBD, "%s: examining zones %u .. %u\n", f->file_name,
+               zbd_zone_nr(f->zbd_info, zb), zbd_zone_nr(f->zbd_info, ze));
        assert(f->fd != -1);
        for (z = zb; z < ze; z++) {
                pthread_mutex_lock(&z->mutex);
@@ -653,10 +660,10 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
                                start_z = z;
                        } else if (start_z < ze && !reset_wp) {
                                dprint(FD_ZBD,
-                                      "%s: resetting zones %lu .. %lu\n",
+                                      "%s: resetting zones %u .. %u\n",
                                       f->file_name,
-                                      start_z - f->zbd_info->zone_info,
-                                      z - f->zbd_info->zone_info);
+                                       zbd_zone_nr(f->zbd_info, start_z),
+                                       zbd_zone_nr(f->zbd_info, z));
                                if (zbd_reset_range(td, f, start_z->start,
                                                z->start - start_z->start) < 0)
                                        res = 1;
@@ -666,9 +673,9 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
                default:
                        if (start_z == ze)
                                break;
-                       dprint(FD_ZBD, "%s: resetting zones %lu .. %lu\n",
-                              f->file_name, start_z - f->zbd_info->zone_info,
-                              z - f->zbd_info->zone_info);
+                       dprint(FD_ZBD, "%s: resetting zones %u .. %u\n",
+                              f->file_name, zbd_zone_nr(f->zbd_info, start_z),
+                              zbd_zone_nr(f->zbd_info, z));
                        if (zbd_reset_range(td, f, start_z->start,
                                            z->start - start_z->start) < 0)
                                res = 1;
@@ -677,9 +684,9 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
                }
        }
        if (start_z < ze) {
-               dprint(FD_ZBD, "%s: resetting zones %lu .. %lu\n", f->file_name,
-                      start_z - f->zbd_info->zone_info,
-                      z - f->zbd_info->zone_info);
+               dprint(FD_ZBD, "%s: resetting zones %u .. %u\n", f->file_name,
+                       zbd_zone_nr(f->zbd_info, start_z),
+                       zbd_zone_nr(f->zbd_info, z));
                if (zbd_reset_range(td, f, start_z->start,
                                    z->start - start_z->start) < 0)
                        res = 1;
@@ -765,7 +772,8 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f)
        pthread_mutex_unlock(&f->zbd_info->mutex);
        for (z = zb ; z < ze; z++)
                pthread_mutex_unlock(&z->mutex);
-       dprint(FD_ZBD, "%s(%s): swd = %ld\n", __func__, f->file_name, swd);
+       dprint(FD_ZBD, "%s(%s): swd = %llu\n", __func__, f->file_name,
+               (unsigned long long) swd);
        /*
         * If data verification is enabled reset the affected zones before
         * writing any data to avoid that a zone reset has to be issued while
@@ -995,8 +1003,8 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
        }
 
        if (z->verify_block * min_bs >= f->zbd_info->zone_size)
-               log_err("%s: %d * %d >= %ld\n", f->file_name, z->verify_block,
-                       min_bs, f->zbd_info->zone_size);
+               log_err("%s: %d * %d >= %llu\n", f->file_name, z->verify_block,
+                       min_bs, (unsigned long long) f->zbd_info->zone_size);
        io_u->offset = z->start + z->verify_block++ * min_bs;
        return z;
 }
@@ -1301,7 +1309,7 @@ char *zbd_write_status(const struct thread_stat *ts)
 {
        char *res;
 
-       if (asprintf(&res, "; %ld zone resets", ts->nr_zone_resets) < 0)
+       if (asprintf(&res, "; %llu zone resets", (unsigned long long) ts->nr_zone_resets) < 0)
                return NULL;
        return res;
 }