#include <stdlib.h>
#include <libgen.h>
#include <assert.h>
-#include "list.h"
+#include "flist.h"
#include "fio.h"
static const char iolog_ver2[] = "fio version 2 iolog";
void queue_io_piece(struct thread_data *td, struct io_piece *ipo)
{
- list_add_tail(&ipo->list, &td->io_log_list);
+ flist_add_tail(&ipo->list, &td->io_log_list);
td->total_io_size += ipo->len;
}
{
struct io_piece *ipo;
- while (!list_empty(&td->io_log_list)) {
+ while (!flist_empty(&td->io_log_list)) {
int ret;
- ipo = list_entry(td->io_log_list.next, struct io_piece, list);
- list_del(&ipo->list);
+ ipo = flist_entry(td->io_log_list.next, struct io_piece, list);
+ flist_del(&ipo->list);
ret = ipo_special(td, ipo);
if (ret < 0) {
free(ipo);
}
- while (!list_empty(&td->io_hist_list)) {
- ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
- list_del(&ipo->list);
+ while (!flist_empty(&td->io_hist_list)) {
+ ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
+ flist_del(&ipo->list);
free(ipo);
}
}
*
* 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) {
- INIT_LIST_HEAD(&ipo->list);
- list_add_tail(&ipo->list, &td->io_hist_list);
+ 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);
*/
ipo = malloc(sizeof(*ipo));
memset(ipo, 0, sizeof(*ipo));
- INIT_LIST_HEAD(&ipo->list);
+ INIT_FLIST_HEAD(&ipo->list);
ipo->offset = offset;
ipo->len = bytes;
ipo->ddir = rw;
FILE *f;
unsigned int i;
- f = fopen(td->o.write_iolog_file, "w+");
+ f = fopen(td->o.write_iolog_file, "a");
if (!f) {
perror("fopen write iolog");
return 1;
{
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.
unsigned int i;
FILE *f;
- f = fopen(name, "w");
+ f = fopen(name, "a");
if (!f) {
perror("fopen log");
return;
free(log);
}
-void finish_log(struct thread_data *td, struct io_log *log, const char *name)
+void finish_log_named(struct thread_data *td, struct io_log *log,
+ const char *prefix, const char *postfix)
{
char file_name[256], *p;
- snprintf(file_name, 200, "%s_%s.log", td->o.name, name);
+ snprintf(file_name, 200, "%s_%s.log", prefix, postfix);
p = basename(file_name);
__finish_log(log, p);
}
+
+void finish_log(struct thread_data *td, struct io_log *log, const char *name)
+{
+ finish_log_named(td, log, td->o.name, name);
+}