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:
committed by
Thomas Lamprecht
parent
7c2a554b97
commit
738897852c
@ -49,6 +49,13 @@ my sub get_rbd_path {
|
|||||||
return $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 sub get_rbd_dev_path {
|
||||||
my ($scfg, $storeid, $volume) = @_;
|
my ($scfg, $storeid, $volume) = @_;
|
||||||
|
|
||||||
@ -76,8 +83,7 @@ my sub get_rbd_dev_path {
|
|||||||
|
|
||||||
if (!-e $pve_path && -e $path) {
|
if (!-e $pve_path && -e $path) {
|
||||||
# possibly mapped before rbd-pve rule existed
|
# possibly mapped before rbd-pve rule existed
|
||||||
my $real_dev = abs_path($path);
|
my $rbd_id = get_rbd_id($path);
|
||||||
my ($rbd_id) = ($real_dev =~ m|/dev/rbd([0-9]+)$|);
|
|
||||||
my $dev_cluster_id = file_read_firstline("/sys/devices/rbd/${rbd_id}/cluster_fsid");
|
my $dev_cluster_id = file_read_firstline("/sys/devices/rbd/${rbd_id}/cluster_fsid");
|
||||||
return $path if $cluster_id eq $dev_cluster_id;
|
return $path if $cluster_id eq $dev_cluster_id;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user