From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer v2 1/5] fix #5250: install: config: add new `btrfs_opts` with `compress` config option
Date: Tue, 13 Aug 2024 18:15:30 +0200 [thread overview]
Message-ID: <20240813161538.1660140-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20240813161538.1660140-1-c.heiss@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v1 -> v2:
* no changes
Proxmox/Install/Config.pm | 15 ++++++++++
proxmox-auto-installer/src/utils.rs | 1 +
proxmox-installer-common/src/options.rs | 31 +++++++++++++++++++++
proxmox-installer-common/src/setup.rs | 21 ++++++++++++--
proxmox-tui-installer/src/setup.rs | 2 ++
proxmox-tui-installer/src/views/bootdisk.rs | 5 ++--
6 files changed, 71 insertions(+), 4 deletions(-)
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index ae70093..7e67f69 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -79,6 +79,9 @@ my sub init_cfg {
copies => 1,
arc_max => Proxmox::Install::RunEnv::default_zfs_arc_max(), # in MiB
},
+ btrfs_opts => {
+ compress => 'off',
+ },
# TODO: single disk selection config
target_hd => undef,
disk_selection => {},
@@ -173,6 +176,18 @@ sub get_zfs_opt {
return defined($k) ? $zfs_opts->{$k} : $zfs_opts;
}
+sub set_btrfs_opt {
+ my ($k, $v) = @_;
+ my $opts = get('btrfs_opts');
+ croak "unknown btrfs opts key '$k'" if !exists($opts->{$k});
+ $opts->{$k} = $v;
+}
+sub get_btrfs_opt {
+ my ($k) = @_;
+ my $opts = get('btrfs_opts');
+ return defined($k) ? $opts->{$k} : $opts;
+}
+
sub set_target_hd { set_key('target_hd', $_[0]); }
sub get_target_hd { return get('target_hd'); }
diff --git a/proxmox-auto-installer/src/utils.rs b/proxmox-auto-installer/src/utils.rs
index 45ad222..ae7dbbd 100644
--- a/proxmox-auto-installer/src/utils.rs
+++ b/proxmox-auto-installer/src/utils.rs
@@ -340,6 +340,7 @@ pub fn parse_answer(
minfree: None,
maxvz: None,
zfs_opts: None,
+ btrfs_opts: None,
target_hd: None,
disk_selection: BTreeMap::new(),
existing_storage_auto_rename: 1,
diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs
index 9375ded..d99e26d 100644
--- a/proxmox-installer-common/src/options.rs
+++ b/proxmox-installer-common/src/options.rs
@@ -102,10 +102,40 @@ impl LvmBootdiskOptions {
}
}
+/// See the accompanying mount option in btrfs(5).
+#[derive(Copy, Clone, Debug, Default, Deserialize, Eq, PartialEq)]
+#[serde(rename_all(deserialize = "lowercase"))]
+pub enum BtrfsCompressOption {
+ On,
+ #[default]
+ Off,
+ Zlib,
+ Lzo,
+ Zstd,
+}
+
+impl fmt::Display for BtrfsCompressOption {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{}", format!("{self:?}").to_lowercase())
+ }
+}
+
+impl From<&BtrfsCompressOption> for String {
+ fn from(value: &BtrfsCompressOption) -> Self {
+ value.to_string()
+ }
+}
+
+pub const BTRFS_COMPRESS_OPTIONS: &[BtrfsCompressOption] = {
+ use BtrfsCompressOption::*;
+ &[On, Off, Zlib, Lzo, Zstd]
+};
+
#[derive(Clone, Debug)]
pub struct BtrfsBootdiskOptions {
pub disk_size: f64,
pub selected_disks: Vec<usize>,
+ pub compress: BtrfsCompressOption,
}
impl BtrfsBootdiskOptions {
@@ -115,6 +145,7 @@ impl BtrfsBootdiskOptions {
Self {
disk_size: disk.size,
selected_disks: (0..disks.len()).collect(),
+ compress: BtrfsCompressOption::default(),
}
}
}
diff --git a/proxmox-installer-common/src/setup.rs b/proxmox-installer-common/src/setup.rs
index e4e609b..d7f1c47 100644
--- a/proxmox-installer-common/src/setup.rs
+++ b/proxmox-installer-common/src/setup.rs
@@ -13,8 +13,8 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use crate::{
options::{
- BtrfsRaidLevel, Disk, FsType, ZfsBootdiskOptions, ZfsChecksumOption, ZfsCompressOption,
- ZfsRaidLevel,
+ BtrfsBootdiskOptions, BtrfsCompressOption, BtrfsRaidLevel, Disk, FsType,
+ ZfsBootdiskOptions, ZfsChecksumOption, ZfsCompressOption, ZfsRaidLevel,
},
utils::CidrAddress,
};
@@ -221,6 +221,20 @@ impl From<ZfsBootdiskOptions> for InstallZfsOption {
}
}
+#[derive(Debug, Deserialize, Serialize)]
+pub struct InstallBtrfsOption {
+ #[serde(serialize_with = "serialize_as_display")]
+ pub compress: BtrfsCompressOption,
+}
+
+impl From<BtrfsBootdiskOptions> for InstallBtrfsOption {
+ fn from(opts: BtrfsBootdiskOptions) -> Self {
+ InstallBtrfsOption {
+ compress: opts.compress,
+ }
+ }
+}
+
pub fn read_json<T: for<'de> Deserialize<'de>, P: AsRef<Path>>(path: P) -> Result<T, String> {
let file = File::open(path).map_err(|err| err.to_string())?;
let reader = BufReader::new(file);
@@ -475,6 +489,9 @@ pub struct InstallConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub zfs_opts: Option<InstallZfsOption>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub btrfs_opts: Option<InstallBtrfsOption>,
+
#[serde(
serialize_with = "serialize_disk_opt",
skip_serializing_if = "Option::is_none",
diff --git a/proxmox-tui-installer/src/setup.rs b/proxmox-tui-installer/src/setup.rs
index ee4e1c7..70b8e28 100644
--- a/proxmox-tui-installer/src/setup.rs
+++ b/proxmox-tui-installer/src/setup.rs
@@ -18,6 +18,7 @@ impl From<InstallerOptions> for InstallConfig {
minfree: None,
maxvz: None,
zfs_opts: None,
+ btrfs_opts: None,
target_hd: None,
disk_selection: BTreeMap::new(),
existing_storage_auto_rename: 0,
@@ -66,6 +67,7 @@ impl From<InstallerOptions> for InstallConfig {
}
AdvancedBootdiskOptions::Btrfs(btrfs) => {
config.hdsize = btrfs.disk_size;
+ config.btrfs_opts = Some(btrfs.clone().into());
for (i, disk) in options.bootdisk.disks.iter().enumerate() {
config
diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs
index 1e22105..8db33dd 100644
--- a/proxmox-tui-installer/src/views/bootdisk.rs
+++ b/proxmox-tui-installer/src/views/bootdisk.rs
@@ -19,8 +19,8 @@ use proxmox_installer_common::{
check_zfs_raid_config,
},
options::{
- AdvancedBootdiskOptions, BootdiskOptions, BtrfsBootdiskOptions, Disk, FsType,
- LvmBootdiskOptions, ZfsBootdiskOptions, ZFS_CHECKSUM_OPTIONS, ZFS_COMPRESS_OPTIONS,
+ AdvancedBootdiskOptions, BootdiskOptions, BtrfsBootdiskOptions, BtrfsCompressOption, Disk,
+ FsType, LvmBootdiskOptions, ZfsBootdiskOptions, ZFS_CHECKSUM_OPTIONS, ZFS_COMPRESS_OPTIONS,
},
setup::{BootType, ProductConfig, ProxmoxProduct, RuntimeInfo},
};
@@ -602,6 +602,7 @@ impl BtrfsBootdiskOptionsView {
BtrfsBootdiskOptions {
disk_size,
selected_disks,
+ compress: BtrfsCompressOption::default(),
},
))
}
--
2.45.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2024-08-13 16:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 16:15 [pve-devel] [PATCH installer v2 0/5] fix #5250: add btrfs `compress` mount option support Christoph Heiss
2024-08-13 16:15 ` Christoph Heiss [this message]
2024-08-13 16:15 ` [pve-devel] [PATCH installer v2 2/5] fix #5250: install: write btrfs `compress` option to fstab Christoph Heiss
2024-08-13 16:15 ` [pve-devel] [PATCH installer v2 3/5] fix #5250: proxinstall: expose new btrfs `compress` option Christoph Heiss
2024-08-13 16:15 ` [pve-devel] [PATCH installer v2 4/5] fix #5250: tui: " Christoph Heiss
2024-08-13 16:15 ` [pve-devel] [PATCH installer v2 5/5] fix #5250: auto-installer: " Christoph Heiss
2024-09-25 11:43 ` [pve-devel] [PATCH installer v2 0/5] fix #5250: add btrfs `compress` mount option support Christoph Heiss
2024-11-10 18:44 ` [pve-devel] applied: " Thomas Lamprecht
2024-11-11 10:35 ` Christoph Heiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240813161538.1660140-2-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.