#!/bin/sh
GVF=FIO-VERSION-FILE
-DEF_VER=fio-3.9
+DEF_VER=fio-3.10
LF='
'
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
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)
}
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;
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;
}
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);
}
}
-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;
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)
}
}
- 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,
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);
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);
{
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)
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;
}
{
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)
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";
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);
struct client_file *files;
unsigned int nr_files;
+
+ struct buf_output buf;
};
typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
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"
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
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
+++ /dev/null
-/*
- * 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);
-}
--- /dev/null
+; 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
+++ /dev/null
-; 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
--- /dev/null
+; 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
+++ /dev/null
-; 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
--- /dev/null
+; 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
+++ /dev/null
-; 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
--- /dev/null
+; 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
+++ /dev/null
-; 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
--- /dev/null
+[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
+++ /dev/null
-[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
--- /dev/null
+; 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
+++ /dev/null
-; 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
+++ /dev/null
-# 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
{
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);
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)
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);
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);
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
}
/* 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;
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);
* 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;
* 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;
* 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;
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)
#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);
#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)
{
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;
}
* take that into account.
*/
for (i = 3; i < 64; i++)
- if ((1UL << i) > size)
+ if ((1ULL << i) > size)
return lfsr_taps[i];
return NULL;
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;
[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];
unitprefix = sistr;
for (post_index = 0; base > 1; post_index++)
- base /= thousand[!!pow2];
+ base /= thousand;
switch (units) {
case N2S_NONE:
* 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++;
}
* 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]);
static void zipf_update(struct zipf_state *zs)
{
- unsigned long to_gen;
+ uint64_t to_gen;
unsigned int i;
/*
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));
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);
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;
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;
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
.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",
<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" />
<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"/>
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;
}
}
- 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);
}
SYSTEM_INFO sysInfo;
MEMORYSTATUSEX status;
- switch (name)
- {
+ switch (name) {
case _SC_NPROCESSORS_ONLN:
val = GetNumLogicalProcessors();
if (val == -1)
/* 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);
}
-char* ctime_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)
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);
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;
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());
success = UnmapViewOfFile(addr);
if (!success)
- {
success = VirtualFree(addr, 0, MEM_RELEASE);
- }
return !success;
}
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)
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) {
{
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;
* 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;
int munlock(const void * addr, size_t len)
{
BOOL success = VirtualUnlock((LPVOID)addr, len);
+
if (!success) {
errno = win_to_posix_error(GetLastError());
return -1;
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)
{
- void* mapAddr;
+ 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());
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;
}
{
int64_t pos = _telli64(fildes);
ssize_t len = _write(fildes, buf, nbyte);
+
_lseeki64(fildes, pos, SEEK_SET);
return len;
}
{
int64_t pos = _telli64(fildes);
ssize_t len = read(fildes, buf, nbyte);
+
_lseeki64(fildes, pos, SEEK_SET);
return len;
}
{
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;
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);
}
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;
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;
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));
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)
}
#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;
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));
} 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));
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);
} 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);
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;
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]);
#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;
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;
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;
int main(int argc, char *argv[])
{
- size_t size = (1UL << 23) - 200;
+ uint64_t size = (1ULL << 23) - 200;
int seed = 1;
if (argc > 1) {
--- /dev/null
+# Expected result: fio runs and completes the job
+# Buggy result: fio segfaults
+#
+[test]
+ioengine=null
+size=10g
+io_submit_mode=offload
+iodepth=16
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
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
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)
#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
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()
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;
}
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;
}
}
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]));
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;
}
}
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.
{
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;
}
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);
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;
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;
}
}
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;
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
}
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;
}
{
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;
}