#include "hash.h"
#include "smalloc.h"
#include "verify.h"
+#include "trim.h"
#include "diskutil.h"
#include "cgroup.h"
#include "profile.h"
td_set_runstate(td, TD_RUNNING);
while ( (td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
+ (!flist_empty(&td->trim_list)) ||
((td->this_io_bytes[0] + td->this_io_bytes[1]) < td->o.size) ) {
struct timeval comp_time;
unsigned long bytes_done[2] = { 0, 0 };
}
}
+ assert(!td->trim_entries);
+
if (td->o.fill_device && td->error == ENOSPC) {
td->error = 0;
td->terminate = 1;
if (io_u) {
assert(io_u->flags & IO_U_F_FREE);
io_u->flags &= ~(IO_U_F_FREE | IO_U_F_FREE_DEF);
+ io_u->flags &= ~IO_U_F_TRIMMED;
io_u->error = 0;
flist_del(&io_u->list);
};
unsigned long long offset;
unsigned long len;
- unsigned long flags;
+ unsigned int flags;
enum fio_ddir ddir;
union {
unsigned long delay;
if (io_u->file)
return 0;
if (flist_empty(&td->trim_list))
- return 0;
+ return 1;
assert(td->trim_entries);
ipo = flist_entry(td->trim_list.next, struct io_piece, trim_list);
remove_trim_entry(td, ipo);
- ipo->flags |= IP_F_TRIMMED;
+
+ io_u->offset = ipo->offset;
+ io_u->buflen = ipo->len;
+ io_u->file = ipo->file;
/*
* If not verifying that trimmed ranges return zeroed data,
rb_erase(&ipo->rb_node, &td->io_hist_tree);
}
td->io_hist_len--;
- }
-
- io_u->offset = ipo->offset;
- io_u->buflen = ipo->len;
- io_u->file = ipo->file;
+ free(ipo);
+ } else
+ ipo->flags |= IP_F_TRIMMED;
if (!fio_file_open(io_u->file)) {
int r = td_io_open_file(td, io_u->file);
}
}
- get_file(ipo->file);
+ get_file(io_u->file);
assert(fio_file_open(io_u->file));
io_u->ddir = DDIR_TRIM;
io_u->xfer_buf = NULL;
io_u->xfer_buflen = io_u->buflen;
- free(ipo);
dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
return 0;
}
if (!ret)
return 0;
- log_err("trims: verify failed at file %s offset %llu, length %lu\n",
- io_u->file->file_name, io_u->offset, io_u->buflen);
+ log_err("trim: verify failed at file %s offset %llu, length %lu"
+ ", block offset %lu\n",
+ io_u->file->file_name, io_u->offset, io_u->buflen,
+ (p - io_u->buf));
return ret;
}
ipo = rb_entry(n, struct io_piece, rb_node);
rb_erase(n, &td->io_hist_tree);
+ assert(ipo->flags & IP_F_ONRB);
+ ipo->flags &= ~IP_F_ONRB;
} else if (!flist_empty(&td->io_hist_list)) {
ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
flist_del(&ipo->list);
+ assert(ipo->flags & IP_F_ONLIST);
+ ipo->flags &= ~IP_F_ONLIST;
}
if (ipo) {