Module Qcow_cluster_map
type t
A cluster map which describes cluster usage in the file. The cluster map tracks which clusters are free, and which are used, and where the references are.
type move_state
=
Describes the state of a block move
type reference
= Qcow_types.Cluster.t * int
module Move : sig ... end
type move
=
{
move : Move.t;
state : move_state;
}
describes the state of an in-progress block move
val string_of_move : move -> string
val set_cluster_state : t -> Qcow_types.Cluster.IntervalSet.t -> cluster_state -> cluster_state -> unit
Update the state of a cluster
module type MutableSet = sig ... end
val zero : t
A cluster map for a zero-length disk
val make : free:Qcow_bitmap.t -> refs:reference Qcow_types.Cluster.Map.t -> cache:Qcow_cache.t -> first_movable_cluster:Qcow_types.Cluster.t -> runtime_asserts:bool -> id:string option -> cluster_size:int -> t
Given a set of free clusters, and the first cluster which can be moved (i.e. that isn't fixed header), construct an empty cluster map.
val total_used : t -> int64
Return the number of tracked used clusters
val total_free : t -> int64
Return the number of tracked free clusters
val resize : t -> Qcow_types.Cluster.t -> unit
resize t new_size_clusters
is called when the file is to be resized.
val add : t -> reference -> Qcow_types.Cluster.t -> unit
add t ref cluster
markscluster
as in-use and notes the reference fromreference
.
val remove : t -> Qcow_types.Cluster.t -> unit
remove t cluster
markscluster
as free and invalidates any reference to it (e.g. in response to a discard)
module Junk : MutableSet
Clusters which contain arbitrary data
module Erased : MutableSet
Clusters which have been erased but haven't been flushed yet so can't be safely reallocated.
module Available : MutableSet
Clusters which are available for reallocation
module Copies : MutableSet
Clusters which contain copies, as part of a compact
module Roots : MutableSet
Clusters which have been allocated but not yet placed somewhere reachable from the GC
val wait : t -> unit Lwt.t
wait t
wait for some amount of recycling work to become available, e.g.- junk could be created
- available could be used
- a move might require a reference update
val start_moves : t -> Move.t list
start_moves t
calculates the block moves required to compactt
and marks the clusters as moving
val moves : t -> move Qcow_types.Cluster.Map.t
moves t
returns the state of the current active moves
val set_move_state : t -> Move.t -> move_state -> unit
Update the state of the given move operation
val is_moving : t -> Qcow_types.Cluster.t -> bool
is_moving t cluster
returns true ifcluster
is still moving
val cancel_move : t -> Qcow_types.Cluster.t -> unit
cancel_move cluster
cancels any in-progress move of clustercluster
. This should be called with the cluster write lock held whenever there has been a change in the contents ofcluster
val find : t -> Qcow_types.Cluster.t -> reference
find t cluster
returns the reference tocluster
, or raisesNot_found
val get_last_block : t -> Qcow_types.Cluster.t
get_last_block t
is the last allocated block int
. Note if there are no data blocks this will point to the last header block even though it is immovable.
val is_immovable : t -> Qcow_types.Cluster.t -> bool
is_immovable t cluster
is true ifcluster
is fixed and cannot be moved i.e. it is before the first_movable_cluster i.e. it is part of the fixed (L1) header structure.
val update_references : t -> Qcow_types.Cluster.t Qcow_types.Cluster.Map.t -> unit
update_references t subst
updates the reference table following the given set of substitutions. Any reference to a source block must be updated to the destination block otherwise it will be left pointing to junk. Normally this is guaranteed by the Metadata.Physical.set function, but when compacting we split the operation into phases and copy the block first at the byte level, leaving the map out-of-sync
val to_summary_string : t -> string
to_summary_string t
returns a terse printable summary oft
module Debug : sig ... end