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

Conversation

minwooim
Copy link
Contributor

@minwooim minwooim commented Aug 12, 2024

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)

If --cmd_type!=nvme, it prints out generic status code like below:

fio: io_uring_cmd: /dev/: status=0x4

* Check the filename to figure out cmd_type since we don't have
* thread_data here.
*/
ret = sscanf(io_u->file->file_name, "/dev/ng%dn%d", &ctrlid, &nsid);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use strstr to check if the filename begins with /dev/ng? Then there is no need to have the ctrlid and nsid variables which are ultimately unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

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

strlcat(msg, ")", MAXERRDETAIL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this strlcat and just add the ) to the snprtinf call above this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

@vincentkfu
Copy link
Collaborator

This looks fine. Just two small changes requested.

@minwooim
Copy link
Contributor Author

This looks fine. Just two small changes requested.

Applied all the changes, Thanks for the review.

* 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")) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty terrible, to be honest. You cannot impute type of device based on the name of the device special node. It's perfectly valid to have different names for these. This will need a rethink to be workable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of two alternatives:

  1. Change .errdetails to also take a struct thread_data argument. td gives you access to the ioengine options which you can use to find the cmd_type. You would need to bump FIO_IOOPS_VERSION.
  2. Add a pointer to td to struct io_u.

The first choice seems like the better approach to me.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First choice definitely the better one. And yes, it's not a problem to change the prototype of the arguments. Just remember to change FIO_IOOPS_VERSION as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated! Thanks,

@vincentkfu
Copy link
Collaborator

Please update the commit message for the patch adding errdetials to the io_uring_cmd ioengine. It no longer uses the filename to determine cmd_type.

Also you might as well squash the first two patches that change the function prototype and bump the version since they need to go together.

No functional changes here, but added a 'struct thread_data *td' to the
errdetails callback.  This is a prep patch for the following commits to
access 'td->eo' instance from .errdetails callback.

Bump up FIO_IOOPS_VERSION to 36 since the previous commits updated
.errdetails callback for ioengines by adding 'thread_data' argument.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
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)

If --cmd_type!=nvme, it prints out generic status code like below:

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

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
@minwooim
Copy link
Contributor Author

Please update the commit message for the patch adding errdetials to the io_uring_cmd ioengine. It no longer uses the filename to determine cmd_type.

Also you might as well squash the first two patches that change the function prototype and bump the version since they need to go together.

Updated, Thanks for your review.

@axboe
Copy link
Owner

axboe commented Aug 16, 2024

This looks good to me now.

@axboe axboe merged commit 7bc1231 into axboe:master Aug 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants