Skip to content

Commit e0f0856

Browse files
authored
Merge pull request #91 from hannesm/cstruct-6-1-0
adapt to cstruct 6.0.0 and fmt 0.8.7 API
2 parents dd4867a + ae3efab commit e0f0856

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

lib/back/blkback.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ module Make(A: ACTIVATIONS)(X: Xs_client_lwt.S)(B: Mirage_block.S) = struct
105105

106106
module BlockError = struct
107107
open Lwt
108-
let fail_read e = Fmt.kstrf fail_with "%a" B.pp_error e
109-
let fail_write e = Fmt.kstrf fail_with "%a" B.pp_write_error e
108+
let fail_read e = Fmt.kstr fail_with "%a" B.pp_error e
109+
let fail_write e = Fmt.kstr fail_with "%a" B.pp_write_error e
110110
end
111111

112112
let service_thread t stats =

lib/back/block_request.ml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let string_of_request r =
3030
let int x = string_of_int x in
3131
let list ty xs = String.concat "; " (List.map ty xs) in
3232
Printf.sprintf "{ id = [ %s ]; op = %s; sector = %Ld; length = %d; buffers = [ %s ]; depends = [ %s ]}"
33-
(list int64 r.id) (string_of_op r.op) r.sector r.length (list int (List.map Cstruct.len r.buffers)) (list int64 r.depends)
33+
(list int64 r.id) (string_of_op r.op) r.sector r.length (list int (List.map Cstruct.length r.buffers)) (list int64 r.depends)
3434

3535
type t = request list
3636

@@ -46,7 +46,7 @@ let conflicts a b = match a.op, b.op with
4646
|| (add b.sector (of_int b.length) < a.sector))
4747

4848
let add t id op sector buffers =
49-
let length = List.fold_left (+) 0 (List.map Cstruct.len buffers) / 512 in
49+
let length = List.fold_left (+) 0 (List.map Cstruct.length buffers) / 512 in
5050
let r = { id = [id]; op; sector; length; buffers; depends = [] } in
5151
let depends = List.(concat (map (fun r -> r.id) (filter (conflicts r) t))) in
5252
let r = { r with depends } in
@@ -60,12 +60,8 @@ let coalesce requests =
6060
| r :: rs -> reqs (if current = [] then finished else current :: finished) (Int64.(add r.sector (of_int r.length))) [ r ] rs in
6161
(* merge adjacent cstruct buffers *)
6262
let rec merge_buffers finished current = function
63-
| [] -> List.rev (if Cstruct.len current = 0 then finished else current :: finished)
64-
| b :: bs when current.Cstruct.len <> 0
65-
&& current.Cstruct.buffer == b.Cstruct.buffer
66-
&& (current.Cstruct.off + current.Cstruct.len = b.Cstruct.off) ->
67-
merge_buffers finished (Cstruct.add_len current b.Cstruct.len) bs
68-
| b :: bs -> merge_buffers (if Cstruct.len current = 0 then finished else current :: finished) b bs in
63+
| [] -> List.rev (if Cstruct.length current = 0 then finished else current :: finished)
64+
| b :: bs -> merge_buffers (if Cstruct.length current = 0 then finished else current :: finished) b bs in
6965
let merge requests =
7066
let batches = reqs [] (-1L) [] requests in
7167
List.map (function

mirage-block-xen.opam

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ depends: [
1111
"dune" {>= "1.0"}
1212
"logs"
1313
"lwt" {>= "2.4.3"}
14-
"cstruct" {>= "1.9.0"}
14+
"cstruct" {>= "6.0.0"}
1515
"ppx_cstruct" {>= "3.6.0"}
1616
"shared-memory-ring"
1717
"shared-memory-ring-lwt"
1818
"mirage-block" {>= "2.0.0"}
1919
"io-page" {>= "2.0.0"}
2020
"mirage-xen" {>= "7.0.0"}
2121
"xenstore"
22+
"fmt" {>= "0.8.7"}
2223
]
2324
build: [
2425
["dune" "subst"] {dev}

0 commit comments

Comments
 (0)