OpenZFS/src 89f729d.github/workflows/scripts qemu-4-build-vm.sh

During CI, use `nproc` instead of `sysctl -n hw.ncpu`

The latter may give the wrong result if cpusets are in use.

Sponsored by:   ConnectWise
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by:  Alan Somers <asomers at gmail.com>
Closes #18012
DeltaFile
+1-1.github/workflows/scripts/qemu-4-build-vm.sh
+1-11 files

OpenZFS/src dfb0875tests/zfs-tests/tests/functional/events slow_vdev_degraded_sit_out.ksh

ZTS: Add slow_vdev_degraded_sit_out retry

While not common the draid3 vdev type has been observed to
not always sit out a vdev when run in the CI.  To prevent
continued false positives allow the test to be retried up
to three times before considering it a failure.

Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #18003
DeltaFile
+21-5tests/zfs-tests/tests/functional/events/slow_vdev_degraded_sit_out.ksh
+21-51 files

OpenZFS/src 2d9ba1econfig kernel-blkdev.m4

config: Fix LLVM-21 -Wuninitialized-const-pointer warning (#17997)

LLVM-21 enables -Wuninitialized-const-pointer which results in the
following compiler warning and the bdev_file_open_by_path() interface
not being detected for 6.9 and newer kernels.  The blk_holder_ops
are not used by the ZFS code so we can safely use a NULL argument
for this check.

    bdev_file_open_by_path/bdev_file_open_by_path.c:110:54: error:
    variable 'h' is uninitialized when passed as a const pointer
    argument here [-Werror,-Wuninitialized-const-pointer]

Reviewed-by: Rob Norris <robn at despairlabs.com>

Closes #17682
Closes #17684
(cherry picked from commit 9acedbaceec362d08a33ebfe7c4c7efcee81d094)

Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Moch <mail at alexmoch.com>
Co-authored-by: Brian Behlendorf <behlendorf1 at llnl.gov>
DeltaFile
+3-6config/kernel-blkdev.m4
+3-61 files

OpenZFS/src 05e2747lib/libspl/include/sys types.h

Provide loff_t via <fcntl.h> on musl-based Linux systems

Musl exposes loff_t only as a macro in <fcntl.h> when _GNU_SOURCE is
defined. Including <fcntl.h> ensures the type is available, and a
fallback typedef is provided when no macro is defined. This fixes build
failures on musl systems.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Moch <mail at alexmoch.com>
Closes #18002
DeltaFile
+11-0lib/libspl/include/sys/types.h
+11-01 files

OpenZFS/src ffaea08include/os/freebsd/spl/sys sysmacros.h

FreeBSD: Remove HAVE_INLINE_FLSL use

These macros are deprecated in FreeBSD kernel for several years,
and unneeded for much longer.  Instead, similar to Linux, let
kernel let compiler do the right things.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #18004
DeltaFile
+4-73include/os/freebsd/spl/sys/sysmacros.h
+4-731 files

OpenZFS/src 88d012alib/libspl taskq.c, module/os/freebsd/spl spl_taskq.c

Fix snapshot automount expiry cancellation deadlock

A deadlock occurs when snapshot expiry tasks are cancelled while holding
locks. The snapshot expiry task (snapentry_expire) spawns an umount
process and waits for it to complete. Concurrently, ARC memory pressure
triggers arc_prune which calls zfs_exit_fs(), attempting to cancel the
expiry task while holding locks. The umount process spawned by the
expiry task blocks trying to acquire locks held by arc_prune, which is
blocked waiting for the expiry task to complete. This creates a circular
dependency: expiry task waits for umount, umount waits for arc_prune,
arc_prune waits for expiry task.

Fix by adding non-blocking cancellation support to taskq_cancel_id().
The zfs_exit_fs() path calls zfsctl_snapshot_unmount_delay() to
reschedule the unmount, which needs to cancel any existing expiry task.
It now uses non-blocking cancellation to avoid waiting while holding
locks, breaking the deadlock by returning immediately when the task is
already running.


    [10 lines not shown]
DeltaFile
+24-26module/os/linux/zfs/zfs_ctldir.c
+20-7module/os/linux/spl/spl-taskq.c
+10-3module/os/freebsd/spl/spl_taskq.c
+3-3module/zfs/spa.c
+2-2lib/libspl/taskq.c
+2-1module/zfs/zfs_fm.c
+61-428 files not shown
+71-4814 files

OpenZFS/src 4754ac8cmd/raidz_test raidz_test.c

raidz_test: Restore rand_data protection

It feels dirty to modify protection of a memory allocated via libc,
but at least we should try to restore it before freeing.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17977
DeltaFile
+2-0cmd/raidz_test/raidz_test.c
+2-01 files

OpenZFS/src 338d432cmd/raidz_test raidz_test.c

raidz_test: Fix ZIO ABDs initialization

 - When filling ABDs of several segments, consider offset.
 - "Corrupt" ABDs with actually different data to fail something.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17977
DeltaFile
+16-3cmd/raidz_test/raidz_test.c
+16-31 files

OpenZFS/src 95b2eb5cmd/raidz_test raidz_test.c raidz_test.h

raidz_test: Set io_offset reasonably

 - io_offset of 1 makes no sense.  Set default to 0.
 - Initialize io_offset in all cases.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17977
DeltaFile
+1-1cmd/raidz_test/raidz_test.c
+1-1cmd/raidz_test/raidz_test.h
+2-22 files

OpenZFS/src 3647fa3tests/zfs-tests/tests/functional/raidz raidz_001_neg.ksh

ZFS: Enable more logs for raidz_001_neg

The output is not so big here, so lets collect something useful.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17977
DeltaFile
+1-1tests/zfs-tests/tests/functional/raidz/raidz_001_neg.ksh
+1-11 files

OpenZFS/src 928ecccinclude/sys ddt.h, module/zfs zio.c ddt.c

DDT: Reduce global DDT lock scope during writes

Before this change DDT lock was taken 4 times per written block,
and as effectively a pool-wide lock it can be highly congested.
This change introduces a new per-entry dde_io_lock, protecting some
fields during I/O ready and done stages, so that we don't need the
global lock there.

According to my write tests on 64-thread system with 4KB blocks this
significantly reduce the global lock contention, reducing CPU usage
from 100% to expected ~80%, and increasing write throughput by 10%.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17960
DeltaFile
+82-37module/zfs/zio.c
+3-0include/sys/ddt.h
+2-0module/zfs/ddt.c
+87-373 files

OpenZFS/src a5b665dinclude/sys ddt.h, module/zfs ddt.c

DDT: Switch to using wmsums for lookup stats

ddt_lookup() is a very busy code under a highly congested global
lock.  Anything we can save here is very important.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17980
DeltaFile
+84-8module/zfs/ddt.c
+15-0include/sys/ddt.h
+99-82 files

OpenZFS/src 48f33c1module/zfs zio.c

DDT: Make children writes inherit allocator

Even though unlike gang children it is not so critical for dedup
children to inherit parent's allocator, there is still no reason
for them to have allocation policy different from normal writes.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17961
DeltaFile
+4-3module/zfs/zio.c
+4-31 files

OpenZFS/src 9a453b2.github/workflows zfs-qemu-packages.yml, .github/workflows/scripts qemu-test-repo-vm.sh

CI: zfs-test-packages: Add in new repos

Test install from our new repos: zfs-latest, zfs-legacy,
zfs-2.3, zfs-2.2, from the zfs-test-packages workflow.
This on-demand workflow is use to verify that the zfs RPMs
in the repos are correct.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
Closes #17956
DeltaFile
+12-6.github/workflows/scripts/qemu-test-repo-vm.sh
+1-1.github/workflows/zfs-qemu-packages.yml
+13-72 files

OpenZFS/src bfd137dconfig kernel-kmap-atomic-args.m4

config/kmap_atomic: initialise test data

6.18 changes kmap_atomic() to take a const pointer. This is no problem
for the places we use it, but Clang fails the test due to a warning
about being unable to guarantee that uninitialised data will definitely
not change. Easily solved by forcibly initialising it.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17954
DeltaFile
+1-1config/kernel-kmap-atomic-args.m4
+1-11 files

OpenZFS/src b7e00c7udev zvol_id.c

zvol_id: make array length properly known at compile time

Using strlen() in an static array declaration is a GCC extension. Clang
calls it "gnu-folding-constant" and warns about it, which breaks the
build. If it were widespread we could just turn off the warning, but
since there's only one case, lets just change the array to an explicit
size.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17954
DeltaFile
+1-1udev/zvol_id.c
+1-11 files

OpenZFS/src c631f5emodule Kbuild.in

Linux: bump -std to gnu11

Linux switched from -std=gnu89 to -std=gnu11 in 5.18
(torvalds/linux at e8c07082a810f). We've always overridden that with gnu99
because we use some newer features.

More recent kernels are using C11 features in headers that we include.
GCC generally doesn't seem to care, but more recent versions of Clang
seem to be enforcing our gnu99 override more strictly, which breaks the
build in some configurations.

Just bumping our "override" to match the kernel seems to be the easiest
workaround. It's an effective no-op since 5.18, while still allowing us
to build on older kernels.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17954
DeltaFile
+1-1module/Kbuild.in
+1-11 files

OpenZFS/src 39303femodule/zfs zfs_chksum.c

chksum: run 256K benchmark on demand, preserve chksum_stat_data

Reviewed-by: Tino Reichardt <milky-zfs at mcmilk.de>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Alexx Saver <lzsaver.eth at ethermail.io>
Co-authored-by: Adam Moss <c at yotes.com>
Closes #17945
Closes #17946
DeltaFile
+13-11module/zfs/zfs_chksum.c
+13-111 files

OpenZFS/src 7f7d493lib/libspl tunables.c

FreeBSD: Fix uninitialized variable error

On FreeBSD errno is defined as (* __error()), which means compiler
can't say whether two consecutive reads will return the same.
And without this knowledge the reported error is formally right.

Caching of the errno in local variable fixes the issue.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Rob Norris <robn at despairlabs.com>
Signed-off-by: Alexander Motin <alexander.motin at TrueNAS.com>
Closes #17975
DeltaFile
+8-4lib/libspl/tunables.c
+8-41 files

OpenZFS/src e37937fcmd ztest.c

ztest: fix broken random call

Bad copypasta in 4d451bae8a, leading to random stuff being blasted all
over stack, destroying the program.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Igor Kozhukhov <igor at dilos.org>
Reviewed-by: Sean Eric Fagan <sean.fagan at klarasystems.com>
Signed-off-by: Rob Norris <rob.norris at klarasystems.com>
Closes #17957
DeltaFile
+1-1cmd/ztest.c
+1-11 files

OpenZFS/src 1f3444fcmd/zpool zpool_main.c

zpool: fix special vdev -v -o conflict

Right now, running `zpool list` with -v and -o passed
does not work properly for special vdevs. This commit
fixes that problem.

See the discussion on #17839.
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Shreshth Srivastava <shreshthsrivastava2 at gmail.com>
Closes #17932
DeltaFile
+41-24cmd/zpool/zpool_main.c
+41-241 files

OpenZFS/src 36e4f18module/os/linux/spl spl-taskq.c

Fix taskq NULL pointer dereference on timer race

Remove unsafe timer_pending() check in taskq_cancel_id() that created a
race where:
- Timer expires and timer_pending() returns FALSE
- task_done() frees task with tqent_func = NULL
- Timer callback executes and queues freed task
- Worker thread crashes executing NULL function

Always call timer_delete_sync() unconditionally to ensure timer callback
completes before task is freed.

Reliably reproducible by injecting mdelay(10) after setting CANCEL flag
to widen the race window, combined with frequent task cancellations
(e.g., snapshot automount expiry).

Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Ameer Hamza <ahamza at ixsystems.com>
Closes #17942
DeltaFile
+24-7module/os/linux/spl/spl-taskq.c
+24-71 files

OpenZFS/src 71609a9cmd/zpool zpool_main.c, include thread_pool.h

zfs: replace tpool with taskq

They're basically the same thing; lets just carry one.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17948
DeltaFile
+406-811lib/libzfs/libzfs.abi
+0-612lib/libtpool/thread_pool.c
+0-94lib/libtpool/thread_pool_impl.h
+0-56include/thread_pool.h
+20-18cmd/zpool/zpool_main.c
+11-10lib/libzfs/libzfs_mount.c
+437-1,60112 files not shown
+477-1,64918 files

OpenZFS/src be7d8ealib/libspl taskq.c

taskq: initialize tsd on first use

Doing it this way means that callers don't have to call
system_taskq_init() and also get the system and system_delay taskqs that
they possibly don't even want.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17948
DeltaFile
+11-4lib/libspl/taskq.c
+11-41 files

OpenZFS/src 06c73cf.github/workflows smatch.yml

CI: Add smatch static analysis workflow

Smatch is an actively maintained kernel-aware static analyzer
for C with a low false positive rate.  Since the code checker
can be run relatively quickly against the entire OpenZFS code
base (15 min) it makes sense to add it as a GitHub Actions
workflow.  Today smatch reports a significant numbers warnings
so the workflow is configured to always pass as long as the
analysis was run.  The results are available for reference.
Long term it would ideal to resolve all of the errors/warnings
at which point the workflow can be updated to fail when new
problems are detected.

Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Toomas Soome <tsoome at me.com>
Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Closes #17935
DeltaFile
+52-0.github/workflows/smatch.yml
+52-01 files

OpenZFS/src 74b50a7config deb.am, contrib/debian control Makefile.am

libuutil: remove packaging

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17934
DeltaFile
+0-29rpm/generic/zfs.spec.in
+2-22contrib/debian/control
+9-10config/deb.am
+0-2contrib/debian/Makefile.am
+0-2contrib/debian/openzfs-libuutil3.docs
+0-1contrib/debian/clean
+11-661 files not shown
+11-677 files

OpenZFS/src adb316finclude libuutil.h libuutil_impl.h, lib/libuutil libuutil.abi uu_list.c

libuutil: remove the whole thing

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17934
DeltaFile
+0-3,360lib/libuutil/libuutil.abi
+0-723lib/libuutil/uu_list.c
+0-569lib/libuutil/uu_avl.c
+0-327include/libuutil.h
+0-255lib/libuutil/uu_misc.c
+0-157include/libuutil_impl.h
+0-5,39114 files not shown
+11-5,79120 files

OpenZFS/src 871fa61cmd/zed/agents zfs_diagnosis.c, cmd/zfs zfs_main.c

zfs: replace uu_list with sys/list

Lets just use the list implementation we use everywhere else.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17934
DeltaFile
+27-50cmd/zed/agents/zfs_diagnosis.c
+20-42cmd/zfs/zfs_main.c
+47-922 files

OpenZFS/src b593748cmd/zfs zfs_main.c zfs_iter.c, cmd/zpool zpool_iter.c

zfs: replace uu_avl with sys/avl

Lets just use the AVL implementation we use everywhere else.

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <robn at despairlabs.com>
Closes #17934
DeltaFile
+107-215cmd/zfs/zfs_main.c
+35-94lib/libzfs/libzfs_changelist.c
+20-51lib/libzfs/libzfs_config.c
+21-42cmd/zpool/zpool_iter.c
+21-35cmd/zfs/zfs_iter.c
+1-3lib/libzfs/libzfs_impl.h
+205-4401 files not shown
+205-4427 files

OpenZFS/src e63d026cmd/zpool zpool_main.c zpool_vdev.c

cmd/zpool cstyle issues

add missing headers.
usage() is no-return, so anything after call to it is unreachable code.
use (void) cast where we do ignore return value.

Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Toomas Soome <tsoome at me.com>
Closes #17885
DeltaFile
+224-187cmd/zpool/zpool_main.c
+4-4cmd/zpool/zpool_vdev.c
+228-1912 files