From e8a0b539cb154ab32ff19e479ff7bf2361ad0701 Mon Sep 17 00:00:00 2001 From: "zhuqingsong.0909" Date: Thu, 19 Oct 2023 11:29:27 +0800 Subject: [PATCH] fix assert failed when timeout during call rate_ddir. Adding DDIR_TIMEOUT in enum fio_ddir, and rate_ddir returns it when fio timeouts. set_io_u_file will directly break out of the loop, and fill_io_u won't be called, which causes assert to fail in rate_ddir, because td->rwmix_ddir is DDIR_INVAL. Signed-off-by: QingSong Zhu zhuqingsong.0909@bytedance.com --- io_ddir.h | 1 + io_u.c | 10 +++++++--- zbd.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/io_ddir.h b/io_ddir.h index 217eb628..280c1e79 100644 --- a/io_ddir.h +++ b/io_ddir.h @@ -11,6 +11,7 @@ enum fio_ddir { DDIR_WAIT, DDIR_LAST, DDIR_INVAL = -1, + DDIR_TIMEOUT = -2, DDIR_RWDIR_CNT = 3, DDIR_RWDIR_SYNC_CNT = 4, diff --git a/io_u.c b/io_u.c index 07e5bac5..13187882 100644 --- a/io_u.c +++ b/io_u.c @@ -717,7 +717,7 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir) * check if the usec is capable of taking negative values */ if (now > td->o.timeout) { - ddir = DDIR_INVAL; + ddir = DDIR_TIMEOUT; return ddir; } usec = td->o.timeout - now; @@ -726,7 +726,7 @@ static enum fio_ddir rate_ddir(struct thread_data *td, enum fio_ddir ddir) now = utime_since_now(&td->epoch); if ((td->o.timeout && (now > td->o.timeout)) || td->terminate) - ddir = DDIR_INVAL; + ddir = DDIR_TIMEOUT; return ddir; } @@ -951,7 +951,7 @@ static int fill_io_u(struct thread_data *td, struct io_u *io_u) set_rw_ddir(td, io_u); - if (io_u->ddir == DDIR_INVAL) { + if (io_u->ddir == DDIR_INVAL || io_u->ddir == DDIR_TIMEOUT) { dprint(FD_IO, "invalid direction received ddir = %d", io_u->ddir); return 1; } @@ -1419,6 +1419,10 @@ static long set_io_u_file(struct thread_data *td, struct io_u *io_u) put_file_log(td, f); td_io_close_file(td, f); io_u->file = NULL; + + if (io_u->ddir == DDIR_TIMEOUT) + return 1; + if (td->o.file_service_type & __FIO_FSERVICE_NONUNIFORM) fio_file_reset(td, f); else { diff --git a/zbd.c b/zbd.c index caac68bb..c4f7b12f 100644 --- a/zbd.c +++ b/zbd.c @@ -2171,6 +2171,7 @@ retry: case DDIR_WAIT: case DDIR_LAST: case DDIR_INVAL: + case DDIR_TIMEOUT: goto accept; } -- 2.25.1