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.
Drop the check for $scfg->{path} for BTRFS and ZFS pool storages, since BTRFS must always have a path and ZFS pool can never have a path. Signed-off-by: Daniel Kral <d.k...@proxmox.com> --- changes since v2: * drop $scfg->{path} check for btrfs and ZFS pool and add the reasoning for that to the commit message 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 780a0d4..97c0fa6 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2176,14 +2176,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->{type} eq 'btrfs' && $scfg->{quotas}; + my $is_zfs_pool = $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