public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH zfsonlinux] fix scrub breaking with newer userspace utils and older kernel module
@ 2026-03-12 10:15 Stoiko Ivanov
  2026-03-13 14:18 ` applied: " Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages in thread
From: Stoiko Ivanov @ 2026-03-12 10:15 UTC (permalink / raw)
  To: pve-devel

currently when running an older kernel with ZFS 2.3 modules (e.g. by
actively pinning it) running zfs scrub fails, due to some changes in
2.4, which are not backward compatible.

This patch was submitted upstream at:
https://github.com/openzfs/zfs/pull/18314

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
minimally tested by:
* installing PVE 9.1 from iso, upgrading to the latest versions from
  pve-no-subscription, and pinning the old kernel (still with ZFS 2.3)
* running `zpool scrub` (error occurs)
* installing zfs userspace with this patch applied
* running `zpool scrub` (scrub starts)

 ...y-include-start-and-end-nv-pairs-if-.patch | 60 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 61 insertions(+)
 create mode 100644 debian/patches/0009-libzfs-scrub-only-include-start-and-end-nv-pairs-if-.patch

diff --git a/debian/patches/0009-libzfs-scrub-only-include-start-and-end-nv-pairs-if-.patch b/debian/patches/0009-libzfs-scrub-only-include-start-and-end-nv-pairs-if-.patch
new file mode 100644
index 000000000..0675045fb
--- /dev/null
+++ b/debian/patches/0009-libzfs-scrub-only-include-start-and-end-nv-pairs-if-.patch
@@ -0,0 +1,60 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Stoiko Ivanov <s.ivanov@proxmox.com>
+Date: Wed, 11 Mar 2026 12:56:12 +0100
+Subject: [PATCH] libzfs: scrub: only include start and end nv pairs if needed
+ for scrub
+
+This patch addresses running `zpool scrub <pool>` with ZFS 2.4 userspace
+while the loaded kernel module is still 2.3, failing with:
+```
+cannot scrub <pool>: the loaded zfs module does not support an option
+for this operation. A reboot may be required to enable this option.
+```
+
+Checking for the source of the message via `strace` showed the scrub
+ioctl failing and setting errno to ZFS_ERR_IOC_ARG_UNAVAIL[0]. With
+that and the comments in `module/zfs/zfs_ioctl.c`[1] commit: 894edd084
+seemed like a likely cause for the backward incompatibility.
+
+The corresponding kernelspace code in `module/zfs/zfs_ioctl.c` defaults
+to a setting of 0 if either parameter is not set, so not providing the
+nvpairs in case both are 0 should not make a semantic difference.
+
+Tested by:
+* loading zfs.ko in version 2.3.6
+* running `zpool scrub testpool` with zpool from master (error occurs)
+* running `zpool scrub testpool` with this patch applied (scrub is
+  started)
+
+This should help users who are still stuck on an older kernel module,
+while their distribution ships newer ZFS userspace.
+
+This was observed in the Proxmox community forum:
+https://forum.proxmox.com/threads/.180467/
+
+[0] https://github.com/openzfs/zfs/blob/d35951b18d6e12afeb0d5b0539ff2467ab4bfbcf/include/sys/fs/zfs.h#L1762
+[1] https://github.com/openzfs/zfs/blob/d35951b18d6e12afeb0d5b0539ff2467ab4bfbcf/module/zfs/zfs_ioctl.c#L7799
+Fixes: 894edd084 ("Add TXG timestamp database")
+Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
+---
+ lib/libzfs/libzfs_pool.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c
+index db5cd6dc00ac4882f3877b5b3bd4ac50967626b3..1b59b50cbd1cff7b14e79f10fd8bb8564e8e0e7e 100644
+--- a/lib/libzfs/libzfs_pool.c
++++ b/lib/libzfs/libzfs_pool.c
+@@ -2797,8 +2797,11 @@ zpool_scan_range(zpool_handle_t *zhp, pool_scan_func_t func,
+ 	nvlist_t *args = fnvlist_alloc();
+ 	fnvlist_add_uint64(args, "scan_type", (uint64_t)func);
+ 	fnvlist_add_uint64(args, "scan_command", (uint64_t)cmd);
+-	fnvlist_add_uint64(args, "scan_date_start", (uint64_t)date_start);
+-	fnvlist_add_uint64(args, "scan_date_end", (uint64_t)date_end);
++	if (date_start != 0 || date_end != 0) {
++		fnvlist_add_uint64(args, "scan_date_start",
++		    (uint64_t)date_start);
++		fnvlist_add_uint64(args, "scan_date_end", (uint64_t)date_end);
++	}
+ 
+ 	err = lzc_scrub(ZFS_IOC_POOL_SCRUB, zhp->zpool_name, args, NULL);
+ 	fnvlist_free(args);
diff --git a/debian/patches/series b/debian/patches/series
index e6637ed22..bd2f52458 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@
 0006-dont-symlink-zed-scripts.patch
 0007-Add-systemd-unit-for-importing-specific-pools.patch
 0008-zpool-status-tighten-bounds-for-noalloc-stat-availab.patch
+0009-libzfs-scrub-only-include-start-and-end-nv-pairs-if-.patch
-- 
2.47.3





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-13 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 10:15 [PATCH zfsonlinux] fix scrub breaking with newer userspace utils and older kernel module Stoiko Ivanov
2026-03-13 14:18 ` applied: " Fabian Grünbichler

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