[PATCH 5/7] verify/trim: make trim_backlog_batch work

Vincent Fu <[email protected]>
Newsgroups org.kernel.vger.fio
Message-ID <[email protected]>
In order to detect when we are at the beginning of a trim phase we check
io_hist_len and should check that the previous operation was not a
*trim* (instead of not a read). Without this change trim_backlog_batch
will have no effect because after one batch is done, fio will simply
start a new batch because io_hist_len is still a multiple of
trim_backlog and the last operation in a batch was a trim which is not a
read.

For check_get_verify checking against read is appropriate but for
check_get_trim we must check against a trim.

Also we need to decrement the trim_batch count for the first trim
operation we send through.

Signed-off-by: Vincent Fu <[email protected]>
---
 io_u.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/io_u.c b/io_u.c
index 66cfa16a..17f5e853 100644
--- a/io_u.c
+++ b/io_u.c
@@ -1761,12 +1761,14 @@ static bool check_get_trim(struct thread_data *td, struct io_u *io_u)
 		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;
-- 
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.