From 738897852cbd55ab5708b0b6ade64c059d0cc44a Mon Sep 17 00:00:00 2001 From: Friedrich Weber Date: Fri, 31 Oct 2025 11:36:11 +0100 Subject: [PATCH] plugin: rbd: factor out subroutine to obtain RBD ID This allows the subroutine to be reused. No functional change intended. Signed-off-by: Friedrich Weber Link: https://lore.proxmox.com/20251031103709.60233-5-f.weber@proxmox.com --- src/PVE/Storage/RBDPlugin.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm index cf371c7..69957d2 100644 --- a/src/PVE/Storage/RBDPlugin.pm +++ b/src/PVE/Storage/RBDPlugin.pm @@ -49,6 +49,13 @@ my sub get_rbd_path { return $path; } +my sub get_rbd_id { + my ($path) = @_; + my $real_dev = abs_path($path); + my ($rbd_id) = ($real_dev =~ m|/dev/rbd([0-9]+)$|); + return $rbd_id; +} + my sub get_rbd_dev_path { my ($scfg, $storeid, $volume) = @_; @@ -76,8 +83,7 @@ my sub get_rbd_dev_path { if (!-e $pve_path && -e $path) { # possibly mapped before rbd-pve rule existed - my $real_dev = abs_path($path); - my ($rbd_id) = ($real_dev =~ m|/dev/rbd([0-9]+)$|); + my $rbd_id = get_rbd_id($path); my $dev_cluster_id = file_read_firstline("/sys/devices/rbd/${rbd_id}/cluster_fsid"); return $path if $cluster_id eq $dev_cluster_id; }