* [pbs-devel] [PATCH proxmox-backup] datastore: pass relative path to group type iterator
@ 2025-05-22 12:51 Christian Ebner
2025-06-04 12:39 ` [pbs-devel] applied: " Fabian Grünbichler
0 siblings, 1 reply; 2+ messages in thread
From: Christian Ebner @ 2025-05-22 12:51 UTC (permalink / raw)
To: pbs-devel
`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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup] datastore: pass relative path to group type iterator
2025-05-22 12:51 [pbs-devel] [PATCH proxmox-backup] datastore: pass relative path to group type iterator Christian Ebner
@ 2025-06-04 12:39 ` Fabian Grünbichler
0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2025-06-04 12:39 UTC (permalink / raw)
To: pbs-devel, Christian Ebner
On Thu, 22 May 2025 14:51:28 +0200, Christian Ebner wrote:
> `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`.
>
> [...]
Applied, thanks!
[1/1] datastore: pass relative path to group type iterator
commit: 7149ecdacdd01b44e55398fa708b1a5b3905ec78
Best regards,
--
Fabian Grünbichler <f.gruenbichler@proxmox.com>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-04 12:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-22 12:51 [pbs-devel] [PATCH proxmox-backup] datastore: pass relative path to group type iterator Christian Ebner
2025-06-04 12:39 ` [pbs-devel] applied: " Fabian Grünbichler
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