Since there are only two distinct outcomes, i.e. raw format + do_format and subvol format + needs_chown, break down the conditions to reduce the branching depth.
Signed-off-by: Daniel Kral <d.k...@proxmox.com> --- changes since v1: - new! src/PVE/LXC.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 1152131..c634b70 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2163,14 +2163,11 @@ sub alloc_disk { die "storage '$storage' does not support content type 'rootdir'\n" if !$scfg->{content}->{rootdir}; - if ($scfg->{path}) { - if ($size_kb > 0 && !($scfg->{type} eq 'btrfs' && $scfg->{quotas})) { - $do_format = 1; - } else { - $format = 'subvol'; - $needs_chown = 1; - } - } elsif ($scfg->{type} eq 'zfspool') { + my $is_unsized_on_path = $scfg->{path} && $size_kb <= 0; + my $is_btrfs_quotas = $scfg->{path} && $scfg->{type} eq 'btrfs' && $scfg->{quotas}; + my $is_zfs_pool = !$scfg->{path} && $scfg->{type} eq 'zfspool'; + + if ($is_unsized_on_path || $is_btrfs_quotas || $is_zfs_pool) { $format = 'subvol'; $needs_chown = 1; } else { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel