From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 14E3A1FF168
	for <inbox@lore.proxmox.com>; Tue, 18 Feb 2025 17:29:09 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 1A39911DFB;
	Tue, 18 Feb 2025 17:29:04 +0100 (CET)
References: <20240709115116.333708-1-m.sandoval@proxmox.com>
 <49fb5ba5-02df-4ff6-8928-3d9376d0f532@proxmox.com>
User-agent: mu4e 1.10.8; emacs 29.4
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>
Date: Tue, 18 Feb 2025 17:28:55 +0100
In-reply-to: <49fb5ba5-02df-4ff6-8928-3d9376d0f532@proxmox.com>
Message-ID: <s8o5xl71ak3.fsf@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.299 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
 POISEN_SPAM_PILL          0.1 Meta: its spam
 POISEN_SPAM_PILL_1        0.1 random spam to be learned in bayes
 POISEN_SPAM_PILL_3        0.1 random spam to be learned in bayes
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URI_NOVOWEL               0.5 URI hostname has long non-vowel sequence
Subject: Re: [pve-devel] [PATCH storage 1/2] fix #3873: btrfs: check for
 correct subvolume taking snapshot
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>


Fiona Ebner <f.ebner@proxmox.com> writes:

> Am 09.07.24 um 13:51 schrieb Maximiliano Sandoval:
>> Suppose we are doing a snapshot of disk 0 for VM 100. The
>> dir_glob_foreach runs over $path=/subvolume/images/100, lists all
>> snapshot names and appends their names to the path of the disk, e.g.
>> /subvolume/images/vm-100-disk-0@SNAP_NAME, but the original directory
>> $path might contain a second disk `vm-100-disk-1` which is also listed
>> by the dir_glib_foreach.
>>
>> The patch skips images which reference other disks.
>>
>> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
>> ---
>>  src/PVE/Storage/BTRFSPlugin.pm | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
>> index 42815cb..dc0420d 100644
>> --- a/src/PVE/Storage/BTRFSPlugin.pm
>> +++ b/src/PVE/Storage/BTRFSPlugin.pm
>> @@ -767,6 +767,9 @@ sub volume_export {
>>  	push @$cmd, (map { "$path\@$_" } ($with_snapshots // [])->@*), $path;
>>      } else {
>>  	dir_glob_foreach(dirname($path), $BTRFS_VOL_REGEX, sub {
>
> I feel like this would be a bit nicer (and slightly more robust) if it
> used foreach_subvol() and would check the basename like done in
> free_image(). Or even better, introduce a new helper that iterates over
> all snapshots of a specific volume to not repeat ourselves here and in
> free_image(). Since foreach_subvol() is only used once (i.e. in
> free_image()), we could even replace that. There's another pre-existing
> thing that's a bit confusing, which is that BTRFS_VOL_REGEX only matches
> snapshot volumes and not the actual volume itself AFAICS.
>
>> +	    if (index($path, $_[1]) < 0) {
>> +		return
>> +	    }
>>  	    push @$cmd, "$path\@$_[2]" if !(defined($snapshot) && $_[2] eq $snapshot);
>>  	});
>>      }


v2 sent.


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel