]> git.proxmox.com Git - pve-storage.git/commitdiff
btrfs: free image: only remove snapshots for current subvol
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 13 Sep 2021 09:01:42 +0000 (11:01 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Oct 2021 11:55:14 +0000 (13:55 +0200)
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 <f.ebner@proxmox.com>
PVE/Storage/BTRFSPlugin.pm

index b30000baefe7b09ae19a41db7c1436a5478457af..1407f443f1f5e83964345b4b1f926da4ee8664f9 100644 (file)
@@ -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";
     });