The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #103 from avsm/fsync-op

add Uring.fsync and Uring.fdatasync ops

authored by

Anil Madhavapeddy and committed by
GitHub
c8dbfda2 4a8b98c9

+60
+8
vendor/opam/uring/lib/uring/uring.ml
··· 333 333 external submit_unlinkat : t -> id -> Unix.file_descr -> Sketch.ptr -> bool -> bool = "ocaml_uring_submit_unlinkat" [@@noalloc] 334 334 external submit_send_msg : t -> id -> Unix.file_descr -> Msghdr.t -> Sketch.ptr -> bool = "ocaml_uring_submit_send_msg" [@@noalloc] 335 335 external submit_recv_msg : t -> id -> Unix.file_descr -> Msghdr.t -> Sketch.ptr -> bool = "ocaml_uring_submit_recv_msg" [@@noalloc] 336 + external submit_fsync : t -> id -> Unix.file_descr -> int64 -> int -> bool = "ocaml_uring_submit_fsync" [@@noalloc] 337 + external submit_fdatasync : t -> id -> Unix.file_descr -> int64 -> int -> bool = "ocaml_uring_submit_fdatasync" [@@noalloc] 336 338 337 339 type cqe_option = private 338 340 | Cqe_none ··· 554 556 with_id_full t (fun id -> 555 557 let iovec = Sketch.Iovec.alloc t.sketch buffers in 556 558 Uring.submit_recv_msg t.uring id fd msghdr iovec) user_data ~extra_data:msghdr 559 + 560 + let fsync t ?(off=0L) ?(len=0) fd user_data = 561 + with_id t (fun id -> Uring.submit_fsync t.uring id fd off len) user_data 562 + 563 + let fdatasync t ?(off=0L) ?(len=0) fd user_data = 564 + with_id t (fun id -> Uring.submit_fdatasync t.uring id fd off len) user_data 557 565 558 566 let cancel t job user_data = 559 567 ignore (Heap.ptr job : Uring.id); (* Check it's still valid *)
+10
vendor/opam/uring/lib/uring/uring.mli
··· 607 607 (** [recv_msg t fd msghdr d] will submit a [recvmsg(2)] request. If the request is 608 608 successful then the [msghdr] will contain the sender address and the data received. *) 609 609 610 + val fsync : 'a t -> ?off:int64 -> ?len:int -> Unix.file_descr -> 'a -> 'a job option 611 + (** [fsync t ?off ?len fd d] will submit an [fsync(2)] request, with the optional 612 + offset [off] and length [len] specifying the subset of the file to perform the 613 + synchronisation on. *) 614 + 615 + val fdatasync : 'a t -> ?off:int64 -> ?len:int -> Unix.file_descr -> 'a -> 'a job option 616 + (** [fdatasync t ?off ?len fd d] will submit an [fdatasync(2)] request, with the optional 617 + offset [off] and length [len] specifying the subset of the file to perform the 618 + synchronisation on. *) 619 + 610 620 (** {2 Probing} 611 621 612 622 You can check which operations are supported by the running kernel. *)
+26
vendor/opam/uring/lib/uring/uring_stubs.c
··· 850 850 } 851 851 852 852 value /* noalloc */ 853 + ocaml_uring_submit_fsync(value v_uring, value v_id, value v_fd, value v_off, value v_len) 854 + { 855 + struct io_uring *ring = Ring_val(v_uring); 856 + struct io_uring_sqe *sqe = io_uring_get_sqe(ring); 857 + if (!sqe) return (Val_false); 858 + io_uring_prep_fsync(sqe, Int_val(v_fd), 0); 859 + sqe->off = Int64_val(v_off); 860 + sqe->len = Int_val(v_len); 861 + io_uring_sqe_set_data(sqe, (void *)Long_val(v_id)); 862 + return (Val_true); 863 + } 864 + 865 + value /* noalloc */ 866 + ocaml_uring_submit_fdatasync(value v_uring, value v_id, value v_fd, value v_off, value v_len) 867 + { 868 + struct io_uring *ring = Ring_val(v_uring); 869 + struct io_uring_sqe *sqe = io_uring_get_sqe(ring); 870 + if (!sqe) return (Val_false); 871 + io_uring_prep_fsync(sqe, Int_val(v_fd), IORING_FSYNC_DATASYNC); 872 + sqe->off = Int64_val(v_off); 873 + sqe->len = Int_val(v_len); 874 + io_uring_sqe_set_data(sqe, (void *)Long_val(v_id)); 875 + return (Val_true); 876 + } 877 + 878 + value /* noalloc */ 853 879 ocaml_uring_submit_cancel(value v_uring, value v_id, value v_target) { 854 880 struct io_uring *ring = Ring_val(v_uring); 855 881 struct io_uring_sqe *sqe;
+16
vendor/opam/uring/tests/main.md
··· 184 184 x.st_kind, Printf.sprintf "0o%o" x.st_perm, x.st_size;; 185 185 - : Unix.file_kind * string * int = (Unix.S_REG, "0o600", 9) 186 186 187 + # Uring.fsync t fd `Create;; 188 + - : [ `Create ] Uring.job option = Some <abstr> 189 + # Uring.submit t;; 190 + - : int = 1 191 + # let v, read = consume t;; 192 + val v : [ `Create ] = `Create 193 + val read : int = 0 194 + 195 + # Uring.fdatasync t ~off:1L ~len:5 fd `Create;; 196 + - : [ `Create ] Uring.job option = Some <abstr> 197 + # Uring.submit t;; 198 + - : int = 1 199 + # let v, read = consume t;; 200 + val v : [ `Create ] = `Create 201 + val read : int = 0 202 + 187 203 # let fd : unit = Unix.close fd;; 188 204 val fd : unit = () 189 205