From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0BEF7B8D05 for ; Wed, 6 Dec 2023 14:28:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E62BA279E for ; Wed, 6 Dec 2023 14:28:39 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 6 Dec 2023 14:28:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A08C642547 for ; Wed, 6 Dec 2023 14:28:38 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Wed, 6 Dec 2023 14:28:34 +0100 Message-Id: <20231206132834.240700-3-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231206132834.240700-1-g.goller@proxmox.com> References: <20231206132834.240700-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.161 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v2 proxmox-backup 2/2] datastore: store datastore lock on tmpfs 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: , X-List-Received-Date: Wed, 06 Dec 2023 13:28:40 -0000 Store the lockfiles that lock the whole datastore (which get created on startup) on tmpfs in `/run/proxmox-backup/locks`. This allows datastores to always be unmounted without having to restart. Signed-off-by: Gabriel Goller --- pbs-datastore/src/chunk_store.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs index fb282749..41332db3 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -18,6 +18,8 @@ use crate::file_formats::{ }; use crate::DataBlob; +pub const DATASTORE_LOCKS_DIR: &str = "/run/proxmox-backup/locks"; + /// File system based chunk store pub struct ChunkStore { name: String, // used for error reporting @@ -124,7 +126,7 @@ impl ChunkStore { } // create lock file with correct owner/group - let lockfile_path = Self::lockfile_path(&base); + let lockfile_path = Self::lockfile_path(name); proxmox_sys::fs::replace_file(lockfile_path, b"", options.clone(), false)?; // create 64*1024 subdirs @@ -153,8 +155,9 @@ impl ChunkStore { Self::open(name, base, sync_level) } - fn lockfile_path>(base: P) -> PathBuf { - let mut lockfile_path: PathBuf = base.into(); + fn lockfile_path(base: &str) -> PathBuf { + let mut lockfile_path: PathBuf = DATASTORE_LOCKS_DIR.into(); + lockfile_path.push(base); lockfile_path.push(".lock"); lockfile_path } @@ -181,7 +184,7 @@ impl ChunkStore { bail!("unable to open chunk store '{name}' at {chunk_dir:?} - {err}"); } - let lockfile_path = Self::lockfile_path(&base); + let lockfile_path = Self::lockfile_path(name); let locker = ProcessLocker::new(lockfile_path)?; -- 2.39.2