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

eio_linux: retry openat2 on EAGAIN #693

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lib_eio_linux/low_level.ml
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,21 @@ let with_chunk ~fallback fn =
| None ->
fallback ()

let openat2 ~sw ?seekable ~access ~flags ~perm ~resolve ?dir path =
let use dir =
let res = Sched.enter "openat2" (enqueue_openat2 (access, flags, perm, resolve, dir, path)) in
let rec openat2 ~sw ?seekable ~access ~flags ~perm ~resolve ?dir path =
let use dir_opt =
let res = Sched.enter "openat2" (enqueue_openat2 (access, flags, perm, resolve, dir_opt, path)) in
if res < 0 then (
Switch.check sw; (* If cancelled, report that instead. *)
raise @@ Err.wrap_fs (Uring.error_of_errno res) "openat2" ""
);
let fd : Unix.file_descr = Obj.magic res in
Fd.of_unix ~sw ?seekable ~close_unix:true fd
match Uring.error_of_errno res with
| EAGAIN ->
(* Linux can return this due to a concurrent update.
It also seems to happen sometimes with no concurrent updates. *)
openat2 ~sw ?seekable ~access ~flags ~perm ~resolve ?dir path
| e -> raise @@ Err.wrap_fs e "openat2" ""
) else (
let fd : Unix.file_descr = Obj.magic res in
Fd.of_unix ~sw ?seekable ~close_unix:true fd
)
in
match dir with
| None -> use None
Expand Down
Loading