From: Fabian Ebner Date: Thu, 28 Apr 2022 08:47:18 +0000 (+0200) Subject: rbd: unmap volume after rename X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=959471784834e6015f2c8edd50a642a87f2528a6;p=pve-storage.git rbd: unmap volume after rename When krbd is used, subsequent removal after an an operation involving a rename could fail with > librbd::image::PreRemoveRequest: 0x559b7506a470 \ > check_image_watchers: image has watchers - not removing because the old mapping was still present. For both operations with a rename, the owning guest should be offline, but even if it weren't, unmap simply fails when the volume is in-use. Signed-off-by: Fabian Ebner --- diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm index e9856a9..d71af36 100644 --- a/PVE/Storage/RBDPlugin.pm +++ b/PVE/Storage/RBDPlugin.pm @@ -482,6 +482,9 @@ sub create_base { ); run_rbd_command($cmd, errmsg => "rbd rename '$name' error"); + eval { $class->unmap_volume($storeid, $scfg, $volname); }; + warn $@ if $@; + my $running = undef; #fixme : is create_base always offline ? $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running); @@ -817,6 +820,9 @@ sub rename_volume { errmsg => "could not rename image '${source_image}' to '${target_volname}'", ); + eval { $class->unmap_volume($storeid, $scfg, $source_volname); }; + warn $@ if $@; + $base_name = $base_name ? "${base_name}/" : ''; return "${storeid}:${base_name}${target_volname}";