14 bool 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_first_entry(&td->trim_list, struct io_piece, trim_list);
28 remove_trim_entry(td, ipo);
30 io_u->offset = ipo->offset;
31 io_u->buflen = ipo->len;
32 io_u->file = ipo->file;
35 * If not verifying that trimmed ranges return zeroed data,
36 * remove this from the to-read verify lists
38 if (!td->o.trim_zero) {
39 if (ipo->flags & IP_F_ONLIST)
40 flist_del(&ipo->list);
42 assert(ipo->flags & IP_F_ONRB);
43 rb_erase(&ipo->rb_node, &td->io_hist_tree);
48 ipo->flags |= IP_F_TRIMMED;
50 if (!fio_file_open(io_u->file)) {
51 int r = td_io_open_file(td, io_u->file);
54 dprint(FD_VERIFY, "failed file %s open\n",
55 io_u->file->file_name);
61 assert(fio_file_open(io_u->file));
62 io_u->ddir = DDIR_TRIM;
63 io_u->xfer_buf = NULL;
64 io_u->xfer_buflen = io_u->buflen;
66 dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
70 bool io_u_should_trim(struct thread_data *td, struct io_u *io_u)
72 unsigned long long val;
76 if (!td->o.trim_percentage)
79 frand_max = rand_max(&td->trim_state);
80 r = __rand(&td->trim_state);
81 val = (frand_max / 100ULL);
83 val *= (unsigned long long) td->o.trim_percentage;