gc: remove .bad files on garbage collect
The iterator of get_chunk_iterator is extended with a third parameter indicating whether the current file is a chunk (false) or a .bad file (true). Count their sizes to the total of removed bytes, since it also frees disk space. .bad files are only deleted if the corresponding chunk exists, i.e. has been rewritten. Otherwise we might delete data only marked bad because of transient errors. While at it, also clean up and use nix::unistd::unlinkat instead of unsafe libc calls. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
aadcc2815c
commit
a9767cf7de
@ -85,7 +85,7 @@ impl DataStore {
|
||||
pub fn get_chunk_iterator(
|
||||
&self,
|
||||
) -> Result<
|
||||
impl Iterator<Item = (Result<tools::fs::ReadDirEntry, Error>, usize)>,
|
||||
impl Iterator<Item = (Result<tools::fs::ReadDirEntry, Error>, usize, bool)>,
|
||||
Error
|
||||
> {
|
||||
self.chunk_store.get_chunk_iterator()
|
||||
@ -495,6 +495,9 @@ impl DataStore {
|
||||
if gc_status.pending_bytes > 0 {
|
||||
worker.log(&format!("Pending removals: {} (in {} chunks)", HumanByte::from(gc_status.pending_bytes), gc_status.pending_chunks));
|
||||
}
|
||||
if gc_status.removed_bad > 0 {
|
||||
worker.log(&format!("Removed bad files: {}", gc_status.removed_bad));
|
||||
}
|
||||
|
||||
worker.log(&format!("Original data usage: {}", HumanByte::from(gc_status.index_data_bytes)));
|
||||
|
||||
|
Reference in New Issue
Block a user