init: error out when readonly is set for a trim/verify workload
authorVincent Fu <vincentfu@gmail.com>
Mon, 31 Mar 2025 14:01:30 +0000 (10:01 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 7 Apr 2025 14:54:38 +0000 (10:54 -0400)
Fio may issue trim commands for a verify/trim job. Abort and print an
error message if this type of job is run with the --readonly option.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
init.c

diff --git a/init.c b/init.c
index 85ae67fdb2876f4e9f2e84af6def5ad81f9e92a1..20f5462d45bffdcd84c9cd935313825234cc34dd 100644 (file)
--- a/init.c
+++ b/init.c
@@ -612,7 +612,14 @@ static int fixup_options(struct thread_data *td)
        struct thread_options *o = &td->o;
        int ret = 0;
 
-       if (read_only && (td_write(td) || td_trim(td))) {
+       /*
+        * 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 (read_only && (td_write(td) || td_trim(td) || td->trim_verify)) {
                log_err("fio: trim and write operations are not allowed"
                         " with the --readonly parameter.\n");
                ret |= 1;
@@ -729,13 +736,6 @@ 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, "