From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 9937B1FF189
	for <inbox@lore.proxmox.com>; Fri,  4 Apr 2025 14:47:12 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 547C31EEE4;
	Fri,  4 Apr 2025 14:46:59 +0200 (CEST)
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri,  4 Apr 2025 14:46:47 +0200
Message-ID: <20250404124651.1283950-3-c.heiss@proxmox.com>
X-Mailer: git-send-email 2.48.1
In-Reply-To: <20250404124651.1283950-1-c.heiss@proxmox.com>
References: <20250404124651.1283950-1-c.heiss@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.030 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
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [proxmox.com, bootdisk.rs]
Subject: [pve-devel] [PATCH installer 2/3] tui: bootdisk: always return
 proper value for default zfs max arc size
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.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