Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_uring: Add .errdetails to parse CQ status #1804

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions engines/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,39 @@ static struct io_u *fio_ioring_cmd_event(struct thread_data *td, int event)
return io_u;
}

static char *fio_ioring_cmd_errdetails(struct thread_data *td,
struct io_u *io_u)
{
struct ioring_options *o = td->eo;
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);

if (o->cmd_type == FIO_URING_CMD_NVME) {
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 +1623,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
2 changes: 1 addition & 1 deletion engines/librpma_fio.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ struct io_u *librpma_fio_client_event(struct thread_data *td, int event)
return io_u;
}

char *librpma_fio_client_errdetails(struct io_u *io_u)
char *librpma_fio_client_errdetails(struct thread_data *td, struct io_u *io_u)
{
/* get the string representation of an error */
enum ibv_wc_status status = io_u->error;
Expand Down
2 changes: 1 addition & 1 deletion engines/librpma_fio.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ int librpma_fio_client_getevents(struct thread_data *td, unsigned int min,

struct io_u *librpma_fio_client_event(struct thread_data *td, int event);

char *librpma_fio_client_errdetails(struct io_u *io_u);
char *librpma_fio_client_errdetails(struct thread_data *td, struct io_u *io_u);

static inline int librpma_fio_client_io_read(struct thread_data *td,
struct io_u *io_u, int flags)
Expand Down
2 changes: 1 addition & 1 deletion engines/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ int fio_sgio_close(struct thread_data *td, struct fio_file *f)
* Build an error string with details about the driver, host or scsi
* error contained in the sg header Caller will use as necessary.
*/
static char *fio_sgio_errdetails(struct io_u *io_u)
static char *fio_sgio_errdetails(struct thread_data *td, struct io_u *io_u)
{
struct sg_io_hdr *hdr = &io_u->hdr;
#define MAXERRDETAIL 1024
Expand Down
2 changes: 1 addition & 1 deletion io_u.c
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ static void __io_u_log_error(struct thread_data *td, struct io_u *io_u)
zbd_log_err(td, io_u);

if (td->io_ops->errdetails) {
char *err = td->io_ops->errdetails(io_u);
char *err = td->io_ops->errdetails(td, io_u);

log_err("fio: %s\n", err);
free(err);
Expand Down
4 changes: 2 additions & 2 deletions ioengines.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "zbd_types.h"
#include "dataplacement.h"

#define FIO_IOOPS_VERSION 35
#define FIO_IOOPS_VERSION 36

#ifndef CONFIG_DYNAMIC_ENGINES
#define FIO_STATIC static
Expand Down Expand Up @@ -40,7 +40,7 @@ struct ioengine_ops {
int (*commit)(struct thread_data *);
int (*getevents)(struct thread_data *, unsigned int, unsigned int, const struct timespec *);
struct io_u *(*event)(struct thread_data *, int);
char *(*errdetails)(struct io_u *);
char *(*errdetails)(struct thread_data *, struct io_u *);
int (*cancel)(struct thread_data *, struct io_u *);
void (*cleanup)(struct thread_data *);
int (*open_file)(struct thread_data *, struct fio_file *);
Expand Down