Skip to content

Commit

Permalink
Merge branch 'io_uring_cmd/support-write-family' of https://github.co…
Browse files Browse the repository at this point in the history
…m/samsungds/fio

* 'io_uring_cmd/support-write-family' of https://github.com/samsungds/fio:
  io_uring: Add 'write_mode' option for optional cmds
  • Loading branch information
vincentkfu committed Jun 3, 2024
2 parents 93dc854 + 87a4903 commit 1757469
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 4 deletions.
16 changes: 16 additions & 0 deletions HOWTO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,22 @@ with the caveat that when used on the command line, they must come after the
With writefua option set to 1, write operations include
the force unit access (fua) flag. Default is 0.

.. option:: write_mode=str : [io_uring_cmd]

Specifies the type of write operation. Defaults to 'write'.

**write**
Use Write commands for write operations

**uncor**
Use Write Uncorrectable commands for write opreations

**zeroes**
Use Write Zeroes commands for write operations

**verify**
Use Verify commands for write operations

.. option:: sg_write_mode=str : [sg]

Specify the type of write commands to issue. This option can take ten values:
Expand Down
64 changes: 63 additions & 1 deletion engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ enum uring_cmd_type {
FIO_URING_CMD_NVME = 1,
};

enum uring_cmd_write_mode {
FIO_URING_CMD_WMODE_WRITE = 1,
FIO_URING_CMD_WMODE_UNCOR,
FIO_URING_CMD_WMODE_ZEROES,
FIO_URING_CMD_WMODE_VERIFY,
};

struct io_sq_ring {
unsigned *head;
unsigned *tail;
Expand Down Expand Up @@ -83,13 +90,15 @@ struct ioring_data {

struct nvme_dsm *dsm;
uint32_t cdw12_flags[DDIR_RWDIR_CNT];
uint8_t write_opcode;
};

struct ioring_options {
struct thread_data *td;
unsigned int hipri;
unsigned int readfua;
unsigned int writefua;
unsigned int write_mode;
struct cmdprio_options cmdprio_options;
unsigned int fixedbufs;
unsigned int registerfiles;
Expand Down Expand Up @@ -158,6 +167,34 @@ static struct fio_option options[] = {
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_IOURING,
},
{
.name = "write_mode",
.lname = "Additional Write commands support (Write Uncorrectable, Write Zeores)",
.type = FIO_OPT_STR,
.off1 = offsetof(struct ioring_options, write_mode),
.help = "Issue Write Uncorrectable or Zeroes command instaed of Write command",
.def = "write",
.posval = {
{ .ival = "write",
.oval = FIO_URING_CMD_WMODE_WRITE,
.help = "Issue Write commands for write operations"
},
{ .ival = "uncor",
.oval = FIO_URING_CMD_WMODE_UNCOR,
.help = "Issue Write Uncorrectable commands for write operations"
},
{ .ival = "zeroes",
.oval = FIO_URING_CMD_WMODE_ZEROES,
.help = "Issue Write Zeroes commands for write operations"
},
{ .ival = "verify",
.oval = FIO_URING_CMD_WMODE_VERIFY,
.help = "Issue Verify commands for write operations"
},
},
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_IOURING,
},
{
.name = "fixedbufs",
.lname = "Fixed (pre-mapped) IO buffers",
Expand Down Expand Up @@ -455,7 +492,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, ld->cdw12_flags[io_u->ddir]);
dsm, ld->write_opcode, ld->cdw12_flags[io_u->ddir]);
}

static struct io_u *fio_ioring_event(struct thread_data *td, int event)
Expand Down Expand Up @@ -1243,6 +1280,23 @@ static int fio_ioring_init(struct thread_data *td)
}

if (!strcmp(td->io_ops->name, "io_uring_cmd")) {
if (td_write(td)) {
switch (o->write_mode) {
case FIO_URING_CMD_WMODE_UNCOR:
ld->write_opcode = nvme_cmd_write_uncor;
break;
case FIO_URING_CMD_WMODE_ZEROES:
ld->write_opcode = nvme_cmd_write_zeroes;
break;
case FIO_URING_CMD_WMODE_VERIFY:
ld->write_opcode = nvme_cmd_verify;
break;
default:
ld->write_opcode = nvme_cmd_write;
break;
}
}

if (o->readfua)
ld->cdw12_flags[DDIR_READ] = 1 << 30;
if (o->writefua)
Expand Down Expand Up @@ -1371,6 +1425,14 @@ static int fio_ioring_cmd_open_file(struct thread_data *td, struct fio_file *f)
td_verror(td, EINVAL, "fio_ioring_cmd_open_file");
return 1;
}

if (o->write_mode != FIO_URING_CMD_WMODE_WRITE &&
!td_write(td)) {
log_err("%s: 'readwrite=|rw=' has no write\n",
f->file_name);
td_verror(td, EINVAL, "fio_ioring_cmd_open_file");
return 1;
}
}
if (!ld || !o->registerfiles)
return generic_open_file(td, f);
Expand Down
4 changes: 2 additions & 2 deletions engines/nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ 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,
unsigned int cdw12_flags)
uint8_t write_opcode, unsigned int cdw12_flags)
{
struct nvme_data *data = FILE_ENG_DATA(io_u->file);
__u64 slba;
Expand All @@ -376,7 +376,7 @@ int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
cmd->opcode = nvme_cmd_read;
break;
case DDIR_WRITE:
cmd->opcode = nvme_cmd_write;
cmd->opcode = write_opcode;
break;
case DDIR_TRIM:
fio_nvme_uring_cmd_trim_prep(cmd, io_u, dsm);
Expand Down
5 changes: 4 additions & 1 deletion engines/nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ enum nvme_admin_opcode {
enum nvme_io_opcode {
nvme_cmd_write = 0x01,
nvme_cmd_read = 0x02,
nvme_cmd_write_uncor = 0x04,
nvme_cmd_write_zeroes = 0x08,
nvme_cmd_dsm = 0x09,
nvme_cmd_verify = 0x0c,
nvme_cmd_io_mgmt_recv = 0x12,
nvme_zns_cmd_mgmt_send = 0x79,
nvme_zns_cmd_mgmt_recv = 0x7a,
Expand Down Expand Up @@ -427,7 +430,7 @@ int fio_nvme_get_info(struct fio_file *f, __u64 *nlba, __u32 pi_act,

int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
struct iovec *iov, struct nvme_dsm *dsm,
unsigned int cdw12_flags);
uint8_t write_opcode, 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);
Expand Down
20 changes: 20 additions & 0 deletions fio.1
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,26 @@ unit access (fua) flag. Default: 0.
With writefua option set to 1, write operations include the force
unit access (fua) flag. Default: 0.
.TP
.BI (io_uring_cmd)write_mode \fR=\fPstr
Specifies the type of write operation. Defaults to 'write'.
.RS
.RS
.TP
.B write
Use Write commands for write operations
.TP
.B uncor
Use Write Uncorrectable commands for write opreations
.TP
.B zeroes
Use Write Zeroes commands for write operations
.TP
.B verify
Use Verify commands for write operations
.TP
.RE
.RE
.TP
.BI (sg)sg_write_mode \fR=\fPstr
Specify the type of write commands to issue. This option can take multiple
values:
Expand Down

0 comments on commit 1757469

Please sign in to comment.