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 {
+           if (index($path, $_[1]) < 0) {
+               return
+           }
            push @$cmd, "$path\@$_[2]" if !(defined($snapshot) && $_[2] eq 
$snapshot);
        });
     }
-- 
2.39.2



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

Reply via email to