Skip to content

Commit

Permalink
io_uring: Add .errdetails to parse CQ status
Browse files Browse the repository at this point in the history
Background
 - fio normally prints out the strerr and errno value when facing
   errors.  In case of io_uring_cmd ioengine with --cmd_type=nvme,
   io_u->error represents the CQ entry status code type and status
   code which should be parsed as a NVMe error value rather than
   errno.

In io_u error failure condition, it prints out parsed CQ entry error
status values with SCT(Status Code Type) and SC(Status Code).  The print
will be like the following example:

  fio: io_uring_cmd: /dev/ng0n1: cq entry status (sct=0x00; sc=0x04)

For the further use cases of --cmd_type!=nvme, this patch checks the
given io_u's file is NVMe generic device or not.  If not, it prints out
generic status code like below:

  fio: io_uring_cmd: /dev/<devnode>: status=0x4

Signed-off-by: Minwoo Im <[email protected]>
  • Loading branch information
minwooim committed Aug 14, 2024
1 parent 55b10cc commit 6bc18c0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,41 @@ static struct io_u *fio_ioring_cmd_event(struct thread_data *td, int event)
return io_u;
}

static char *fio_ioring_cmd_errdetails(struct io_u *io_u)
{
unsigned int sct = (io_u->error >> 8) & 0x7;
unsigned int sc = io_u->error & 0xff;
#define MAXERRDETAIL 1024
#define MAXMSGCHUNK 128
char *msg, msgchunk[MAXMSGCHUNK];

msg = calloc(1, MAXERRDETAIL);
strcpy(msg, "io_uring_cmd: ");

snprintf(msgchunk, MAXMSGCHUNK, "%s: ", io_u->file->file_name);
strlcat(msg, msgchunk, MAXERRDETAIL);

/*
* Check the filename to figure out cmd_type since we don't have
* thread_data here.
*/
if (strstr(io_u->file->file_name, "/dev/ng")) {
strlcat(msg, "cq entry status (", MAXERRDETAIL);

snprintf(msgchunk, MAXMSGCHUNK, "sct=0x%02x; ", sct);
strlcat(msg, msgchunk, MAXERRDETAIL);

snprintf(msgchunk, MAXMSGCHUNK, "sc=0x%02x)", sc);
strlcat(msg, msgchunk, MAXERRDETAIL);
} else {
/* Print status code in generic */
snprintf(msgchunk, MAXMSGCHUNK, "status=0x%x", io_u->error);
strlcat(msg, msgchunk, MAXERRDETAIL);
}

return msg;
}

static int fio_ioring_cqring_reap(struct thread_data *td, unsigned int events,
unsigned int max)
{
Expand Down Expand Up @@ -1590,6 +1625,7 @@ static struct ioengine_ops ioengine_uring_cmd = {
.commit = fio_ioring_commit,
.getevents = fio_ioring_getevents,
.event = fio_ioring_cmd_event,
.errdetails = fio_ioring_cmd_errdetails,
.cleanup = fio_ioring_cleanup,
.open_file = fio_ioring_cmd_open_file,
.close_file = fio_ioring_cmd_close_file,
Expand Down

0 comments on commit 6bc18c0

Please sign in to comment.