io_uring: Add 'readfua' and 'writefua' options
authorMinwoo Im <minwoo.im@samsung.com>
Tue, 14 May 2024 05:21:09 +0000 (14:21 +0900)
committerMinwoo Im <minwoo.im@samsung.com>
Thu, 23 May 2024 21:27:52 +0000 (06:27 +0900)
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 <minwoo.im@samsung.com>
HOWTO.rst
engines/io_uring.c
engines/nvme.c
engines/nvme.h
fio.1

index 2f8ef6d42cbfa05972c5e87373aa5dd18b60af86..56951f13075d45498186588e18942d2b2e3b719d 100644 (file)
--- 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.
index 9069fa3e81a5caaf03c038481f072c25fcca3385..3a03ae35240d2b98a74e34e3867d36a37992b243 100644 (file)
@@ -82,11 +82,14 @@ struct ioring_data {
        struct cmdprio cmdprio;
 
        struct nvme_dsm *dsm;
+       uint32_t cdw12_flags[DDIR_RWDIR_CNT];
 };
 
 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 +138,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",
@@ -432,7 +455,7 @@ static int fio_ioring_cmd_prep(struct thread_data *td, struct io_u *io_u)
 
        return fio_nvme_uring_cmd_prep(cmd, io_u,
                        o->nonvectored ? NULL : &ld->iovecs[io_u->index],
-                       dsm);
+                       dsm, ld->cdw12_flags[io_u->ddir]);
 }
 
 static struct io_u *fio_ioring_event(struct thread_data *td, int event)
@@ -1219,6 +1242,13 @@ static int fio_ioring_init(struct thread_data *td)
                }
        }
 
+       if (!strcmp(td->io_ops->name, "io_uring_cmd")) {
+               if (o->readfua)
+                       ld->cdw12_flags[DDIR_READ] = 1 << 30;
+               if (o->writefua)
+                       ld->cdw12_flags[DDIR_WRITE] = 1 << 30;
+       }
+
        return 0;
 }
 
index c6629e8644c67bef77c1d6deb399d4993b93831f..7b73c806af449f05dc5a062e485a76e095056a8e 100644 (file)
@@ -362,7 +362,8 @@ void fio_nvme_uring_cmd_trim_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
 }
 
 int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
-                           struct iovec *iov, struct nvme_dsm *dsm)
+                           struct iovec *iov, struct nvme_dsm *dsm,
+                           unsigned int cdw12_flags)
 {
        struct nvme_data *data = FILE_ENG_DATA(io_u->file);
        __u64 slba;
@@ -391,7 +392,7 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
        cmd->cdw10 = slba & 0xffffffff;
        cmd->cdw11 = slba >> 32;
        /* cdw12 represent number of lba's for read/write */
-       cmd->cdw12 = nlb | (io_u->dtype << 20);
+       cmd->cdw12 = nlb | (io_u->dtype << 20) | cdw12_flags;
        cmd->cdw13 = io_u->dspec << 16;
        if (iov) {
                iov->iov_base = io_u->xfer_buf;
index 2d5204fc01f9c6ce050937d90a45078fa261b14b..2db9eb86ddcc8b4d7c59bb29c2dafa5336cb9198 100644 (file)
@@ -426,7 +426,8 @@ int fio_nvme_get_info(struct fio_file *f, __u64 *nlba, __u32 pi_act,
                      struct nvme_data *data);
 
 int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
-                           struct iovec *iov, struct nvme_dsm *dsm);
+                           struct iovec *iov, struct nvme_dsm *dsm,
+                           unsigned int cdw12_flags);
 
 void fio_nvme_pi_fill(struct nvme_uring_cmd *cmd, struct io_u *io_u,
                      struct nvme_cmd_ext_io_opts *opts);
diff --git a/fio.1 b/fio.1
index ee8124946a81a087375fb17293e7a8db5cfc81c4..4201132844333c766fdea595a032c93ce13eced3 100644 (file)
--- 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