From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id AC0171FF187 for ; Tue, 18 Nov 2025 11:45:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 24496106EE; Tue, 18 Nov 2025 11:45:42 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 18 Nov 2025 11:45:28 +0100 Message-ID: <20251118104529.254348-2-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251118104529.254348-1-c.ebner@proxmox.com> References: <20251118104529.254348-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763462709204 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 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 Subject: [pbs-devel] [PATCH proxmox-backup 1/2] tools: move rlimit helper from pbs-client to pbs-tools 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" 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 --- 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 { - 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 { 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 { + 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