X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=log.c;h=8754eb051a1ecfb3ba38290b8d88d5a6bb547c8a;hp=07ba950b9e147a5dfa98c7264fcebf660a5546d0;hb=8ce9cd3dfab6a802272378e02695e87ebe40a973;hpb=f29b25a370598d387e539c3dcae126274c6cbf4d diff --git a/log.c b/log.c index 07ba950b..8754eb05 100644 --- a/log.c +++ b/log.c @@ -57,44 +57,44 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u) { struct io_piece *ipo; -restart: - if (!list_empty(&td->io_log_list)) { + while (!list_empty(&td->io_log_list)) { ipo = list_entry(td->io_log_list.next, struct io_piece, list); list_del(&ipo->list); - io_u->offset = ipo->offset; - io_u->buflen = ipo->len; - io_u->ddir = ipo->ddir; - io_u->file = ipo->file; /* * invalid ddir, this is a file action */ - if (io_u->ddir == DDIR_INVAL) { + if (ipo->ddir == DDIR_INVAL) { struct fio_file *f = &td->files[ipo->fileno]; if (ipo->file_action == FIO_LOG_OPEN_FILE) { assert(!td_io_open_file(td, f)); free(ipo); - goto restart; + continue; } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) { td_io_close_file(td, f); free(ipo); - goto restart; + continue; } } + io_u->offset = ipo->offset; + io_u->buflen = ipo->len; + io_u->ddir = ipo->ddir; + io_u->file = &td->files[ipo->fileno]; + get_file(io_u->file); + + dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset, + io_u->buflen, io_u->file->file_name); + if (ipo->delay) iolog_delay(td, ipo->delay); - /* - * work around, this needs a format change to work for > 1 file - */ - if (!io_u->file) - io_u->file = &td->files[0]; free(ipo); return 0; } + td->done = 1; return 1; } @@ -108,6 +108,12 @@ void prune_io_piece_log(struct thread_data *td) rb_erase(n, &td->io_hist_tree); 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); + free(ipo); + } } /* @@ -132,8 +138,7 @@ 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. */ - if (!td_random(td) || !td->o.overwrite || - (io_u->file->flags & FIO_FILE_NOSORT)) { + if (!td_random(td) || !td->o.overwrite) { INIT_LIST_HEAD(&ipo->list); list_add_tail(&ipo->list, &td->io_hist_list); return; @@ -177,9 +182,10 @@ static int read_iolog2(struct thread_data *td, FILE *f) { unsigned long long offset; unsigned int bytes; - int rw, reads, writes, fileno = 0, file_action = 0; /* stupid gcc */ + int reads, writes, fileno = 0, file_action = 0; /* stupid gcc */ char *fname, *act; char *str, *p; + enum fio_ddir rw; free_release_files(td); @@ -235,9 +241,14 @@ static int read_iolog2(struct thread_data *td, FILE *f) if (rw == DDIR_READ) reads++; - else if (rw == DDIR_WRITE) + else if (rw == DDIR_WRITE) { writes++; - else if (rw != DDIR_SYNC && rw != DDIR_INVAL) { + /* + * Don't add a write for ro mode + */ + if (read_only) + continue; + } else if (rw != DDIR_SYNC && rw != DDIR_INVAL) { log_err("bad ddir: %d\n", rw); continue; } @@ -250,7 +261,7 @@ static int read_iolog2(struct thread_data *td, FILE *f) INIT_LIST_HEAD(&ipo->list); ipo->offset = offset; ipo->len = bytes; - ipo->ddir = (enum fio_ddir) rw; + ipo->ddir = rw; if (bytes > td->o.max_bs[rw]) td->o.max_bs[rw] = bytes; if (rw == DDIR_INVAL) { @@ -258,12 +269,18 @@ static int read_iolog2(struct thread_data *td, FILE *f) ipo->file_action = file_action; } list_add_tail(&ipo->list, &td->io_log_list); + td->total_io_size += bytes; } free(str); free(act); free(fname); + if (writes && read_only) { + log_err("fio: <%s> skips replay of %d writes due to read-only\n", td->o.name, writes); + writes = 0; + } + if (!reads && !writes) return 1; else if (reads && !writes) @@ -284,7 +301,8 @@ static int read_iolog(struct thread_data *td, FILE *f) unsigned long long offset; unsigned int bytes; char *str, *p; - int rw, reads, writes; + int reads, writes; + int rw; /* * Read in the read iolog and store it, reuse the infrastructure @@ -301,9 +319,14 @@ static int read_iolog(struct thread_data *td, FILE *f) } if (rw == DDIR_READ) reads++; - else if (rw == DDIR_WRITE) + else if (rw == DDIR_WRITE) { writes++; - else if (rw != DDIR_SYNC) { + /* + * Don't add a write for ro mode + */ + if (read_only) + continue; + } else if (rw != DDIR_SYNC) { log_err("bad ddir: %d\n", rw); continue; } @@ -317,10 +340,16 @@ static int read_iolog(struct thread_data *td, FILE *f) if (bytes > td->o.max_bs[rw]) td->o.max_bs[rw] = bytes; list_add_tail(&ipo->list, &td->io_log_list); + td->total_io_size += bytes; } free(str); + if (writes && read_only) { + log_err("fio: <%s> skips replay of %d writes due to read-only\n", td->o.name, writes); + writes = 0; + } + if (!reads && !writes) return 1; else if (reads && !writes)