fio: allow trim operations for verify/trim workloads
authorVincent Fu <vincentfu@gmail.com>
Mon, 31 Mar 2025 14:01:28 +0000 (10:01 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 7 Apr 2025 14:54:38 +0000 (10:54 -0400)
Fio has the ability to verify trim operations by running a verify
workload and setting the trim_percentage, trim_backlog, and
trim_verify_zero options. Some of the written blocks will then be
trimmed and then read back to see if they are zeroed out.

This patch changes fio_ro_check to allow trim operations when fio is
running a verify/trim workload.

Fixes: 196ccc44 ("fio.h: also check trim operations in fio_ro_check")
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
fio.h
init.c

diff --git a/fio.h b/fio.h
index d642325813fd844859e1ff74f0ddc4752daa059f..00f0f09b09daa9af9ab71ab680ae376871706458 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -292,6 +292,7 @@ struct thread_data {
 
        unsigned int verify_batch;
        unsigned int trim_batch;
+       bool trim_verify;
 
        struct thread_io_list *vstate;
 
@@ -618,7 +619,14 @@ extern bool eta_time_within_slack(unsigned int time);
 static inline void fio_ro_check(const struct thread_data *td, struct io_u *io_u)
 {
        assert(!(io_u->ddir == DDIR_WRITE && !td_write(td)) &&
-              !(io_u->ddir == DDIR_TRIM && !td_trim(td)));
+              !(io_u->ddir == DDIR_TRIM && !(td_trim(td) || td->trim_verify)));
+
+       /*
+        * The last line above allows trim operations during trim/verify
+        * workloads. For these workloads we cannot simply set the trim bit for
+        * the thread's ddir because then fio would assume that
+        * ddir={trimewrite, randtrimwrite}.
+        */
 }
 
 static inline bool multi_range_trim(struct thread_data *td, struct io_u *io_u)
diff --git a/init.c b/init.c
index 95f2179d6b4b189f9055c696f2e0ea1def2ec700..85ae67fdb2876f4e9f2e84af6def5ad81f9e92a1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -729,6 +729,13 @@ static int fixup_options(struct thread_data *td)
                                                o->start_delay_high);
        }
 
+       /*
+        * Denote whether we are verifying trims. Now we only have to check a
+        * single variable instead of having to check all three options.
+        */
+       td->trim_verify = o->verify && o->trim_backlog && o->trim_percentage;
+       dprint(FD_VERIFY, "td->trim_verify=%d\n", td->trim_verify);
+
        if (o->norandommap && o->verify != VERIFY_NONE
            && !fixed_block_size(o))  {
                log_err("fio: norandommap given for variable block sizes, "