From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v5 proxmox-backup 1/2] garbage collection: fail on ArchiveType::Blob in open index reader
Date: Wed, 16 Apr 2025 12:49:59 +0200 [thread overview]
Message-ID: <20250416105000.270166-2-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250416105000.270166-1-c.ebner@proxmox.com>
Instead of returning a None, fail if the open index reader is called
on a blob file. Blobs cannot be read as index anyways and this allows
to distinguish cases where the index file cannot be read because
vanished.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
Changes since version 4:
- Adapt open_index_reader to fail for archive type blob, allows
detection of missing index files.
pbs-datastore/src/datastore.rs | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index aa38e2ac1..333f5f8d2 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1031,13 +1031,15 @@ impl DataStore {
Ok(list)
}
- // Similar to open index, but ignore index files with blob or unknown archive type.
- // Further, do not fail if file vanished.
- fn open_index_reader(&self, absolute_path: &Path) -> Result<Option<Box<dyn IndexFile>>, Error> {
+ // Similar to open index, but return with Ok(None) if index file vanished.
+ fn open_index_reader(
+ &self,
+ absolute_path: &Path,
+ ) -> Result<Option<Box<dyn IndexFile>>, Error> {
let archive_type = match ArchiveType::from_path(absolute_path) {
- Ok(archive_type) => archive_type,
// ignore archives with unknown archive type
- Err(_) => return Ok(None),
+ Ok(ArchiveType::Blob) | Err(_) => bail!("unexpected archive type"),
+ Ok(archive_type) => archive_type,
};
if absolute_path.is_relative() {
@@ -1064,7 +1066,7 @@ impl DataStore {
.with_context(|| format!("can't open dynamic index '{absolute_path:?}'"))?;
Ok(Some(Box::new(reader)))
}
- ArchiveType::Blob => Ok(None),
+ ArchiveType::Blob => bail!("unexpected archive type blob"),
}
}
@@ -1151,6 +1153,11 @@ impl DataStore {
worker.check_abort()?;
worker.fail_on_shutdown()?;
+ match ArchiveType::from_path(&file) {
+ Ok(ArchiveType::FixedIndex) | Ok(ArchiveType::DynamicIndex) => (),
+ Ok(ArchiveType::Blob) | Err(_) => continue,
+ }
+
let mut path = snapshot.backup_dir.full_path();
path.push(file);
--
2.39.5
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-04-16 10:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 10:49 [pbs-devel] [PATCH v5 proxmox-backup 0/2] fix rare race in garbage collection Christian Ebner
2025-04-16 10:49 ` Christian Ebner [this message]
2025-04-16 10:50 ` [pbs-devel] [PATCH v5 proxmox-backup 2/2] garbage collection: fix rare race in chunk marking phase Christian Ebner
2025-04-16 12:56 ` [pbs-devel] applied: [PATCH v5 proxmox-backup 0/2] fix rare race in garbage collection Thomas Lamprecht
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=20250416105000.270166-2-c.ebner@proxmox.com \
--to=c.ebner@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal