backend: clean up requeued io_u's master
authorVincent Fu <vincent.fu@samsung.com>
Wed, 4 Jun 2025 22:00:01 +0000 (22:00 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 5 Jun 2025 01:44:43 +0000 (01:44 +0000)
When an atttempt to queue an io_u returns FIO_Q_BUSY, the io_u is added
to td->io_u_requeues. If the runtime timeout expires with
td->io_u_requeues not empty, the job will not close the relevant
file because its file->references will be non-zero since the requeued
io_u still holds a reference to the file.

This patch discards the contents of td->io_u_requeues during io_u
cleanup which leads to file closure when its last reference is
destroyed. This is relevant for resource-constrained environments.

Suggested-by: Jonghwi Jeong <jongh2.jeong@samsung.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
backend.c

index f2a4ad35e208540ab80638ab9c9c9668d2dec4e0..0cdee86465edf826917a859dbb38a87063c6e263 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1284,6 +1284,10 @@ static void cleanup_io_u(struct thread_data *td)
                fio_memfree(io_u, sizeof(*io_u), td_offload_overlap(td));
        }
 
                fio_memfree(io_u, sizeof(*io_u), td_offload_overlap(td));
        }
 
+       while ((io_u = io_u_rpop(&td->io_u_requeues)) != NULL) {
+               put_io_u(td, io_u);
+       }
+
        free_io_mem(td);
 
        io_u_rexit(&td->io_u_requeues);
        free_io_mem(td);
 
        io_u_rexit(&td->io_u_requeues);