-
Notifications
You must be signed in to change notification settings - Fork 706
Handle add ctrl errors #2802
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
Handle add ctrl errors #2802
Conversation
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>
ikegami-t
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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")
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
No worries. Since I wrote all the error handling code I should have spotted it. I had a very good reproducer |
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>
c3e7c61 to
1f1027a
Compare
The previous 'fix' was not really working because the error status is in errno not in the return value.
fixes: #2801