verify/trim: stop issuing trims if we run out
authorVincent Fu <vincentfu@gmail.com>
Mon, 31 Mar 2025 14:01:31 +0000 (10:01 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 7 Apr 2025 14:54:38 +0000 (10:54 -0400)
If we have drained the list of trim operations but its original contents
were fewer than a full batch we should zero out the running batch count
to make sure that we issue another full set of trim_backlog write
operations before considering trims again. Otherwise we will immediately
trim after each subsequent write operation until we have met the batch
size requirement.

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

diff --git a/io_u.c b/io_u.c
index f782471777c8f28fa19d919ed695aa8438903612..66cfa16a6a2eea2f5779785cff86101e93c75d46 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1749,13 +1749,17 @@ 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;