From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pbs-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id BB1E31FF172 for <inbox@lore.proxmox.com>; Wed, 16 Apr 2025 12:50:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7DA5833B66; Wed, 16 Apr 2025 12:50:49 +0200 (CEST) From: Christian Ebner <c.ebner@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Wed, 16 Apr 2025 12:49:59 +0200 Message-Id: <20250416105000.270166-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250416105000.270166-1-c.ebner@proxmox.com> References: <20250416105000.270166-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [datastore.rs] Subject: [pbs-devel] [PATCH v5 proxmox-backup 1/2] garbage collection: fail on ArchiveType::Blob in open index reader X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion <pbs-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/> List-Post: <mailto:pbs-devel@lists.proxmox.com> List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" <pbs-devel-bounces@lists.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