package qcow-types
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=c799f3c2eda00b345d37ccd759bcd7b8be8744216b77a38883ff4cd99727ae37
sha512=2160598f460240f9580991e7f7d69e3ef83a2e6ec62268b711840d359cd303d4e14a5d65d89ceb82a6f77b434d06a01af9daa7780808a885f3307909c11dcfd8
doc/qcow-types/Qcow_cluster_map/index.html
Module Qcow_cluster_map
Source
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 =
| Copying
(*a background copy is in progress. If this cluster is modified then the copy should be aborted.
*)| Copied
(*contents of this cluster have been copied once to another cluster. If this cluster is modified then the copy should be aborted.
*)| Flushed
(*contents of this cluster have been copied and flushed to disk: it is now safe to rewrite the pointer. If this cluster is modified then the copy should be aborted.
*)| Referenced
(*the reference has been rewritten; it is now safe to write to this cluster again. On the next flush, the copy is complete and the original block can be recycled.
*)
Describes the state of a block move
describes the state of an in-progress block move
val set_cluster_state :
t ->
Qcow_types.Cluster.IntervalSet.t ->
cluster_state ->
cluster_state ->
unit
Update the state of a cluster
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.
resize t new_size_clusters
is called when the file is to be resized.
add t ref cluster
marks cluster
as in-use and notes the reference from reference
.
remove t cluster
marks cluster
as free and invalidates any reference to it (e.g. in response to a discard)
Clusters which contain arbitrary data
Clusters which have been erased but haven't been flushed yet so can't be safely reallocated.
Clusters which are available for reallocation
Clusters which contain copies, as part of a compact
Clusters which have been allocated but not yet placed somewhere reachable from the GC
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
start_moves t
calculates the block moves required to compact t
and marks the clusters as moving
moves t
returns the state of the current active moves
Update the state of the given move operation
is_moving t cluster
returns true if cluster
is still moving
cancel_move cluster
cancels any in-progress move of cluster cluster
. This should be called with the cluster write lock held whenever there has been a change in the contents of cluster
find t cluster
returns the reference to cluster
, or raises Not_found
get_last_block t
is the last allocated block in t
. Note if there are no data blocks this will point to the last header block even though it is immovable.
is_immovable t cluster
is true if cluster
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.
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