if (!td->o.write_iolog_file)
return;
- fprintf(td->iolog_f, "%s %s %llu %lu\n", io_u->file->file_name, act[io_u->ddir], io_u->offset, io_u->buflen);
+ fprintf(td->iolog_f, "%s %s %llu %lu\n", io_u->file->file_name,
+ act[io_u->ddir], io_u->offset,
+ io_u->buflen);
}
void log_file(struct thread_data *td, struct fio_file *f,
* invalid ddir, this is a file action
*/
if (ipo->ddir == DDIR_INVAL) {
- struct fio_file *f = &td->files[ipo->fileno];
+ struct fio_file *f = td->files[ipo->fileno];
if (ipo->file_action == FIO_LOG_OPEN_FILE) {
assert(!td_io_open_file(td, f));
io_u->offset = ipo->offset;
io_u->buflen = ipo->len;
io_u->ddir = ipo->ddir;
- io_u->file = &td->files[ipo->fileno];
+ 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);
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);
+ }
}
/*
* 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;
struct io_piece *ipo;
int r;
- r = sscanf(p, "%256s %256s %llu %u", fname, act, &offset, &bytes);
+ r = sscanf(p, "%256s %256s %llu %u", fname, act, &offset,
+ &bytes);
if (r == 4) {
/*
* Check action first
else if (!strcmp(act, "sync"))
rw = DDIR_SYNC;
else {
- log_err("fio: bad iolog file action: %s\n",act);
+ log_err("fio: bad iolog file action: %s\n",
+ act);
continue;
}
} else if (r == 2) {
fileno = get_fileno(td, fname);
file_action = FIO_LOG_CLOSE_FILE;
} else {
- log_err("fio: bad iolog file action: %s\n",act);
+ log_err("fio: bad iolog file action: %s\n",
+ act);
continue;
}
} else {
log_err("bad iolog2: %s", p);
continue;
}
-
+
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;
}
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)
unsigned int bytes;
char *str, *p;
int reads, writes;
- enum fio_ddir rw;
+ int rw;
/*
* Read in the read iolog and store it, reuse the infrastructure
}
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;
}
INIT_LIST_HEAD(&ipo->list);
ipo->offset = offset;
ipo->len = bytes;
- ipo->ddir = rw;
+ ipo->ddir = (enum fio_ddir) rw;
if (bytes > td->o.max_bs[rw])
td->o.max_bs[rw] = bytes;
list_add_tail(&ipo->list, &td->io_log_list);
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)
return;
}
- 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);
+ 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);
+ }
fclose(f);
free(log->log);