]> git.proxmox.com Git - pve-storage.git/commitdiff
RBD plugin: path: conditionalize get_rbd_dev_path() call
authorFiona Ebner <f.ebner@proxmox.com>
Wed, 31 Aug 2022 08:50:54 +0000 (10:50 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 13 Sep 2022 07:55:56 +0000 (09:55 +0200)
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>
PVE/Storage/RBDPlugin.pm

index eeeaf3f51f03edb839f234657c6cbc35e1c76349..d76f93094f2ab63513e098c4c538c6909cbe7df3 100644 (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}";