[PATCH 4/7] verify/trim: stop issuing trims if we run out

Vincent Fu <[email protected]>
Newsgroups org.kernel.vger.fio
Message-ID <[email protected]>
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 <[email protected]>
---
 io_u.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/io_u.c b/io_u.c
index f7824717..66cfa16a 100644
--- 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;
-- 
2.47.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.