public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>
Cc: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH storage 1/2] fix #3873: btrfs: check for correct subvolume taking snapshot
Date: Fri, 13 Sep 2024 15:51:32 +0200	[thread overview]
Message-ID: <s8oseu38xwb.fsf@proxmox.com> (raw)
In-Reply-To: <49fb5ba5-02df-4ff6-8928-3d9376d0f532@proxmox.com> (Fiona Ebner's message of "Tue, 10 Sep 2024 15:13:39 +0200")

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.

Agreed, I will submit a patch improving the situation (mostly for
readability reasons) once I am back from vacations. Imho this could be
merged as-is as this is rather self-contained and already tested.

-- 
Maximiliano


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


  reply	other threads:[~2024-09-13 13:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 11:51 Maximiliano Sandoval
2024-07-09 11:51 ` [pve-devel] [PATCH storage 2/2] btrfs: forcefully set image to readwrite Maximiliano Sandoval
2024-08-19 11:27 ` [pve-devel] [PATCH storage 1/2] fix #3873: btrfs: check for correct subvolume taking snapshot Maximiliano Sandoval
2024-08-20 14:01 ` Hannes Laimer
2024-09-10 13:13 ` Fiona Ebner
2024-09-13 13:51   ` Maximiliano Sandoval [this message]
2024-09-13 13:43 ` Maximiliano Sandoval

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s8oseu38xwb.fsf@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal