From: Stefan Reiter <s.reiter@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] clean up .bad file handling in sweep_unused_chunks
Date: Tue, 8 Sep 2020 15:02:46 +0200 [thread overview]
Message-ID: <20200908130246.8065-1-s.reiter@proxmox.com> (raw)
Code cleanup, no functional change intended.
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
src/backup/chunk_store.rs | 58 ++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 35 deletions(-)
diff --git a/src/backup/chunk_store.rs b/src/backup/chunk_store.rs
index 1d9de70a..7f5c0693 100644
--- a/src/backup/chunk_store.rs
+++ b/src/backup/chunk_store.rs
@@ -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) => {
- 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
+ // 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(_) => {
+ match unlinkat(Some(dirfd), filename, UnlinkatFlags::NoRemoveDir) {
+ Err(err) =>
worker.warn(format!(
- "error during stat on '{:?}' - {}",
- orig_filename,
+ "unlinking corrupt chunk {:?} failed on store '{}' - {}",
+ filename,
+ self.name,
err,
- ));
- continue;
+ )),
+ 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!(
- "could not get original filename from .bad file '{:?}' - {}",
- filename,
+ "error during stat on '{:?}' - {}",
+ orig_filename,
err,
));
- continue;
}
}
-
- if let Err(err) = unlinkat(Some(dirfd), filename, UnlinkatFlags::NoRemoveDir) {
- worker.warn(format!(
- "unlinking corrupt chunk {:?} failed on store '{}' - {}",
- filename,
- self.name,
- err,
- ));
- } else {
- status.removed_bad += 1;
- status.removed_bytes += stat.st_size as u64;
- }
} else if stat.st_atime < min_atime {
//let age = now - stat.st_atime;
//println!("UNLINK {} {:?}", age/(3600*24), filename);
--
2.20.1
next reply other threads:[~2020-09-08 13:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 13:02 Stefan Reiter [this message]
2020-09-10 4:37 ` Dietmar Maurer
2020-09-10 4:38 ` [pbs-devel] applied: " Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200908130246.8065-1-s.reiter@proxmox.com \
--to=s.reiter@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.