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.sando...@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); > }); > } _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel