From b155c6311461ea599cc3bdd023da151af852f0ab Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Tue, 14 May 2024 14:21:09 +0900 Subject: [PATCH] io_uring: Add 'readfua' and 'writefua' options Provide options to set the FUA flag in CDW12 in the NVMe command. FUA affects the internal operation of the NVMe controller and is used for testing. In this patchset we expand readfua and writefua options to directly control FUA flag in io_uring_cmd engine. Signed-off-by: Minwoo Im --- HOWTO.rst | 4 ++-- engines/io_uring.c | 27 +++++++++++++++++++++++++++ fio.1 | 4 ++-- io_u.h | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/HOWTO.rst b/HOWTO.rst index 2f8ef6d42c..56951f1307 100644 --- a/HOWTO.rst +++ b/HOWTO.rst @@ -2823,12 +2823,12 @@ with the caveat that when used on the command line, they must come after the Specify stat system call type to measure lookup/getattr performance. Default is **stat** for :manpage:`stat(2)`. -.. option:: readfua=bool : [sg] +.. option:: readfua=bool : [sg] [io_uring_cmd] With readfua option set to 1, read operations include the force unit access (fua) flag. Default is 0. -.. option:: writefua=bool : [sg] +.. option:: writefua=bool : [sg] [io_uring_cmd] With writefua option set to 1, write operations include the force unit access (fua) flag. Default is 0. diff --git a/engines/io_uring.c b/engines/io_uring.c index 9069fa3e81..f070c4fee5 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -87,6 +87,8 @@ struct ioring_data { struct ioring_options { struct thread_data *td; unsigned int hipri; + unsigned int readfua; + unsigned int writefua; struct cmdprio_options cmdprio_options; unsigned int fixedbufs; unsigned int registerfiles; @@ -135,6 +137,26 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_IOURING, }, + { + .name = "readfua", + .lname = "Read fua flag support", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct ioring_options, readfua), + .help = "Set FUA flag (force unit access) for all Read operations", + .def = "0", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_IOURING, + }, + { + .name = "writefua", + .lname = "Write fua flag support", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct ioring_options, writefua), + .help = "Set FUA flag (force unit access) for all Write operations", + .def = "0", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_IOURING, + }, { .name = "fixedbufs", .lname = "Fixed (pre-mapped) IO buffers", @@ -424,6 +446,11 @@ static int fio_ioring_cmd_prep(struct thread_data *td, struct io_u *io_u) sqe->uring_cmd_flags = IORING_URING_CMD_FIXED; sqe->buf_index = io_u->index; } + if ((io_u->ddir == DDIR_WRITE && o->writefua) || + (io_u->ddir == DDIR_READ && o->readfua)) + io_u->fua = 1; + else + io_u->fua = 0; cmd = (struct nvme_uring_cmd *)sqe->cmd; dsm_size = sizeof(*ld->dsm) + td->o.num_range * sizeof(struct nvme_dsm_range); diff --git a/fio.1 b/fio.1 index ee8124946a..4201132844 100644 --- a/fio.1 +++ b/fio.1 @@ -2602,11 +2602,11 @@ that "owns" the device also needs to support hipri (also known as iopoll and mq_poll). The MegaRAID driver is an example of a SCSI LLD. Default: clear (0) which does normal (interrupted based) IO. .TP -.BI (sg)readfua \fR=\fPbool +.BI (sg, io_uring_cmd)readfua \fR=\fPbool With readfua option set to 1, read operations include the force unit access (fua) flag. Default: 0. .TP -.BI (sg)writefua \fR=\fPbool +.BI (sg, io_uring_cmd)writefua \fR=\fPbool With writefua option set to 1, write operations include the force unit access (fua) flag. Default: 0. .TP diff --git a/io_u.h b/io_u.h index ab93d50f96..94396f810b 100644 --- a/io_u.h +++ b/io_u.h @@ -125,6 +125,7 @@ struct io_u { uint32_t dtype; uint32_t dspec; + uint32_t fua; union { #ifdef CONFIG_LIBAIO