buc->type = B_TYPE_READ;
} else if (io_u->ddir == DDIR_WRITE) {
binject_buc_init(bd, io_u);
- buc->type = B_TYPE_WRITE;
+ if (io_u->flags & IO_U_F_BARRIER)
+ buc->type = B_TYPE_WRITEBARRIER;
+ else
+ buc->type = B_TYPE_WRITE;
} else if (io_u->ddir == DDIR_TRIM) {
binject_buc_init(bd, io_u);
buc->type = B_TYPE_DISCARD;
.open_file = fio_binject_open_file,
.close_file = fio_binject_close_file,
.get_file_size = generic_get_file_size,
- .flags = FIO_RAWIO,
+ .flags = FIO_RAWIO | FIO_BARRIER,
};
#else /* FIO_HAVE_BINJECT */
unsigned int thinktime_blocks;
unsigned int fsync_blocks;
unsigned int fdatasync_blocks;
+ unsigned int barrier_blocks;
unsigned long start_delay;
unsigned long long timeout;
unsigned long long ramp_time;
return td->rwmix_ddir;
}
+static void set_rw_ddir(struct thread_data *td, struct io_u *io_u)
+{
+ io_u->ddir = get_rw_ddir(td);
+
+ if (io_u->ddir == DDIR_WRITE && (td->io_ops->flags & FIO_BARRIER) &&
+ td->o.barrier_blocks &&
+ !(td->io_issues[DDIR_WRITE] % td->o.barrier_blocks) &&
+ td->io_issues[DDIR_WRITE])
+ io_u->flags |= IO_U_F_BARRIER;
+}
+
void put_file_log(struct thread_data *td, struct fio_file *f)
{
int ret = put_file(td, f);
if (td->io_ops->flags & FIO_NOIO)
goto out;
- io_u->ddir = get_rw_ddir(td);
+ set_rw_ddir(td, io_u);
/*
* fsync() or fdatasync() or trim etc, we are done
if (io_u) {
assert(io_u->flags & IO_U_F_FREE);
io_u->flags &= ~(IO_U_F_FREE | IO_U_F_FREE_DEF);
- io_u->flags &= ~IO_U_F_TRIMMED;
+ io_u->flags &= ~(IO_U_F_TRIMMED | IO_U_F_BARRIER);
io_u->error = 0;
flist_del(&io_u->list);
IO_U_F_IN_CUR_DEPTH = 1 << 3,
IO_U_F_BUSY_OK = 1 << 4,
IO_U_F_TRIMMED = 1 << 5,
+ IO_U_F_BARRIER = 1 << 6,
};
/*
FIO_NOIO = 1 << 6, /* thread does only pseudo IO */
FIO_SIGQUIT = 1 << 7, /* needs SIGQUIT to exit */
FIO_PIPEIO = 1 << 8, /* input/output no seekable */
+ FIO_BARRIER = 1 << 9, /* engine supports barriers */
};
/*
.help = "Issue fdatasync for writes every given number of blocks",
.def = "0",
},
+ {
+ .name = "write_barrier",
+ .type = FIO_OPT_INT,
+ .off1 = td_var_offset(barrier_blocks),
+ .help = "Make every Nth write a barrier write",
+ .def = "0",
+ },
#ifdef FIO_HAVE_SYNC_FILE_RANGE
{
.name = "sync_file_range",