Module Qcow_recycler.Make

Parameters

Signature

type t

A cluster recycling engine

val create : base:B.t -> sector_size:int -> cluster_bits:int -> cache:Qcow_cache.t -> locks:Qcow_locks.t -> metadata:Qcow_metadata.t -> runtime_asserts:bool -> t

Initialise a cluster recycler over the given block device

val set_cluster_map : t -> Qcow_cluster_map.t -> unit

Set the associated cluster map (which will be updated on every cluster write)

val start_background_thread : t -> keep_erased:int64 -> ?⁠compact_after_unmaps:int64 -> unit -> unit

Start a background thread which will perform block recycling

val allocate : t -> Qcow_types.Cluster.t -> Qcow_types.Cluster.IntervalSet.t option

allocate t n returns n clusters which are ready for re-use. If there are not enough clusters free then this returns None.

val erase : t -> Qcow_types.Cluster.IntervalSet.t -> (unit, B.write_error) Stdlib.result Lwt.t

Write zeroes over the specified set of clusters

val copy : t -> Qcow_types.Cluster.t -> Qcow_types.Cluster.t -> (unit, B.write_error) Stdlib.result Lwt.t

copy src dst copies the cluster src to dst

val move_all : ?⁠progress_cb:(percent:int -> unit) -> t -> Qcow_cluster_map.Move.t list -> (unit, Qcow_metadata.write_error) Stdlib.result Lwt.t

move_all t mv perform the initial data copy of the move operations mv

val update_references : t -> (int64, Qcow_metadata.write_error) Stdlib.result Lwt.t

update_references t rewrites references to any recently copied and flushed block, returning the number of writes completed.

val flush : t -> (unit, B.write_error) Stdlib.result Lwt.t

Issue a flush to the block device, update internal recycler state.