Skip to content

Conversation

@igaw
Copy link
Collaborator

@igaw igaw commented May 8, 2025

The previous 'fix' was not really working because the error status is in errno not in the return value.

fixes: #2801

Unfortunately, libnvme follows the POSIX way to return errors. This
means the return value is not containing the error code, it is in
errno.

While at it, also print the returned value only when debug mode
is enabled.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Copy link
Contributor

@ikegami-t ikegami-t left a comment

Choose a reason for hiding this comment

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

Changes looks good but as commented the existing flags handling seems not correct. Sorry for the PR: #2797 errors as I could not review correctly. Thank you.

fabrics.c Outdated
if (flags != -EINVAL)
nvme_show_connect_msg(c, flags);
nvme_strerror(-ret));
} else if (flags != -EINVAL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The existing flags checking not correct since never set -EINVAL to flags so always executed nvme_show_connect_msg() if ret set zero.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, the flags check doesn't make sense. The flag can't be EINVAL, because we already filtered this out. It turns out that the device name is supposed to be printed on connect. I don't like it, IMO it should only printed with --verbose but it's too late to change this now. So lets keep it.

0ad49ad ("Print device name on connect")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It turns out we can cleanup the error code path even more. Thanks for pointing it out!

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you. The changes look good.

@igaw
Copy link
Collaborator Author

igaw commented May 9, 2025

Changes looks good but as commented the existing flags handling seems not correct. Sorry for the PR: #2797 errors as I could not review correctly. Thank you.

No worries. Since I wrote all the error handling code I should have spotted it. I had a very good reproducer
(blktests nvme/030 kept returning EAGAIN) but it went away for some reason. Thus I didn't really test it.

With the introduction of nvme_add_ctrl we can use the return code
directly and don't rely on the errno being set.

Also we can directly leave the function on error because we don't have
to cleanup things explicitly anymore.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
@igaw igaw force-pushed the handle-add-ctrl-errors branch from c3e7c61 to 1f1027a Compare May 9, 2025 07:17
@igaw igaw merged commit 16a38f7 into linux-nvme:master May 12, 2025
17 checks passed
@igaw igaw deleted the handle-add-ctrl-errors branch May 12, 2025 07:24
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.

2 participants