]> git.proxmox.com Git - proxmox-backup.git/blame - src/backup.rs
src/backup.rs: describe the garbage collection problem
[proxmox-backup.git] / src / backup.rs
CommitLineData
d78345bc
DM
1//! This module implements the proxmox backup chunked data storage
2//!
3//! A chunk is simply defined as binary blob. We store them inside a
4//! `ChunkStore`, addressed by the SHA256 digest of the binary
5//! blob. This technology is also known as content-addressable
6//! storage.
7//!
8//! We store larger files by splitting them into chunks. The resulting
9//! SHA256 digest list is stored as separate index file. The
10//! `DynamicIndex*` format is able to deal with dynamic chunk sizes,
11//! whereas the `FixedIndex*` format is an optimization to store a
12//! list of equal sized chunks.
04652189
DM
13//!
14//! # ChunkStore Locking
15//!
16//! We need to be able to restart the proxmox-backup service daemons,
17//! so that we can update the software without rebooting the host. But
18//! such restarts must not abort running backup jobs, so we need to
19//! keep the old service running until those jobs are finished. This
20//! implies that we need some kink of locking for the
21//! ChunkStore. Please note that it is perfectly valid to have
22//! multiple parallel ChunkStore writers, even when they write the
23//! same chunk (because the chunk would have the same name and the
24//! same data). The only real problem is garbage collection, because
25//! we need to avoid deleting chunks which are still referenced.
26//!
27//! * Read Index Files:
28//!
29//! Acquire shared lock for .idx files.
30//!
31//!
32//! * Delete Index Files:
33//!
34//! Acquire exclusive lock for .idx files. This makes sure that we do
35//! not delete index files while they are still in use.
36//!
37//!
38//! * Create Index Files:
39//!
8a475734 40//! Acquire shared lock for ChunkStore (process wide).
04652189
DM
41//!
42//! Note: We create temporary (.tmp) file, then do an atomic rename ...
43//!
44//!
45//! * Garbage Collect:
46//!
8a475734
DM
47//! Acquire exclusive lock for ChunkStore (process wide). If we have
48//! already an shared lock for ChunkStore, try to updraged that
49//! lock.
04652189
DM
50//!
51//!
52//! * Server Restart
53//!
54//! Try to abort running garbage collection to release exclusive
55//! ChunkStore lock asap. Start new service with existing listening
56//! socket.
57//!
8a475734
DM
58//!
59//! # Garbage Collection
60//!
61//! Deleting backups is as easy as deleting the corresponding .idx
62//! files. Unfortunately, this does not free up any storage, because
63//! those files just contains references to chunks.
64//!
65//! To free up some storage, we run a garbage collection process at
66//! regular intervals. The collector uses an mark and sweep
67//! approach. In the first run, it scans all .idx files to mark used
68//! chunks. The second run then removes all unmarked chunks from the
69//! store.
70//!
71//! The above locking mechanism makes sure that we are the only
72//! process running GC.
73//!
74//!
75
cbdd8c54 76
7e336555
DM
77mod chunk_stat;
78pub use chunk_stat::*;
79
06178f13 80pub use proxmox_protocol::Chunker;
e5064ba6
DM
81
82mod chunk_store;
83pub use chunk_store::*;
84
7bc1d727
WB
85mod index;
86pub use index::*;
87
e5064ba6
DM
88mod fixed_index;
89pub use fixed_index::*;
90
91mod dynamic_index;
92pub use dynamic_index::*;
93
b3483782
DM
94mod backup_info;
95pub use backup_info::*;
96
e5064ba6
DM
97mod datastore;
98pub use datastore::*;