From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 524E31FF190 for ; Fri, 10 Jan 2025 18:01:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8BF2325C; Fri, 10 Jan 2025 18:00:52 +0100 (CET) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Fri, 10 Jan 2025 18:00:39 +0100 Message-Id: <20250110170040.201474-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.011 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [RFC PATCH 1/2] install: btrfs: fix raid level falling back to single mode X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" >From a user's perspective, the BTRFS single mode has been removed since d85180e ("tui: rename raid levels 0/1 to align with GUI installer"). The user can now only select at least the "RAID0" level, but if a user selects any raid level with only one disk configured on the system, BTRFS will be setup in 'single' mode instead of the chosen raid level. The TUI installer has a separate check for this, but the GUI installer as well as the auto installer will silently fallback to single mode, which could be confusing for and unwanted by the user. Therefore, remove the BTRFS single mode from being selected when configuring disks in the GUI installer and during the installation in general, which makes the auto installer fail if the wrong amount of disks are selected for the specified raid level. This makes btrfs' raid disk count validation align with the one from zfs. Signed-off-by: Daniel Kral --- Discussion BTRFS didn't allow a single-disk RAID0 configuration before kernel 5.15 and AFAIK also silently used the single profile for that case, but this has changed since then. If we want users to still be able to create a BTRFS filesystem in single mode (which seems very reasonable), I can do a v2 or followup to add a "btrfs (single)" entry to the disk setup. Testing I have tested this by the usual installer test procedure (debug shell, patch files, launch target installer manually) and the GUI installer disallows creating a btrfs raid1 or raid10 with only one disk, but allows it with at least the correct amount of disks. The same applies to the autoinstaller with the same test cases. Unpatched a single-disk RAID0 install resulted in: ``` root@pve:~# btrfs filesystem usage -T . [ ... ] Data Metadata System Id Path single single single Unallocated Total Slack -- --------- ------ --------- -------- ----------- -------- ------- 1 /dev/sda3 4.01GB 520.00MiB 4.00MiB 26.98GiB 31.50GiB 3.50KiB [ ... ] ``` and patched a single-disk RAID0 install results in: ``` ``` root@pve:~# btrfs filesystem usage -T . [ ... ] Data Metadata System Id Path RAID0 RAID0 RAID0 Unallocated Total Slack -- --------- ------ --------- -------- ----------- -------- ------- 1 /dev/sda3 4.00GB 512.00MiB 8.00MiB 26.99GiB 31.50GiB 3.50KiB [ ... ] ``` ``` Proxmox/Install.pm | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm index c0a17b2..b72a83e 100644 --- a/Proxmox/Install.pm +++ b/Proxmox/Install.pm @@ -359,20 +359,16 @@ sub get_btrfs_raid_setup { my $mode; - if ($diskcount == 1) { - $mode = 'single'; + if ($filesys eq 'btrfs (RAID0)') { + $mode = 'raid0'; + } elsif ($filesys eq 'btrfs (RAID1)') { + die "btrfs (RAID1) needs at least 2 devices\n" if $diskcount < 2; + $mode = 'raid1'; + } elsif ($filesys eq 'btrfs (RAID10)') { + die "btrfs (RAID10) needs at least 4 devices\n" if $diskcount < 4; + $mode = 'raid10'; } else { - if ($filesys eq 'btrfs (RAID0)') { - $mode = 'raid0'; - } elsif ($filesys eq 'btrfs (RAID1)') { - die "btrfs (RAID1) needs at least 2 devices\n" if $diskcount < 2; - $mode = 'raid1'; - } elsif ($filesys eq 'btrfs (RAID10)') { - die "btrfs (RAID10) needs at least 4 devices\n" if $diskcount < 4; - $mode = 'raid10'; - } else { - die "unknown btrfs mode '$filesys'\n"; - } + die "unknown btrfs mode '$filesys'\n"; } return ($devlist, $mode); -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel