Skip to contentSkip to conversation

Recent changes (master)

PATCH Jens Axboe 1 participant 1 message Oct 29

lore
Share & tools
lore

Jens Axboe

author
#0 lore raw

The following changes since commit 80eb2516037c627d77cd7e8a428cb534b830f9b6:

Merge branch 'configure-libatomic' of https://github.com/kraj/fio (2026-10-21 10:47:54 -0400)

are available in the Git repository at:

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

for you to fetch changes up to f8127399732876749f4855fb35ac3b8693fc7463:

Merge branch 'zbyrne/gpuaccel-null-backend-fix' of https://github.com/ROCm/fio (2026-10-28 14:14:27 -0400)

----------------------------------------------------------------
Artsem Lebiadzevich (1):
backend: issue the remaining backlog trims at the end of do_io()

Vincent Fu (2):
Merge branch 'trim-backlog-drain' of https://github.com/ViderStar/fio
Merge branch 'zbyrne/gpuaccel-null-backend-fix' of https://github.com/ROCm/fio

zbyrne (1):
engines/gpuaccel: Null check engine backend before registering opened file.

 backend.c          | 15 ++++++++++++++-
 engines/gpuaccel.c |  6 +++++-
 t/verify-trim.py   | 29 +++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

---

Diff of recent changes:

backend.c +14 -1
index 88557f0b..8843cdda 100644
@@ -1198,6 +1198,7 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done)
 		td->o.time_based) {
 		struct timespec comp_time;
 		struct io_u *io_u;
+		bool drain_trims = false;
 		int full;
 		enum fio_ddir ddir;
 
@@ -1219,13 +1220,25 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done)
 		if (flow_threshold_exceeded(td))
 			continue;
 
+		/*
+		 * Trims queued by trim_backlog are only issued when
+		 * io_hist_len reaches a multiple of the backlog. Once all
+		 * regular I/O has been issued, issue the remaining ones in
+		 * one batch instead of leaking them.
+		 */
+		if (td->trim_entries && (td->flags & TD_F_TRIM_BACKLOG) &&
+		    !td->o.time_based && io_issue_bytes_exceeded(td)) {
+			td->trim_batch = td->trim_entries;
+			drain_trims = true;
+		}
+
 		/*
 		 * Break if we exceeded the bytes. The exception is time
 		 * based runs, but we still need to break out of the loop
 		 * for those to run verification, if enabled.
 		 * Jobs read from iolog do not use this stop condition.
 		 */
-		if (bytes_issued >= total_bytes &&
+		if (!drain_trims && bytes_issued >= total_bytes &&
 		    !td->o.read_iolog_file &&
 		    (!td->o.time_based ||
 		     (td->o.time_based && td->o.verify != VERIFY_NONE)))
engines/gpuaccel.c +5 -1
index 75e89ac7..dc8415c5 100644
@@ -394,7 +394,11 @@ int fio_gpuaccel_open_file(struct thread_data *td, struct fio_file *f)
 	if (rc)
 		return rc;
 
-	if (o->io_mode == IO_DIRECT) {
+	/*
+	 * setup_files() opens block devices for a size check before ->init has
+	 * set o->backend; the handle is registered on the later real open.
+	 */
+	if (be && o->io_mode == IO_DIRECT) {
 		rc = be->file_handle_register(f->fd, &handle);
 		if (rc != 0) {
 			goto exit_err;
t/verify-trim.py +29 -0
index e95b2709..e072c7c5 100755
@@ -31,6 +31,7 @@ VERIFY_OPT_LIST = [
     'direct',
     'iodepth',
     'filesize',
+    'size',
     'bs',
     'time_based',
     'runtime',
@@ -209,6 +210,34 @@ TEST_LIST = [
             },
         "test_class": VerifyTrimTest,
     },
+    {
+        # seq write, trim_backlog larger than the number of writes:
+        # the queued trims must still be issued at the end
+        "test_id": 106,
+        "fio_opts": {
+            "rw": "write",
+            "trim_percentage": 50,
+            "trim_backlog": 1000,
+            "trim_verify_zero": 1,
+            "size": "1M",
+            "output-format": "json",
+            },
+        "test_class": VerifyTrimTest,
+    },
+    {
+        # rand write, trim_backlog larger than the number of writes:
+        # the queued trims must still be issued at the end
+        "test_id": 107,
+        "fio_opts": {
+            "rw": "randwrite",
+            "trim_percentage": 50,
+            "trim_backlog": 1000,
+            "trim_verify_zero": 1,
+            "size": "1M",
+            "output-format": "json",
+            },
+        "test_class": VerifyTrimTest,
+    },
     {
         # do_verify=0: trim must still be issued when trim_percentage=100
         "test_id": 200,