if (td->o.read_iolog_file) { int need_swap; char * fname = get_name_by_idx(td->o.read_iolog_file, td->subjob_number);
/* * Check if it's a blktrace file and load that if possible. * Otherwise assume it's a normal log file and load that. */ if (is_blktrace(fname, &need_swap)) { td->io_log_blktrace = 1; ret = init_blktrace_read(td, fname, need_swap); } else { td->io_log_blktrace = 0; ret = init_iolog_read(td, fname); } free(fname); ... }
...
# blktrace.c
/* * Check if this is a blktrace binary data file. We read a single trace * into memory and check for the magic signature. */ boolis_blktrace(constchar *filename, int *need_swap) { structblk_io_tracet; int fd, ret;
fd = open(filename, O_RDONLY); if (fd < 0) returnfalse;
ret = read(fd, &t, sizeof(t)); close(fd);
if (ret < 0) { perror("read blktrace"); returnfalse; } elseif (ret != sizeof(t)) { log_err("fio: short read on blktrace file\n"); returnfalse; }
static int ipo_special(struct thread_data *td, struct io_piece *ipo) { struct fio_file *f; int ret;
/* * Not a special ipo */ if (ipo->ddir != DDIR_INVAL) return 0;
f = td->files[ipo->fileno];
if (ipo->delay) iolog_delay(td, ipo->delay); if (fio_fill_issue_time(td)) fio_gettime(&td->last_issue, NULL); switch (ipo->file_action) { case FIO_LOG_OPEN_FILE: if (td->o.replay_redirect && fio_file_open(f)) { dprint(FD_FILE, "iolog: ignoring re-open of file %s\n", f->file_name); break; } ret = td_io_open_file(td, f); if (!ret) break; td_verror(td, ret, "iolog open file"); return -1; case FIO_LOG_CLOSE_FILE: td_io_close_file(td, f); break; case FIO_LOG_UNLINK_FILE: td_io_unlink_file(td, f); break; case FIO_LOG_ADD_FILE: /* * Nothing to do */ break; default: log_err("fio: bad file action %d\n", ipo->file_action); break; }