[pve-devel] [PATCH storage 1/2] fix #3873: btrfs: check for correct subvolume taking snapshot

Maximiliano Sandoval m.sandoval at proxmox.com
Tue Jul 9 13:51:15 CEST 2024


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 at 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 at 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





More information about the pve-devel mailing list