MI: return value + errno unification#418
Merged
igaw merged 3 commits intolinux-nvme:masterfrom Jul 7, 2022
Merged
Conversation
We'll want to make further use of the MI status values in an upcoming change, so add the full set of values from NVMe-MI v1.2b. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
It's not an error to have an endpoint in our list prior to scanning; just suppress the duplicate and keep going. Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
This change unifies and documents the error return values for the MI
implementation. This gives us the following semantics:
- zero on success
- -1 for errors in the MI communication with an endpoint, with errno
set accordingly
- positive values where the MI communication succeeded, but we received
an error response from the endpoint. The return value will be that
from the MI response status field, and should correspond to one of
the nvme_mi_resp_status values.
We add these semantics to the file-level kdoc comments in mi.h.
Most of the changes here are replacing the negative-errno returns:
return -EIO;
with:
errno = EIO;
return -1;
but there are a few slightly-more-involved changes where we need to
preserve errno across a cleanup/log that might clobber it.
For the dbus code in mi-mctp.c, we need to convert the sd_bus convention of
negative-errno values into errno; we can do most of these through the
dbus_err() helper.
Fixes: linux-nvme#417
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Codecov Report
@@ Coverage Diff @@
## master #418 +/- ##
==========================================
+ Coverage 16.16% 16.41% +0.24%
==========================================
Files 31 31
Lines 5010 5074 +64
Branches 973 974 +1
==========================================
+ Hits 810 833 +23
- Misses 3948 3988 +40
- Partials 252 253 +1
Continue to review full report at Codecov.
|
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series implements a unification of the return values across the MI code, so that we have consistent semantics between libnvme and libnvme-mi.
From the final patch:
Patch 1 extends the defined MI status values, so we're complete with what's in the current spec, and patch 2 implements a small fix to the error handling when we have duplicate endpoints during a scan.
As always, comments and feedback most welcome. Let me know if this is a suitable equivalent to the libnvme core API semantics.