| `PhysicalVolume of pv ]
(* A segment describes the owner of a range of disk addresses. *)
-type segment =
- int63 * int63 * (* disk offset, size of segment *)
- owner * (* owner *)
- int63 (* owner offset *)
+type segment = owner * int63 (* owner, owner offset *)
type interval = int63 * int63 (* start point, end point (bytes) *)
(* List of owned segments before we build the segment tree. *)
type ownership_list =
(device * (* block_device (disk) *)
- segment) list
+ (int63 * int63 * (* disk offset, size of segment *)
+ owner * int63 (* owner, owner offset *)
+ )
+ ) list
(* Ownership tables. *)
let create_ownership machine =
let rec insert_segment tree segment =
let start, size, owner, owner_offset = segment in
let seginterval = start, start +^ size in
- eprintf "inserting (%s,%s) ...\n"
- (Int63.to_string (fst seginterval))
- (Int63.to_string (snd seginterval));
+ let seg = owner, owner_offset in
+
match tree with
(* Test if we should insert into this leaf or node: *)
| Leaf (interval, segs) when interval <-< seginterval ->
- Leaf (interval, segment :: segs)
+ Leaf (interval, seg :: segs)
| Node (left, (interval, segs), right)
when interval <-< seginterval ->
- Node (left, (interval, segment :: segs), right)
+ Node (left, (interval, seg :: segs), right)
| (Leaf _) as leaf -> leaf
let printer ((sp, ep), segments) =
sprintf "[%s-%s] " (Int63.to_string sp) (Int63.to_string ep) ^
String.concat ";"
- (List.map (fun (_, _, owner,_) -> string_of_owner owner)
+ (List.map (fun (owner,_) -> string_of_owner owner)
segments)
in
print_binary_tree printer printer tree
let owners = query tree in
List.map (
- fun (_, _, owner, owner_offset) -> (owner, offset -^ owner_offset)
+ fun (owner, owner_offset) -> (owner, offset -^ owner_offset)
) owners