11 bool get_next_trim(struct thread_data *td, struct io_u *io_u)
16 * this io_u is from a requeue, we already filled the offsets
20 if (flist_empty(&td->trim_list))
23 assert(td->trim_entries);
24 ipo = flist_first_entry(&td->trim_list, struct io_piece, trim_list);
25 remove_trim_entry(td, ipo);
27 io_u->offset = ipo->offset;
28 io_u->buflen = ipo->len;
29 io_u->file = ipo->file;
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 ipo->flags |= IP_F_TRIMMED;
47 if (!fio_file_open(io_u->file)) {
48 int r = td_io_open_file(td, io_u->file);
51 dprint(FD_VERIFY, "failed file %s open\n",
52 io_u->file->file_name);
58 assert(fio_file_open(io_u->file));
59 io_u->ddir = DDIR_TRIM;
60 io_u->xfer_buf = NULL;
61 io_u->xfer_buflen = io_u->buflen;
63 dprint(FD_VERIFY, "get_next_trim: ret io_u %p\n", io_u);
67 bool io_u_should_trim(struct thread_data *td, struct io_u *io_u)
69 unsigned long long val;
73 if (!td->o.trim_percentage)
76 frand_max = rand_max(&td->trim_state);
77 r = __rand(&td->trim_state);
78 val = (frand_max / 100ULL);
80 val *= (unsigned long long) td->o.trim_percentage;