public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shan Shaji <s.shaji@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 1/3] partially fix #6933: ui: storage: add option to specify zfs recordsize
Date: Tue,  4 Aug 2026 14:40:19 +0200	[thread overview]
Message-ID: <20260804124021.83704-2-s.shaji@proxmox.com> (raw)
In-Reply-To: <20260804124021.83704-1-s.shaji@proxmox.com>

Earlier, to change the recordsize of an zfs storage dataset the users
had to use the `zfs` cli. Improved this by adding an option to specify
the recordsize while creating the storage. By default the recordsize is
set at 128KB.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---
 src/api2/node/disks/zfs.rs | 14 ++++++++++++--
 www/Utils.js               | 28 ++++++++++++++++++++++++++++
 www/window/ZFSCreate.js    |  8 ++++++++
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 7a62e3f70..43d0ce259 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -7,8 +7,8 @@ use proxmox_schema::api;
 
 use pbs_api_types::{
     DATASTORE_SCHEMA, DISK_ARRAY_SCHEMA, DISK_LIST_SCHEMA, DataStoreConfig, NODE_SCHEMA,
-    PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID_SCHEMA, ZFS_ASHIFT_SCHEMA, ZPOOL_NAME_SCHEMA,
-    ZfsCompressionType, ZfsRaidLevel, ZpoolListItem,
+    PRIV_SYS_AUDIT, PRIV_SYS_MODIFY, UPID_SCHEMA, ZFS_ASHIFT_SCHEMA, ZFS_RECORD_SIZE_SCHEMA,
+    ZPOOL_NAME_SCHEMA, ZfsCompressionType, ZfsRaidLevel, ZpoolListItem,
 };
 
 use crate::tools::disks::{
@@ -138,6 +138,10 @@ pub fn zpool_details(name: String) -> Result<Value, Error> {
                 type: bool,
                 optional: true,
             },
+            recordsize: {
+                schema: ZFS_RECORD_SIZE_SCHEMA,
+                optional: true,
+            }
         },
     },
     returns: {
@@ -155,6 +159,7 @@ pub fn create_zpool(
     compression: Option<String>,
     ashift: Option<usize>,
     add_datastore: Option<bool>,
+    recordsize: Option<String>,
     rpcenv: &mut dyn RpcEnvironment,
 ) -> Result<String, Error> {
     let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
@@ -292,6 +297,11 @@ pub fn create_zpool(
             if let Some(compression) = compression {
                 command.arg(format!("compression={compression}"));
             }
+
+            if let Some(recordsize) = recordsize {
+                command.arg(format!("recordsize={recordsize}"));
+            }
+
             command.args(["relatime=on", &name]);
             info!("# {command:?}");
             match proxmox_sys::command::run_command(command, None) {
diff --git a/www/Utils.js b/www/Utils.js
index d6bfd459e..1c96bd0b3 100644
--- a/www/Utils.js
+++ b/www/Utils.js
@@ -395,6 +395,34 @@ Ext.define('PBS.Utils', {
         return cls;
     },
 
+    validateZfsRecordSize: function (value) {
+        if (!value) {
+            return true;
+        }
+
+        let match = value.match(/^([1-9][0-9]*)([km])?$/i);
+        if (!match) {
+            return gettext(
+                'Invalid format. Use numbers with optional k or m suffix (e.g., 16k).',
+            );
+        }
+
+        let bytes = parseInt(match[1], 10);
+        let suffix = match[2]?.toLowerCase();
+
+        if (suffix === 'k') {
+            bytes *= 1024;
+        } else if (suffix === 'm') {
+            bytes *= 1024 * 1024;
+        }
+
+        if (bytes < 512 || (bytes & (bytes - 1)) !== 0 || bytes > 16 * 1024 * 1024) {
+            return gettext('Value must be a power of 2 between 512 and 16m');
+        }
+
+        return true;
+    },
+
     constructor: function () {
         var me = this;
 
diff --git a/www/window/ZFSCreate.js b/www/window/ZFSCreate.js
index 9a32bd5f3..7dcffc1b8 100644
--- a/www/window/ZFSCreate.js
+++ b/www/window/ZFSCreate.js
@@ -72,6 +72,14 @@ Ext.define('PBS.window.CreateZFS', {
                     value: '12',
                     name: 'ashift',
                 },
+                {
+                    xtype: 'proxmoxtextfield',
+                    name: 'recordsize',
+                    fieldLabel: gettext('Record Size'),
+                    allowBlank: true,
+                    validator: PBS.Utils.validateZfsRecordSize,
+                    emptyText: '128k'
+                },
             ],
             columnB: [
                 {
-- 
2.47.3





  reply	other threads:[~2026-08-04 12:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 12:40 [PATCH proxmox{-backup,} 0/3] partially fix #6933: add option to specify zfs recordsize Shan Shaji
2026-08-04 12:40 ` Shan Shaji [this message]
2026-08-04 12:40 ` [PATCH proxmox-backup 2/3] partially fix #6933: bin: add option to specify ZFS recordsize Shan Shaji
2026-08-04 12:40 ` [PATCH proxmox 3/3] pbs-api-types: zfs: define schema for recordsize Shan Shaji

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=20260804124021.83704-2-s.shaji@proxmox.com \
    --to=s.shaji@proxmox.com \
    --cc=pbs-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