We need to do a little bit more to make sure that the writes land on the
offsets that were trimmed.
We only have a single random seed for offsets. So we need to just use
the offset from trim commands when issuing writes.
When we have variable block sizes we need to make sure that the trim and
write commands are the same size.
When randommap is enabled we have to let it adjust the block size for
trim commands to make sure that the trim command does not touch any
blocks that have already been touched.
For sizes of write commands just use the size of the trim command.
Fixes:
c16dc793a3c45780f67ce65244b6e91323dee014 "Add randtrimwrite data
direction"
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
#define file_randommap(td, f) (!(td)->o.norandommap && fio_file_axmap((f)))
#define td_trimwrite(td) (((td)->o.td_ddir & TD_DDIR_TRIMWRITE) \
== TD_DDIR_TRIMWRITE)
+#define td_randtrimwrite(td) (((td)->o.td_ddir & TD_DDIR_RANDTRIMWRITE) \
+ == TD_DDIR_RANDTRIMWRITE)
static inline int ddir_sync(enum fio_ddir ddir)
{
b = offset = -1ULL;
- if (rw_seq) {
+ if (td_randtrimwrite(td) && ddir == DDIR_WRITE) {
+ /* don't mark randommap for these writes */
+ io_u_set(td, io_u, IO_U_F_BUSY_OK);
+ offset = f->last_start[DDIR_TRIM];
+ *is_random = true;
+ ret = 0;
+ } else if (rw_seq) {
if (td_random(td)) {
if (should_do_random(td, ddir)) {
ret = get_next_rand_block(td, f, ddir, &b);
assert(ddir_rw(ddir));
+ if (td_randtrimwrite(td) && ddir == DDIR_WRITE) {
+ struct fio_file *f = io_u->file;
+
+ return f->last_pos[DDIR_TRIM] - f->last_start[DDIR_TRIM];
+ }
+
if (td->o.bs_is_seq_rand)
ddir = is_random ? DDIR_WRITE : DDIR_READ;