From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id CB1C61FF13F for ; Thu, 09 Apr 2026 17:54:07 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AA3D8A602; Thu, 9 Apr 2026 17:54:49 +0200 (CEST) From: Samuel Rufinatscha To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-datacenter-manager v8 2/3] pdm-config: wire user and ACL cache generation Date: Thu, 9 Apr 2026 17:54:28 +0200 Message-ID: <20260409155437.312760-9-s.rufinatscha@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260409155437.312760-1-s.rufinatscha@proxmox.com> References: <20260409155437.312760-1-s.rufinatscha@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775750014037 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.230 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 Message-ID-Hash: GMWPMNFMAXT7XRREWUYYQVOSO6J2LZMB X-Message-ID-Hash: GMWPMNFMAXT7XRREWUYYQVOSO6J2LZMB X-MailFrom: s.rufinatscha@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Enables user.cfg and acl.cfg caching by wiring proxmox_access_control::init::AccessControlBackend's cache_generation() and increment_cache_generation() with ConfigVersionCache. Since the trait expects a single shared generation for both user.cfg and acl.cfg files, the ConfigVersionCache's user_cache_generation variable is renamed to user_and_acl_generation to reflect its actual scope. Safety: the renamed generation was unused before, no layout change, the shared-memory size and field order remain unchanged. Signed-off-by: Samuel Rufinatscha --- Changes from v7 to v8: * Rebased * Improve commit message Changes from v6 to v7: * Rebased Changes from v5 to v6: * Rebased Changes from v4 to v5: * Rebased lib/pdm-config/src/access_control.rs | 11 +++++++++++ lib/pdm-config/src/config_version_cache.rs | 16 ++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/pdm-config/src/access_control.rs b/lib/pdm-config/src/access_control.rs index 0c17c99..6bc6ca6 100644 --- a/lib/pdm-config/src/access_control.rs +++ b/lib/pdm-config/src/access_control.rs @@ -26,4 +26,15 @@ impl proxmox_access_control::init::AccessControlBackend for AccessControlBackend Ok(()) } + + fn cache_generation(&self) -> Option { + crate::ConfigVersionCache::new() + .ok() + .map(|c| c.user_and_acl_generation()) + } + + fn increment_cache_generation(&self) -> Result<(), Error> { + let c = crate::ConfigVersionCache::new()?; + Ok(c.increase_user_and_acl_generation()) + } } diff --git a/lib/pdm-config/src/config_version_cache.rs b/lib/pdm-config/src/config_version_cache.rs index 36a6a77..d27ec95 100644 --- a/lib/pdm-config/src/config_version_cache.rs +++ b/lib/pdm-config/src/config_version_cache.rs @@ -21,8 +21,8 @@ use proxmox_shared_memory::*; #[repr(C)] struct ConfigVersionCacheDataInner { magic: [u8; 8], - // User (user.cfg) cache generation/version. - user_cache_generation: AtomicUsize, + // User (user.cfg) and ACL (acl.cfg) generation/version. + user_and_acl_generation: AtomicUsize, // Traffic control (traffic-control.cfg) generation/version. traffic_control_generation: AtomicUsize, // Tracks updates to the remote/hostname/nodename mapping cache. @@ -124,19 +124,19 @@ impl ConfigVersionCache { Ok(Arc::new(Self { shmem })) } - /// Returns the user cache generation number. - pub fn user_cache_generation(&self) -> usize { + /// Returns the user and ACL cache generation number. + pub fn user_and_acl_generation(&self) -> usize { self.shmem .data() - .user_cache_generation + .user_and_acl_generation .load(Ordering::Acquire) } - /// Increase the user cache generation number. - pub fn increase_user_cache_generation(&self) { + /// Increase the user and ACL cache generation number. + pub fn increase_user_and_acl_generation(&self) { self.shmem .data() - .user_cache_generation + .user_and_acl_generation .fetch_add(1, Ordering::AcqRel); } -- 2.47.3