Skip to content

Commit

Permalink
io_uring: Add 'readfua' and 'writefua' options
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
minwooim committed May 20, 2024
1 parent 3ed8eea commit b155c63
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions HOWTO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 27 additions & 0 deletions engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fio.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions io_u.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ struct io_u {

uint32_t dtype;
uint32_t dspec;
uint32_t fua;

union {
#ifdef CONFIG_LIBAIO
Expand Down

0 comments on commit b155c63

Please sign in to comment.