engines/io_uring: allow setting of IOSQE_ASYNC
authorJens Axboe <axboe@kernel.dk>
Tue, 8 Sep 2020 15:57:03 +0000 (09:57 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 8 Sep 2020 15:57:03 +0000 (09:57 -0600)
Add engine option 'force_async'. If that is set to N, then every N
requests will have IOSQE_ASYNC set to force async offload.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/io_uring.c

index ca5b90c91be78b3d8964dc87c130d41ccdc6de24..e2b5e6ee3725d18289372bdb0e5fd276cddfa807 100644 (file)
@@ -66,6 +66,7 @@ struct ioring_data {
        unsigned iodepth;
        bool ioprio_class_set;
        bool ioprio_set;
+       int prepped;
 
        struct ioring_mmap mmap[3];
 };
@@ -82,6 +83,7 @@ struct ioring_options {
        unsigned int nonvectored;
        unsigned int uncached;
        unsigned int nowait;
+       unsigned int force_async;
 };
 
 static const int ddir_to_op[2][2] = {
@@ -197,6 +199,15 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_IOURING,
        },
+       {
+               .name   = "force_async",
+               .lname  = "Force async",
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct ioring_options, force_async),
+               .help   = "Set IOSQE_ASYNC every N requests",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_IOURING,
+       },
        {
                .name   = NULL,
        },
@@ -277,6 +288,11 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
                }
        }
 
+       if (o->force_async && ++ld->prepped == o->force_async) {
+               ld->prepped = 0;
+               sqe->flags |= IOSQE_ASYNC;
+       }
+
        sqe->user_data = (unsigned long) io_u;
        return 0;
 }