14 int get_next_trim(struct thread_data *td, struct io_u *io_u)
19 * this io_u is from a requeue, we already filled the offsets
23 if (flist_empty(&td->trim_list))
26 assert(td->trim_entries);
27 ipo = flist_entry(td->trim_list.next, struct io_piece, trim_list);
28 remove_trim_entry(td, ipo);
29 ipo->flags |= IP_F_TRIMMED;
32 * If not verifying that trimmed ranges return zeroed data,
33 * remove this from the to-read verify lists
35 if (!td->o.trim_zero) {
36 if (ipo->flags & IP_F_ONLIST)
37 flist_del(&ipo->list);
39 assert(ipo->flags & IP_F_ONRB);
40 rb_erase(&ipo->rb_node, &td->io_hist_tree);
45 io_u->offset = ipo->offset;
46 io_u->buflen = ipo->len;
47 io_u->file = ipo->file;
49 if (!fio_file_open(io_u->file)) {
50 int r = td_io_open_file(td, io_u->file);
53 dprint(FD_VERIFY, "failed file %s open\n",
54 io_u->file->file_name);
60 assert(fio_file_open(io_u->file));
61 io_u->ddir = DDIR_TRIM;
62 io_u->xfer_buf = NULL;
63 io_u->xfer_buflen = io_u->buflen;
66 dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
70 int io_u_should_trim(struct thread_data *td, struct io_u *io_u)
72 unsigned long long val;
75 if (!td->o.trim_percentage)
78 r = os_random_long(&td->trim_state);
79 val = (OS_RAND_MAX / 100ULL);
80 val *= (unsigned long long) td->o.trim_percentage;