fix #3873: btrfs: use foreach_snapshot_of_subvol helper in volume_export
Suppose we are taking a snapshot of VM 100's disk-0. 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. By using the helper we only iterate over the snapshots of the guest. Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
This commit is contained in:
committed by
Fiona Ebner
parent
171b760d81
commit
c05ef0dbce
@ -796,8 +796,9 @@ sub volume_export {
|
||||
if (ref($with_snapshots) eq 'ARRAY') {
|
||||
push @$cmd, (map { "$path\@$_" } ($with_snapshots // [])->@*), $path;
|
||||
} else {
|
||||
dir_glob_foreach(dirname($path), $BTRFS_VOL_REGEX, sub {
|
||||
push @$cmd, "$path\@$_[2]" if !(defined($snapshot) && $_[2] eq $snapshot);
|
||||
foreach_snapshot_of_subvol($path, sub {
|
||||
my ($snap_name) = @_;
|
||||
push @$cmd, "$path\@$snap_name" if !(defined($snapshot) && $snap_name eq $snapshot);
|
||||
});
|
||||
}
|
||||
$path .= "\@$snapshot" if defined($snapshot);
|
||||
|
||||
Reference in New Issue
Block a user