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 8AF09609E5 for ; Fri, 9 Oct 2020 12:46:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7039715E75 for ; Fri, 9 Oct 2020 12:45:43 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 3CDC815E6B for ; Fri, 9 Oct 2020 12:45:42 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 07A2245CAD for ; Fri, 9 Oct 2020 12:45:42 +0200 (CEST) From: Thomas Lamprecht To: pbs-devel@lists.proxmox.com Date: Fri, 9 Oct 2020 12:45:36 +0200 Message-Id: <20201009104536.16876-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.138 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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 backup] backup: index readers: drop useless shared lock 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: Fri, 09 Oct 2020 10:46:13 -0000 This is only acquired in those two methods, both as shared. So it has no use. It seems, that it was planned in the past that the index deletion should take the exclusive, while read and write takes the shared flock on the index, as one can guess from the lock comments in commit 046521895307aa8bde8bab7ea3ef9e437d5ab5e5 But then later, in commit c8ec450e379f54e7ac648b3a3ff701b37e9a6620) the documented semantics where changed to use a temp file and do an atomic rename instead for atomicity. The reader shared flock on the index file was done inbetween, probably as preparatory step, but was not removed again when strategy was changed to using the file rename instead. Do so now, to avoid confusion of readers and a useless flock. Signed-off-by: Thomas Lamprecht --- src/backup/dynamic_index.rs | 6 ------ src/backup/fixed_index.rs | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs index 1cc4e53b..8731a418 100644 --- a/src/backup/dynamic_index.rs +++ b/src/backup/dynamic_index.rs @@ -90,12 +90,6 @@ impl DynamicIndexReader { } pub fn new(mut file: std::fs::File) -> Result { - if let Err(err) = - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) - { - bail!("unable to get shared lock - {}", err); - } - // FIXME: This is NOT OUR job! Check the callers of this method and remove this! file.seek(SeekFrom::Start(0))?; diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index a2317f0b..eff50055 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -65,12 +65,6 @@ impl FixedIndexReader { } pub fn new(mut file: std::fs::File) -> Result { - if let Err(err) = - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) - { - bail!("unable to get shared lock - {}", err); - } - file.seek(SeekFrom::Start(0))?; let header_size = std::mem::size_of::(); -- 2.27.0