Merge in the arithmetic parser.
#!/bin/sh
GVF=FIO-VERSION-FILE
-DEF_VER=fio-2.1.12
+DEF_VER=fio-2.1.13
LF='
'
For certain types of io the result may still be skewed a bit,
since the speed may be different. It is possible to specify
a number of IO's to do before getting a new offset, this is
- one by appending a ':<nr>' to the end of the string given.
+ done by appending a ':<nr>' to the end of the string given.
For a random read, it would look like 'rw=randread:8' for
passing in an offset modifier with a value of 8. If the
suffix is used with a sequential IO pattern, then the value
while having 90% 4k writes and 10% 8k writes, you would
specify:
- bssplit=2k/50:4k/50,4k/90,8k/10
+ bssplit=2k/50:4k/50,4k/90:8k/10
blocksize_unaligned
bs_unaligned If this option is given, any byte size value within bsrange
}
static int fio_binject_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec fio_unused *t)
+ unsigned int max,
+ const struct timespec fio_unused *t)
{
struct binject_data *bd = td->io_ops->data;
int left = max, ret, r = 0, ev_index = 0;
}
static int fio_gf_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct gf_data *g = td->io_ops->data;
unsigned int events = 0;
}
static int fio_guasi_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct guasi_data *ld = td->io_ops->data;
int n, r;
struct io_event *aio_events;
struct iocb **iocbs;
struct io_u **io_us;
- int iocbs_nr;
+
+ /*
+ * Basic ring buffer. 'head' is incremented in _queue(), and
+ * 'tail' is incremented in _commit(). We keep 'queued' so
+ * that we know if the ring is full or empty, when
+ * 'head' == 'tail'. 'entries' is the ring size, and
+ * 'is_pow2' is just an optimization to use AND instead of
+ * modulus to get the remainder on ring increment.
+ */
+ int is_pow2;
+ unsigned int entries;
+ unsigned int queued;
+ unsigned int head;
+ unsigned int tail;
};
struct libaio_options {
},
};
+static inline void ring_inc(struct libaio_data *ld, unsigned int *val,
+ unsigned int add)
+{
+ if (ld->is_pow2)
+ *val = (*val + add) & (ld->entries - 1);
+ else
+ *val = (*val + add) % ld->entries;
+}
+
static int fio_libaio_prep(struct thread_data fio_unused *td, struct io_u *io_u)
{
struct fio_file *f = io_u->file;
}
static int fio_libaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct libaio_data *ld = td->io_ops->data;
struct libaio_options *o = td->eo;
unsigned actual_min = td->o.iodepth_batch_complete == 0 ? 0 : min;
+ struct timespec __lt, *lt = NULL;
int r, events = 0;
+ if (t) {
+ __lt = *t;
+ lt = &__lt;
+ }
+
do {
if (o->userspace_reap == 1
&& actual_min == 0
ld->aio_events + events);
} else {
r = io_getevents(ld->aio_ctx, actual_min,
- max, ld->aio_events + events, t);
+ max, ld->aio_events + events, lt);
}
if (r >= 0)
events += r;
else if (r == -EAGAIN)
usleep(100);
+ else
+ break;
} while (events < min);
return r < 0 ? r : events;
fio_ro_check(td, io_u);
- if (ld->iocbs_nr == (int) td->o.iodepth)
+ if (ld->queued == td->o.iodepth)
return FIO_Q_BUSY;
/*
* have pending io, to let fio complete those first.
*/
if (ddir_sync(io_u->ddir)) {
- if (ld->iocbs_nr)
+ if (ld->queued)
return FIO_Q_BUSY;
do_io_u_sync(td, io_u);
}
if (io_u->ddir == DDIR_TRIM) {
- if (ld->iocbs_nr)
+ if (ld->queued)
return FIO_Q_BUSY;
do_io_u_trim(td, io_u);
return FIO_Q_COMPLETED;
}
- ld->iocbs[ld->iocbs_nr] = &io_u->iocb;
- ld->io_us[ld->iocbs_nr] = io_u;
- ld->iocbs_nr++;
+ ld->iocbs[ld->head] = &io_u->iocb;
+ ld->io_us[ld->head] = io_u;
+ ring_inc(ld, &ld->head, 1);
+ ld->queued++;
return FIO_Q_QUEUED;
}
struct libaio_data *ld = td->io_ops->data;
struct iocb **iocbs;
struct io_u **io_us;
- int ret;
+ struct timeval tv;
+ int ret, wait_start = 0;
- if (!ld->iocbs_nr)
+ if (!ld->queued)
return 0;
- io_us = ld->io_us;
- iocbs = ld->iocbs;
do {
- ret = io_submit(ld->aio_ctx, ld->iocbs_nr, iocbs);
+ long nr = ld->queued;
+
+ nr = min((unsigned int) nr, ld->entries - ld->tail);
+ io_us = ld->io_us + ld->tail;
+ iocbs = ld->iocbs + ld->tail;
+
+ ret = io_submit(ld->aio_ctx, nr, iocbs);
if (ret > 0) {
fio_libaio_queued(td, io_us, ret);
io_u_mark_submit(td, ret);
- ld->iocbs_nr -= ret;
- io_us += ret;
- iocbs += ret;
+
+ ld->queued -= ret;
+ ring_inc(ld, &ld->tail, ret);
ret = 0;
- } else if (!ret || ret == -EAGAIN || ret == -EINTR) {
+ wait_start = 0;
+ } else if (ret == -EINTR || !ret) {
if (!ret)
io_u_mark_submit(td, ret);
+ wait_start = 0;
+ continue;
+ } else if (ret == -EAGAIN) {
+ /*
+ * If we get EAGAIN, we should break out without
+ * error and let the upper layer reap some
+ * events for us. If we have no queued IO, we
+ * must loop here. If we loop for more than 30s,
+ * just error out, something must be buggy in the
+ * IO path.
+ */
+ if (ld->queued) {
+ ret = 0;
+ break;
+ }
+ if (!wait_start) {
+ fio_gettime(&tv, NULL);
+ wait_start = 0;
+ } else if (mtime_since_now(&tv) > 30000) {
+ log_err("fio: aio appears to be stalled, giving up\n");
+ break;
+ }
+ usleep(1);
continue;
+ } else if (ret == -ENOMEM) {
+ /*
+ * If we get -ENOMEM, reap events if we can. If
+ * we cannot, treat it as a fatal event since there's
+ * nothing we can do about it.
+ */
+ if (ld->queued)
+ ret = 0;
+ break;
} else
break;
- } while (ld->iocbs_nr);
+ } while (ld->queued);
return ret;
}
static int fio_libaio_init(struct thread_data *td)
{
- struct libaio_data *ld = malloc(sizeof(*ld));
struct libaio_options *o = td->eo;
+ struct libaio_data *ld;
int err = 0;
- memset(ld, 0, sizeof(*ld));
+ ld = calloc(1, sizeof(*ld));
/*
* First try passing in 0 for queue depth, since we don't
return 1;
}
- ld->aio_events = malloc(td->o.iodepth * sizeof(struct io_event));
- memset(ld->aio_events, 0, td->o.iodepth * sizeof(struct io_event));
- ld->iocbs = malloc(td->o.iodepth * sizeof(struct iocb *));
- memset(ld->iocbs, 0, sizeof(struct iocb *));
- ld->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(ld->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
- ld->iocbs_nr = 0;
+ ld->entries = td->o.iodepth;
+ ld->is_pow2 = is_power_of_2(ld->entries);
+ ld->aio_events = calloc(ld->entries, sizeof(struct io_event));
+ ld->iocbs = calloc(ld->entries, sizeof(struct iocb *));
+ ld->io_us = calloc(ld->entries, sizeof(struct io_u *));
td->io_ops->data = ld;
return 0;
static int fio_null_getevents(struct thread_data *td, unsigned int min_events,
unsigned int fio_unused max,
- struct timespec fio_unused *t)
+ const struct timespec fio_unused *t)
{
struct null_data *nd = (struct null_data *) td->io_ops->data;
int ret = 0;
#define SUSPEND_ENTRIES 8
static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct posixaio_data *pd = td->io_ops->data;
os_aiocb_t *suspend_list[SUSPEND_ENTRIES];
}
static int fio_rbd_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct rbd_data *rbd_data = td->io_ops->data;
unsigned int events = 0;
}
static int fio_rdmaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct rdmaio_data *rd = td->io_ops->data;
enum ibv_wc_opcode comp_opcode;
}
static int fio_sgio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec fio_unused *t)
+ unsigned int max,
+ const struct timespec fio_unused *t)
{
struct sgio_data *sd = td->io_ops->data;
int left = max, ret, r = 0;
* numbers. Required.
*/
static int fio_skeleton_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
return 0;
}
}
static int fio_solarisaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max, const struct timespec *t)
{
struct solarisaio_data *sd = td->io_ops->data;
struct timeval tv;
static int fio_vsyncio_getevents(struct thread_data *td, unsigned int min,
unsigned int max,
- struct timespec fio_unused *t)
+ const struct timespec fio_unused *t)
{
struct syncio_data *sd = td->io_ops->data;
int ret;
static BOOL timeout_expired(DWORD start_count, DWORD end_count);
static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t);
+ unsigned int max, const struct timespec *t);
static struct io_u *fio_windowsaio_event(struct thread_data *td, int event);
static int fio_windowsaio_queue(struct thread_data *td,
struct io_u *io_u);
}
static int fio_windowsaio_getevents(struct thread_data *td, unsigned int min,
- unsigned int max, struct timespec *t)
+ unsigned int max,
+ const struct timespec *t)
{
struct windowsaio_data *wd = td->io_ops->data;
unsigned int dequeued = 0;
}
}
- if (!o->size || o->size > total_size)
+ if (!o->size || (total_size && o->size > total_size))
o->size = total_size;
if (o->size < td_min_bs(td)) {
extern struct thread_data *threads;
-static inline void fio_ro_check(struct thread_data *td, struct io_u *io_u)
+static inline void fio_ro_check(const struct thread_data *td, struct io_u *io_u)
{
assert(!(io_u->ddir == DDIR_WRITE && !td_write(td)));
}
#define FIO_TIME_H
struct thread_data;
-extern uint64_t utime_since(struct timeval *, struct timeval *);
-extern uint64_t utime_since_now(struct timeval *);
-extern uint64_t mtime_since(struct timeval *, struct timeval *);
-extern uint64_t mtime_since_now(struct timeval *);
-extern uint64_t time_since_now(struct timeval *);
+extern uint64_t utime_since(const struct timeval *,const struct timeval *);
+extern uint64_t utime_since_now(const struct timeval *);
+extern uint64_t mtime_since(const struct timeval *, const struct timeval *);
+extern uint64_t mtime_since_now(const struct timeval *);
+extern uint64_t time_since_now(const struct timeval *);
extern uint64_t mtime_since_genesis(void);
extern uint64_t utime_since_genesis(void);
extern void usec_spin(unsigned int);
log_info("fio: clocksource=cpu may not be reliable\n");
}
-uint64_t utime_since(struct timeval *s, struct timeval *e)
+uint64_t utime_since(const struct timeval *s, const struct timeval *e)
{
long sec, usec;
uint64_t ret;
return ret;
}
-uint64_t utime_since_now(struct timeval *s)
+uint64_t utime_since_now(const struct timeval *s)
{
struct timeval t;
return utime_since(s, &t);
}
-uint64_t mtime_since(struct timeval *s, struct timeval *e)
+uint64_t mtime_since(const struct timeval *s, const struct timeval *e)
{
long sec, usec, ret;
return ret;
}
-uint64_t mtime_since_now(struct timeval *s)
+uint64_t mtime_since_now(const struct timeval *s)
{
struct timeval t;
void *p = __builtin_return_address(0);
return mtime_since(s, &t);
}
-uint64_t time_since_now(struct timeval *s)
+uint64_t time_since_now(const struct timeval *s)
{
return mtime_since_now(s) / 1000;
}
* If latency target is enabled, we might be ramping up or down and not
* using the full queue depth available.
*/
-int queue_full(struct thread_data *td)
+int queue_full(const struct thread_data *td)
{
const int qempty = io_u_qempty(&td->io_u_freelist);
q->io_us[q->nr++] = io_u;
}
-static inline int io_u_qempty(struct io_u_queue *q)
+static inline int io_u_qempty(const struct io_u_queue *q)
{
return !q->nr;
}
#include <guasi.h>
#endif
-#define FIO_IOOPS_VERSION 20
+#define FIO_IOOPS_VERSION 21
enum {
IO_U_F_FREE = 1 << 0,
int (*prep)(struct thread_data *, struct io_u *);
int (*queue)(struct thread_data *, struct io_u *);
int (*commit)(struct thread_data *);
- int (*getevents)(struct thread_data *, unsigned int, unsigned int, struct timespec *);
+ int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
struct io_u *(*event)(struct thread_data *, int);
int (*cancel)(struct thread_data *, struct io_u *);
void (*cleanup)(struct thread_data *);
extern int __must_check td_io_prep(struct thread_data *, struct io_u *);
extern int __must_check td_io_queue(struct thread_data *, struct io_u *);
extern int __must_check td_io_sync(struct thread_data *, struct fio_file *);
-extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, struct timespec *);
+extern int __must_check td_io_getevents(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
extern int __must_check td_io_commit(struct thread_data *);
extern int __must_check td_io_open_file(struct thread_data *, struct fio_file *);
extern int td_io_close_file(struct thread_data *, struct fio_file *);
extern void io_u_fill_buffer(struct thread_data *td, struct io_u *, unsigned int, unsigned int);
void io_u_mark_complete(struct thread_data *, unsigned int);
void io_u_mark_submit(struct thread_data *, unsigned int);
-int queue_full(struct thread_data *);
+int queue_full(const struct thread_data *);
-int do_io_u_sync(struct thread_data *, struct io_u *);
-int do_io_u_trim(struct thread_data *, struct io_u *);
+int do_io_u_sync(const struct thread_data *, struct io_u *);
+int do_io_u_trim(const struct thread_data *, struct io_u *);
#ifdef FIO_INC_DEBUG
static inline void dprint_io_u(struct io_u *io_u, const char *p)
}
int td_io_getevents(struct thread_data *td, unsigned int min, unsigned int max,
- struct timespec *t)
+ const struct timespec *t)
{
int r = 0;
return td->io_ops->get_file_size(td, f);
}
-static int do_sync_file_range(struct thread_data *td, struct fio_file *f)
+static int do_sync_file_range(const struct thread_data *td,
+ struct fio_file *f)
{
off64_t offset, nbytes;
return sync_file_range(f->fd, offset, nbytes, td->o.sync_file_range);
}
-int do_io_u_sync(struct thread_data *td, struct io_u *io_u)
+int do_io_u_sync(const struct thread_data *td, struct io_u *io_u)
{
int ret;
return ret;
}
-int do_io_u_trim(struct thread_data *td, struct io_u *io_u)
+int do_io_u_trim(const struct thread_data *td, struct io_u *io_u)
{
#ifndef FIO_HAVE_TRIM
io_u->error = EINVAL;
td->total_io_size += ipo->len;
}
-void log_io_u(struct thread_data *td, struct io_u *io_u)
+void log_io_u(const struct thread_data *td, const struct io_u *io_u)
{
if (!td->o.write_iolog_file)
return;
td->io_hist_len--;
}
-void trim_io_piece(struct thread_data *td, struct io_u *io_u)
+void trim_io_piece(struct thread_data *td, const struct io_u *io_u)
{
struct io_piece *ipo = io_u->ipo;
void setup_log(struct io_log **log, struct log_params *p,
const char *filename)
{
- struct io_log *l = malloc(sizeof(*l));
+ struct io_log *l;
- memset(l, 0, sizeof(*l));
+ l = calloc(1, sizeof(*l));
l->nr_samples = 0;
l->max_samples = 1024;
l->log_type = p->log_type;
struct io_u;
extern int __must_check read_iolog_get(struct thread_data *, struct io_u *);
-extern void log_io_u(struct thread_data *, struct io_u *);
+extern void log_io_u(const struct thread_data *, const struct io_u *);
extern void log_file(struct thread_data *, struct fio_file *, enum file_log_act);
extern int __must_check init_iolog(struct thread_data *td);
extern void log_io_piece(struct thread_data *, struct io_u *);
extern void unlog_io_piece(struct thread_data *, struct io_u *);
-extern void trim_io_piece(struct thread_data *, struct io_u *);
+extern void trim_io_piece(struct thread_data *, const struct io_u *);
extern void queue_io_piece(struct thread_data *, struct io_piece *);
extern void prune_io_piece_log(struct thread_data *);
extern void write_iolog_close(struct thread_data *);
struct json_object *json_create_object(void)
{
- struct json_object *obj = malloc(sizeof(struct json_object));
- if (obj)
- memset(obj, 0, sizeof(struct json_object));
- return obj;
+ return calloc(1, sizeof(struct json_object));
}
struct json_array *json_create_array(void)
{
- struct json_array *array = malloc(sizeof(struct json_array));
- if (array)
- memset(array, 0, sizeof(struct json_array));
- return array;
+ return calloc(1, sizeof(struct json_array));
}
static struct json_pair *json_create_pair(const char *name, struct json_value *value)
<Product Id="*"
Codepage="1252" Language="1033"
Manufacturer="fio" Name="fio"
- UpgradeCode="2338A332-5511-43CF-B9BD-5C60496CCFCC" Version="2.1.12">
+ UpgradeCode="2338A332-5511-43CF-B9BD-5C60496CCFCC" Version="2.1.13">
<Package
Description="Flexible IO Tester"
InstallerVersion="301" Keywords="Installer,MSI,Database"