From: Fabian Ebner Date: Mon, 13 Sep 2021 09:01:42 +0000 (+0200) Subject: btrfs: free image: only remove snapshots for current subvol X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=9524b31ee3a68526d157dabc0af8a7b964cd786c btrfs: free image: only remove snapshots for current subvol instead of all in the same directory. Reported in the community forum: https://forum.proxmox.com/threads/error-could-not-statfs-no-such-file-or-directory.96057/ Signed-off-by: Fabian Ebner --- diff --git a/PVE/Storage/BTRFSPlugin.pm b/PVE/Storage/BTRFSPlugin.pm index b30000b..1407f44 100644 --- a/PVE/Storage/BTRFSPlugin.pm +++ b/PVE/Storage/BTRFSPlugin.pm @@ -6,7 +6,7 @@ use warnings; use base qw(PVE::Storage::Plugin); use Fcntl qw(S_ISDIR O_WRONLY O_CREAT O_EXCL); -use File::Basename qw(dirname); +use File::Basename qw(basename dirname); use File::Path qw(mkpath); use IO::Dir; use POSIX qw(EEXIST); @@ -421,9 +421,11 @@ sub free_image { } my $dir = dirname($subvol); + my $basename = basename($subvol); my @snapshot_vols; foreach_subvol($dir, sub { my ($volume, $name, $snapshot) = @_; + return if $name ne $basename; return if !defined $snapshot; push @snapshot_vols, "$dir/$volume"; });