Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Apr 8, 2025

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit c283fe11bda9efde7f063e6fe693802724ddc8c0:

ci: set kvm permissions for GHA QEMU jobs (2025-04-04 11:27:27 -0400)

are available in the Git repository at:

git://git.kernel.dk/fio.git master

for you to fetch changes up to f18c2fd5f3e8114b5bfbe04e5511421c24b25fe1:

ci: add verify-trim.py test script (2025-04-07 10:54:38 -0400)

----------------------------------------------------------------
Vincent Fu (7):
fio: allow trim operations for verify/trim workloads
trim_verify: include a trim panel in the output
init: error out when readonly is set for a trim/verify workload verify/trim: stop issuing trims if we run out verify/trim: make trim_backlog_batch work t/verify-trim.py: superficial test script for verify/trim
ci: add verify-trim.py test script

 .github/workflows/qemu.yml |   4 +
 backend.c                  |   3 +-
 ci/actions-full-test.sh    |   2 +
 fio.h                      |  10 +-
 init.c                     |   9 +-
 io_u.c                     |  18 ++-
 t/run-fio-tests.py         |   8 ++
 t/verify-trim.py           | 309 +++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 354 insertions(+), 9 deletions(-)
 create mode 100755 t/verify-trim.py

---

Diff of recent changes:

.github/workflows/qemu.yml +4 -0
index db71fbe8..16787018 100644
@@ -49,6 +49,10 @@ jobs:
               -device nvme-ns,id=nvm-1,drive=nvm-1,bus=nvme0,nsid=1,logical_block_size=4096,physical_block_size=4096,fdp.ruhs=0-63
             test_cmd: "nvme fdp status /dev/ng0n1 && python3 t/nvmept_fdp.py --fio ./fio --dut /dev/ng0n1"
             extra_pkgs: "nvme-cli"
+          - config: verify-trim
+            device:
+            test_cmd: "python3 t/verify-trim.py"
+            extra_pkgs: sg3-utils
           - config: ZBD
             device:
             test_cmd: "./t/zbd/run-tests-against-nullb"
backend.c +2 -1
index b75eea80..f2a4ad35 100644
@@ -1994,7 +1994,8 @@ static void *thread_main(void *data)
 			update_runtime(td, elapsed_us, DDIR_READ);
 		if (td_write(td) && td->io_bytes[DDIR_WRITE])
 			update_runtime(td, elapsed_us, DDIR_WRITE);
-		if (td_trim(td) && td->io_bytes[DDIR_TRIM])
+		if (td->io_bytes[DDIR_TRIM] && (td_trim(td) ||
+			((td->flags & TD_F_TRIM_BACKLOG) && td_write(td))))
 			update_runtime(td, elapsed_us, DDIR_TRIM);
 		fio_gettime(&td->start, NULL);
 		fio_sem_up(stat_sem);
ci/actions-full-test.sh +2 -0
index 854788c1..4222a21a 100755
@@ -10,10 +10,12 @@ main() {
 
     echo "Running long running tests..."
     export PYTHONUNBUFFERED="TRUE"
+    # We can't load modules so skip 1018 which requires null_blk
     skip=(
         6
 	1007
 	1008
+	1018
     )
     args=(
         --debug
fio.h +9 -1
index d6423258..00f0f09b 100644
@@ -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)
init.c +8 -1
index 95f2179d..20f5462d 100644
@@ -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;
io_u.c +12 -6
index f7824717..17f5e853 100644
@@ -1749,20 +1749,26 @@ static bool check_get_trim(struct thread_data *td, struct io_u *io_u)
 {
 	if (!(td->flags & TD_F_TRIM_BACKLOG))
 		return false;
-	if (!td->trim_entries)
+	if (!td->trim_entries) {
+		td->trim_batch = 0;
 		return false;
+	}
 
 	if (td->trim_batch) {
 		td->trim_batch--;
 		if (get_next_trim(td, io_u))
 			return true;
+		else
+			td->trim_batch = 0;
 	} else if (!(td->io_hist_len % td->o.trim_backlog) &&
-		     td->last_ddir_completed != DDIR_READ) {
-		td->trim_batch = td->o.trim_batch;
-		if (!td->trim_batch)
-			td->trim_batch = td->o.trim_backlog;
-		if (get_next_trim(td, io_u))
+		     td->last_ddir_completed != DDIR_TRIM) {
+		if (get_next_trim(td, io_u)) {
+			td->trim_batch = td->o.trim_batch;
+			if (!td->trim_batch)
+				td->trim_batch = td->o.trim_backlog;
+			td->trim_batch--;
 			return true;
+		}
 	}
 
 	return false;
t/run-fio-tests.py +8 -0
index 7ceda067..b4863297 100755
@@ -1115,6 +1115,14 @@ TEST_LIST = [
         'success':          SUCCESS_LONG,
         'requirements':     [],
     },
+    {
+        'test_id':          1018,
+        'test_class':       FioExeTest,
+        'exe':              't/verify-trim.py',
+        'parameters':       ['-f', '{fio_path}'],
+        'success':          SUCCESS_DEFAULT,
+        'requirements':     [Requirements.linux],
+    },
 ]
 
 
t/verify-trim.py new file +309 -0

309 lines not on this page · raw message