From: David Riley <d.riley@proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: David Riley <d.riley@proxmox.com>
Subject: [PATCH pve-manager 1/2] fix #3936: ui: storage: add validation for ZFS blocksize
Date: Tue, 12 May 2026 15:48:51 +0200 [thread overview]
Message-ID: <20260512134852.142044-2-d.riley@proxmox.com> (raw)
In-Reply-To: <20260512134852.142044-1-d.riley@proxmox.com>
Add validation to the ZFS storage blocksize form field to prevent
misconfigurations.
Validation [0][1]:
* Range: 512 bytes to 16 MiB
* Format: Allow positive integers with optional 'k' or 'm' suffix.
* Constraint: Must be a power of two.
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=3936
[0] https://openzfs.github.io/openzfs-docs/man/v2.4/7/zfsprops.7.html#volblocksize
[1] https://openzfs.github.io/openzfs-docs/man/v2.4/7/zfsprops.7.html#recordsize
Signed-off-by: David Riley <d.riley@proxmox.com>
---
www/manager6/Utils.js | 34 +++++++++++++++++++++++++++++
www/manager6/storage/ZFSEdit.js | 1 +
www/manager6/storage/ZFSPoolEdit.js | 1 +
3 files changed, 36 insertions(+)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 01e80682..a8f684a0 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -274,6 +274,40 @@ Ext.define('PVE.Utils', {
return '<i class="fa fa-' + iconCls + '"></i> ' + value;
},
+ validate_zfs_blocksize: function (value) {
+ if (!value || 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] ? match[2].toLowerCase() : '';
+
+ if (suffix === 'k') {
+ bytes *= 1024;
+ } else if (suffix === 'm') {
+ bytes *= 1024 * 1024;
+ }
+
+ if (bytes < 512 || (bytes & (bytes - 1)) !== 0) {
+ return gettext(
+ 'Value must be a power of 2 and at least 512 (e.g., 4k, 8k, 16k, 32k).',
+ );
+ }
+
+ if (bytes > 16 * 1024 * 1024) {
+ return gettext('Value is too large (max 16 MiB).');
+ }
+
+ return true;
+ },
+
render_pbs_fingerprint: (fp) => fp.substring(0, 23),
render_backup_encryption: function (v, meta, record) {
diff --git a/www/manager6/storage/ZFSEdit.js b/www/manager6/storage/ZFSEdit.js
index e9d24642..ef18fa11 100644
--- a/www/manager6/storage/ZFSEdit.js
+++ b/www/manager6/storage/ZFSEdit.js
@@ -67,6 +67,7 @@ Ext.define('PVE.storage.ZFSInputPanel', {
value: '4k',
fieldLabel: gettext('Block Size'),
allowBlank: false,
+ validator: PVE.Utils.validate_zfs_blocksize,
},
{
xtype: me.isCreate ? 'textfield' : 'displayfield',
diff --git a/www/manager6/storage/ZFSPoolEdit.js b/www/manager6/storage/ZFSPoolEdit.js
index 0066dfef..2d7b4498 100644
--- a/www/manager6/storage/ZFSPoolEdit.js
+++ b/www/manager6/storage/ZFSPoolEdit.js
@@ -106,6 +106,7 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
emptyText: '16k',
fieldLabel: gettext('Block Size'),
allowBlank: true,
+ validator: PVE.Utils.validate_zfs_blocksize,
},
],
});
--
2.47.3
next prev parent reply other threads:[~2026-05-12 13:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 13:48 [PATCH manager/storage 0/2] fix #3936: add validation for ZFS blocksize David Riley
2026-05-12 13:48 ` David Riley [this message]
2026-05-13 14:05 ` [PATCH pve-manager 1/2] fix #3936: ui: storage: " Fiona Ebner
2026-05-15 6:57 ` David Riley
2026-05-12 13:48 ` [PATCH pve-storage 2/2] fix #3936: api: add zfs-blocksize format David Riley
2026-05-13 14:35 ` applied: " Fiona Ebner
2026-05-15 8:00 ` superseded: [PATCH manager/storage 0/2] fix #3936: add validation for ZFS blocksize David Riley
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=20260512134852.142044-2-d.riley@proxmox.com \
--to=d.riley@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