gc: treat .bad files like regular chunks
Simplify the phase 2 code by treating .bad files just like regular chunks, with the exception of stat logging. To facilitate, we need to touch .bad files in phase 1. We only do this under the condition that 1) the original chunk is missing (as before), and 2) the original chunk is still referenced somewhere (since the code lives in the error handler for a failed chunk touch, it only gets called for chunks we expect to be there, i.e. ones that are referenced). Untouched they will then be cleaned up after 24 hours (or after the last longer-running task finishes). Reason 2) is also a fix for .bad files not being cleaned up at all if the original is no longer referenced anywhere (e.g. a user deleting all snapshots after seeing some corrupt chunks appear). cond_touch_path is introduced to touch arbitrary paths in the chunk store with the same logic as touching chunks. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
1ed022576c
commit
fd19256470
@ -446,6 +446,17 @@ impl DataStore {
|
||||
file_name,
|
||||
err,
|
||||
);
|
||||
|
||||
// touch any corresponding .bad files to keep them around, meaning if a chunk is
|
||||
// rewritten correctly they will be removed automatically, as well as if no index
|
||||
// file requires the chunk anymore (won't get to this loop then)
|
||||
for i in 0..=9 {
|
||||
let bad_ext = format!("{}.bad", i);
|
||||
let mut bad_path = PathBuf::new();
|
||||
bad_path.push(self.chunk_path(digest).0);
|
||||
bad_path.set_extension(bad_ext);
|
||||
self.chunk_store.cond_touch_path(&bad_path, false)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user