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

cffi: add a configure option to opt-out of "nice" errors #39

Open
cyphar opened this issue Jul 19, 2024 · 2 comments
Open

cffi: add a configure option to opt-out of "nice" errors #39

cyphar opened this issue Jul 19, 2024 · 2 comments
Milestone

Comments

@cyphar
Copy link
Member

cyphar commented Jul 19, 2024

While the new API makes error management much nicer, some users might just want to get raw errnos.

We can very easily switch to returning raw errnos from a type perspective, but it's a little unclear what we should do for errors that don't have an underlying errno. We can just copy the kernel and just use -EINVAL 😅, or we could use an errno that the kernel rarely returns like -ENOANO, never returns like -ENOPARAM, or a large negative number that doesn't map to any errno (INT_MIN if we want to be safe, I guess?).

This requires us getting a nice config API first (#21).

(Suggested by @brauner.)

@cyphar
Copy link
Member Author

cyphar commented Jul 21, 2024

ESERVERFAULT (errno 526, a kernel-internal errno from the NFSv3 protocol) semantically makes sense (the error description is An untranslatable error occurred) and is an errno userspace should never see returned from the kernel so we're safe remapping errors to it without causing confusion.

@cyphar
Copy link
Member Author

cyphar commented Aug 10, 2024

We can also switch away from using Mutex<HashMap<...>> to one of these lockless alternatives:

  1. https://github.com/hawkw/sharded-slab (has the benefit of having generation numbers, which reduces the risk of a user double-getting the same ID and clearing another thread's error by accident.)
  2. https://github.com/loyd/idr-ebr is similar, but it isn't optimised for insert/remove (which is our usecase!) so sharded-slab is probably better.

@cyphar cyphar added this to the 0.2.0 milestone Sep 11, 2024
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

No branches or pull requests

1 participant