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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id F3BE3B847E for ; Mon, 4 Dec 2023 14:18:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D4809DA54 for ; Mon, 4 Dec 2023 14:18:24 +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 ; Mon, 4 Dec 2023 14:18:24 +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 EBA7744773 for ; Mon, 4 Dec 2023 14:18:23 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Mon, 4 Dec 2023 14:18:20 +0100 Message-Id: <20231204131820.204423-3-g.goller@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231204131820.204423-1-g.goller@proxmox.com> References: <20231204131820.204423-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.167 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 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: Mon, 04 Dec 2023 13:18:55 -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