Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH 0/2] Cleanup and fix iolog replay
@ 2026-12-01 23:37 Damien Le Moal
  2026-12-01 23:38 ` [PATCH 1/2] iolog: refactor read_iolog() Damien Le Moal
  2026-12-01 23:38 ` [PATCH 2/2] iolog: fix iolog_items_to_fetch() Damien Le Moal
  0 siblings, 2 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-12-01 23:37 UTC (permalink / raw)
  To: fio, Vincent Fu, Jens Axboe

Jens, Vincent,

The first patch is a small cleanup of read_iolog(). The second patch fixes
an issue with replaying low-IOPS iologs leading to workloads prematurely
ending before an iolog file is fully replayed.

Damien Le Moal (2):
  iolog: refactor read_iolog()
  iolog: fix iolog_items_to_fetch()

 iolog.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] iolog: refactor read_iolog()
  2026-12-01 23:37 [PATCH 0/2] Cleanup and fix iolog replay Damien Le Moal
@ 2026-12-01 23:38 ` Damien Le Moal
  2026-12-01 23:38 ` [PATCH 2/2] iolog: fix iolog_items_to_fetch() Damien Le Moal
  1 sibling, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-12-01 23:38 UTC (permalink / raw)
  To: fio, Vincent Fu, Jens Axboe

In read_iolog(), use a switch-case for handling an iolog item rw type.
This is cleaner and more efficient than a series of if-else-if.
No functional change.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 iolog.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/iolog.c b/iolog.c
index 41a3102c6c5c..54fb8283b766 100644
--- a/iolog.c
+++ b/iolog.c
@@ -582,30 +582,38 @@ static bool read_iolog(struct thread_data *td)
 			continue;
 		}
 
-		if (rw == DDIR_READ)
+		switch (rw) {
+		case DDIR_READ:
 			reads++;
-		else if (rw == DDIR_WRITE) {
+			break;
+		case DDIR_WRITE:
 			/*
 			 * Don't add a write for ro mode
 			 */
 			if (read_only)
 				continue;
 			writes++;
-		} else if (rw == DDIR_TRIM) {
+			break;
+		case DDIR_TRIM:
 			/*
 			 * Don't add a trim for ro mode
 			 */
 			if (read_only)
 				continue;
 			trims++;
-		} else if (rw == DDIR_WAIT) {
+			break;
+		case DDIR_WAIT:
 			if (td->o.no_stall)
 				continue;
 			waits++;
-		} else if (rw == DDIR_INVAL) {
-		} else if (ddir_sync(rw)) {
-			syncs++;
-		} else {
+			break;
+		case DDIR_INVAL:
+			break;
+		default:
+			if (ddir_sync(rw)) {
+				syncs++;
+				break;
+			}
 			log_err("bad ddir: %d\n", rw);
 			continue;
 		}
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] iolog: fix iolog_items_to_fetch()
  2026-12-01 23:37 [PATCH 0/2] Cleanup and fix iolog replay Damien Le Moal
  2026-12-01 23:38 ` [PATCH 1/2] iolog: refactor read_iolog() Damien Le Moal
@ 2026-12-01 23:38 ` Damien Le Moal
  2026-12-02  1:45   ` Vincent Fu
  1 sibling, 1 reply; 4+ messages in thread
From: Damien Le Moal @ 2026-12-01 23:38 UTC (permalink / raw)
  To: fio, Vincent Fu, Jens Axboe

When replaying an iolog with read_iolog_chunked=true, if the iolog
describes a workload ithat has very low IOPS intervals (IOPS < 1),
iolog_items_to_fetch() may return 0 due to the IOPS calculation it does
based on the last time the iolog file was read (td->io_log_highmark_time).
This causes read_iolog() to do nothing and the job to end, even if the
iolog file is not yet fully replayed.

Avoid this by returning the defualt 10 items (now defined as
IOLOG_DEFAULT_ITEMS_TO_FETCH) when the calculation leads to a value that
is 0 or less. When the iolog file is fully replayed, read_iolog() will
still do nothing and the job end normally after replaying the entire
iolog file.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 iolog.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/iolog.c b/iolog.c
index 54fb8283b766..824764bf34a6 100644
--- a/iolog.c
+++ b/iolog.c
@@ -418,6 +418,8 @@ void write_iolog_close(struct thread_data *td)
 	td->iolog_buf = NULL;
 }
 
+#define IOLOG_DEFAULT_ITEMS_TO_FETCH	10
+
 int64_t iolog_items_to_fetch(struct thread_data *td)
 {
 	struct timespec now;
@@ -426,18 +428,18 @@ int64_t iolog_items_to_fetch(struct thread_data *td)
 	int64_t items_to_fetch;
 
 	if (!td->io_log_highmark)
-		return 10;
-
+		return IOLOG_DEFAULT_ITEMS_TO_FETCH;
 
 	fio_gettime(&now, NULL);
 	elapsed = ntime_since(&td->io_log_highmark_time, &now);
 	if (elapsed) {
 		for_1s = (td->io_log_highmark - td->io_log_current) * 1000000000 / elapsed;
 		items_to_fetch = for_1s - td->io_log_current;
-		if (items_to_fetch < 0)
-			items_to_fetch = 0;
-	} else
+		if (items_to_fetch <= 0)
+			items_to_fetch = IOLOG_DEFAULT_ITEMS_TO_FETCH;
+	} else {
 		items_to_fetch = 0;
+	}
 
 	td->io_log_highmark = td->io_log_current + items_to_fetch;
 	td->io_log_checkmark = (td->io_log_highmark + 1) / 2;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] iolog: fix iolog_items_to_fetch()
  2026-12-01 23:38 ` [PATCH 2/2] iolog: fix iolog_items_to_fetch() Damien Le Moal
@ 2026-12-02  1:45   ` Vincent Fu
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Fu @ 2026-12-02  1:45 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: fio, Jens Axboe

On Tue, Dec 1, 2026 at 6:38 PM Damien Le Moal <dlemoal@kernel.org> wrote:
>
> When replaying an iolog with read_iolog_chunked=true, if the iolog
> describes a workload ithat has very low IOPS intervals (IOPS < 1),

that

> iolog_items_to_fetch() may return 0 due to the IOPS calculation it does
> based on the last time the iolog file was read (td->io_log_highmark_time).
> This causes read_iolog() to do nothing and the job to end, even if the
> iolog file is not yet fully replayed.
>
> Avoid this by returning the defualt 10 items (now defined as

default

> IOLOG_DEFAULT_ITEMS_TO_FETCH) when the calculation leads to a value that
> is 0 or less. When the iolog file is fully replayed, read_iolog() will
> still do nothing and the job end normally after replaying the entire

ends

> iolog file.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  iolog.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/iolog.c b/iolog.c
> index 54fb8283b766..824764bf34a6 100644
> --- a/iolog.c
> +++ b/iolog.c
> @@ -418,6 +418,8 @@ void write_iolog_close(struct thread_data *td)
>         td->iolog_buf = NULL;
>  }
>
> +#define IOLOG_DEFAULT_ITEMS_TO_FETCH   10
> +
>  int64_t iolog_items_to_fetch(struct thread_data *td)
>  {
>         struct timespec now;
> @@ -426,18 +428,18 @@ int64_t iolog_items_to_fetch(struct thread_data *td)
>         int64_t items_to_fetch;
>
>         if (!td->io_log_highmark)
> -               return 10;
> -
> +               return IOLOG_DEFAULT_ITEMS_TO_FETCH;
>
>         fio_gettime(&now, NULL);
>         elapsed = ntime_since(&td->io_log_highmark_time, &now);
>         if (elapsed) {
>                 for_1s = (td->io_log_highmark - td->io_log_current) * 1000000000 / elapsed;

Would you send a new patch 3/3 with the above changed to 1000000000ULL to avoid
arithmetic overflow?

There is an outstanding PR on GitHub with a similar fix but it has been 3 weeks
since I provided feedback and the author has not yet responded, so I'm happy to
take this patch.

https://github.com/axboe/fio/pull/2178

Vincent

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02  1:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 23:37 [PATCH 0/2] Cleanup and fix iolog replay Damien Le Moal
2026-12-01 23:38 ` [PATCH 1/2] iolog: refactor read_iolog() Damien Le Moal
2026-12-01 23:38 ` [PATCH 2/2] iolog: fix iolog_items_to_fetch() Damien Le Moal
2026-12-02  1:45   ` Vincent Fu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox