#include <assert.h>
#include "flist.h"
#include "fio.h"
+#include "verify.h"
static const char iolog_ver2[] = "fio version 2 iolog";
void log_io_u(struct thread_data *td, struct io_u *io_u)
{
- const char *act[] = { "read", "write", "sync" };
+ const char *act[] = { "read", "write", "sync", "datasync" };
assert(io_u->ddir < 3);
*
* For both these cases, just reading back data in the order we
* wrote it out is the fastest.
+ *
+ * One exception is if we don't have a random map AND we are doing
+ * verifies, in that case we need to check for duplicate blocks and
+ * drop the old one, which we rely on the rb insert/lookup for
+ * handling.
*/
- if (!td_random(td) || !td->o.overwrite) {
+ if ((!td_random(td) || !td->o.overwrite) &&
+ (file_randommap(td, ipo->file) || td->o.verify == VERIFY_NONE)) {
INIT_FLIST_HEAD(&ipo->list);
flist_add_tail(&ipo->list, &td->io_hist_list);
return;
}
RB_CLEAR_NODE(&ipo->rb_node);
- p = &td->io_hist_tree.rb_node;
- parent = NULL;
/*
* Sort the entry into the verification list
*/
+restart:
+ p = &td->io_hist_tree.rb_node;
+ parent = NULL;
while (*p) {
parent = *p;
__ipo = rb_entry(parent, struct io_piece, rb_node);
- if (ipo->offset <= __ipo->offset)
+ if (ipo->offset < __ipo->offset)
p = &(*p)->rb_left;
- else
+ else if (ipo->offset > __ipo->offset)
p = &(*p)->rb_right;
+ else {
+ assert(ipo->len == __ipo->len);
+ rb_erase(parent, &td->io_hist_tree);
+ goto restart;
+ }
}
rb_link_node(&ipo->rb_node, parent, p);
rw = DDIR_WRITE;
else if (!strcmp(act, "sync"))
rw = DDIR_SYNC;
+ else if (!strcmp(act, "datasync"))
+ rw = DDIR_DATASYNC;
else {
log_err("fio: bad iolog file action: %s\n",
act);
if (read_only)
continue;
writes++;
- } else if (rw != DDIR_SYNC && rw != DDIR_INVAL) {
+ } else if (!ddir_sync(rw)) {
log_err("bad ddir: %d\n", rw);
continue;
}
{
int ret = 0;
- if (td->io_ops->flags & FIO_DISKLESSIO)
- return 0;
-
if (td->o.read_iolog_file) {
/*
* Check if it's a blktrace file and load that if possible.
}
for (i = 0; i < log->nr_samples; i++) {
- fprintf(f, "%lu, %lu, %u\n", log->log[i].time, log->log[i].val,
- log->log[i].ddir);
+ fprintf(f, "%lu, %lu, %u, %u\n", log->log[i].time,
+ log->log[i].val,
+ log->log[i].ddir,
+ log->log[i].bs);
}
fclose(f);