[pve-devel] [PATCH container v2 05/11] alloc_disk: simplify storage-specific logic for vdisk_alloc arguments
Fiona Ebner
f.ebner at proxmox.com
Thu Feb 20 14:22:43 CET 2025
Am 11.02.25 um 17:08 schrieb Daniel Kral:
> 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.kral at proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner at 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};
Nit: since the btrfs plugin always has a path, that part can be dropped
> + my $is_zfs_pool = !$scfg->{path} && $scfg->{type} eq 'zfspool';
Nit: since the zfspool plugin never has a path, that part can be dropped
> +
> + if ($is_unsized_on_path || $is_btrfs_quotas || $is_zfs_pool) {
> $format = 'subvol';
> $needs_chown = 1;
> } else {
More information about the pve-devel
mailing list