[pve-devel] [RFC PATCH 2/2] common: btrfs: lower minimum amount of disks for raid10 to 2
Daniel Kral
d.kral at proxmox.com
Fri Jan 10 18:00:40 CET 2025
As the installer allows single-disk RAID0 configurations and BTRFS
allows to create a filesystem with the RAID10 profile with only two
disks since kernel version 5.15 [0], lower the minimum amount of disks
the installer requires for a BTRFS RAID10 setup.
The motiviation for this is to allow users to create a BTRFS RAID10
configuration even though they do not have the necessary disks ready at
setup time itself without needing to convert the profile afterwards.
[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b2f78e88052bc0bee56bbf646d245fcfb431a873
Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
Discussion
If this patch seems like something worthwile, I think it would be
necessary to have some sort of warning popup for 2 <= $diskcount < 4 in
RAID10, and maybe also the same for $diskcount == 1 in RAID0, that
there's no advantage to create a degenerate RAID0/10 without planning to
add at least 1/2 disks later. I would add this in a v2 or followup if
this gets ACKed.
Proxmox/Install.pm | 2 +-
proxmox-installer-common/src/disk_checks.rs | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Proxmox/Install.pm b/Proxmox/Install.pm
index b72a83e..d52d17b 100644
--- a/Proxmox/Install.pm
+++ b/Proxmox/Install.pm
@@ -365,7 +365,7 @@ sub get_btrfs_raid_setup {
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;
+ die "btrfs (RAID10) needs at least 2 devices\n" if $diskcount < 2;
$mode = 'raid10';
} else {
die "unknown btrfs mode '$filesys'\n";
diff --git a/proxmox-installer-common/src/disk_checks.rs b/proxmox-installer-common/src/disk_checks.rs
index ecc43bd..bd1c54c 100644
--- a/proxmox-installer-common/src/disk_checks.rs
+++ b/proxmox-installer-common/src/disk_checks.rs
@@ -129,7 +129,7 @@ pub fn check_btrfs_raid_config(level: BtrfsRaidLevel, disks: &[Disk]) -> Result<
match level {
BtrfsRaidLevel::Raid0 => check_raid_min_disks(disks, 1)?,
BtrfsRaidLevel::Raid1 => check_raid_min_disks(disks, 2)?,
- BtrfsRaidLevel::Raid10 => check_raid_min_disks(disks, 4)?,
+ BtrfsRaidLevel::Raid10 => check_raid_min_disks(disks, 2)?,
}
Ok(())
@@ -204,8 +204,8 @@ mod tests {
assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid1, &disks).is_ok());
assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &[]).is_err());
- assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &disks[..3]).is_err());
- assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &disks[..4]).is_ok());
+ assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &disks[..1]).is_err());
+ assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &disks[..2]).is_ok());
assert!(check_btrfs_raid_config(BtrfsRaidLevel::Raid10, &disks).is_ok());
}
--
2.39.5
More information about the pve-devel
mailing list