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 632E360990 for ; Sat, 6 Feb 2021 14:48:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 54D1C11A1A for ; Sat, 6 Feb 2021 14:48:48 +0100 (CET) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 38BDB11A0D for ; Sat, 6 Feb 2021 14:48:44 +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 F015D41AEB for ; Sat, 6 Feb 2021 14:48:43 +0100 (CET) Message-ID: <8adf8d91-6992-3c1c-baf6-435c0eb15a2f@proxmox.com> Date: Sat, 6 Feb 2021 14:48:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Thunderbird/86.0 Content-Language: en-US To: Proxmox VE development discussion , Fabian Ebner References: <20210115105805.19994-1-f.ebner@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20210115105805.19994-1-f.ebner@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.062 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: [pve-devel] applied: [PATCH storage] remove lock from is_base_and_used check X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Feb 2021 13:48:48 -0000 On 15.01.21 11:58, Fabian Ebner wrote: > and squash the __no_lock-variant into it. > > This lock is not broad enough, because for a caller that plans to do or not do > some storage operation based on the result of the check, the following could > happen: > 1. volume_is_base_and_used is called and the result is used to enter a branch > 2. situation on the storage changes in the meantime > 3. the branch chosen in 1. might not be the one that should be taken anymore > > This means that callers are responsible for locking, and luckily the existing > callers do use their own locks already: > 1. vdisk_free used the __no_lock-variant with a broader lock also covering > the free operation. > 2. vdisk_clone is not a caller, but is relevant and it does lock the storage > 2. the calls during VM migration and VM destruction happen in the context of a > locked VM config. Because the clone operation also locks the VM config, it > cannot happen that a linked clone is created while the template VM is > migrated away or destroyed or vice versa. And even if that were the case, > the base disk would not be freed, because of what vdisk_free/vdisk_clone do. > > Signed-off-by: Fabian Ebner > --- > PVE/Storage.pm | 28 ++++++++++------------------ > 1 file changed, 10 insertions(+), 18 deletions(-) > > applied, thanks!