fix assert failed when timeout during call rate_ddir.
authorzhuqingsong.0909 <zhuqingsong.0909@bytedance.com>
Thu, 19 Oct 2023 03:29:27 +0000 (11:29 +0800)
committerzhuqingsong.0909 <zhuqingsong.0909@bytedance.com>
Thu, 19 Oct 2023 12:10:52 +0000 (20:10 +0800)
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
io_u.c
zbd.c

index 217eb62862efb74938193da9e2f4b786282a6cf1..280c1e796a2690b599f28ae453020d11cbc3b836 100644 (file)
--- 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 07e5bac5ef5257ec20af830cf3a5ef60f88123c7..131878822e416a1b55d0bb04e68f9da2ef66a02a 100644 (file)
--- 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 caac68bb3731eed7ef5a9c4f68e560b39bdc35ad..c4f7b12f75aaa67ed6fb4f9c369b88d042a1e24b 100644 (file)
--- 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;
        }