[LU-9053] standardize error code returned by lustreapi Created: 26/Jan/17 Updated: 31/Jan/17 Resolved: 31/Jan/17 |
|
| Status: | Closed |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Jinshan Xiong (Inactive) | Assignee: | WC Triage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Rank (Obsolete): | 9223372036854775807 |
| Description |
|
right now it's pretty random. Sometimes the APIs return -errno, sometimes they set errno and return -1. Typical examples are llapi_fswap_layouts_grouplock() and llapi_layout_get_by_fd(). I would say the funnier one is llapi_open_by_fid() where llapi_search_mounts() return error code but llapi_open_by_fid() itself returns -1 as if the errno has been set. |
| Comments |
| Comment by Andreas Dilger [ 26/Jan/17 ] |
|
There was a long discussion about this in My thought is that it makes sense to update existing functions to both return -errno and also set errno internally. Callers can then either check rc < 0 and access errno, or continue to use the return code directly. This gives is a path to move toward a single style of error returns. |
| Comment by Jinshan Xiong (Inactive) [ 26/Jan/17 ] |
|
Hi Andreas, Which way do you prefer for the new APIs? |
| Comment by Andreas Dilger [ 29/Jan/17 ] |
|
The newer llapi_layout code is using -1 and errno. |