On 2/14/24 5:06 AM, Ankit Kumar wrote: > @@ -609,6 +619,14 @@ static inline void fio_ro_check(const struct thread_data *td, struct io_u *io_u) > !(io_u->ddir == DDIR_TRIM && !td_trim(td))); > } > > +static inline bool multi_range_trim(struct thread_data *td, struct io_u *io_u) > +{ > + if (io_u->ddir == DDIR_TRIM && td->o.num_range > 1) > + return true; > + else > + return false; > +} > + Nit: unnecessary else, just get rid of it. > @@ -966,22 +969,68 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) > else if (td->o.zone_mode == ZONE_MODE_ZBD) > setup_zbd_zone_mode(td, io_u); > > - /* > - * No log, let the seq/rand engine retrieve the next buflen and > - * position. > - */ > - if (get_next_offset(td, io_u, &is_random)) { > - dprint(FD_IO, "io_u %p, failed getting offset\n", io_u); > - return 1; > - } > + if (multi_range_trim(td, io_u)) { > + buf = io_u->buf; > + buflen = 0; > > - io_u->buflen = get_next_buflen(td, io_u, is_random); > - if (!io_u->buflen) { > - dprint(FD_IO, "io_u %p, failed getting buflen\n", io_u); > - return 1; > - } > + while (i < td->o.num_range) { > + range = (struct trim_range *)buf; > + if (get_next_offset(td, io_u, &is_random)) { > + dprint(FD_IO, "io_u %p, failed getting offset\n", > + io_u); > + break; > + } > + > + io_u->buflen = get_next_buflen(td, io_u, is_random); > + if (!io_u->buflen) { > + dprint(FD_IO, "io_u %p, failed getting buflen\n", io_u); > + break; > + } > + > + if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { > + dprint(FD_IO, "io_u %p, off=0x%llx + len=0x%llx exceeds file size=0x%llx\n", > + io_u, > + (unsigned long long) io_u->offset, io_u->buflen, > + (unsigned long long) io_u->file->real_file_size); > + break; > + } > + > + range->start = io_u->offset; > + range->len = io_u->buflen; > + buflen += io_u->buflen; > + f->last_start[io_u->ddir] = io_u->offset; > + f->last_pos[io_u->ddir] = io_u->offset + range->len; > + > + buf += sizeof(struct trim_range); > + i++; > > + if (td_random(td) && file_randommap(td, io_u->file)) > + mark_random_map(td, io_u, io_u->offset, io_u->buflen); > + } > + if (buflen) { > + io_u->buflen = buflen; > + io_u->number_trim = i; > + } else { > + return 1; > + } > + } else { > + /* > + * No log, let the seq/rand engine retrieve the next buflen and > + * position. > + */ > + if (get_next_offset(td, io_u, &is_random)) { > + dprint(FD_IO, "io_u %p, failed getting offset\n", io_u); > + return 1; > + } > + > + io_u->buflen = get_next_buflen(td, io_u, is_random); > + if (!io_u->buflen) { > + dprint(FD_IO, "io_u %p, failed getting buflen\n", io_u); > + return 1; > + } > + } This is a huge block and a bit of a mess because of it - since this is highly unlikely for anything but special workloads, please move it into a function so we can hopefully get it out-of-line in the hot path. Also looks like you forgot to bump the server version? -- Jens Axboe