From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8DEF978745 for ; Tue, 28 Jun 2022 15:15:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6045BB847 for ; Tue, 28 Jun 2022 15:15:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 28 Jun 2022 15:15:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2EB8A43D15 for ; Tue, 28 Jun 2022 15:15:15 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 28 Jun 2022 15:15:14 +0200 Message-Id: <20220628131514.3798702-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220628131514.3798702-1-d.csapak@proxmox.com> References: <20220628131514.3798702-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.050 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [hierarchy.rs, self.name] Subject: [pbs-devel] [PATCH proxmox-backup v2 1/1] partially fix #2915: 'stat' in case ReadDirEntry does not contain type X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2022 13:15:47 -0000 readdir/getdents may return 'DT_UNKNOWN' for the file type (which corresponds to 'None' in nix::dir::Entry), so stat the file and check the type Signed-off-by: Dominik Csapak --- pbs-datastore/src/chunk_store.rs | 23 ++++++---------- pbs-datastore/src/hierarchy.rs | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs index c9714c1e..3bebc645 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex}; use anyhow::{bail, format_err, Error}; use pbs_api_types::GarbageCollectionStatus; -use proxmox_sys::fs::{create_dir, create_path, CreateOptions}; +use proxmox_sys::fs::{create_dir, create_path, file_type_from_file_stat, CreateOptions}; use proxmox_sys::process_locker::{ ProcessLockExclusiveGuard, ProcessLockSharedGuard, ProcessLocker, }; @@ -375,24 +375,19 @@ impl ChunkStore { ), }; - let file_type = match entry.file_type() { - Some(file_type) => file_type, - None => bail!( - "unsupported file system type on chunk store '{}'", - self.name - ), - }; - if file_type != nix::dir::Type::File { - continue; - } - - chunk_count += 1; - let filename = entry.file_name(); let lock = self.mutex.lock(); if let Ok(stat) = fstatat(dirfd, filename, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) { + let file_type = file_type_from_file_stat(&stat); + if file_type != Some(nix::dir::Type::File) { + drop(lock); + continue; + } + + chunk_count += 1; + if stat.st_atime < min_atime { //let age = now - stat.st_atime; //println!("UNLINK {} {:?}", age/(3600*24), filename); diff --git a/pbs-datastore/src/hierarchy.rs b/pbs-datastore/src/hierarchy.rs index d5007b07..8609364b 100644 --- a/pbs-datastore/src/hierarchy.rs +++ b/pbs-datastore/src/hierarchy.rs @@ -5,6 +5,7 @@ use std::sync::Arc; use anyhow::{bail, format_err, Error}; use pbs_api_types::{BackupNamespace, BackupType, BACKUP_DATE_REGEX, BACKUP_ID_REGEX}; +use proxmox_sys::fs::get_file_type; use crate::backup_info::{BackupDir, BackupGroup}; use crate::DataStore; @@ -36,6 +37,17 @@ impl Iterator for ListSnapshots { Ok(ref entry) => { match entry.file_type() { Some(nix::dir::Type::Directory) => entry, // OK + None => match get_file_type(entry.parent_fd(), entry.file_name()) { + Ok(nix::dir::Type::Directory) => entry, + Ok(_) => continue, + Err(err) => { + log::info!( + "error listing snapshots for {}: {err}", + self.group.group() + ); + continue; + } + }, _ => continue, } } @@ -93,6 +105,17 @@ impl Iterator for ListGroups { Ok(ref entry) => { match entry.file_type() { Some(nix::dir::Type::Directory) => entry, // OK + None => match get_file_type(entry.parent_fd(), entry.file_name()) { + Ok(nix::dir::Type::Directory) => entry, + Ok(_) => continue, + Err(err) => { + log::info!( + "error listing groups for {}: {err}", + self.store.name() + ); + continue; + } + }, _ => continue, } } @@ -114,6 +137,17 @@ impl Iterator for ListGroups { Ok(ref entry) => { match entry.file_type() { Some(nix::dir::Type::Directory) => entry, // OK + None => match get_file_type(entry.parent_fd(), entry.file_name()) { + Ok(nix::dir::Type::Directory) => entry, + Ok(_) => continue, + Err(err) => { + log::info!( + "error listing groups for {}: {err}", + self.store.name() + ); + continue; + } + }, _ => continue, } } @@ -176,6 +210,19 @@ impl Iterator for ListNamespaces { Ok(ref entry) => { match entry.file_type() { Some(nix::dir::Type::Directory) => entry, // OK + None => match get_file_type(entry.parent_fd(), entry.file_name()) { + Ok(nix::dir::Type::Directory) => entry, + Ok(_) => continue, + Err(err) => { + let mut base_path = self.base_path.to_owned(); + if !self.ns.is_root() { + base_path.push(self.ns.path()); + } + base_path.push("ns"); + log::info!("error listing dirs in {:?}: {err}", base_path); + continue; + } + }, _ => continue, } } -- 2.30.2