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 7A6CE1FF18C for ; Mon, 12 May 2025 14:59:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 730E54C19; Mon, 12 May 2025 14:59:42 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Mon, 12 May 2025 14:59:33 +0200 Message-Id: <20250512125933.156192-1-h.laimer@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.025 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup] api: also update datastore cache on api process 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" Until now we only told the proxy through the command socket that it should check if it has to update its cache. We never did that for the cache the api process holds, this wasn't really a problem because we never actually used any chunks store refs that would have been cached in the first place, still, if we should ever have the api process do anything that involves a `datastore_lookup` it will also be in the cache on the api process. This also updates the process-local cache whenever we tell the proxy process to update its cache. And since this is the same logic in a few places I moved it into a new helper function that does both, - tell the proxy to update its cache - and, update its own Signed-off-by: Hannes Laimer --- src/api2/admin/datastore.rs | 30 ++++++++++++++++++------------ src/api2/config/datastore.rs | 32 +++++--------------------------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index a3ba82e21..02a53a932 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -164,6 +164,23 @@ fn get_all_snapshot_files( Ok((manifest, files)) } +/// Triggers a cache update (if needed) on both the api and proxy process +pub async fn update_datastore_cache(name: &str) -> Result<(), Error> { + if let Ok(proxy_pid) = proxmox_rest_server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN) + { + let sock = proxmox_daemon::command_socket::path_from_pid(proxy_pid); + let _ = proxmox_daemon::command_socket::send_raw( + sock, + &format!( + "{{\"command\":\"update-datastore-cache\",\"args\":\"{}\"}}\n", + name + ), + ) + .await; + }; + DataStore::update_datastore_cache(name) +} + #[api( input: { properties: { @@ -2752,18 +2769,7 @@ pub async fn unmount(store: String, rpcenv: &mut dyn RpcEnvironment) -> Result