From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tools: move rlimit helper from pbs-client to pbs-tools
Date: Tue, 18 Nov 2025 11:45:28 +0100 [thread overview]
Message-ID: <20251118104529.254348-2-c.ebner@proxmox.com> (raw)
In-Reply-To: <20251118104529.254348-1-c.ebner@proxmox.com>
Move the helper to the more common tools, since it will be reused
for bumping the limits during garbage collection for datastores
with S3 backend.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
pbs-client/src/tools/mod.rs | 23 -----------------------
pbs-tools/src/lib.rs | 25 +++++++++++++++++++++++++
proxmox-backup-client/src/main.rs | 4 ++--
3 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs
index 7a496d14c..8b0d3c806 100644
--- a/pbs-client/src/tools/mod.rs
+++ b/pbs-client/src/tools/mod.rs
@@ -711,29 +711,6 @@ pub fn has_pxar_filename_extension(name: &str, with_didx_extension: bool) -> boo
}
}
-/// Raise the soft limit for open file handles to the hard limit
-///
-/// Returns the values set before raising the limit as libc::rlimit64
-pub fn raise_nofile_limit() -> Result<libc::rlimit64, Error> {
- let mut old = libc::rlimit64 {
- rlim_cur: 0,
- rlim_max: 0,
- };
- if 0 != unsafe { libc::getrlimit64(libc::RLIMIT_NOFILE, &mut old as *mut libc::rlimit64) } {
- bail!("Failed to get nofile rlimit");
- }
-
- let mut new = libc::rlimit64 {
- rlim_cur: old.rlim_max,
- rlim_max: old.rlim_max,
- };
- if 0 != unsafe { libc::setrlimit64(libc::RLIMIT_NOFILE, &mut new as *mut libc::rlimit64) } {
- bail!("Failed to set nofile rlimit");
- }
-
- Ok(old)
-}
-
/// Creates a temporary file (with `O_TMPFILE`) in `XDG_CACHE_HOME`. If we
/// cannot create the file there it will be created in `/tmp` instead.
pub fn create_tmp_file() -> std::io::Result<std::fs::File> {
diff --git a/pbs-tools/src/lib.rs b/pbs-tools/src/lib.rs
index af900c925..e9be0c6f0 100644
--- a/pbs-tools/src/lib.rs
+++ b/pbs-tools/src/lib.rs
@@ -1,3 +1,5 @@
+use anyhow::{bail, Error};
+
pub mod cert;
pub mod crypt_config;
pub mod format;
@@ -26,3 +28,26 @@ pub fn setup_libc_malloc_opts() {
libc::mallopt(libc::M_MMAP_THRESHOLD, 4096 * 32);
}
}
+
+/// Raise the soft limit for open file handles to the hard limit
+///
+/// Returns the values set before raising the limit as libc::rlimit64
+pub fn raise_nofile_limit() -> Result<libc::rlimit64, Error> {
+ let mut old = libc::rlimit64 {
+ rlim_cur: 0,
+ rlim_max: 0,
+ };
+ if 0 != unsafe { libc::getrlimit64(libc::RLIMIT_NOFILE, &mut old as *mut libc::rlimit64) } {
+ bail!("Failed to get nofile rlimit");
+ }
+
+ let mut new = libc::rlimit64 {
+ rlim_cur: old.rlim_max,
+ rlim_max: old.rlim_max,
+ };
+ if 0 != unsafe { libc::setrlimit64(libc::RLIMIT_NOFILE, &mut new as *mut libc::rlimit64) } {
+ bail!("Failed to set nofile rlimit");
+ }
+
+ Ok(old)
+}
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 999e50205..16b02ac99 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -41,7 +41,7 @@ use pbs_client::tools::{
crypto_parameters, format_key_source, get_encryption_key_password, KEYFD_SCHEMA,
KEYFILE_SCHEMA, MASTER_PUBKEY_FD_SCHEMA, MASTER_PUBKEY_FILE_SCHEMA,
},
- raise_nofile_limit, CHUNK_SIZE_SCHEMA, REPO_URL_SCHEMA,
+ CHUNK_SIZE_SCHEMA, REPO_URL_SCHEMA,
};
use pbs_client::{
delete_ticket_info, parse_backup_specification, view_task_result, BackupDetectionMode,
@@ -58,7 +58,7 @@ use pbs_datastore::manifest::BackupManifest;
use pbs_datastore::read_chunk::AsyncReadChunk;
use pbs_key_config::{decrypt_key, rsa_encrypt_key_config, KeyConfig};
use pbs_tools::crypt_config::CryptConfig;
-use pbs_tools::json;
+use pbs_tools::{json, raise_nofile_limit};
pub mod key;
pub mod namespace;
--
2.47.3
_______________________________________________
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-11-18 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 10:45 [pbs-devel] [PATCH proxmox-backup 0/2] raise nofile limit for GC on S3 stores Christian Ebner
2025-11-18 10:45 ` Christian Ebner [this message]
2025-11-18 10:45 ` [pbs-devel] [PATCH proxmox-backup 2/2] GC: raise nofile soft limit to the hard limit on s3 backed stores Christian Ebner
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=20251118104529.254348-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.