public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 2/3] tui: bootdisk: always return proper value for default zfs max arc size
Date: Fri,  4 Apr 2025 14:46:47 +0200	[thread overview]
Message-ID: <20250404124651.1283950-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250404124651.1283950-1-c.heiss@proxmox.com>

In preparation for fixing #6285 [0].

`0` means to just skip writing the module parameter. But (especially)
with the upcoming change in ZFS 2.3 - which makes the size basically
that of the system memory minus 1 GiB - we want to always write some
value.

[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6285

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 proxmox-tui-installer/src/views/bootdisk.rs | 32 ++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/proxmox-tui-installer/src/views/bootdisk.rs b/proxmox-tui-installer/src/views/bootdisk.rs
index b0fc131..313a3c9 100644
--- a/proxmox-tui-installer/src/views/bootdisk.rs
+++ b/proxmox-tui-installer/src/views/bootdisk.rs
@@ -626,26 +626,27 @@ impl ViewWrapper for BtrfsBootdiskOptionsView {
 
 struct ZfsBootdiskOptionsView {
     view: MultiDiskOptionsView<FormView>,
+    zfs_arc_max_default: usize,
 }
 
 impl ZfsBootdiskOptionsView {
     // TODO: Re-apply previous disk selection from `options` correctly
     fn new(runinfo: &RuntimeInfo, options: &ZfsBootdiskOptions) -> Self {
+        let zfs_arc_max_default = runinfo.total_memory.div_ceil(2);
+
         let arc_max_view = {
             // Always leave a GiB of headroom for the OS.
             let view =
                 IntegerEditView::new_with_suffix("MiB").max_value(runinfo.total_memory - 1024);
 
-            // If the runtime environment provides a non-zero value, that is
-            // also not the built-in ZFS default of half the system memory, use
-            // that as default.
-            // Otherwise, just place the ZFS default into the placeholder.
-            if runinfo.default_zfs_arc_max > 0
-                && runinfo.default_zfs_arc_max != runinfo.total_memory / 2
-            {
+            // If the runtime environment provides a value that is not the (ZFS) default of
+            // half the system memory, use that as default.
+            // Otherwise, just place the (ZFS) default of 50% of available system memory into the
+            // placeholder.
+            if runinfo.default_zfs_arc_max != zfs_arc_max_default {
                 view.content(options.arc_max)
             } else {
-                view.placeholder(runinfo.total_memory / 2)
+                view.placeholder(zfs_arc_max_default)
             }
         };
 
@@ -687,7 +688,10 @@ impl ZfsBootdiskOptionsView {
                 "ZFS is not compatible with hardware RAID controllers, for details see the documentation."
             ).center());
 
-        Self { view }
+        Self {
+            view,
+            zfs_arc_max_default,
+        }
     }
 
     fn new_with_defaults(runinfo: &RuntimeInfo) -> Self {
@@ -706,13 +710,15 @@ impl ZfsBootdiskOptionsView {
 
         // If a value is set, return that and clamp it to at least [`ZFS_ARC_MIN_SIZE_MIB`].
         //
-        // Otherwise, if no value was set or an error occurred return `0`. The former simply means
-        // that the placeholder value is still there.
+        // Otherwise, if no value was set or an error occurred return the default value. The former
+        // simply means that the placeholder value is still there.
         let arc_max = view
             .get_child::<IntegerEditView>(4)?
             .get_content_maybe()
-            .map_or(Ok(0), |v| v.map(|v| v.max(ZFS_ARC_MIN_SIZE_MIB)))
-            .unwrap_or(0);
+            .map_or(Ok(self.zfs_arc_max_default), |v| {
+                v.map(|v| v.max(ZFS_ARC_MIN_SIZE_MIB))
+            })
+            .unwrap_or(self.zfs_arc_max_default);
 
         Some((
             disks,
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-04-04 12:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04 12:46 [pve-devel] [PATCH installer 0/3] fix #6285: always set up zfs modprobe configuration Christoph Heiss
2025-04-04 12:46 ` [pve-devel] [PATCH installer 1/3] run env: always return proper value for default zfs max arc size Christoph Heiss
2025-04-04 12:46 ` Christoph Heiss [this message]
2025-04-04 12:46 ` [pve-devel] [PATCH installer 3/3] fix #6285: install: always set up zfs modprobe configuration Christoph Heiss
2025-04-04 13:01 ` [pve-devel] applied-series: [PATCH installer 0/3] fix #6285: " Thomas Lamprecht

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=20250404124651.1283950-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal