RBD plugin: path: conditionalize get_rbd_dev_path() call

The return value of get_rbd_dev_path() is only used when $scfg->{krbd}
evaluates to true and the function shouldn't have any side effects
that are needed later, so the call can be avoided otherwise.

This also saves a RADOS connection and command with configurations for
external clusters with krbd disabled.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner
2022-08-31 10:50:54 +02:00
committed by Fabian Grünbichler
parent c560cb58a5
commit e8e477112f

View File

@ -417,8 +417,10 @@ sub path {
my ($vtype, $name, $vmid) = $class->parse_volname($volname);
$name .= '@'.$snapname if $snapname;
my $rbd_dev_path = get_rbd_dev_path($scfg, $storeid, $name);
return ($rbd_dev_path, $vmid, $vtype) if $scfg->{krbd};
if ($scfg->{krbd}) {
my $rbd_dev_path = get_rbd_dev_path($scfg, $storeid, $name);
return ($rbd_dev_path, $vmid, $vtype);
}
my $rbd_path = get_rbd_path($scfg, $name);
my $path = "rbd:${rbd_path}";