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 F3F211FF165 for <inbox@lore.proxmox.com>; Thu, 22 May 2025 14:51:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A91C2356BA; Thu, 22 May 2025 14:51:46 +0200 (CEST) From: Christian Ebner <c.ebner@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Thu, 22 May 2025 14:51:28 +0200 Message-Id: <20250522125128.428673-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup] datastore: pass relative path to group type iterator 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> `ListGroupsType::new_at` creates a new iterator over all groups of give backup type with provided parent file descriptor. The parent directory file descriptor is passed to the `read_subdir` call, which itself uses it to open the type directory via `openat`. This call does however ignore the passed file handle if the given path is absolute [0], which is always the case for the type path generated via `DataStore::type_path`. Fix this by passing only the type name as relative path to the `read_subdir` call, use the absolute path only for `ListGroupType::new`. This helps avoiding re-traversing the absolute path in the `ListGroups` iterator, and since it is then the only callside for `ListGroupsType::new_at`, inline the instantiation. [0] https://linux.die.net/man/2/openat Signed-off-by: Christian Ebner <c.ebner@proxmox.com> --- Similar to [1], this was encountered while inspecting strace outputs in order to investigate the garbage collection performance issues as reported in the community forum [2]. [1] https://lore.proxmox.com/pbs-devel/20250522062140.51956-1-c.ebner@proxmox.com/T/ [2] https://forum.proxmox.com/threads/166214/ pbs-datastore/src/hierarchy.rs | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/pbs-datastore/src/hierarchy.rs b/pbs-datastore/src/hierarchy.rs index e0bf84419..6c1287c3e 100644 --- a/pbs-datastore/src/hierarchy.rs +++ b/pbs-datastore/src/hierarchy.rs @@ -1,4 +1,3 @@ -use std::os::unix::io::RawFd; use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; @@ -73,17 +72,8 @@ pub struct ListGroupsType { impl ListGroupsType { pub fn new(store: Arc<DataStore>, ns: BackupNamespace, ty: BackupType) -> Result<Self, Error> { - Self::new_at(libc::AT_FDCWD, store, ns, ty) - } - - fn new_at( - fd: RawFd, - store: Arc<DataStore>, - ns: BackupNamespace, - ty: BackupType, - ) -> Result<Self, Error> { Ok(Self { - dir: proxmox_sys::fs::read_subdir(fd, &store.type_path(&ns, ty))?, + dir: proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &store.type_path(&ns, ty))?, store, ns, ty, @@ -197,15 +187,16 @@ impl Iterator for ListGroups { if let Ok(group_type) = BackupType::from_str(name) { // found a backup group type, descend into it to scan all IDs in it // by switching to the id-state branch - match ListGroupsType::new_at( - entry.parent_fd(), - Arc::clone(&self.store), - self.ns.clone(), - group_type, - ) { - Ok(ty) => self.id_state = Some(ty), - Err(err) => return Some(Err(err)), - } + let dir = match proxmox_sys::fs::read_subdir(entry.parent_fd(), name) { + Ok(dir) => dir, + Err(err) => return Some(Err(err.into())), + }; + self.id_state = Some(ListGroupsType { + dir, + store: Arc::clone(&self.store), + ns: self.ns.clone(), + ty: group_type, + }); } } } -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel