X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=log.c;h=6604c1c8ac9295877e2f2a5b95ef2d54f09b21da;hb=8bb7679e73d3086a01b9d21a650b0d7a859412b6;hp=5c468ad9f96c0a708fde126482f01a3bb6a430c3;hpb=01743ee1718e7ec4b16ae3e53c8f64900c6052cc;p=fio.git diff --git a/log.c b/log.c index 5c468ad9..6604c1c8 100644 --- a/log.c +++ b/log.c @@ -183,28 +183,40 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u) * * 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); @@ -388,7 +400,7 @@ static int init_iolog_write(struct thread_data *td) 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; @@ -455,7 +467,7 @@ void __finish_log(struct io_log *log, const char *name) unsigned int i; FILE *f; - f = fopen(name, "w"); + f = fopen(name, "a"); if (!f) { perror("fopen log"); return; @@ -471,11 +483,17 @@ void __finish_log(struct io_log *log, const char *name) 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); +}