From: Vincent Fu Date: Mon, 31 Mar 2025 14:01:30 +0000 (-0400) Subject: init: error out when readonly is set for a trim/verify workload X-Git-Tag: fio-3.40~36 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=940837453a72c3babfd02fdc042e1e64de59a3c1;p=fio.git init: error out when readonly is set for a trim/verify workload 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 --- diff --git a/init.c b/init.c index 85ae67fd..20f5462d 100644 --- 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, "