clean up .bad file handling in sweep_unused_chunks
Code cleanup, no functional change intended. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
3cddfb29be
commit
597427afaf
|
@ -325,52 +325,40 @@ impl ChunkStore {
|
|||
|
||||
if let Ok(stat) = fstatat(dirfd, filename, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) {
|
||||
if bad {
|
||||
match std::ffi::CString::new(&filename.to_bytes()[..64]) {
|
||||
Ok(orig_filename) => {
|
||||
// filename validity checked in iterator
|
||||
let orig_filename = std::ffi::CString::new(&filename.to_bytes()[..64]).unwrap();
|
||||
match fstatat(
|
||||
dirfd,
|
||||
orig_filename.as_c_str(),
|
||||
nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW)
|
||||
{
|
||||
Ok(_) => { /* do nothing */ },
|
||||
Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => {
|
||||
// chunk hasn't been rewritten yet, keep
|
||||
// .bad file around for manual recovery
|
||||
continue;
|
||||
},
|
||||
Err(err) => {
|
||||
// some other error, warn user and keep
|
||||
// .bad file around too
|
||||
worker.warn(format!(
|
||||
"error during stat on '{:?}' - {}",
|
||||
orig_filename,
|
||||
err,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
worker.warn(format!(
|
||||
"could not get original filename from .bad file '{:?}' - {}",
|
||||
filename,
|
||||
err,
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(err) = unlinkat(Some(dirfd), filename, UnlinkatFlags::NoRemoveDir) {
|
||||
Ok(_) => {
|
||||
match unlinkat(Some(dirfd), filename, UnlinkatFlags::NoRemoveDir) {
|
||||
Err(err) =>
|
||||
worker.warn(format!(
|
||||
"unlinking corrupt chunk {:?} failed on store '{}' - {}",
|
||||
filename,
|
||||
self.name,
|
||||
err,
|
||||
));
|
||||
} else {
|
||||
)),
|
||||
Ok(_) => {
|
||||
status.removed_bad += 1;
|
||||
status.removed_bytes += stat.st_size as u64;
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => {
|
||||
// chunk hasn't been rewritten yet, keep .bad file
|
||||
},
|
||||
Err(err) => {
|
||||
// some other error, warn user and keep .bad file around too
|
||||
worker.warn(format!(
|
||||
"error during stat on '{:?}' - {}",
|
||||
orig_filename,
|
||||
err,
|
||||
));
|
||||
}
|
||||
}
|
||||
} else if stat.st_atime < min_atime {
|
||||
//let age = now - stat.st_atime;
|
||||
//println!("UNLINK {} {:?}", age/(3600*24), filename);
|
||||
|
|
Loading…
Reference in New Issue