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 <f.weber@proxmox.com>
Link: https://lore.proxmox.com/20251031103709.60233-5-f.weber@proxmox.com
This commit is contained in:
Friedrich Weber
2025-10-31 11:36:11 +01:00
committed by Thomas Lamprecht
parent 7c2a554b97
commit 738897852c

View File

@ -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;
}